Re: 答复: [外部邮件] Re: [PATCH] arm64: mm: refresh stale pmd snapshot after split_contpmd()
From: David Hildenbrand (Arm)
Date: Mon Jun 29 2026 - 03:45:23 EST
On 6/27/26 04:46, Li,Rongqing wrote:
>>
>>
>>
>> On 6/25/26 4:39 AM, lirongqing wrote:
>>> From: Li RongQing <lirongqing@xxxxxxxxx>
>>>
>>> split_contpmd() modifies the pmd entries in-place by clearing the CONT
>>> bit, but the local 'pmd' variable still holds the old snapshot with
>>> CONT set. The subsequent split_pmd() call uses this stale value to
>>> derive the pgprot for the new PTE entries via pmd_pgprot(), causing
>>> the resulting PTEs to be populated with incorrect protection bits.
>>
>> If I read the code correctly, CONT bit is cleared by split_pmd(), then the bit
>> may be set again for PTEs if we want to have cont ptes. So I don't see any
>> problem, did I miss something?
>>
>
> You are right, there's no functional issue with the current code.
> However, I think explicitly re-reading the pmd is the safer and clearer
> approach — it makes the intent obvious (we need the post-modification state)
> rather than relying on the implicit assumption that "CONT bit doesn't affect pgprot."
Note that it's going to be another read (READ_ONCE()) that cannot be optimized
out. Manual pmd_mknoncont() might be cheaper.
But then, nobody care about it being set or not ...
--
Cheers,
David