Skip to content

Commit e9a15a4

Browse files
kaihuangsuryasaimadhu
authored andcommitted
x86/cpufeatures: Make SGX_LC feature bit depend on SGX bit
Move SGX_LC feature bit to CPUID dependency table to make clearing all SGX feature bits easier. Also remove clear_sgx_caps() since it is just a wrapper of setup_clear_cpu_cap(X86_FEATURE_SGX) now. Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: Kai Huang <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Acked-by: Dave Hansen <[email protected]> Acked-by: Jarkko Sakkinen <[email protected]> Link: https://lkml.kernel.org/r/5d4220fd0a39f52af024d3fa166231c1d498dd10.1616136308.git.kai.huang@intel.com
1 parent 633b061 commit e9a15a4

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

arch/x86/kernel/cpu/cpuid-deps.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static const struct cpuid_dep cpuid_deps[] = {
7272
{ X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW },
7373
{ X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES },
7474
{ X86_FEATURE_PER_THREAD_MBA, X86_FEATURE_MBA },
75+
{ X86_FEATURE_SGX_LC, X86_FEATURE_SGX },
7576
{}
7677
};
7778

arch/x86/kernel/cpu/feat_ctl.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,9 @@ static void init_vmx_capabilities(struct cpuinfo_x86 *c)
9393
}
9494
#endif /* CONFIG_X86_VMX_FEATURE_NAMES */
9595

96-
static void clear_sgx_caps(void)
97-
{
98-
setup_clear_cpu_cap(X86_FEATURE_SGX);
99-
setup_clear_cpu_cap(X86_FEATURE_SGX_LC);
100-
}
101-
10296
static int __init nosgx(char *str)
10397
{
104-
clear_sgx_caps();
98+
setup_clear_cpu_cap(X86_FEATURE_SGX);
10599

106100
return 0;
107101
}
@@ -116,7 +110,7 @@ void init_ia32_feat_ctl(struct cpuinfo_x86 *c)
116110

117111
if (rdmsrl_safe(MSR_IA32_FEAT_CTL, &msr)) {
118112
clear_cpu_cap(c, X86_FEATURE_VMX);
119-
clear_sgx_caps();
113+
clear_cpu_cap(c, X86_FEATURE_SGX);
120114
return;
121115
}
122116

@@ -177,6 +171,6 @@ void init_ia32_feat_ctl(struct cpuinfo_x86 *c)
177171
!(msr & FEAT_CTL_SGX_LC_ENABLED) || !enable_sgx) {
178172
if (enable_sgx)
179173
pr_err_once("SGX disabled by BIOS\n");
180-
clear_sgx_caps();
174+
clear_cpu_cap(c, X86_FEATURE_SGX);
181175
}
182176
}

0 commit comments

Comments
 (0)