Skip to content

Commit e7b6385

Browse files
Sean Christophersonsuryasaimadhu
authored andcommitted
x86/cpufeatures: Add Intel SGX hardware bits
Populate X86_FEATURE_SGX feature from CPUID and tie it to the Kconfig option with disabled-features.h. IA32_FEATURE_CONTROL.SGX_ENABLE must be examined in addition to the CPUID bits to enable full SGX support. The BIOS must both set this bit and lock IA32_FEATURE_CONTROL for SGX to be supported (Intel SDM section 36.7.1). The setting or clearing of this bit has no impact on the CPUID bits above, which is why it needs to be detected separately. Signed-off-by: Sean Christopherson <[email protected]> Co-developed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Jethro Beekman <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 2c27367 commit e7b6385

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
242242
#define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
243243
#define X86_FEATURE_TSC_ADJUST ( 9*32+ 1) /* TSC adjustment MSR 0x3B */
244+
#define X86_FEATURE_SGX ( 9*32+ 2) /* Software Guard Extensions */
244245
#define X86_FEATURE_BMI1 ( 9*32+ 3) /* 1st group bit manipulation extensions */
245246
#define X86_FEATURE_HLE ( 9*32+ 4) /* Hardware Lock Elision */
246247
#define X86_FEATURE_AVX2 ( 9*32+ 5) /* AVX2 instructions */

arch/x86/include/asm/disabled-features.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
# define DISABLE_ENQCMD (1 << (X86_FEATURE_ENQCMD & 31))
6363
#endif
6464

65+
#ifdef CONFIG_X86_SGX
66+
# define DISABLE_SGX 0
67+
#else
68+
# define DISABLE_SGX (1 << (X86_FEATURE_SGX & 31))
69+
#endif
70+
6571
/*
6672
* Make sure to add features to the correct mask
6773
*/
@@ -74,7 +80,7 @@
7480
#define DISABLED_MASK6 0
7581
#define DISABLED_MASK7 (DISABLE_PTI)
7682
#define DISABLED_MASK8 0
77-
#define DISABLED_MASK9 (DISABLE_SMAP)
83+
#define DISABLED_MASK9 (DISABLE_SMAP|DISABLE_SGX)
7884
#define DISABLED_MASK10 0
7985
#define DISABLED_MASK11 0
8086
#define DISABLED_MASK12 0

arch/x86/include/asm/msr-index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@
609609
#define FEAT_CTL_LOCKED BIT(0)
610610
#define FEAT_CTL_VMX_ENABLED_INSIDE_SMX BIT(1)
611611
#define FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX BIT(2)
612+
#define FEAT_CTL_SGX_ENABLED BIT(18)
612613
#define FEAT_CTL_LMCE_ENABLED BIT(20)
613614

614615
#define MSR_IA32_TSC_ADJUST 0x0000003b

0 commit comments

Comments
 (0)