From patchwork Wed Feb 14 12:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13556549 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 6066BC48BC3 for ; Wed, 14 Feb 2024 13:46:03 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=L+oaVMJj/Bjzy/8SKJAW9+ByBpJnMcxcCEypuGz6SxQ=; b=PRy7mnVdfmd/AO8ZEF0CHAEkAZ weCc31qeCVxc9LzlauJBai+ctAKlW+NP6MkM9KfgCToj7QkKARB3PG0Oo9GuPpfaO+eC28flXSZLp yI7JVBrD30JiYhT1BXRK9SYZnwPTFIPPVeDVTpgZ4fzANJj2wN9/4xmwxIFZ3YUxENnDi6EzOmN4P hKkqd61d64xD1ZH6aIx9YmMILQ4ZVNbZGVl/Zj0GV2DeD9KedZETJoAPQiUm5040YOU+sjsBSNIMq ILBRTYyEp4YM6H4XP0+uMGFGj3kTrFTe5rdL2mDYGeLSfzyg2TFAiCVBThXV6o6YFvJ0xTKwvZRqY yPc78EWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raFa9-0000000D3hx-3j7U; Wed, 14 Feb 2024 13:45:49 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raEPw-0000000Cp89-1d0X for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 12:31:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xB/mYZkbr5+wxmNwrn7xpjisrtVvEFG2X093yBnkuGY=; b=UzPIOiEIaBh8uFItbmOfPdJ0P8 xtZPx8QtnZaJ1ga++4kvtaNWLsX8h8IWaXQx8YbqRj5XhdwRA6nM82BHDkOpEJuNO4Uo8mPMm02mI AKR3QU5FNT7eMQ/cS+zb/LuGCnB8cexBSxzXOcvOini3nb57TZnbrMpVn0Ocu8LIW7sqvWELJUjJq bpD7BZgsc3snfV5PsKKOQ0zwi5g4VmxcLz8AieuIigAEK56+Pwgo5p4o9n8LxDFiWcEjlvdOqxMx9 MtHCTMxgUdbXbvHk/Xr1J3PW8GpBygqPdCuEFyYyH4CEXSC1jQ4Z/WEVUdjcdGHW9XlHkG3hU9fxW sd+rg55Q==; Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raEPp-0000000GEDJ-3Yib for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 12:31:11 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-410040e1fcdso31158965e9.0 for ; Wed, 14 Feb 2024 04:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707913864; x=1708518664; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xB/mYZkbr5+wxmNwrn7xpjisrtVvEFG2X093yBnkuGY=; b=CBnERD09DiGjiXL/r/qzrulmydi1S/hDdeSeEQshnUNU7WvyTde9OLM8g8ZtcwuYRO cV61/lJ9gIzgdWM7Diz4V1vqcIaACDBiovz5MxU6gImnlamZ/n36wU3vzml+FYirdzqW YXFGSc+X23C+LDprxSH2mFoSpA2QPz+2hufDYoQj4nyLFKrwWYGgjxjaW253XU6volVN I4oCOJ3hnX8inhVDT+vM1oduRmsC916vJszuXuJfKtEk77h5BBLRsnBjEffY89b0t7vs csUti47Ps1tpXtryLv7B8K1pNpFAR70ac5jx+k34ylmFnFrJTjpD3gjUgspbk3gaO9ji OqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707913864; x=1708518664; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xB/mYZkbr5+wxmNwrn7xpjisrtVvEFG2X093yBnkuGY=; b=ulabBSPomx1yfo4HAAl+QrX7zF+m87GXTVWaUTCU9vH3w6yoHr/dnEK3z3QkShsON6 i63d6AIxvPKazY8m2RgQniX9KL4n2uTxKxi8olQXZidFODFkSKuwGVIwYb6TSG6X0Un1 E/8BImfNANiB5J3pRg41kMWEh4RxgiI3Fc7/3twIgCfPOmS3tUcRBsmTTT9bQoSHkPDW Hw7OKy0OHCiBpxGYDBbSCnDOdmvZNh2PwH/mP5/CS71MGLGmFcmLpFVXaoFlR19fboUw F37Rwvp3+i7Em6pd8fmsCwYMKXOCZj4XK7O1VQaq+NTjufqqOaxx8eJOTYELE3V49Dik IY0Q== X-Gm-Message-State: AOJu0YyZfI+Bk8wPxyiXlGISKodpbJykQspZMDuM0GrXfOjI36S0zyZf mPXN8A57LKbt9mgWHox6SNJKJO8ovFWYc3CseNWgGt6JoRLlKVD42gP2pKhis9HDJwOaCcQrT8y qS+5GZ816f/vAmzKgtwOHbxlgymhIZoORfLT9Z36fZO8BFMCcJhHUJZfsLBo7IfFIJLkTwkLdNi CLpi4ZAyGBUTja+P6uOzXgUsAwDC40vDK9xKJCI9Z0 X-Google-Smtp-Source: AGHT+IEA6chSQ8en9KQRNq09V0YgH8/aEkA9N6fU2OWZfPnDx3EAYTviMPrrx7eHgjOFy6B7vW1dI3DN X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:600c:a3a1:b0:411:a7e2:3d1 with SMTP id hn33-20020a05600ca3a100b00411a7e203d1mr8913wmb.6.1707913863998; Wed, 14 Feb 2024 04:31:03 -0800 (PST) Date: Wed, 14 Feb 2024 13:29:23 +0100 In-Reply-To: <20240214122845.2033971-45-ardb+git@google.com> Mime-Version: 1.0 References: <20240214122845.2033971-45-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1822; i=ardb@kernel.org; h=from:subject; bh=Z0ZgGEfpKUtf6qjfEXxNzR8II3DYIwckYLN0dHdtLDQ=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIfXMJjWXdN7DTzk/PGts/GIvspDv3HdnWa7txbdc7DT+H nR0PencUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACYSrcrIMG/NFlNple0NV7IM OX3bNt0yfZeudM8lMWFuyS3GqqIl3xn+yk+MTXnN8MdV4ouAWdDkZ3flTPbweQa5PvbTkHPObFL gAgA= X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214122845.2033971-82-ardb+git@google.com> Subject: [PATCH v8 37/43] arm64: ptdump: Disregard unaddressable VA space From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_123106_180477_75C2F2D1 X-CRM114-Status: GOOD ( 16.84 ) 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 From: Ard Biesheuvel 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. So define the start address at runtime based on vabits_actual. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/ptdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 5f0849528ccf..16d0cf1d85c4 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -313,7 +313,6 @@ static void __init ptdump_initialize(void) static struct ptdump_info kernel_ptdump_info __ro_after_init = { .mm = &init_mm, - .base_addr = PAGE_OFFSET, }; void ptdump_check_wx(void) @@ -329,7 +328,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} } } @@ -370,6 +369,7 @@ static int __init ptdump_init(void) static struct addr_marker address_markers[ARRAY_SIZE(m)] __ro_after_init; kernel_ptdump_info.markers = memcpy(address_markers, m, sizeof(m)); + kernel_ptdump_info.base_addr = page_offset; ptdump_initialize(); ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");