[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aNEyt/z8eAXQr8/r@intel.com>
Date: Mon, 22 Sep 2025 19:27:51 +0800
From: Chao Gao <chao.gao@...el.com>
To: Sean Christopherson <seanjc@...gle.com>
CC: Paolo Bonzini <pbonzini@...hat.com>, <kvm@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, Tom Lendacky <thomas.lendacky@....com>,
Mathias Krause <minipli@...ecurity.net>, John Allen <john.allen@....com>,
Rick Edgecombe <rick.p.edgecombe@...el.com>, Binbin Wu
<binbin.wu@...ux.intel.com>, Xiaoyao Li <xiaoyao.li@...el.com>, "Maxim
Levitsky" <mlevitsk@...hat.com>, Zhang Yi Z <yi.z.zhang@...ux.intel.com>,
"Xin Li" <xin@...or.com>
Subject: Re: [PATCH v16 19/51] KVM: x86: Don't emulate task switches when IBT
or SHSTK is enabled
>@@ -12178,6 +12178,25 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index,
> struct x86_emulate_ctxt *ctxt = vcpu->arch.emulate_ctxt;
> int ret;
>
>+ if (kvm_is_cr4_bit_set(vcpu, X86_CR4_CET)) {
>+ u64 u_cet, s_cet;
>+
>+ /*
>+ * Check both User and Supervisor on task switches as inter-
>+ * privilege level task switches are impacted by CET at both
>+ * the current privilege level and the new privilege level, and
>+ * that information is not known at this time. The expectation
>+ * is that the guest won't require emulation of task switches
>+ * while using IBT or Shadow Stacks.
>+ */
>+ if (__kvm_emulate_msr_read(vcpu, MSR_IA32_U_CET, &u_cet) ||
>+ __kvm_emulate_msr_read(vcpu, MSR_IA32_S_CET, &s_cet))
>+ return EMULATION_FAILED;
is it ok to return EMULATION_FAILED (-1) here?
It looks like this error code will be propagated to userspace and be
interpreted as -EPERM.
Powered by blists - more mailing lists