public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: "Liran Alon" <liran.alon@oracle.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"kvm list" <kvm@vger.kernel.org>,
	"Jim Mattson" <jmattson@google.com>,
	vkuznets@redhat.com
Subject: Re: [PATCH kvm-unit-tests 0/8]: x86: vmx: Test INIT processing in various CPU VMX states
Date: Tue, 1 Oct 2019 11:40:34 -0700	[thread overview]
Message-ID: <20191001184034.GC27090@linux.intel.com> (raw)
In-Reply-To: <86619DAE-C601-4162-9622-E3DE8CB1C295@gmail.com>

On Mon, Sep 30, 2019 at 06:29:52PM -0700, Nadav Amit wrote:
> > On Sep 30, 2019, at 6:23 PM, Liran Alon <liran.alon@oracle.com> wrote:
> > 
> > If INIT signal won’t be kept pending until exiting VMX operation, target
> > CPU which was sent with INIT signal when it was running guest, basically
> > lost INIT signal forever and just received an exit-reason it cannot do much
> > with.  That’s why I thought Intel designed this mechanism like I specified
> > above.
> 
> Well, the host can always issue an INIT using an IPI.

And conversely, if the INIT persisted then the host would be forced to do
VMXOFF, otherwise it effectively couldn't do VM-Enter on that logical CPU.

> > I also remembered to verify this behaviour against some discussions made online:
> > 1) https://software.intel.com/en-us/forums/virtualization-software-development/topic/355484
> > * "When the 16-bit guest issues an INIT IPI to itself using the APIC, I run into an infinite VMExit situation that my hypervisor cannot seem to recover from.”
> > * "In response to the VMExit with a reason of 3 (which is expected), the hypervisor resets the 16-bit guest's registers, limits, access rights, etc. to simulate starting execution from a known initialization point.  However, it seems that as soon as the hypervisor resumes guest execution, the VMExit occurs again, repeatedly.”
> > 2) https://patchwork.kernel.org/patch/2244311/
> > "I actually find it very useful. On INIT vmexit hypervisor may call vmxoff and do proper reset."
> > 
> > Anyway, Sean, can you assist verifying inside Intel what should be the expected behaviour?
> 
> It might always be (yet) another kvm-unit-tests bug that is only apparent on
> bare-metal. But if Sean can confirm what the expected behavior is, it would
> save time.
> 
> I do not have an ITP, so debugging on bare-metal is not fun at all...

My understanding of the architecture is that the INIT should be consumed
on VM-Exit.  The only scenario where an event is not consumed/acknowledge
is when a vanilla interrupt occurs without VM_EXIT_ACK_INTR_ON_EXIT set,
in which case the VM-Exit is technically considered a "pending" interrupt.
For all other cases (NMI, SMI, INIT, and INTR w/ ACK-ON-EXIT), the VM-Exit
is the end result of delivering the event.

INITs are indeed blocked and not dropped in VMX root mode.  But entering
non-root (guest) mode should unblock INITs and cause a VM-Exit, and thus
clear the INIT that was pended while in VMX root mode.  This behavior does
not conflict with the whitepaper[*] referenced by link (2) above, and in
fact the whitepaper explicitly covers guest mode behavior in a footnote:

  When the processor is in VMX guest mode, delivery of INIT causes a
  normal VMEXIT, of course.

The INIT attack described uses "VMX mode" to refer to VMX root mode, and
other than the footnote, doesn't mention VMX guest mode.  My reading of it
is that they're showing a proof of concept of based on getting the OS into
VMX root mode but not actually running a guest, e.g. this can be done
in KVM by creating a VM (KVM_CREATE_VM) but not running it (KVM_RUN).

Anyways, I'll double check that the INIT should indeed be consumed as part
of the VM-Exit.

[*] https://invisiblethingslab.com/resources/2011/Software%20Attacks%20on%20Intel%20VT-d.pdf

  reply	other threads:[~2019-10-01 18:40 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 12:52 [PATCH kvm-unit-tests 0/8]: x86: vmx: Test INIT processing in various CPU VMX states Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 1/8] x86: vmx: Refactor init of VMX caps to separate function Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 2/8] x86: vmx: Prepare init_vmx() for VMX support on AP CPUs Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 3/8] x86: vmx: Expose vmx_init() to be used " Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 4/8] x86: vmx: Support VMXON on AP CPUs VMX region Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 5/8] x86: vmx: Use MSR_IA32_FEATURE_CONTROL bits names Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 6/8] x86: vmx: Expose util to enable VMX in MSR_IA32_FEATURE_CONTROL Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 7/8] x86: vmx: Allow tests to hand-over test-vmcs between CPUs Liran Alon
2019-09-19 12:52 ` [PATCH kvm-unit-tests 8/8] x86: vmx: Test INIT processing during various CPU VMX states Liran Alon
2019-09-19 14:08 ` [PATCH kvm-unit-tests 0/8]: x86: vmx: Test INIT processing in " Vitaly Kuznetsov
2019-09-24 15:34   ` Liran Alon
2019-09-24 15:42     ` Paolo Bonzini
2019-09-25 23:57       ` Liran Alon
2019-09-26  8:47         ` Paolo Bonzini
2019-09-30 23:02 ` Nadav Amit
2019-10-01  0:48   ` Liran Alon
2019-10-01  1:14     ` Nadav Amit
2019-10-01  1:23       ` Liran Alon
2019-10-01  1:29         ` Nadav Amit
2019-10-01 18:40           ` Sean Christopherson [this message]
2019-10-01 23:21             ` Sean Christopherson
2019-10-01 23:34             ` Sean Christopherson
2019-10-01 23:37               ` Nadav Amit
2019-10-02  0:10                 ` Liran Alon
2019-10-02  0:19             ` Liran Alon

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=20191001184034.GC27090@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=liran.alon@oracle.com \
    --cc=nadav.amit@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=vkuznets@redhat.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