mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhao Gongyi" <zhaogongyi@bytedance.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
	<catalin.marinas@arm.com>,  <will@kernel.org>,
	"Ryan Roberts" <Ryan.Roberts@arm.com>
Cc: <dev.jain@arm.com>, <baolin.wang@linux.alibaba.com>,
	 <lance.yang@linux.dev>, <mark.rutland@arm.com>,
	 <akpm@linux-foundation.org>, <ljs@kernel.org>,
	<liam@infradead.org>,  <vbabka@kernel.org>, <rppt@kernel.org>,
	<surenb@google.com>,  <mhocko@suse.com>,
	<linux-arm-kernel@lists.infradead.org>,  <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>,  <stable@vger.kernel.org>
Subject: Re: [PATCH] arm64/mm: restrict transparent contpte mappings to valid PTEs
Date: Mon, 26 Oct 2026 21:30:08 +0800	[thread overview]
Message-ID: <52e7e1f6-3535-474d-9b46-6bb62f96eefc@bytedance.com> (raw)
In-Reply-To: <1c0141e8-3033-4f59-b247-34dee14cbb1f@kernel.org>

On 10/25/26 8:34 PM, David Hildenbrand (Arm) wrote:
> 
> Can you paste the code here for easy review if that it the right approach?
> 

Hi David,

Sure. Here is the minimal prototype I tested. It leaves
contpte_set_ptes() unchanged, so present-invalid PTEs can retain
PTE_CONT. The pte_present() check excludes swap entries, where the
same bit position can be part of the swap offset.

diff --git a/arch/arm64/include/asm/pgtable.h 
b/arch/arm64/include/asm/pgtable.h
index 6000905a2..2f89959ec 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -185,6 +185,7 @@ static __always_inline bool pte_present(pte_t pte)
   * Returns true if the pte is valid and has the contiguous bit set.
   */
  #define pte_valid_cont(pte)	(pte_valid(pte) && pte_cont(pte))
+#define pte_present_cont(pte)	(pte_present(pte) && pte_cont(pte))
  /*
   * Could the pte be present in the TLB? We must check mm_tlb_flush_pending
   * so that we don't erroneously return false for pages that have been
@@ -1704,7 +1705,7 @@ static __always_inline void 
contpte_try_fold(struct mm_struct *mm,
  static __always_inline void contpte_try_unfold(struct mm_struct *mm,
  				unsigned long addr, pte_t *ptep, pte_t pte)
  {
-	if (unlikely(pte_valid_cont(pte)))
+	if (unlikely(pte_present_cont(pte)))
  		__contpte_try_unfold(mm, addr, ptep, pte);
  }

The diff is against 24a19b953e2a. The runtime tests used the same
changes on an arm64 tree whose base pgtable.h and contpte.c blobs
matched. In a QEMU/KVM guest with KASAN enabled, the guard-marker
reproducer passed 100 iterations, and the fork and PMD-split probes
passed five runs each, without warnings or KASAN reports. The
unmodified kernel failed on the first guard-marker iteration in the
earlier A/B test.

This shows that the reported failure can be prevented by a small
change to the unfold check. As Catalin pointed out, this prototype
does not extend pte_batch_hint() to present-invalid entries or address
the other pte_valid_cont() users. I agree with taking v2 as the current
fix and considering the broader grouping changes separately.

Thanks,
Gongyi

  reply	other threads:[~2026-10-26 13:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  9:36 Zhao Gongyi
2026-10-13 10:13 ` Dev Jain
2026-10-14  6:16   ` Zhao Gongyi
2026-10-13 15:39 ` Lance Yang
2026-10-14  6:31   ` Zhao Gongyi
2026-10-14  6:46     ` Lance Yang
2026-10-14  8:38       ` Baolin Wang
2026-10-14  9:24         ` Lance Yang
2026-10-14  9:35           ` Baolin Wang
2026-10-14 10:03     ` Dev Jain
2026-10-14 10:45       ` Lance Yang
2026-10-14 11:02         ` Dev Jain
2026-10-14  9:41 ` David Hildenbrand (Arm)
2026-10-19  7:06   ` Zhao Gongyi
2026-10-23 20:55     ` David Hildenbrand (Arm)
2026-10-24 16:00       ` Zhao Gongyi
2026-10-25 12:34         ` David Hildenbrand (Arm)
2026-10-26 13:30           ` Zhao Gongyi [this message]
2026-10-26 12:30         ` Catalin Marinas
2026-10-23 12:12 ` [PATCH v2] " Zhao Gongyi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52e7e1f6-3535-474d-9b46-6bb62f96eefc@bytedance.com \
    --to=zhaogongyi@bytedance.com \
    --cc=Ryan.Roberts@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=catalin.marinas@arm.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®