Re: [PATCH] kvm/x86: clear hlt for intel cpu when resetting vcpu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux