Re: [RFC PATCH v2 01/26] x86/cpufeatures: Add SGX1 and SGX2 sub-features
From: Kai Huang <hidden>
Date: 2021-01-19 22:57:26
On Tue, 2021-01-19 at 10:03 -0800, Sean Christopherson wrote:
On Tue, Jan 19, 2021, Borislav Petkov wrote:quoted
On Mon, Jan 18, 2021 at 04:26:49PM +1300, Kai Huang wrote:quoted
diff --git a/arch/x86/kernel/cpu/feat_ctl.c b/arch/x86/kernel/cpu/feat_ctl.c index 3b1b01f2b248..7937a315f8cf 100644 --- a/arch/x86/kernel/cpu/feat_ctl.c +++ b/arch/x86/kernel/cpu/feat_ctl.c@@ -96,7 +96,6 @@ static void init_vmx_capabilities(struct cpuinfo_x86 *c)static void clear_sgx_caps(void) { setup_clear_cpu_cap(X86_FEATURE_SGX); - setup_clear_cpu_cap(X86_FEATURE_SGX_LC);Why is that line being removed here? Shouldn't this add SGX1 and SGX2 here instead as this function is supposed to, well, *clear* sgx caps on feat_ctl setup failures or "nosgx" cmdline?Doesn't adding making the SGX sub-features depend on X86_FEATURE_SGX have the same net effect? Or am I misreading do_clear_cpu_cap()?
On my testing machine with SGX, SGX_LC, and SGX1. I just double tested that clearing X86_FEATURE_SGX also clears SGX1 and SGX_LC bits.
Though if we use the cpuid_deps table, I'd vote to get rid of clear_sgx_caps() and call setup_clear_cpu_cap(X86_FEATURE_SGX) directly.
Yes I can do that.
And probably change the existing SGX_LC behavior and drop clear_sgx_caps() in a separate patch instead of squeezing it into this one.
To double confirm, you want: 1) This patch to introduce SGX1, SGX2, and also put SGX1 and SGX2 in to CPUID dependency table; 2) A separate patch to put SGX_LC to CPUID dependency table too, and also git rid of clear_sgx_caps() Correct? Btw, in your original patch, both SGX1 and SGX2 depends on SGX, but I changed to make SGX2 depend on SGX1. However I still make SGX_LC depend on SGX, but not SGX1. Does this make sense to you?