Re: [PATCH] x86/intel: Clear SGX bit if both SGX driver and KVM SGX are not enabled
From: Dave Hansen
Date: Mon Sep 12 2022 - 10:35:10 EST
On 9/12/22 07:31, Reinette Chatre wrote:
>
> On 9/12/2022 3:47 AM, Jarkko Sakkinen wrote:
>> On Fri, Sep 09, 2022 at 08:08:53PM +1200, Kai Huang wrote:
>>> Currently on platform which has SGX enabled, if CONFIG_X86_SGX is not
>>> enabled, the X86_FEATURE_SGX is not cleared, resulting in /proc/cpuinfo
>>> shows "sgx" feature. This is not desired.
>>>
>>> Clear SGX feature bit if both SGX driver and KVM SGX are not enabled in
>>> init_ia32_feat_ctl().
>>>
>>> Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx>
>> Is it a pattern that flags are cleared when they are disabled by the
>> kernel? I don't know the answer for this.
There's no good pattern.
But, one guideline is that the X86_FEATURE_*'s are for the *kernel*.
They are *not* for userspace. The fact that the features are exposed to
userspace in cpuinfo is unfortunate, but it doesn't change our guideline.
So, if this patch is done only for the benefit of userspace, I don't
think we should apply it.