From patchwork Tue Sep 12 14:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13381864 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 BDCC1CA0EF5 for ; Tue, 12 Sep 2023 15:30:30 +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=UaK+flF+GeMESrwGxjU6hsIJQlqnB8NvcgnPpyvtpGM=; b=nyu4IKLyXEGsNBeQL5z3THAZsH 3i6JbEpHAXJ+q1gOrMGhdzCFOMAPE/33nXCYVdZkBefFl8EOqA5yE7jSpaS6hQWjntXHg+C+ARVxH /E4yMsV1IkViTSD7rDCo+SIbDncCysidfiRbQXt/uii1ue0uFMS+fytUUmMa7aosZ7WbccBzJvloz nbVRLroxMU6BqA+urObAY+jxwFsV0b3YglDpJm765wwYtiFkkGFETtst7c77iRZ2RXqbhb9st8Q5v Hp6v+Zlt1J3RmGj4jI5cX4+E2lwAmSDHJI3Lx7ws2ma+WqcNQm5iFNzjQXJW9NYJavhoEQggH3KpW bwbUPKVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qg5LR-003ihd-1k; Tue, 12 Sep 2023 15:30:29 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qg4Ei-003XUd-21 for linux-arm-kernel@lists.infradead.org; Tue, 12 Sep 2023 14:19:34 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-31fa1631b0eso1663443f8f.2 for ; Tue, 12 Sep 2023 07:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694528366; x=1695133166; 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=2q1VRrjkhHjbG6wFyzvSTGEX790OB5iXPWlDPWUoBkw=; b=y+LVHXhqMtroXhHzaXCMBpPB0X4ANWoEU2EKHojPVw9a5EmhK5Z2UxZn1ZJn/0Q5j2 BD5NJyMv2k47/zJRKrajr+Vf/rwr5kIVx5MMtn+8y3AV9RMKAw907+4rKimQRNNk/70N slVcBe4dQZTTFyY+WyGD8zg2gCXrtNn0xBmoA+0cd0aOU29uQqvSIBxNc6GYosCEmAma +0cmoZuLj1F0v3idylH5inplSnNtjHzn9GkPAUGxpR12BjZ1C/kgMzGlSY37AXBRWCQF vrr6U2u0grjOui0O99RxFKXuC3LYz402qj3Sf2Igbl8m5lewxvSz6JBy9W9157PfnQq5 jefw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694528366; x=1695133166; 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=2q1VRrjkhHjbG6wFyzvSTGEX790OB5iXPWlDPWUoBkw=; b=F40Lvnfr9Rn2OvE8TEYDkjiTKi9/2RHPYzDC+W1Flm9Q5wj6rgh7Y+wXINTkc1/hxP JcJmqM1yXYN0ZESgrqandHyp7pILiJi8xrreDy6rBxrcijz24FvfaSfJ69OZw8YBRoV+ /g8eBXCobEllwWsNTxn9sMJcm+DWUT/7ZbnEcdwpfvT8ol/D5v4P1+6vsmPlrlztd75M GVEELzBuB1bJWwWmprPRwXxRngYDgl4Atvr3ElE0R/idK/qsbvomseVaiB25GUE1v6CI MlW9JQsCRVxhopDoBAkNkVdUFFss3HEq2t9sz42/e2VF/BJTUVwPC295avf6flBdeNk5 v/Wg== X-Gm-Message-State: AOJu0Yyl7/vQg49DTwhTX+iWj/fovxqgWoypR4jAPEjGQqD+7toebFen 3x0DmJILRTRNflwMlc09WkWZb3bv12CKmsYIGFwjfEnUK/SWd86Jf6/DyfMzlS/PQUqAp106Eqp SOVDwdAgFvs/UNLOLWlkEy8LzvfRijJj6L5mQcmYRN4ytAxRQmvrPUUy2b4JifSZeuv3x+NTluW E= X-Google-Smtp-Source: AGHT+IGM8fG/aQOjNu+C/ESUxXvXEUyqDjS+4sjTOyG8sRg3KPt9fi9+kxE3WeGAavzNNNQGsRc4JyTO X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:adf:fc0d:0:b0:318:1210:210b with SMTP id i13-20020adffc0d000000b003181210210bmr183719wrr.12.1694528366412; Tue, 12 Sep 2023 07:19:26 -0700 (PDT) Date: Tue, 12 Sep 2023 14:16:44 +0000 In-Reply-To: <20230912141549.278777-63-ardb@google.com> Mime-Version: 1.0 References: <20230912141549.278777-63-ardb@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=CRvId4fOeua2UCLYyJMWyj3lTxC7N11/FgVB0VS/pms=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIZWh6Hzwsarzh4umPxDxSTtr4PgygvevnqfkLf19wXPjK q76ptV1lLIwiHEwyIopsgjM/vtu5+mJUrXOs2Rh5rAygQxh4OIUgImIzmT4p9O1md+hQLqe3/r5 wfm1XS567RN4GF+tMZjHm7qE0S7lAsN/P6lld0sCZzQL2plWf0ueZC5i0Lbjx7SJ174/qF/Fvs2 XFwA= X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912141549.278777-117-ardb@google.com> Subject: [PATCH v4 54/61] 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 , Joey Gouly X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230912_071928_684114_5CC46404 X-CRM114-Status: GOOD ( 17.87 ) 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 f3fdbf3bb6ad..221baaf521fa 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");