Commit e9a15a40 authored by Kai Huang's avatar Kai Huang Committed by Borislav Petkov

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: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarKai Huang <kai.huang@intel.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
Acked-by: default avatarDave Hansen <dave.hansen@intel.com>
Acked-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Link: https://lkml.kernel.org/r/5d4220fd0a39f52af024d3fa166231c1d498dd10.1616136308.git.kai.huang@intel.com
parent 633b0616
...@@ -72,6 +72,7 @@ static const struct cpuid_dep cpuid_deps[] = { ...@@ -72,6 +72,7 @@ static const struct cpuid_dep cpuid_deps[] = {
{ X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW },
{ X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES },
{ X86_FEATURE_PER_THREAD_MBA, X86_FEATURE_MBA }, { X86_FEATURE_PER_THREAD_MBA, X86_FEATURE_MBA },
{ X86_FEATURE_SGX_LC, X86_FEATURE_SGX },
{} {}
}; };
......
...@@ -93,15 +93,9 @@ static void init_vmx_capabilities(struct cpuinfo_x86 *c) ...@@ -93,15 +93,9 @@ static void init_vmx_capabilities(struct cpuinfo_x86 *c)
} }
#endif /* CONFIG_X86_VMX_FEATURE_NAMES */ #endif /* CONFIG_X86_VMX_FEATURE_NAMES */
static void clear_sgx_caps(void)
{
setup_clear_cpu_cap(X86_FEATURE_SGX);
setup_clear_cpu_cap(X86_FEATURE_SGX_LC);
}
static int __init nosgx(char *str) static int __init nosgx(char *str)
{ {
clear_sgx_caps(); setup_clear_cpu_cap(X86_FEATURE_SGX);
return 0; return 0;
} }
...@@ -116,7 +110,7 @@ void init_ia32_feat_ctl(struct cpuinfo_x86 *c) ...@@ -116,7 +110,7 @@ void init_ia32_feat_ctl(struct cpuinfo_x86 *c)
if (rdmsrl_safe(MSR_IA32_FEAT_CTL, &msr)) { if (rdmsrl_safe(MSR_IA32_FEAT_CTL, &msr)) {
clear_cpu_cap(c, X86_FEATURE_VMX); clear_cpu_cap(c, X86_FEATURE_VMX);
clear_sgx_caps(); clear_cpu_cap(c, X86_FEATURE_SGX);
return; return;
} }
...@@ -177,6 +171,6 @@ void init_ia32_feat_ctl(struct cpuinfo_x86 *c) ...@@ -177,6 +171,6 @@ void init_ia32_feat_ctl(struct cpuinfo_x86 *c)
!(msr & FEAT_CTL_SGX_LC_ENABLED) || !enable_sgx) { !(msr & FEAT_CTL_SGX_LC_ENABLED) || !enable_sgx) {
if (enable_sgx) if (enable_sgx)
pr_err_once("SGX disabled by BIOS\n"); pr_err_once("SGX disabled by BIOS\n");
clear_sgx_caps(); clear_cpu_cap(c, X86_FEATURE_SGX);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment