Skip to content

Commit e3a1f6c

Browse files
David Vrabeltorvalds
David Vrabel
authored andcommitted
x86: pte_protnone() and pmd_protnone() must check entry is not present
Since _PAGE_PROTNONE aliases _PAGE_GLOBAL it is only valid if _PAGE_PRESENT is clear. Make pte_protnone() and pmd_protnone() check for this. This fixes a 64-bit Xen PV guest regression introduced by 8a0516e ("mm: convert p[te|md]_numa users to p[te|md]_protnone_numa"). Any userspace process would endlessly fault. In a 64-bit PV guest, userspace page table entries have _PAGE_GLOBAL set by the hypervisor. This meant that any fault on a present userspace entry (e.g., a write to a read-only mapping) would be misinterpreted as a NUMA hinting fault and the fault would not be correctly handled, resulting in the access endlessly faulting. Signed-off-by: David Vrabel <[email protected]> Acked-by: Mel Gorman <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2b9fb53 commit e3a1f6c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/x86/include/asm/pgtable.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,14 @@ static inline int pmd_present(pmd_t pmd)
476476
*/
477477
static inline int pte_protnone(pte_t pte)
478478
{
479-
return pte_flags(pte) & _PAGE_PROTNONE;
479+
return (pte_flags(pte) & (_PAGE_PROTNONE | _PAGE_PRESENT))
480+
== _PAGE_PROTNONE;
480481
}
481482

482483
static inline int pmd_protnone(pmd_t pmd)
483484
{
484-
return pmd_flags(pmd) & _PAGE_PROTNONE;
485+
return (pmd_flags(pmd) & (_PAGE_PROTNONE | _PAGE_PRESENT))
486+
== _PAGE_PROTNONE;
485487
}
486488
#endif /* CONFIG_NUMA_BALANCING */
487489

0 commit comments

Comments
 (0)