Re: [PATCH] x86/intel: Clear SGX bit if both SGX driver and KVM SGX are not enabled

From: Jarkko Sakkinen
Date: Mon Sep 12 2022 - 06:47:53 EST


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.

I could imagine that sometimes you might want to know whether the CPU
supports a feature, even if e.g. your distribution kernel does not.

There's of course other ways to answer such qeustion, e.g. by using
cpuid utility.

BR, Jarkko