From patchwork Tue Jan 23 14:53:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13527717 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 8EEB1C47DDB for ; Tue, 23 Jan 2024 16:00:39 +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=IEXrLhwOWiRxJ0PkJGqWBLtQVNWCStDo4GFsNe+U0QA=; b=WxKVAhBwX3O+a0UbRcjUjNXODI mV8kKhhfMMzY0ywKqta3WepejMjC3jXP7cg4nUTihohpEd4qE6bDnUqMVsy28WjMf2vSeIjXykLsz G4UyA6sWFTdp7xL6SRE5Euj9OPm045OaGyGd8lfCSHmXsyFVfAgIj0opqMl1Df421dyxQQF1Egqo8 YueSGiR5q6Kj4jJqF+/hXJWCcF9/hutiJBF8m+xXcDnL38eu2uwOVwiUfdMhrHbKMdtwK8aBq7v8k EloC3d/w/Vvb5UgY4d94e6wEPt0LJXSHgrFdg5Mn9H/wmo3szoF3qpSbM9bomsWV6wIFxQlJptZ8P x73F1GlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSJCX-00HAvs-0F; Tue, 23 Jan 2024 16:00:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSIC9-00GuVO-0M for linux-arm-kernel@bombadil.infradead.org; Tue, 23 Jan 2024 14:56:09 +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=S4Bndw/zTFmap5t3jLATpGIBfwHi768410CCT9rElcA=; b=JW+brnEUw/x6hwW5BPVj4zEUtn CtBaFkWqQg7aJD1FlWzfxEc8G4368HCQK5gtGVH5FNim5C2aZQSd7vgRL3wC2seEW86gkYCotLYSq Z/NQtsReeQIdJmTTVWCaEBw15gFmJQI+/whzxWpgeLa4amSCqihKUMzDYLTtjq0PWRtTKT6wQADwF F4PP9xhgYJ6AAym/owe9ByyM0WtafDY39JyjepShEPYljOoHYXdguVy1NyKYfItZtv+TvvAcA0j7B AYANv15gFklHplA+ltDyjZpQz+YVhXXF8DKC4rhsJfQ/YtL5kWzksHZPmn/gkhWjgiYFto4egDjSM IKolZ84w==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rSIC5-00000003vdg-46pq for linux-arm-kernel@lists.infradead.org; Tue, 23 Jan 2024 14:56:07 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-dc2358dce6bso4923742276.3 for ; Tue, 23 Jan 2024 06:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706021764; x=1706626564; 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=S4Bndw/zTFmap5t3jLATpGIBfwHi768410CCT9rElcA=; b=gNkoJrogoRmxvnWUDj5O0Q4DRztKXQyIUn+V090HK/W0YxEnYkxJi8BC36/21rf3yy XJo5Dq2C8ArjtLNf8uWCipxMejbK6U5tDObjedYvVG8hklzFSCwXK0afjiD8lJLcXC2D fMFKdhwv030xFrazE3FlBfryS7wRkSrF71hybFWoMJXenjIhvoBioZDfagmTb0kHx0yY adh20yXCgaZ+tKexnhLsphh+A8lBqokY6D8JYMPFRJhpo/+yZIa5fZ2ihJD7/EkmyEML k6wAgdRAF++mJ71ETdbSzubTpUAGsF12bMzL+EevJUMM84wSblg/R3On1/IFq4kv4RyE d1Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706021764; x=1706626564; 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=S4Bndw/zTFmap5t3jLATpGIBfwHi768410CCT9rElcA=; b=Shub7+30sgUQh9yVoDk7DWjETa7iNMsMKsfg/eBQxw4/SAlZkd8J1+o396p8s8g9Mw 0YI/cM6xu5WdkkgfaVjewqJDpguAr/KEnTRWrQWgzlkptLbcsNP6+toMXGcNJIRFH2t6 2KyuydvEglRMKRuz5jOE8RvOQaqB0sjEUhAk8MK8jSOHQvDoNU1ZzfwDoiWcooAiyITp vLHMzEujvYszRsNHshgMiU2nGqigJOtm8basJLO+dBqAJdAvG2jvmOwJ3if6ZzJ0qmi3 y9JCkqPe8cW/f+oIm6ytGnae8kVbZ9dByB2R1nltOII/OxuDXIbpTAtSz2gIwBPJvK4i IZcQ== X-Gm-Message-State: AOJu0Yzo1pI03058akHuN7EVa+tA+kL4blnfOgPg/Ij5ZYlvunVhx4d8 /mzJyQAmopiomSqU+zCPjxB96/g43+Y4sYt63KBb9WTeMxU03qHPnfMdUzZXZiIz1rTlDcEVsS3 mF82BMvnDbIiejtN3k28Xs3FfND0wfKsITQoPfLgHiCYrp3tUD+Y810pdlW/4zo2+IEJu4uvELH nUIabL+nKJey1jlLye3HrGQvasvkZa8tdLB1w4CzVC X-Google-Smtp-Source: AGHT+IFrku82qxsL8fFzPjVGnOTmZxXcSh6RQnd1Z2fzUpSmrCtT2OR/VHBtPyQ7emppfpzDOIc7RYPN X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6902:2288:b0:dbe:a220:68ee with SMTP id dn8-20020a056902228800b00dbea22068eemr328562ybb.0.1706021764275; Tue, 23 Jan 2024 06:56:04 -0800 (PST) Date: Tue, 23 Jan 2024 15:53:43 +0100 In-Reply-To: <20240123145258.1462979-52-ardb+git@google.com> Mime-Version: 1.0 References: <20240123145258.1462979-52-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=GzVcNg2DAplbAwleBFPVIa5YpcJERq8gk5D5Y6f5riQ=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX9pV9B5snv3qf+4Xa5WRFZyXkw5saJmK1HFrswKhsaX NcM2pjTUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACaSr83I0O6fN2fmPvWgKpu5 e/UKBPoOlT9w1n1p5u8517/o99LeREaGlpbvWbIvvHmrG0NTp8nkzU4/HXHyeVTfobBtAf9iP8m zAAA= X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240123145258.1462979-96-ardb+git@google.com> Subject: [PATCH v7 44/50] 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-20240123_145606_187884_DB6FA0E0 X-CRM114-Status: GOOD ( 16.95 ) 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");