Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/cpu: Add X86_CR4_FRED macro

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

authored by

H. Peter Anvin (Intel) and committed by
Borislav Petkov (AMD)
ff45746f cd19bab8

+9 -3
+7
arch/x86/include/uapi/asm/processor-flags.h
··· 139 139 #define X86_CR4_LAM_SUP_BIT 28 /* LAM for supervisor pointers */ 140 140 #define X86_CR4_LAM_SUP _BITUL(X86_CR4_LAM_SUP_BIT) 141 141 142 + #ifdef __x86_64__ 143 + #define X86_CR4_FRED_BIT 32 /* enable FRED kernel entry */ 144 + #define X86_CR4_FRED _BITUL(X86_CR4_FRED_BIT) 145 + #else 146 + #define X86_CR4_FRED (0) 147 + #endif 148 + 142 149 /* 143 150 * x86-64 Task Priority Register, CR8 144 151 */
+2 -3
arch/x86/kernel/cpu/common.c
··· 382 382 } 383 383 384 384 /* These bits should not change their value after CPU init is finished. */ 385 - static const unsigned long cr4_pinned_mask = 386 - X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP | 387 - X86_CR4_FSGSBASE | X86_CR4_CET; 385 + static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP | 386 + X86_CR4_FSGSBASE | X86_CR4_CET | X86_CR4_FRED; 388 387 static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning); 389 388 static unsigned long cr4_pinned_bits __ro_after_init; 390 389