1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 #ifndef _ASM_PGTABLE_INVERT_H 3 #define _ASM_PGTABLE_INVERT_H 1 4 5 #ifndef __ASSEMBLY__ 6 7 /* 8 * A clear pte value is special, and doesn't g 9 * 10 * Note that even users that only pass a pgpro 11 * than a full pte) won't trigger the special 12 * because even PAGE_NONE has _PAGE_PROTNONE | 13 * set. So the all zero case really is limited 14 * cleared page table entry case. 15 */ 16 static inline bool __pte_needs_invert(u64 val) 17 { 18 return val && !(val & _PAGE_PRESENT); 19 } 20 21 /* Get a mask to xor with the page table entry 22 static inline u64 protnone_mask(u64 val) 23 { 24 return __pte_needs_invert(val) ? ~0ul 25 } 26 27 static inline u64 flip_protnone_guard(u64 oldv 28 { 29 /* 30 * When a PTE transitions from NONE to 31 * invert the PFN part to stop specula 32 * pte_pfn undoes this when needed. 33 */ 34 if (__pte_needs_invert(oldval) != __pt 35 val = (val & ~mask) | (~val & 36 return val; 37 } 38 39 #endif /* __ASSEMBLY__ */ 40 41 #endif 42
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.