Skip to content

Commit 70565f2

Browse files
Barry Songwilldeacon
authored andcommitted
mm: arm64: document why pte is not advanced in contpte_ptep_set_access_flags()
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]> Reviewed-by: David Hildenbrand <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent eeb8fdf commit 70565f2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/arm64/mm/contpte.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ int contpte_ptep_set_access_flags(struct vm_area_struct *vma,
421421
ptep = contpte_align_down(ptep);
422422
start_addr = addr = ALIGN_DOWN(addr, CONT_PTE_SIZE);
423423

424+
/*
425+
* We are not advancing entry because __ptep_set_access_flags()
426+
* only consumes access flags from entry. And since we have checked
427+
* for the whole contpte block and returned early, pte_same()
428+
* within __ptep_set_access_flags() is likely false.
429+
*/
424430
for (i = 0; i < CONT_PTES; i++, ptep++, addr += PAGE_SIZE)
425431
__ptep_set_access_flags(vma, addr, ptep, entry, 0);
426432

0 commit comments

Comments
 (0)