From patchwork Mon Sep 9 12:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13796990 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 20EF1ECE57A for ; Mon, 9 Sep 2024 12:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8qvkXCdHWEWBsZylsWm6hwfThTp5oWOCgEDtNeKXpl8=; b=0C4bBDu7L216aJz5O+ZvTTTDwd wUXB5BfTEqmjrPRhy8a5Ey5ghZrYagbc7vYQJ57TUOsOxhCluyqIAD2PnfQlsYnqjL2rIwazlsIK+ NKTivpuPh8GBxn8riq78NfqX4n3QfUooVSN1PIrO11HH2O2Q3hgV8sce18BJRhyQpWoGJpKMqc/cj FkiEKbdK0tTPoWvpsFkzV/swqAJKWECLu86tl+06rxV4M9FbpTI+V0qJM/E5zykbRuj1LkQ9g2AV4 4VIwJnFZoQID1+mfKOuqkS4etmPKNpGEoJoWPOoHyI6ShX9lo0pDvSCuFyqwcBDjrjdv/N/FflKtd FlI8bYJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sndtR-00000001wey-1ceL; Mon, 09 Sep 2024 12:53:21 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sndns-00000001uYj-1IMc for linux-arm-kernel@lists.infradead.org; Mon, 09 Sep 2024 12:47:39 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-374c294d841so3244389f8f.1 for ; Mon, 09 Sep 2024 05:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725886054; x=1726490854; 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=8qvkXCdHWEWBsZylsWm6hwfThTp5oWOCgEDtNeKXpl8=; b=v+CqfCKFXramUNM8VXBZ0uvlYXE/QE5kH6PrkjBwGOohaVErSOVv1Ns/yjUwJmbKla WnWJL3YoxsdF/HyTw+4C1XlmeEd+Iocoa4NxJk8qUO6NAMMe+KXR1+RbSaYKRJjYSF2a zQXNZy5RJRPSw80a4534+GSZ1EjZ0T7NVn0itbFUC78vtXyEhq6C8NbmdIzF7xdUtvlT sf/BIwZsd/4lr3vyxCZk5g6wsv02ePXXcSm1Ix505mqHDjinfg3r2pFUSBInvSGWWis6 ZqCUPJPrv8nEwGMK+f8CZixa3h0TtFeVJBDYreKN8Xe9HgdQErYoLEFxibmqYnlnYmqG 5Cug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725886054; x=1726490854; 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=8qvkXCdHWEWBsZylsWm6hwfThTp5oWOCgEDtNeKXpl8=; b=lGQYucBt/bhWn1kGtpEflq1pPoGB24EzomHa8wAZ5IOkuiKDyOqvinoZi4zwypV2eL el4lDhxtL2ivT0rTHzfGcfqLq8Gk5Xw2TvNWil48blLrDn5ARrnkLuEwXn6urA1bU91x JsdOiHLs+2FlxYOHeff90MdEBvJA42GOn3oK1cLwSuFjEwrqxc3Z+kREtP+yvkS/rymQ fFlvhOQJiQZLk5kYi7Tx3xx0ONFA7lGjvtmxPBnwNJkINRcNN5WgcemsR1NirSHpO81C AraXebl/fVxr+UDk/ifAgISZHEh00g5qvGKz5jZZsqqL1nS0a0GNJPFU6Vk+VWdclsWD +SYQ== X-Forwarded-Encrypted: i=1; AJvYcCUyUEgDRK86sHN9G1b9vFCBCkWGV0nc0wh7jE0AkZNnYZa+Zopc4PU4C0DvWqzD59Ls2bjLygEWxBFjAzIS6B7s@lists.infradead.org X-Gm-Message-State: AOJu0YzPQb3qFU0T7bZbl3b0MebY41Spfs0BAvZCU4GBBwEaUGPc35Te UQUaMw7pZ5rwGFS7Nvl49DChMmEKXaWfZMo46kaKQwigvOu9ebcFTyOrKnZJ0YrdemlDmCAS1lE 3ig0/5AuxFewGEKekQaioArhwyw== X-Google-Smtp-Source: AGHT+IHXNUAE7VdC5OTZOKpQ5J1caGnUk0ojDWhw1KiR9y5AZtlPfQlw2THkS+FmwEps5TC/2oefb8PtdRKpmxLL8Qc= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:68:fe9:ac10:f1b7]) (user=sebastianene job=sendgmr) by 2002:adf:f4d0:0:b0:374:badb:3cc0 with SMTP id ffacd0b85a97d-3788969b893mr13963f8f.9.1725886054280; Mon, 09 Sep 2024 05:47:34 -0700 (PDT) Date: Mon, 9 Sep 2024 12:47:20 +0000 In-Reply-To: <20240909124721.1672199-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240909124721.1672199-1-sebastianene@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240909124721.1672199-5-sebastianene@google.com> Subject: [PATCH v10 4/5] arm64: ptdump: Don't override the level when operating on the stage-2 tables From: Sebastian Ene To: akpm@linux-foundation.org, alexghiti@rivosinc.com, ankita@nvidia.com, ardb@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, james.morse@arm.com, vdonnefort@google.com, mark.rutland@arm.com, maz@kernel.org, oliver.upton@linux.dev, rananta@google.com, ryan.roberts@arm.com, sebastianene@google.com, shahuang@redhat.com, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240909_054736_679693_EBB429E4 X-CRM114-Status: GOOD ( 14.33 ) 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 Ptdump uses the init_mm structure directly to dump the kernel pagetables. When ptdump is called on the stage-2 pagetables, this mm argument is not used. Prevent the level from being overwritten by checking the argument against NULL. Signed-off-by: Sebastian Ene Acked-by: Will Deacon --- 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 ca53ef274a8b..264c5f9b97d8 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -197,8 +197,8 @@ void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 prot = 0; /* check if the current level has been folded dynamically */ - if ((level == 1 && mm_p4d_folded(st->mm)) || - (level == 2 && mm_pud_folded(st->mm))) + if (st->mm && ((level == 1 && mm_p4d_folded(st->mm)) || + (level == 2 && mm_pud_folded(st->mm)))) level = 0; if (level >= 0)