linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: SMM fixes for nVMX
@ 2021-08-26  9:57 Maxim Levitsky
  2021-08-26  9:57 ` [PATCH 1/2] KVM: VMX: avoid running vmx_handle_exit_irqoff in case of emulation Maxim Levitsky
  2021-08-26  9:57 ` [PATCH 2/2] VMX: nSVM: enter protected mode prior to returning to nested guest from SMM Maxim Levitsky
  0 siblings, 2 replies; 10+ messages in thread
From: Maxim Levitsky @ 2021-08-26  9:57 UTC (permalink / raw)
  To: kvm
  Cc: Thomas Gleixner, Wanpeng Li, Joerg Roedel, H. Peter Anvin,
	Jim Mattson, Sean Christopherson, Ingo Molnar, Paolo Bonzini,
	Vitaly Kuznetsov, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Borislav Petkov, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Maxim Levitsky

Those are two patches that fix SMM entries while nested guests
are active and either EPT or unrestricted guest mode is disabled
(EPT disables the later)

1. First patch makes sure that we don't run vmx_handle_exit_irqoff
   when we emulate a handful of real mode smm instructions.

   When in emulation mode, vmx exit reason is not updated,
   and thus this function uses outdated values and crashes.

2. Second patch works around an incorrect restore of segment
   registers upon entry to nested guest from SMM.

   When entering the nested guest from SMM we enter real mode,
   and from it straight to nested guest, and in particular
   once we restore L2's CR0, enter_pmode is called which
   'restores' the segment registers from real mode segment
   cache.

   Normally this isn't a problem since after we finish entering
   the nested guest, we restore all its registers from SMRAM,
   but for the brief period when L2's segment registers are not up to date,
   we trip 'vmx_guest_state_valid' check for non unrestricted guest mode, even
   though it will be later valid.

Note that I still am able to crash L1 by migrating a VM with a
nested guest running and smm load, on VMX.

This even happens with normal stock settings of ept=1,unrestricted_guest=1
and will soon be investigated.

Best regards,
	Maxim Levitsky

Maxim Levitsky (2):
  KVM: VMX: avoid running vmx_handle_exit_irqoff in case of emulation
  VMX: nSVM: enter protected mode prior to returning to nested guest
    from SMM

 arch/x86/kvm/vmx/vmx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

-- 
2.26.3



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-09-07  6:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26  9:57 [PATCH 0/2] KVM: SMM fixes for nVMX Maxim Levitsky
2021-08-26  9:57 ` [PATCH 1/2] KVM: VMX: avoid running vmx_handle_exit_irqoff in case of emulation Maxim Levitsky
2021-08-26 16:01   ` Sean Christopherson
2021-08-30 12:27     ` Maxim Levitsky
2021-09-06 10:09     ` Paolo Bonzini
2021-09-06 21:07       ` Maxim Levitsky
2021-09-07  6:50         ` Paolo Bonzini
2021-08-26  9:57 ` [PATCH 2/2] VMX: nSVM: enter protected mode prior to returning to nested guest from SMM Maxim Levitsky
2021-08-26 16:23   ` Sean Christopherson
2021-08-30 12:45     ` Maxim Levitsky

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).