x86/cpu: Add X86_CR4_FRED macro
authorH. Peter Anvin (Intel) <hpa@zytor.com>
Tue, 5 Dec 2023 10:50:00 +0000 (02:50 -0800)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 31 Jan 2024 21:00:38 +0000 (22:00 +0100)
Add X86_CR4_FRED macro for the FRED bit in %cr4. This bit must not be
changed after initialization, so add it to the pinned CR4 bits.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Xin Li <xin3.li@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Shan Kang <shan.kang@intel.com>
Link: https://lore.kernel.org/r/20231205105030.8698-12-xin3.li@intel.com
arch/x86/include/uapi/asm/processor-flags.h
arch/x86/kernel/cpu/common.c

index d898432..f1a4adc 100644 (file)
 #define X86_CR4_LAM_SUP_BIT    28 /* LAM for supervisor pointers */
 #define X86_CR4_LAM_SUP                _BITUL(X86_CR4_LAM_SUP_BIT)
 
+#ifdef __x86_64__
+#define X86_CR4_FRED_BIT       32 /* enable FRED kernel entry */
+#define X86_CR4_FRED           _BITUL(X86_CR4_FRED_BIT)
+#else
+#define X86_CR4_FRED           (0)
+#endif
+
 /*
  * x86-64 Task Priority Register, CR8
  */
index 0b97bcd..c3a1757 100644 (file)
@@ -382,9 +382,8 @@ out:
 }
 
 /* These bits should not change their value after CPU init is finished. */
-static const unsigned long cr4_pinned_mask =
-       X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |
-       X86_CR4_FSGSBASE | X86_CR4_CET;
+static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |
+                                            X86_CR4_FSGSBASE | X86_CR4_CET | X86_CR4_FRED;
 static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning);
 static unsigned long cr4_pinned_bits __ro_after_init;