processor-flags.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_PROCESSOR_FLAGS_H
  3. #define _ASM_X86_PROCESSOR_FLAGS_H
  4. #include <uapi/asm/processor-flags.h>
  5. #include <linux/mem_encrypt.h>
  6. #ifdef CONFIG_VM86
  7. #define X86_VM_MASK X86_EFLAGS_VM
  8. #else
  9. #define X86_VM_MASK 0 /* No VM86 support */
  10. #endif
  11. /*
  12. * CR3's layout varies depending on several things.
  13. *
  14. * If CR4.PCIDE is set (64-bit only), then CR3[11:0] is the address space ID.
  15. * If PAE is enabled, then CR3[11:5] is part of the PDPT address
  16. * (i.e. it's 32-byte aligned, not page-aligned) and CR3[4:0] is ignored.
  17. * Otherwise (non-PAE, non-PCID), CR3[3] is PWT, CR3[4] is PCD, and
  18. * CR3[2:0] and CR3[11:5] are ignored.
  19. *
  20. * In all cases, Linux puts zeros in the low ignored bits and in PWT and PCD.
  21. *
  22. * CR3[63] is always read as zero. If CR4.PCIDE is set, then CR3[63] may be
  23. * written as 1 to prevent the write to CR3 from flushing the TLB.
  24. *
  25. * On systems with SME, one bit (in a variable position!) is stolen to indicate
  26. * that the top-level paging structure is encrypted.
  27. *
  28. * All of the remaining bits indicate the physical address of the top-level
  29. * paging structure.
  30. *
  31. * CR3_ADDR_MASK is the mask used by read_cr3_pa().
  32. */
  33. #ifdef CONFIG_X86_64
  34. /* Mask off the address space ID and SME encryption bits. */
  35. #define CR3_ADDR_MASK __sme_clr(0x7FFFFFFFFFFFF000ull)
  36. #define CR3_PCID_MASK 0xFFFull
  37. #define CR3_NOFLUSH BIT_ULL(63)
  38. #else
  39. /*
  40. * CR3_ADDR_MASK needs at least bits 31:5 set on PAE systems, and we save
  41. * a tiny bit of code size by setting all the bits.
  42. */
  43. #define CR3_ADDR_MASK 0xFFFFFFFFull
  44. #define CR3_PCID_MASK 0ull
  45. #define CR3_NOFLUSH 0
  46. #endif
  47. #ifdef CONFIG_PAGE_TABLE_ISOLATION
  48. # define X86_CR3_PTI_PCID_USER_BIT 11
  49. #endif
  50. #endif /* _ASM_X86_PROCESSOR_FLAGS_H */