From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] Support for GUEST_SMBASE vmcs field for nested virtualization Date: Wed, 06 Jun 2012 15:12:56 +0300 Message-ID: <4FCF4948.9030206@redhat.com> References: <20120606113715.GA9072@rhea> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:24531 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751243Ab2FFMM6 (ORCPT ); Wed, 6 Jun 2012 08:12:58 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q56CCwXq026380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Jun 2012 08:12:58 -0400 In-Reply-To: <20120606113715.GA9072@rhea> Sender: kvm-owner@vger.kernel.org List-ID: On 06/06/2012 02:37 PM, Matthias Lange wrote: > Hi, > > the following patch adds support for the GUEST_SMBASE field in the VMCS for > the case of nested virtualization. There are hypervisors that try to access > that mandatory field. The patch avoids returning a "unsupported vmcs field" > error to the L1 hypervisor by adding the GUEST_SMBASE field into the vmcs12 > struct. > > > diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h > index 31f180c..6a14720 100644 > --- a/arch/x86/include/asm/vmx.h > +++ b/arch/x86/include/asm/vmx.h > @@ -194,6 +194,7 @@ enum vmcs_field { > GUEST_TR_AR_BYTES = 0x00004822, > GUEST_INTERRUPTIBILITY_INFO = 0x00004824, > GUEST_ACTIVITY_STATE = 0X00004826, > + GUEST_SMBASE = 0x00004828, > GUEST_SYSENTER_CS = 0x0000482A, > HOST_IA32_SYSENTER_CS = 0x00004c00, > CR0_GUEST_HOST_MASK = 0x00006000, > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 32eb588..88e21e9 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -294,7 +294,8 @@ struct __packed vmcs12 { > u32 guest_activity_state; > u32 guest_sysenter_cs; > u32 host_ia32_sysenter_cs; > - u32 padding32[8]; /* room for future expansion */ > + u32 guest_smbase; > + u32 padding32[7]; /* room for future expansion */ > u16 virtual_processor_id; > u16 guest_es_selector; > u16 guest_cs_selector; This is okay now. > @@ -6536,6 +6538,7 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) > vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, > vmcs12->guest_interruptibility_info); > vmcs_write32(GUEST_ACTIVITY_STATE, vmcs12->guest_activity_state); > + vmcs_write32(GUEST_SMBASE, vmcs12->guest_smbase); > vmcs_write32(GUEST_SYSENTER_CS, vmcs12->guest_sysenter_cs); > vmcs_writel(GUEST_DR7, vmcs12->guest_dr7); > vmcs_writel(GUEST_RFLAGS, vmcs12->guest_rflags); > @@ -6937,6 +6940,7 @@ void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) > vmcs12->guest_idtr_base = vmcs_readl(GUEST_IDTR_BASE); > > vmcs12->guest_activity_state = vmcs_read32(GUEST_ACTIVITY_STATE); > + vmcs12->guest_smbase = vmcs_read32(GUEST_SMBASE); > vmcs12->guest_interruptibility_info = > vmcs_read32(GUEST_INTERRUPTIBILITY_INFO); > vmcs12->guest_pending_dbg_exceptions = I missed this earlier: I don't think we need this. If we do implement SMM, anything touching SMBASE (SMI delivery and RSM) will be emulated, so we don't need anything in vmcs02 (just vmcs12, which is handled by the code above). -- error compiling committee.c: too many arguments to function