Re: [RFC PATCH v2 06/26] x86/cpu/intel: Allow SGX virtualization without Launch Control support

Jarkko Sakkinen
2021-01-21T01:12:12Z

On Wed, Jan 20, 2021 at 01:02:15PM -0800, Dave Hansen wrote:
> On 1/17/21 7:27 PM, Kai Huang wrote:
> > - enable_sgx = cpu_has(c, X86_FEATURE_SGX) &&
> > - cpu_has(c, X86_FEATURE_SGX_LC) &&
> > - IS_ENABLED(CONFIG_X86_SGX);
> > + enable_sgx_driver = cpu_has(c, X86_FEATURE_SGX) &&
> > + cpu_has(c, X86_FEATURE_SGX1) &&
> > + IS_ENABLED(CONFIG_X86_SGX) &&
> > + cpu_has(c, X86_FEATURE_SGX_LC);
> > + enable_sgx_virt = cpu_has(c, X86_FEATURE_SGX) &&
> > + cpu_has(c, X86_FEATURE_SGX1) &&
> > + IS_ENABLED(CONFIG_X86_SGX) &&
> > + IS_ENABLED(CONFIG_X86_SGX_VIRTUALIZATION) &&
> > + enable_vmx;
>
> Would it be too much to ask that the SGX/SGX1 checks not be duplicated?
> Perhaps:
>
> enable_sgx_any = cpu_feature_enabled(CONFIG_X86_SGX) &&
> cpu_feature_enabled(CONFIG_X86_SGX1);
>
> enable_sgx_driver = enable_sgx_any &&
> cpu_has(c, X86_FEATURE_SGX_LC);
>
> enable_sgx_virt = enable_sgx_any &&
> enable_vmx &&
> IS_ENABLED(CONFIG_X86_SGX_VIRTUALIZATION)
>
> BTW, CONFIG_X86_SGX_VIRTUALIZATION is a pretty porky name. Maybe just
> CONFIG_X86_SGX_VIRT?

If my /dev/sgx_vepc naming gets acceptance, then IMHO the best name
ought to be CONFIG_X86_VEPC.

/Jarkko