From patchwork Thu Nov 24 12:39:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13054944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A0BDC43217 for ; Thu, 24 Nov 2022 12:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Gslbpl5X2abytE7Qir+MWeDOUB765a77sHHSGx9PmTE=; b=H3WCl05IpVMMic 2eXwquiT9dbLzkHlldW+rUgYXHLeu1vjzMOBpmOFuLVN+uzRNXGVf/F4SJdKya2GB21x+w8kQB5ID X3CYCQAxMeg7S3dVaXR4LfpnpHvQZh5db0/eX7yaVhApC2NMCHl1M9u3OE9oam0qtjTP6vdOt1b+s 0c0qTtL4DPNf5GM8LGahA87Ni2ZGzLPoHr1fE1z3FhDW/FMMIbN8rAhyYYnUB1OfdRIRpPlgqp8ii PBRRrHjwlHvILRk2lKcl3yL1gtwKybkGFmGpGDDGsRyruCx79fSqVWbdBEn6rh71qVaE0qLzeLgFZ 776D0EKzHCCCajVsemiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyBgL-008Tws-Md; Thu, 24 Nov 2022 12:50:22 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyBX7-008Okb-Bf for linux-arm-kernel@lists.infradead.org; Thu, 24 Nov 2022 12:40:51 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BCBFEB82788; Thu, 24 Nov 2022 12:40:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E97E1C43148; Thu, 24 Nov 2022 12:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669293646; bh=wUgo5hOEF/bq/9/ZsmwLcIumxx+oSNKNX7Tl3tUX49k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OWGBgRhLVIBOGMqIQhT5MIozEi0fbCHehvwzta1NuNQdF2AYyXkKOnYBOJqdDpT0Z XYBNjGBFXzxVlX0hBS8i5nVYkteshCsHpVI2D/04MXvGL/Fh4WRpmcGpUblClyo7/b N2IlRz07hhDqu+NTYcCzWoNTgMPbPmV2pbGfIXECcPrHvzCt4fIf8h5bIdGb9G0L93 OjNLrhIZ58ZXlW3ULLR1aeJ1DhmCMMAxl4DpT6u2PSfVdZExXNfoWs6/EXRuWcJjO7 4AEp6je91fsnhFh+bSpgPHPj+AFsXxWyN4cC203g7+doOKhniQiqSO8ZBQeLkjo/h5 nnb8clcN/LXug== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual , Richard Henderson , Ryan Roberts Subject: [PATCH v2 18/19] arm64: ptdump: Disregard unaddressable VA space Date: Thu, 24 Nov 2022 13:39:31 +0100 Message-Id: <20221124123932.2648991-19-ardb@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221124123932.2648991-1-ardb@kernel.org> References: <20221124123932.2648991-1-ardb@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221124_044049_593120_B9002FD8 X-CRM114-Status: GOOD ( 17.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Configurations built with support for 52-bit virtual addressing can also run on CPUs that only support 48 bits of VA space, in which case only that part of swapper_pg_dir that represents the 48-bit addressable region is relevant, and everything else is ignored by the hardware. Our software pagetable walker has little in the way of input address validation, and so it will happily start a walk from an address that is not representable by the number of paging levels that are actually active, resulting in lots of bogus output from the page table dumper unless we take care to start at a valid address. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/ptdump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 9bc4066c5bf3..ca38ac2637b5 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -358,7 +358,7 @@ void ptdump_check_wx(void) .ptdump = { .note_page = note_page, .range = (struct ptdump_range[]) { - {PAGE_OFFSET, ~0UL}, + {_PAGE_OFFSET(vabits_actual), ~0UL}, {0, 0} } } @@ -380,6 +380,8 @@ static int __init ptdump_init(void) address_markers[KASAN_START_NR].start_address = KASAN_SHADOW_START; #endif ptdump_initialize(); + if (vabits_actual < VA_BITS) + kernel_ptdump_info.base_addr = _PAGE_OFFSET(vabits_actual); ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); return 0; }