[PATCH kvm-unit-tests 7/9] x86: nVMX: Define VMCS header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Liran Alon <liran.alon@xxxxxxxxxx>
Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx>
---
 x86/vmx.c       | 12 ++++++------
 x86/vmx.h       |  7 ++++++-
 x86/vmx_tests.c |  2 +-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index f80b155c4dae..329082e3faa3 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -340,7 +340,7 @@ void test_vmwrite_vmread(void)
 	struct vmcs *vmcs = alloc_page();
 
 	memset(vmcs, 0, PAGE_SIZE);
-	vmcs->revision_id = basic.revision;
+	vmcs->hdr.revision_id = basic.revision;
 	assert(!vmcs_clear(vmcs));
 	assert(!make_vmcs_current(vmcs));
 
@@ -356,7 +356,7 @@ void test_vmcs_high(void)
 	struct vmcs *vmcs = alloc_page();
 
 	memset(vmcs, 0, PAGE_SIZE);
-	vmcs->revision_id = basic.revision;
+	vmcs->hdr.revision_id = basic.revision;
 	assert(!vmcs_clear(vmcs));
 	assert(!make_vmcs_current(vmcs));
 
@@ -383,7 +383,7 @@ void test_vmcs_lifecycle(void)
 	for (i = 0; i < ARRAY_SIZE(vmcs); i++) {
 		vmcs[i] = alloc_page();
 		memset(vmcs[i], 0, PAGE_SIZE);
-		vmcs[i]->revision_id = basic.revision;
+		vmcs[i]->hdr.revision_id = basic.revision;
 	}
 
 #define VMPTRLD(_i) do { \
@@ -632,7 +632,7 @@ static void test_vmclear_flushing(void)
 		memset(vmcs[i], 0, PAGE_SIZE);
 	}
 
-	vmcs[0]->revision_id = basic.revision;
+	vmcs[0]->hdr.revision_id = basic.revision;
 	assert(!vmcs_clear(vmcs[0]));
 	assert(!make_vmcs_current(vmcs[0]));
 	set_all_vmcs_fields(0x86);
@@ -1203,7 +1203,7 @@ static int init_vmcs(struct vmcs **vmcs)
 {
 	*vmcs = alloc_page();
 	memset(*vmcs, 0, PAGE_SIZE);
-	(*vmcs)->revision_id = basic.revision;
+	(*vmcs)->hdr.revision_id = basic.revision;
 	/* vmclear first to init vmcs */
 	if (vmcs_clear(*vmcs)) {
 		printf("%s : vmcs_clear error\n", __func__);
@@ -1369,7 +1369,7 @@ static void test_vmptrld(void)
 	int width = cpuid_maxphyaddr();
 
 	vmcs = alloc_page();
-	vmcs->revision_id = basic.revision;
+	vmcs->hdr.revision_id = basic.revision;
 
 	/* Unaligned page access */
 	tmp_root = (struct vmcs *)((intptr_t)vmcs + 1);
diff --git a/x86/vmx.h b/x86/vmx.h
index 2126df36f0ba..4a96a88261dd 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -7,8 +7,13 @@
 #include "asm/page.h"
 #include "asm/io.h"
 
+struct vmcs_hdr {
+	u32 revision_id:31;
+	u32 shadow_vmcs:1;
+};
+
 struct vmcs {
-	u32 revision_id; /* vmcs revision identifier */
+	struct vmcs_hdr hdr;
 	u32 abort; /* VMX-abort indicator */
 	/* VMCS data */
 	char data[0];
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 0a3464f87526..932759701314 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -3865,7 +3865,7 @@ static bool valid_vmcs_for_vmentry(void)
 	if (vmcs_save(&current_vmcs))
 		return false;
 
-	return current_vmcs && !(current_vmcs->revision_id >> 31);
+	return current_vmcs && !current_vmcs->hdr.shadow_vmcs;
 }
 
 static void try_vmentry_in_movss_shadow(void)
-- 
1.9.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux