From: "Huang, Kai" <kai.huang@intel.com>
To: "linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>
Cc: "jarkko@kernel.org" <jarkko@kernel.org>, "Christopherson,,
Sean" <seanjc@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Subject: Re: [PATCH] x86/intel: Clear SGX bit if both SGX driver and KVM SGX are not enabled
Date: Fri, 9 Sep 2022 11:05:25 +0000 [thread overview]
Message-ID: <608162bc28e4afef5133968c67b2bfcf4b6ef851.camel@intel.com> (raw)
In-Reply-To: <20220909080853.547058-1-kai.huang@intel.com>
On Fri, 2022-09-09 at 20:08 +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@intel.com>
> ---
>
> Hi Dave, Sean, Jarkko,
>
> Could you help to review? Tested on SGX (BIOS) enabled machine with
> CONFIG_X86_SGX unset.
>
> This patch is generated on latest tip/master, but it applies to
> tip/x86/sgx cleanly as well.
>
> ---
> arch/x86/kernel/cpu/feat_ctl.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/feat_ctl.c b/arch/x86/kernel/cpu/feat_ctl.c
> index 993697e71854..2f67409f5f00 100644
> --- a/arch/x86/kernel/cpu/feat_ctl.c
> +++ b/arch/x86/kernel/cpu/feat_ctl.c
> @@ -191,6 +191,19 @@ void init_ia32_feat_ctl(struct cpuinfo_x86 *c)
> return;
> }
>
> + /*
> + * By reaching here, it is certain that:
> + * - CPU supports SGX.
> + * - SGX is enabled by BIOS.
> + *
> + * However if both SGX driver and KVM SGX are not enabled, just
> + * need to clear SGX feature bit.
> + */
> + if (!enable_sgx_driver && !enable_sgx_kvm) {
> + clear_cpu_cap(c, X86_FEATURE_SGX);
> + return;
> + }
> +
Sorry my bad. I sent out the patch too quickly. This check should be moved
down after checking X86_FEATURE_VMX flag which may result in enable_sgx_kvm
being set to false. I'll send out v2.
--
Thanks,
-Kai
next prev parent reply other threads:[~2022-09-09 11:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 8:08 [PATCH] x86/intel: Clear SGX bit if both SGX driver and KVM SGX are not enabled Kai Huang
2022-09-09 11:05 ` Huang, Kai [this message]
2022-09-09 12:11 ` Dave Hansen
2022-09-12 3:09 ` Huang, Kai
2022-09-12 10:47 ` Jarkko Sakkinen
2022-09-12 14:31 ` Reinette Chatre
2022-09-12 14:34 ` Dave Hansen
2022-09-12 20:54 ` Huang, Kai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=608162bc28e4afef5133968c67b2bfcf4b6ef851.camel@intel.com \
--to=kai.huang@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jarkko@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox