From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2770E450F2 for ; Tue, 1 Jul 2025 04:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751343545; cv=none; b=ftyhLFgpe3CnNE1t814kDFk18ob1RaUk7mrasCOJCiCYafJCxS7LBoFfxIGuMI9miZ4Ob2TWuZkC2B0DGr/i3GgCEjqUDoVBKvR2YeWQljVXu8Z9a5i5WKVgMYbPgfgcY4FWZOEjI+x/tmmVfJw5Id7WK9AS4RGUBqQMTIsn2FY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751343545; c=relaxed/simple; bh=Aj5ZB04KPPjlLHWqo4rXQ5Y1tadyRtfN0jMeN+6ttEM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n163E5xV/saw4yUEPqJXuUD16ObFLJVcNiz7NJsH+cYZAlBqcBbvYng8vpoltOxZpgdqrhSsCAMA4xYSsa0/3SFaq41+EC+HPYPXJY4ry0MdAittHG4ruJJtZ3XGqiimtW4tB9YmjU73X7BhV/oUN8ybtLfq6lDvcpathZJALeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C714415A1; Mon, 30 Jun 2025 21:18:41 -0700 (PDT) Received: from MacBook-Pro.blr.arm.com (MacBook-Pro.blr.arm.com [10.164.18.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 627C83F58B; Mon, 30 Jun 2025 21:18:54 -0700 (PDT) From: Dev Jain To: gregkh@linuxfoundation.org Cc: anshuman.khandual@arm.com, catalin.marinas@arm.com, david@redhat.com, dev.jain@arm.com, ryan.roberts@arm.com, stable@vger.kernel.org, will@kernel.org Subject: [PATCH 5.4.y] arm64: Restrict pagetable teardown to avoid false warning Date: Tue, 1 Jul 2025 09:48:22 +0530 Message-Id: <20250701041822.21892-1-dev.jain@arm.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <2025062303-unsworn-penpal-7142@gregkh> References: <2025062303-unsworn-penpal-7142@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit [Commit 650768c512faba8070bf4cfbb28c95eb5cd203f3 upstream] Commit 9c006972c3fe ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()") removes the pxd_present() checks because the caller checks pxd_present(). But, in case of vmap_try_huge_pud(), the caller only checks pud_present(); pud_free_pmd_page() recurses on each pmd through pmd_free_pte_page(), wherein the pmd may be none. Thus it is possible to hit a warning in the latter, since pmd_none => !pmd_table(). Thus, add a pmd_present() check in pud_free_pmd_page(). This problem was found by code inspection. Fixes: 9c006972c3fe ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()") Cc: stable@vger.kernel.org Reported-by: Ryan Roberts Acked-by: David Hildenbrand Signed-off-by: Dev Jain Reviewed-by: Catalin Marinas Reviewed-by: Anshuman Khandual Reviewed-by: Ryan Roberts Link: https://lore.kernel.org/r/20250527082633.61073-1-dev.jain@arm.com Signed-off-by: Will Deacon (cherry picked from commit 650768c512faba8070bf4cfbb28c95eb5cd203f3) (use READ_ONCE since pmdp_get() not defined) --- arch/arm64/mm/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 8e934bb44f12..ef94bf75b433 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1041,7 +1041,8 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr) next = addr; end = addr + PUD_SIZE; do { - pmd_free_pte_page(pmdp, next); + if (pmd_present(READ_ONCE(*pmdp))) + pmd_free_pte_page(pmdp, next); } while (pmdp++, next += PMD_SIZE, next != end); pud_clear(pudp); -- 2.30.2