public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Ladi Prosek <lprosek@redhat.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com
Subject: Re: [PATCH v3 6/6] KVM: nSVM: fix SMI injection in guest mode
Date: Tue, 3 Oct 2017 21:53:43 +0200	[thread overview]
Message-ID: <20171003195342.GE21107@flask> (raw)
In-Reply-To: <20170925080904.24850-7-lprosek@redhat.com>

2017-09-25 10:09+0200, Ladi Prosek:
> Entering SMM while running in guest mode wasn't working very well because several
> pieces of the vcpu state were left set up for nested operation.
> 
> Some of the issues observed:
> 
> * L1 was getting unexpected VM exits (using L1 interception controls but running
>   in SMM execution environment)
> * MMU was confused (walk_mmu was still set to nested_mmu)
> * INTERCEPT_SMI was not emulated for L1 (KVM never injected SVM_EXIT_SMI)
> 
> Intel SDM actually prescribes the logical processor to "leave VMX operation" upon
> entering SMM in 34.14.1 Default Treatment of SMI Delivery. AMD doesn't seem to
> document this but they provide fields in the SMM state-save area to stash the
> current state of SVM. What we need to do is basically get out of guest mode for
> the duration of SMM. All this completely transparent to L1, i.e. L1 is not given
> control and no L1 observable state changes.

The best description I found is in APM vol. 2, 15.22 SMM Support:

• The simplest solution is to not intercept SMI signals. SMIs
  encountered while in a guest context are taken from within the guest
  context. In this case, the SMM handler is not subject to any
  intercepts set up by the VMM and consequently runs outside of the
  virtualization controls. The state saved in the SMM State-Save area as
  seen by the SMM handler reflects the state of the guest that had been
  running at the time the SMI was encountered. When the SMM handler
  executes the RSM instruction, the processor returns to executing in
  the guest context, and any modifications to the SMM State-Save area
  made by the SMM handler are reflected in the guest state.

I think that the last sentence is not implemented correctly:
svm_prep_enter_smm() loads the host state into VMCB and
enter_smm_save_state_64() then puts host state where the SMM handler
would expect guest state.

Do Windows intercept SMI?

Thanks.

  reply	other threads:[~2017-10-03 19:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-25  8:08 [PATCH v3 0/6] KVM: nested virt SMM fixes Ladi Prosek
2017-09-25  8:08 ` [PATCH v3 1/6] KVM: x86: introduce ISA specific SMM entry/exit callbacks Ladi Prosek
2017-09-25  8:09 ` [PATCH v3 2/6] KVM: x86: introduce ISA specific smi_allowed callback Ladi Prosek
2017-09-25  8:09 ` [PATCH v3 3/6] KVM: nVMX: fix SMI injection in guest mode Ladi Prosek
2017-09-25  8:09 ` [PATCH v3 4/6] KVM: nVMX: treat CR4.VMXE as reserved in SMM Ladi Prosek
2017-09-25  8:09 ` [PATCH v3 5/6] KVM: nSVM: refactor nested_svm_vmrun Ladi Prosek
2017-09-25  8:09 ` [PATCH v3 6/6] KVM: nSVM: fix SMI injection in guest mode Ladi Prosek
2017-10-03 19:53   ` Radim Krčmář [this message]
2017-10-04 10:10     ` Ladi Prosek
2017-10-04 14:42       ` Radim Krčmář
2017-10-10  8:03         ` Ladi Prosek

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=20171003195342.GE21107@flask \
    --to=rkrcmar@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lprosek@redhat.com \
    --cc=pbonzini@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