Message ID | 20231108111806.92604-9-nsaenz@amazon.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: x86: hyperv: Introduce VSM support | expand |
On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote: > VSM's VTLs are modeled by using a distinct vCPU per VTL. While one VTL > is running the rest of vCPUs are left idle. This doesn't play well with > the approach of tracking emulated timer expiration by using the VMX > preemption timer. Inactive VTL's timers are still meant to run and > inject interrupts regardless of their runstate. > > Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com> > --- > arch/x86/kvm/lapic.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index f55d216cb2a0..8cc75b24381b 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -152,9 +152,10 @@ static bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu) > > bool kvm_can_use_hv_timer(struct kvm_vcpu *vcpu) > { > - return kvm_x86_ops.set_hv_timer > - && !(kvm_mwait_in_guest(vcpu->kvm) || > - kvm_can_post_timer_interrupt(vcpu)); > + return kvm_x86_ops.set_hv_timer && > + !(kvm_mwait_in_guest(vcpu->kvm) || > + kvm_can_post_timer_interrupt(vcpu)) && > + !(kvm_hv_vsm_enabled(vcpu->kvm)); > } This has to be fixed this way or another. One idea is to introduce new MP state (KVM_MP_STATE_HALTED_USERSPACE), which will be set on vCPUs that belong to inactive VTLs, and then userspace will do KVM_RUN which will block as if it were for halted state but as soon as vCPU becomes unhalted, it will return to the userspace instead of running again. If we go with the approach of using polling on the inactive VTL's vcpus, then we can switch to a software timer just before we start polling. Also note that AVIC/APICv and their IOMMU's have to be treated the same way. It is disabled during vCPU blocking due to the same reasons of vCPU not being assigned a physical CPU. Currently it happens to work because you disable APIC accelerated map, which in turn disables (inhibits) the APICv/AVIC. Once again if we go with the approach of polling, we should ensure that polling does more or less the same things as kvm_vcpu_block does (we should try to share as much code as possible as well). Best regards, Maxim Levitsky > > static bool kvm_use_posted_timer_interrupt(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index f55d216cb2a0..8cc75b24381b 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -152,9 +152,10 @@ static bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu) bool kvm_can_use_hv_timer(struct kvm_vcpu *vcpu) { - return kvm_x86_ops.set_hv_timer - && !(kvm_mwait_in_guest(vcpu->kvm) || - kvm_can_post_timer_interrupt(vcpu)); + return kvm_x86_ops.set_hv_timer && + !(kvm_mwait_in_guest(vcpu->kvm) || + kvm_can_post_timer_interrupt(vcpu)) && + !(kvm_hv_vsm_enabled(vcpu->kvm)); } static bool kvm_use_posted_timer_interrupt(struct kvm_vcpu *vcpu)
VSM's VTLs are modeled by using a distinct vCPU per VTL. While one VTL is running the rest of vCPUs are left idle. This doesn't play well with the approach of tracking emulated timer expiration by using the VMX preemption timer. Inactive VTL's timers are still meant to run and inject interrupts regardless of their runstate. Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com> --- arch/x86/kvm/lapic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)