kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jim Mattson <jmattson@google.com>
Cc: kvm@vger.kernel.org, Oliver Upton <oupton@google.com>,
	Peter Shier <pshier@google.com>
Subject: Re: [PATCH 1/2] kvm: nVMX: Pending debug exceptions trump expired VMX-preemption timer
Date: Wed, 22 Apr 2020 14:06:49 -0700	[thread overview]
Message-ID: <20200422210649.GA5823@linux.intel.com> (raw)
In-Reply-To: <20200414000946.47396-1-jmattson@google.com>

On Mon, Apr 13, 2020 at 05:09:45PM -0700, Jim Mattson wrote:
> Fixes: f4124500c2c13 ("KVM: nVMX: Fully emulate preemption timer")
> Signed-off-by: Jim Mattson <jmattson@google.com>
> Reviewed-by: Oliver Upton <oupton@google.com>
> Reviewed-by: Peter Shier <pshier@google.com>

...

> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 83050977490c..aae01253bfba 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -4682,7 +4682,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
>  			if (is_icebp(intr_info))
>  				WARN_ON(!skip_emulated_instruction(vcpu));
>  
> -			kvm_queue_exception(vcpu, DB_VECTOR);
> +			kvm_requeue_exception(vcpu, DB_VECTOR);

This isn't wrong per se, but it's effectively papering over an underlying
bug, e.g. the same missed preemption timer bug can manifest if the timer
expires while in KVM context (because the hr timer is left running) and KVM
queues an exception for _any_ reason.  Most of the scenarios where L0 will
queue an exception for L2 are fairly contrived, but they are possible.

I believe the correct fix is to open a "preemption timer window" like we do
for pending SMI, NMI and IRQ.  It's effectively the same handling a pending
SMI on VMX, set req_immediate_exit in the !inject_pending_event() path.

Patches incoming soon-ish, think I've finally got my head wrapped around all
the combinations, though I also thought that was true several hours ago...

>  			return 1;
>  		}
>  		kvm_run->debug.arch.dr6 = dr6 | DR6_FIXED_1;
> @@ -4703,7 +4703,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
>  		break;
>  	case AC_VECTOR:
>  		if (guest_inject_ac(vcpu)) {
> -			kvm_queue_exception_e(vcpu, AC_VECTOR, error_code);
> +			kvm_requeue_exception_e(vcpu, AC_VECTOR, error_code);
>  			return 1;
>  		}
>  
> -- 
> 2.26.0.110.g2183baf09c-goog
> 

  parent reply	other threads:[~2020-04-22 21:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14  0:09 [PATCH 1/2] kvm: nVMX: Pending debug exceptions trump expired VMX-preemption timer Jim Mattson
2020-04-14  0:09 ` [PATCH 2/2] kvm: nVMX: Single-step traps " Jim Mattson
2020-04-14  3:17   ` Sean Christopherson
2020-04-14 16:47     ` Jim Mattson
2020-04-15  0:12       ` Sean Christopherson
2020-04-15  0:20         ` Sean Christopherson
2020-04-15  0:22           ` Sean Christopherson
2020-04-15 23:33         ` Jim Mattson
2020-04-18  4:21           ` Sean Christopherson
2020-04-20 17:18             ` Jim Mattson
2020-04-21  4:41               ` Sean Christopherson
2020-04-21 18:28                 ` Jim Mattson
2020-04-22  0:16                   ` Sean Christopherson
2020-04-22  8:30   ` Paolo Bonzini
2020-04-22 15:48     ` Sean Christopherson
2020-04-22 16:28     ` Jim Mattson
2020-04-22 16:42       ` Sean Christopherson
2020-04-22 21:06 ` Sean Christopherson [this message]
2020-04-22 21:23   ` [PATCH 1/2] kvm: nVMX: Pending debug exceptions " Sean Christopherson
2020-04-22 21:27   ` Jim Mattson
2020-04-22 22:06     ` 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=20200422210649.GA5823@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pshier@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).