From patchwork Thu Mar 2 07:55:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9599677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 510CA60429 for ; Thu, 2 Mar 2017 07:56:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ABD92846A for ; Thu, 2 Mar 2017 07:56:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D84628518; Thu, 2 Mar 2017 07:56:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B01652846A for ; Thu, 2 Mar 2017 07:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=31enuSWSci1GDe/BSW6lRyKkeExQKsXQPmvwKMFr/Yo=; b=aqmEirlL/PeKZs E+I1HL8VGh/eYuno5HGGr/97jTo3rA0uM0stwVLlXKOyLdEJ28WvJD1upZXzpWJICepkkvp+WScTA 3EftmdjmAx3FEnHuKh5NXxpZ3ZojAefelOLUTbAbsRTFWmrp5VDuVpC/ghrGNHiTntvrZAEDwv6pW YUEmLlOxn3JKa+7agJTwdvpPcNKCCE+rfp71kjVjXzlIpYTZvmmfNgJPDA2QsbXMioSNSSZf9Ss1r FoRVsiBNsaQMgtOkNDm668/SYxmTuw8Vwk+vJ4DbilXpt+Xxf7M282z026jySkVFOiAmDS4lfEBU8 XzqSPsFstWaVXSpEGmMA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjLb7-00035X-07; Thu, 02 Mar 2017 07:56:25 +0000 Received: from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjLaz-00032x-J5 for linux-arm-kernel@lists.infradead.org; Thu, 02 Mar 2017 07:56:23 +0000 Received: by mail-pg0-x22e.google.com with SMTP id p5so29626036pga.1 for ; Wed, 01 Mar 2017 23:55:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=8vBQM3MrLtPSRLju3Qx6rKT6aMBQboxhba/RwqZHJ9E=; b=HT9+EEZFc0fivSYAL8N5z8JPsfKRXP2cNlK8bZCCma7mlzOyeit4Rlxxq8H9FV7boX Q8cHbt3Pr4nWEVKPy3dDR0hlGXRLpZ9ZL5OUUyNwcztILbsliR4E9BL1LxOUhPmj3qzR +f38vMkIETFCjvtYBrMN4l7ekTla4juXzQdps= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=8vBQM3MrLtPSRLju3Qx6rKT6aMBQboxhba/RwqZHJ9E=; b=d2z/qMgynTQBu++eNN3XU3LR0MMjVZhRRmGoKFbi4e9NYGUKscSljhKme0WYxGF2pC 8wA6vtWrJ448YavY+mnB+nxp9Xvk5E5VQ/SFMBjfYZr0blMHv42ZG2neIppZrTpvX6OI fPq5Ki5SKu2AQAnlPpi0oJ7EvCjdNGF/kNVE60Tb1u6CJVgoEJUiam88ddwi/mal5eKC jwHv7JkNJK6fGmadC2MUpe/n5KWe5IJrbG8zm4a+Jk8gAr3biPllHTb4UTt4qme6mugx p8/hTMkI+CJ1767TZoid7mImW0xwvBAKxcnOiqa/4YZ1RXOdr4g18zpJzxZqAOmQ4GvX Fw/g== X-Gm-Message-State: AMke39kVilY4zD7cmesLf0TaPgzJlpblJf3B9qMwg/ECVsrUbz41Z5dTKZFfo28MWXJaMfrp X-Received: by 10.84.137.106 with SMTP id 97mr16134790plm.68.1488441356367; Wed, 01 Mar 2017 23:55:56 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id m6sm15007533pgn.58.2017.03.01.23.55.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 23:55:55 -0800 (PST) Date: Wed, 1 Mar 2017 23:55:54 -0800 From: Kees Cook To: Russell King Subject: [PATCH] ARM: dump: Add domain to output Message-ID: <20170302075554.GA33308@beast> MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170301_235617_666101_73B922E9 X-CRM114-Status: GOOD ( 15.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Afzal Mohammed , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This adds the memory domain (on non-LPAE) to the PMD and PTE dumps. This isn't in the regular PMD bits because I couldn't find a clean way to fall back to retain some of the PMD bits when reporting PTE. So this is special-cased currently. New output example: ---[ Modules ]--- 0x7f000000-0x7f001000 4K DOMAIN_KERNEL ro x SHD MEM/CACHED/WBWA 0x7f001000-0x7f002000 4K DOMAIN_KERNEL ro NX SHD MEM/CACHED/WBWA 0x7f002000-0x7f004000 8K DOMAIN_KERNEL RW NX SHD MEM/CACHED/WBWA ---[ Kernel Mapping ]--- 0x80000000-0x80100000 1M DOMAIN_KERNEL RW NX SHD 0x80100000-0x80800000 7M DOMAIN_KERNEL ro x SHD 0x80800000-0x80b00000 3M DOMAIN_KERNEL ro NX SHD 0x80b00000-0xa0000000 501M DOMAIN_KERNEL RW NX SHD ... ---[ Vectors ]--- 0xffff0000-0xffff1000 4K DOMAIN_VECTORS USR ro x SHD MEM/CACHED/WBWA 0xffff1000-0xffff2000 4K DOMAIN_VECTORS ro x SHD MEM/CACHED/WBWA Signed-off-by: Kees Cook --- arch/arm/mm/dump.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c index 21192d6eda40..63faa33a83b1 100644 --- a/arch/arm/mm/dump.c +++ b/arch/arm/mm/dump.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -43,6 +44,7 @@ struct pg_state { unsigned long start_address; unsigned level; u64 current_prot; + const char *domain; }; struct prot_bits { @@ -240,6 +242,8 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, u unit++; } seq_printf(st->seq, "%9lu%c", delta, *unit); + if (st->domain) + seq_printf(st->seq, " %s", st->domain); if (pg_level[st->level].bits) dump_prot(st, pg_level[st->level].bits, pg_level[st->level].num); seq_printf(st->seq, "\n"); @@ -267,6 +271,29 @@ static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start) } } +static void set_domain_name(struct pg_state *st, pmd_t *pmd) +{ +#ifndef CONFIG_ARM_LPAE + switch (pmd_val(*pmd) & PMD_DOMAIN_MASK) { + case PMD_DOMAIN(DOMAIN_KERNEL): + st->domain = "DOMAIN_KERNEL "; + break; + case PMD_DOMAIN(DOMAIN_USER): + st->domain = "DOMAIN_USER "; + break; + case PMD_DOMAIN(DOMAIN_IO): + st->domain = "DOMAIN_IO "; + break; + case PMD_DOMAIN(DOMAIN_VECTORS): + st->domain = "DOMAIN_VECTORS"; + break; + default: + st->domain = "DOMAIN_unknown"; + break; + } +#endif +} + static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start) { pmd_t *pmd = pmd_offset(pud, 0); @@ -275,14 +302,21 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start) for (i = 0; i < PTRS_PER_PMD; i++, pmd++) { addr = start + i * PMD_SIZE; + set_domain_name(st, pmd); if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd)) note_page(st, addr, 3, pmd_val(*pmd)); else walk_pte(st, pmd, addr); - if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1])) - note_page(st, addr + SECTION_SIZE, 3, pmd_val(pmd[1])); + if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1])) { + addr += SECTION_SIZE; + pmd++; + set_domain_name(st, pmd); + note_page(st, addr, 3, pmd_val(*pmd)); + } } + + st->domain = NULL; } static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start)