Skip to content

Commit 1abce05

Browse files
BenjaminGrayNp1mpe
authored andcommitted
powerpc/64s: Fix __pte_needs_flush() false positive warning
Userspace PROT_NONE ptes set _PAGE_PRIVILEGED, triggering a false positive debug assertion that __pte_flags_need_flush() is not called on a kernel mapping. Detect when it is a userspace PROT_NONE page by checking the required bits of PAGE_NONE are set, and none of the RWX bits are set. pte_protnone() is insufficient here because it always returns 0 when CONFIG_NUMA_BALANCING=n. Fixes: b11931e ("powerpc/64s: add pte_needs_flush and huge_pmd_needs_flush") Cc: [email protected] # v6.1+ Reported-by: Russell Currey <[email protected]> Signed-off-by: Benjamin Gray <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent f2c7e35 commit 1abce05

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/powerpc/include/asm/book3s/64/tlbflush.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ static inline void flush_tlb_fix_spurious_fault(struct vm_area_struct *vma,
148148
*/
149149
}
150150

151+
static inline bool __pte_protnone(unsigned long pte)
152+
{
153+
return (pte & (pgprot_val(PAGE_NONE) | _PAGE_RWX)) == pgprot_val(PAGE_NONE);
154+
}
155+
151156
static inline bool __pte_flags_need_flush(unsigned long oldval,
152157
unsigned long newval)
153158
{
@@ -164,8 +169,8 @@ static inline bool __pte_flags_need_flush(unsigned long oldval,
164169
/*
165170
* We do not expect kernel mappings or non-PTEs or not-present PTEs.
166171
*/
167-
VM_WARN_ON_ONCE(oldval & _PAGE_PRIVILEGED);
168-
VM_WARN_ON_ONCE(newval & _PAGE_PRIVILEGED);
172+
VM_WARN_ON_ONCE(!__pte_protnone(oldval) && oldval & _PAGE_PRIVILEGED);
173+
VM_WARN_ON_ONCE(!__pte_protnone(newval) && newval & _PAGE_PRIVILEGED);
169174
VM_WARN_ON_ONCE(!(oldval & _PAGE_PTE));
170175
VM_WARN_ON_ONCE(!(newval & _PAGE_PTE));
171176
VM_WARN_ON_ONCE(!(oldval & _PAGE_PRESENT));

0 commit comments

Comments
 (0)