From: Chao Gao <chao.gao@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Qi Ai <aiqi.i7@bytedance.com>, <pbonzini@redhat.com>,
<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <hpa@zytor.com>,
<kvm@vger.kernel.org>, <fengzhimin@bytedance.com>,
<cenjiahui@bytedance.com>, <fangying.tommy@bytedance.com>,
<dengqiao.joey@bytedance.com>
Subject: Re: [PATCH] kvm/x86: clear hlt for intel cpu when resetting vcpu
Date: Wed, 5 Jul 2023 17:04:31 +0800 [thread overview]
Message-ID: <ZKUyH+P2XmsdHp+p@chao-email> (raw)
In-Reply-To: <ZJ9djqQZWSEjJlfb@google.com>
On Fri, Jun 30, 2023 at 03:56:14PM -0700, Sean Christopherson wrote:
>mn Fri, Jun 30, 2023, Chao Gao wrote:
>> am wondering if we can link vcpu->arch.mp_state to VMCS activity state,
>
>Hrm, maybe.
>
>> i.e., when mp_state is set to RUNNABLE in KVM_SET_MP_STATE ioctl, KVM
>> sets VMCS activity state to active.
>
>Not in the ioctl(), there needs to be a proper set of APIs, e.g. so that the
>existing hack works,
I don't get why the existing hack will be broken if we piggyback on the
KVM_GET/SET_MP_STATE ioctl(). The hack is for "Older userspace" back to
2008. I suppose the "Older userspace" doesn't support disabling hlt exit.
>and so that KVM actually reports out to userspace that a
>vCPU is HALTED if userspace gained control of the vCPU, e.g. after an IRQ exit,
>while the vCPU was HALTED. I.e. mp_state versus vmcs.ACTIVITY_STATE needs to be
>bidirectional, not one-way. E.g. if a vCPU is live migrated, I'm pretty sure
>vmcs.ACTIVITY_STATE is lost, which is wrong.
Yes. Agreed.
>
>I'm half tempted to solve this particular issue by stuffing vmcs.ACTIVITY_STATE on
>shutdown, similar to what SVM does on shutdown interception. KVM doesn't come
>anywhere near faithfully emulating shutdown, so it's unlikely to break anything.
>And then the mp_state vs. hlt_in_guest coulbe tackled separately. Ugh, but that
>wouldn't cover a synthesized KVM_REQ_TRIPLE_FAULT.
I traced the process of guest reboot but I didn't see triple-fault
VMExit. So, I don't think this can fix the issue.
>
>diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>index 44fb619803b8..ee4bb37067d1 100644
>--- a/arch/x86/kvm/vmx/vmx.c
>+++ b/arch/x86/kvm/vmx/vmx.c
>@@ -5312,6 +5312,8 @@ static __always_inline int handle_external_interrupt(struct kvm_vcpu *vcpu)
>
> static int handle_triple_fault(struct kvm_vcpu *vcpu)
> {
>+ vmcs_write32(GUEST_ACTIVITY_STATE, GUEST_ACTIVITY_ACTIVE);
>+
> vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN;
> vcpu->mmio_needed = 0;
> return 0;
>
>
>I don't suppose QEMU can to blast INIT at all vCPUs for this case?
IIUC, userspace can queue INIT to a vCPU via KVM_SET_VCPU_EVENTS ioctl()
with flags = KVM_VCPUEVENT_VALID_SMM and latched_init = 1.
next prev parent reply other threads:[~2023-07-05 9:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 7:26 [PATCH] kvm/x86: clear hlt for intel cpu when resetting vcpu Qi Ai
2023-06-30 10:14 ` Chao Gao
2023-06-30 22:23 ` Isaku Yamahata
2023-06-30 22:56 ` Sean Christopherson
2023-07-04 11:34 ` Qi Ai
2023-07-05 8:40 ` Chao Gao
2023-07-05 9:04 ` Chao Gao [this message]
2023-07-31 19:15 ` Sean Christopherson
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=ZKUyH+P2XmsdHp+p@chao-email \
--to=chao.gao@intel.com \
--cc=aiqi.i7@bytedance.com \
--cc=bp@alien8.de \
--cc=cenjiahui@bytedance.com \
--cc=dave.hansen@linux.intel.com \
--cc=dengqiao.joey@bytedance.com \
--cc=fangying.tommy@bytedance.com \
--cc=fengzhimin@bytedance.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
/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