From: "Huang, Kai" <kai.huang@intel.com>
To: "seanjc@google.com" <seanjc@google.com>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"bp@alien8.de" <bp@alien8.de>, "hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"tglx@kernel.org" <tglx@kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"18341265598@163.com" <18341265598@163.com>
Cc: "hanht2@chinatelecom.cn" <hanht2@chinatelecom.cn>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"weixq1@chinatelecom.cn" <weixq1@chinatelecom.cn>,
"zhangzg12@chinatelecom.cn" <zhangzg12@chinatelecom.cn>
Subject: Re: [PATCH] vmx/nested: Set the SGX feature flag only when hardware supported.
Date: Tue, 24 Mar 2026 10:11:43 +0000 [thread overview]
Message-ID: <95c13b532d2958977d176e965efc433f1f4793c4.camel@intel.com> (raw)
In-Reply-To: <1774322860-25106-1-git-send-email-18341265598@163.com>
On Tue, 2026-03-24 at 11:27 +0800, 18341265598@163.com wrote:
> From: "zhaoge.zhang" <zhangzg12@chinatelecom.cn>
>
> If the hardware does not support the SGX feature and we set the
> corresponding flag, when the L1 hypervisor enables the corresponding
> feature in VMCS12, the VM entry will fail.
>
> Reported-by: wei xiaoqiong <weixq1@chinatelecom.cn>
> Signed-off-by: zhaoge.zhang <zhangzg12@chinatelecom.cn>
> Reviewed-by: Huaitong Han <hanht2@chinatelecom.cn>
> ---
> arch/x86/kvm/vmx/nested.c | 2 +-
> arch/x86/kvm/vmx/vmx.c | 11 -----------
> arch/x86/kvm/vmx/vmx.h | 11 +++++++++++
> 3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 937aeb4..396ac07 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -7278,7 +7278,7 @@ static void nested_vmx_setup_secondary_ctls(u32 ept_caps,
> msrs->secondary_ctls_high |=
> SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
>
> - if (enable_sgx)
> + if (enable_sgx && cpu_has_sgx())
> msrs->secondary_ctls_high |= SECONDARY_EXEC_ENCLS_EXITING;
> }
Are you seeing the case where enable_sgx is true but cpu_has_sgx() reports
false?
It's quite strange because during KVM load, if cpu_has_sgx() is false,
enable_sgx is guaranteed to be false.
The only case that I can think of is after KVM loads somehow machine check
happens, which "soft disables" SGX (CPUID reports SGX1 as 0).
Is this the case you are meeting?
[...]
> +/*
> + * There is no X86_FEATURE for SGX yet, but anyway we need to query CPUID
Btw, the "There is no X86_FEATURE for SGX yet" part is obviously obsolete
now.
next prev parent reply other threads:[~2026-03-24 10:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 3:27 18341265598
2026-03-24 10:11 ` Huang, Kai [this message]
2026-03-31 16:30 ` Sean Christopherson
2026-03-31 21:07 ` Huang, Kai
2026-03-31 23:20 ` zhaogezhang
2026-03-29 8:30 ` kernel test robot
2026-03-29 9:05 ` kernel test robot
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=95c13b532d2958977d176e965efc433f1f4793c4.camel@intel.com \
--to=kai.huang@intel.com \
--cc=18341265598@163.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hanht2@chinatelecom.cn \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@kernel.org \
--cc=weixq1@chinatelecom.cn \
--cc=zhangzg12@chinatelecom.cn \
/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
all inboxes | Powered by JetHome®