Re: [PATCH 2/2] kvm: nVMX: Single-step traps trump expired VMX-preemption timer

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

 



On Mon, Apr 13, 2020 at 8:17 PM Sean Christopherson
<sean.j.christopherson@xxxxxxxxx> wrote:
>
> On Mon, Apr 13, 2020 at 05:09:46PM -0700, Jim Mattson wrote:
> > Previously, if the hrtimer for the nested VMX-preemption timer fired
> > while L0 was emulating an L2 instruction with RFLAGS.TF set, the
> > synthesized single-step trap would be unceremoniously dropped when
> > synthesizing the "VMX-preemption timer expired" VM-exit from L2 to L1.
> >
> > To fix this, don't synthesize a "VMX-preemption timer expired" VM-exit
> > from L2 to L1 when there is a pending debug trap, such as a
> > single-step trap.
> >
> > Fixes: f4124500c2c13 ("KVM: nVMX: Fully emulate preemption timer")
> > Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx>
> > Reviewed-by: Oliver Upton <oupton@xxxxxxxxxx>
> > Reviewed-by: Peter Shier <pshier@xxxxxxxxxx>
> > ---
> >  arch/x86/kvm/vmx/nested.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> > index cbc9ea2de28f..6ab974debd44 100644
> > --- a/arch/x86/kvm/vmx/nested.c
> > +++ b/arch/x86/kvm/vmx/nested.c
> > @@ -3690,7 +3690,9 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu)
> >           vmx->nested.preemption_timer_expired) {
> >               if (block_nested_events)
> >                       return -EBUSY;
> > -             nested_vmx_vmexit(vcpu, EXIT_REASON_PREEMPTION_TIMER, 0, 0);
> > +             if (!vmx_pending_dbg_trap(vcpu))
>
> IMO this one warrants a comment.  It's not immediately obvious that this
> only applies to #DBs that are being injected into L2, and that returning
> -EBUSY will do the wrong thing.

Regarding -EBUSY, I'm in complete agreement. However, I'm not sure
what the potential confusion is regarding the event. Are you
suggesting that one might think that we have a #DB to deliver to L1
while we're in guest mode? IIRC, that can happen under SVM, but I
don't believe it can happen under VMX.

> > +                     nested_vmx_vmexit(vcpu, EXIT_REASON_PREEMPTION_TIMER,
> > +                                       0, 0);
>
> I'd just let the "0, 0);" poke out past 80 chars.

Oh, you rascal, you!

> >               return 0;
> >       }
> >
> > --
> > 2.26.0.110.g2183baf09c-goog
> >



[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