]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/x86/include/asm/pgtable-invert.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_PGTABLE_INVERT_H
3 #define _ASM_PGTABLE_INVERT_H 1
7 static inline bool __pte_needs_invert(u64 val
)
9 return (val
& (_PAGE_PRESENT
|_PAGE_PROTNONE
)) == _PAGE_PROTNONE
;
12 /* Get a mask to xor with the page table entry to get the correct pfn. */
13 static inline u64
protnone_mask(u64 val
)
15 return __pte_needs_invert(val
) ? ~0ull : 0;
18 static inline u64
flip_protnone_guard(u64 oldval
, u64 val
, u64 mask
)
21 * When a PTE transitions from NONE to !NONE or vice-versa
22 * invert the PFN part to stop speculation.
23 * pte_pfn undoes this when needed.
25 if (__pte_needs_invert(oldval
) != __pte_needs_invert(val
))
26 val
= (val
& ~mask
) | (~val
& mask
);
30 #endif /* __ASSEMBLY__ */