* [PATCH] Support for GUEST_SMBASE vmcs field for nested virtualization
@ 2012-06-06 11:37 Matthias Lange
2012-06-06 12:12 ` Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Matthias Lange @ 2012-06-06 11:37 UTC (permalink / raw)
To: kvm
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.
Regards,
Matthias.
---
arch/x86/include/asm/vmx.h | 1 +
arch/x86/kvm/vmx.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
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;
@@ -556,6 +557,7 @@ static unsigned short vmcs_field_to_offset_table[] = {
FIELD(GUEST_TR_BASE, guest_tr_base),
FIELD(GUEST_GDTR_BASE, guest_gdtr_base),
FIELD(GUEST_IDTR_BASE, guest_idtr_base),
+ FIELD(GUEST_SMBASE, guest_smbase),
FIELD(GUEST_DR7, guest_dr7),
FIELD(GUEST_RSP, guest_rsp),
FIELD(GUEST_RIP, guest_rip),
@@ -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 =
--
1.7.9.5
--
Dipl.-Inf. Matthias Lange <mlange@sec.t-labs.tu-berlin.de>
Security in Telecommunications
TU Berlin / Telekom Innovation Laboratories
Ernst-Reuter-Platz 7, 10587 Berlin
Phone: +49 - 30 - 8353 58 553
Mobile: +49 - 160 - 587 28 07
Web: http://www.t-labs.tu-berlin.de/sect
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Support for GUEST_SMBASE vmcs field for nested virtualization
2012-06-06 11:37 [PATCH] Support for GUEST_SMBASE vmcs field for nested virtualization Matthias Lange
@ 2012-06-06 12:12 ` Avi Kivity
2012-06-08 9:40 ` Matthias Lange
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2012-06-06 12:12 UTC (permalink / raw)
To: kvm
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Support for GUEST_SMBASE vmcs field for nested virtualization
2012-06-06 12:12 ` Avi Kivity
@ 2012-06-08 9:40 ` Matthias Lange
0 siblings, 0 replies; 3+ messages in thread
From: Matthias Lange @ 2012-06-08 9:40 UTC (permalink / raw)
To: kvm
[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]
On Wed, Jun 06, 2012 at 03:12:56PM +0300, Avi Kivity wrote:
> On 06/06/2012 02:37 PM, Matthias Lange wrote:
> > @@ -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).
I updated the patch according to your comments.
Matthias.
--
Dipl.-Inf. Matthias Lange <mlange@sec.t-labs.tu-berlin.de>
Security in Telecommunications
TU Berlin / Telekom Innovation Laboratories
Ernst-Reuter-Platz 7, 10587 Berlin
Phone: +49 - 30 - 8353 58 553
Mobile: +49 - 160 - 587 28 07
Web: http://www.t-labs.tu-berlin.de/sect
[-- Attachment #2: 0001-Add-support-for-the-GUEST_SMBASE-VMCS-field-for-Inte.patch --]
[-- Type: text/x-diff, Size: 2219 bytes --]
>From bdcb7c52a5f4202d9322cc85a88a83af596cf11d Mon Sep 17 00:00:00 2001
From: Matthias Lange <mlange@sec.t-labs.tu-berlin.de>
Date: Fri, 18 May 2012 10:58:00 +0200
Subject: [PATCH] Add support for the GUEST_SMBASE VMCS field for Intel VT-x
in the case of nested virtualization. - I take a slot from
the padding32 area to insert the field into the vmcs12
struct
---
arch/x86/include/asm/vmx.h | 1 +
arch/x86/kvm/vmx.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
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..7c703c6 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;
@@ -556,6 +557,7 @@ static unsigned short vmcs_field_to_offset_table[] = {
FIELD(GUEST_TR_BASE, guest_tr_base),
FIELD(GUEST_GDTR_BASE, guest_gdtr_base),
FIELD(GUEST_IDTR_BASE, guest_idtr_base),
+ FIELD(GUEST_SMBASE, guest_smbase),
FIELD(GUEST_DR7, guest_dr7),
FIELD(GUEST_RSP, guest_rsp),
FIELD(GUEST_RIP, guest_rip),
@@ -6937,6 +6939,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 =
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-08 9:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-06 11:37 [PATCH] Support for GUEST_SMBASE vmcs field for nested virtualization Matthias Lange
2012-06-06 12:12 ` Avi Kivity
2012-06-08 9:40 ` Matthias Lange
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox