From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ladi Prosek Subject: [PATCH 0/5] KVM: nested virt SMM fixes Date: Wed, 13 Sep 2017 16:06:23 +0200 Message-ID: <20170913140628.7787-1-lprosek@redhat.com> Cc: rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45662 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751648AbdIMOGh (ORCPT ); Wed, 13 Sep 2017 10:06:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6B717EA87 for ; Wed, 13 Sep 2017 14:06:36 +0000 (UTC) Sender: kvm-owner@vger.kernel.org List-ID: Windows Server 2016 with Hyper-V enabled fails to boot on OVMF with SMM (OVMF_CODE-need-smm.fd). Turns out that the SMM emulation code in KVM does not handle nested virtualization very well, leading to a whole bunch of issues. For example, Hyper-V uses descriptor table exiting (SECONDARY_EXEC_DESC) so when the SMM handler tries to switch from real mode a VM exit occurs and is forwarded to a clueless L1. This series fixes it by switching the vcpu to !guest_mode, i.e. to the L1 state, before entering SMM and then switching back to L2 after the RSM instruction is emulated. Patch 1 is common for both Intel and AMD, patch 2 fixes Intel, and patches 4-5 AMD. Patch 3 adds more state to the SMRAM save area as prescribed by the Intel SDM. It is however not required to make Windows work. Ladi Prosek (5): KVM: x86: introduce ISA specific SMM entry/exit callbacks KVM: nVMX: fix SMI injection in guest mode KVM: nVMX: save nested EPT information in SMRAM state save map KVM: nSVM: refactor nested_svm_vmrun KVM: nSVM: fix SMI injection in guest mode arch/x86/include/asm/kvm_emulate.h | 1 + arch/x86/include/asm/kvm_host.h | 8 ++ arch/x86/kvm/emulate.c | 2 + arch/x86/kvm/svm.c | 180 ++++++++++++++++++++++++------------- arch/x86/kvm/vmx.c | 82 +++++++++++++++-- arch/x86/kvm/x86.c | 9 +- 6 files changed, 207 insertions(+), 75 deletions(-)