lkml.org 
[lkml]   [2023]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v6 09/33] x86/cpu: add X86_CR4_FRED macro
    Date
    From: "H. Peter Anvin (Intel)" <hpa@zytor.com>

    Add X86_CR4_FRED macro for the FRED bit in %cr4. This bit should be a
    pinned bit, not to be changed after initialization.

    Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
    Tested-by: Shan Kang <shan.kang@intel.com>
    Signed-off-by: Xin Li <xin3.li@intel.com>
    ---
    arch/x86/include/uapi/asm/processor-flags.h | 2 ++
    arch/x86/kernel/cpu/common.c | 11 ++++++++---
    2 files changed, 10 insertions(+), 3 deletions(-)

    diff --git a/arch/x86/include/uapi/asm/processor-flags.h b/arch/x86/include/uapi/asm/processor-flags.h
    index c47cc7f2feeb..a90933f1ff41 100644
    --- a/arch/x86/include/uapi/asm/processor-flags.h
    +++ b/arch/x86/include/uapi/asm/processor-flags.h
    @@ -132,6 +132,8 @@
    #define X86_CR4_PKE _BITUL(X86_CR4_PKE_BIT)
    #define X86_CR4_CET_BIT 23 /* enable Control-flow Enforcement Technology */
    #define X86_CR4_CET _BITUL(X86_CR4_CET_BIT)
    +#define X86_CR4_FRED_BIT 32 /* enable FRED kernel entry */
    +#define X86_CR4_FRED _BITULL(X86_CR4_FRED_BIT)

    /*
    * x86-64 Task Priority Register, CR8
    diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
    index 8cd4126d8253..e8cf6f4cfb52 100644
    --- a/arch/x86/kernel/cpu/common.c
    +++ b/arch/x86/kernel/cpu/common.c
    @@ -412,10 +412,15 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c)
    cr4_clear_bits(X86_CR4_UMIP);
    }

    -/* These bits should not change their value after CPU init is finished. */
    +/*
    + * These bits should not change their value after CPU init is finished.
    + * The explicit cast to unsigned long suppresses a warning on i386 for
    + * x86-64 only feature bits >= 32.
    + */
    static const unsigned long cr4_pinned_mask =
    - X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |
    - X86_CR4_FSGSBASE | X86_CR4_CET;
    + (unsigned long)
    + (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;

    --
    2.34.1
    \
     
     \ /
      Last update: 2023-03-27 10:26    [W:2.115 / U:0.068 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site