mm: arm64: document why pte is not advanced in contpte_ptep_set_access_flags()
Subsystems (2)
PATCH v2 1/1 mm: arm64: document why pte is not advanced in contpte_ptep_set_access_flags()
From: Barry Song <[email protected]>
According to David and Ryan, there isn't a bug here, even though we don't advance the PTE entry, because __ptep_set_access_flags() only uses the access flags from the entry.
However, we always check pte_same(pte, entry) using the first entry in __ptep_set_access_flags(). This means that the checks from 1 to nr - 1 are not comparing the same PTE indexes (thus, they always return false), which can be a bit confusing. To clarify the code, let's add some comments.
---
-v2:
* collect Ryan's rb, thanks!
* doc why but not advance entry
* refine changelog and subject
-v1:
https://lore.kernel.org/linux-mm/[email protected]/
arch/arm64/mm/contpte.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/mm/contpte.c +6 -0
@@ -421,6 +421,12 @@ int contpte_ptep_set_access_flags(struct vm_area_struct *vma, ptep =contpte_align_down (ptep); start_addr = addr =ALIGN_DOWN (addr,CONT_PTE_SIZE ); +/* +* We are not advancing entry because __ptep_set_access_flags() +* only consumes access flags from entry. And since we have checked +* for the whole contpte block and returned early, pte_same() +* within __ptep_set_access_flags() is likely false. +*/ for (i =0 ; i <CONT_PTES ; i++, ptep++, addr +=PAGE_SIZE )__ptep_set_access_flags (vma, addr, ptep, entry,0 );
Signature · 1 line
2.39.3 (Apple Git-146)
Quoted 39 lines · Barry Song
From: Barry Song <[email protected]>
According to David and Ryan, there isn't a bug here, even though we don't advance the PTE entry, because
__ptep_set_access_flags()only uses the access flags from the entry.However, we always check
pte_same(pte, entry)using the first entry in__ptep_set_access_flags(). This means that the checks from 1 to nr - 1 are not comparing the same PTE indexes (thus, they always return false), which can be a bit confusing. To clarify the code, let's add some comments.Reviewed-by Ryan Roberts <[email protected]>Signed-off-by Barry Song <[email protected]>Cc Ard Biesheuvel <[email protected]>Cc John Hubbard <[email protected]>Cc Mark Rutland <[email protected]>Cc Catalin Marinas <[email protected]>Cc David Hildenbrand <[email protected]>Cc Will Deacon <[email protected]>---
-v2:
* collect Ryan's rb, thanks!
* doc why but not advance entry
* refine changelog and subject-v1:
https://lore.kernel.org/linux-mm/[email protected]/arch/arm64/mm/contpte.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/mm/contpte.c +0
-0@@ -421,6 +421,12 @@ int contpte_ptep_set_access_flags(struct vm_area_struct *vma, ptep =contpte_align_down (ptep); start_addr = addr =ALIGN_DOWN (addr,CONT_PTE_SIZE );
arch/arm64/mm/contpte.c int contpte_ptep_set_access_flags(struct vm_area_struct *vma, · line 432
Quoted 10 lines
arch/arm64/mm/contpte.c +6
-0+/* +* We are not advancing entry because __ptep_set_access_flags() +* only consumes access flags from entry. And since we have checked +* for the whole contpte block and returned early, pte_same() +* within __ptep_set_access_flags() is likely false. +*/ for (i =0 ; i <CONT_PTES ; i++, ptep++, addr +=PAGE_SIZE )__ptep_set_access_flags (vma, addr, ptep, entry,0 );
Signature · 3 lines
Cheers, David / dhildenb
Quoted 11 lines · Barry Song
According to David and Ryan, there isn't a bug here, even though we don't advance the PTE entry, because
__ptep_set_access_flags()only uses the access flags from the entry.However, we always check
pte_same(pte, entry)using the first entry in__ptep_set_access_flags(). This means that the checks from 1 to nr - 1 are not comparing the same PTE indexes (thus, they always return false), which can be a bit confusing. To clarify the code, let's add some comments.[...]
Applied to arm64 (for-next/mm), thanks!
[1/1] mm: arm64: document why pte is not advanced in contpte_ptep_set_access_flags()
https://git.kernel.org/arm64/c/70565f2be880
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev