Skip to contentSkip to conversation

Basic nested VMX test suite

PATCH Superseded Arthur Chunqi Li 1 participant 4 messages Jul 16, 2013

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Basic nested VMX test suite

These two patches are focued on providing a basic version of VMX nested test suite. This commit provides the architecture of nested VMX similiar to x86/svm.c.

setjmp/longjmp is designed to avoid exiting VMX in call-back form.

Arthur Chunqi Li (2):
kvm-unit-tests : Add setjmp/longjmp to libcflat kvm-unit-tests : The first version of VMX nested test case

 config-x86-common.mak |    2 +
 config-x86_64.mak     |    3 +
 lib/setjmp.h          |   11 +
 lib/x86/msr.h         |    5 +
 lib/x86/setjmp64.S    |   27 +++
 x86/cstart64.S        |    4 +
 x86/unittests.cfg     |    6 +
 x86/vmx.c             |  561 +++++++++++++++++++++++++++++++++++++++++++++++++
 x86/vmx.h             |  406 +++++++++++++++++++++++++++++++++++
 9 files changed, 1025 insertions(+)
 create mode 100644 lib/setjmp.h
 create mode 100644 lib/x86/setjmp64.S
 create mode 100644 x86/vmx.c
 create mode 100644 x86/vmx.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/2 kvm-unit-tests : Add setjmp/longjmp to libcflat

Add setjmp and longjmp functions to libcflat. Now these two functions are only supported in X86_64 arch.

New files added:

        lib/x86/setjmp64.S
        lib/x86/setjmp64.c
---
 config-x86_64.mak  |    2 ++
 lib/setjmp.h       |   11 +++++++++++
 lib/x86/setjmp64.S |   27 +++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)
 create mode 100644 lib/setjmp.h
 create mode 100644 lib/x86/setjmp64.S
config-x86_64.mak +2 -0
index 4e525f5..91ffcce 100644
@@ -4,6 +4,8 @@ bits = 64
 ldarch = elf64-x86-64
 CFLAGS += -D__x86_64__
 
+cflatobjs += lib/x86/setjmp64.o
+
 tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
 	  $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \
 	  $(TEST_DIR)/xsave.flat $(TEST_DIR)/rmap_chain.flat \
lib/setjmp.h new file +11 -0
new file mode 100644
index 0000000..eca70d9
@@ -0,0 +1,11 @@
+#ifndef LIBCFLAT_SETJMP64_H
+#define LIBCFLAT_SETJMP64_H
+
+#include "libcflat.h"
+
+typedef char jmp_buf[64];
+
+void longjmp(jmp_buf env, int val);
+int setjmp(jmp_buf env);
+
+#endif
lib/x86/setjmp64.S new file +27 -0
new file mode 100644
index 0000000..c8ae790
@@ -0,0 +1,27 @@
+.globl setjmp
+setjmp:
+	mov (%rsp), %rsi
+	mov %rsi, (%rdi)
+	mov %rsp, 0x8(%rdi)
+	mov %rbp, 0x10(%rdi)
+	mov %rbx, 0x18(%rdi)
+	mov %r12, 0x20(%rdi)
+	mov %r13, 0x28(%rdi)
+	mov %r14, 0x30(%rdi)
+	mov %r15, 0x38(%rdi)
+	xor %eax, %eax
+	ret
+
+.globl longjmp
+longjmp:
+	mov %esi, %eax
+	mov 0x38(%rdi), %r15
+	mov 0x30(%rdi), %r14
+	mov 0x28(%rdi), %r13
+	mov 0x20(%rdi), %r12
+	mov 0x18(%rdi), %rbx
+	mov 0x10(%rdi), %rbp
+	mov 0x8(%rdi), %rsp
+	mov (%rdi), %rsi
+	mov %rsi, (%rsp)
+	ret
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 2/2 kvm-unit-tests : The first version of VMX nested test case

In reply to Arthur Chunqi Li

This is the first version for VMX nested environment test case. It contains the basic VMX instructions test cases, including VMXON/ VMXOFF/VMXPTRLD/VMXPTRST/VMCLEAR/VMLAUNCH/VMRESUME/VMCALL. This patch also tests the basic execution routine in VMX nested environment and let the VM print "Hello World" to inform its successfully run.

New files added:
x86/vmx.h : contains all VMX related macro declerations x86/vmx.c : main file for VMX nested test case

---
 config-x86-common.mak |    2 +
 config-x86_64.mak     |    1 +
 lib/x86/msr.h         |    5 +
 x86/cstart64.S        |    4 +
 x86/unittests.cfg     |    6 +
 x86/vmx.c             |  561 +++++++++++++++++++++++++++++++++++++++++++++++++
 x86/vmx.h             |  406 +++++++++++++++++++++++++++++++++++
 7 files changed, 985 insertions(+)
 create mode 100644 x86/vmx.c
 create mode 100644 x86/vmx.h
config-x86-common.mak +2 -0
index 455032b..34a41e1 100644
@@ -101,6 +101,8 @@ $(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o
 
 $(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o
 
+$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o
+
 arch_clean:
 	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
 	$(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
config-x86_64.mak +1 -0
index 91ffcce..5d9b22a 100644
@@ -11,5 +11,6 @@ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
 	  $(TEST_DIR)/xsave.flat $(TEST_DIR)/rmap_chain.flat \
 	  $(TEST_DIR)/pcid.flat
 tests += $(TEST_DIR)/svm.flat
+tests += $(TEST_DIR)/vmx.flat
 
 include config-x86-common.mak
lib/x86/msr.h +5 -0
index 509a421..281255a 100644
@@ -396,6 +396,11 @@
 #define MSR_IA32_VMX_VMCS_ENUM          0x0000048a
 #define MSR_IA32_VMX_PROCBASED_CTLS2    0x0000048b
 #define MSR_IA32_VMX_EPT_VPID_CAP       0x0000048c
+#define MSR_IA32_VMX_TRUE_PIN		0x0000048d
+#define MSR_IA32_VMX_TRUE_PROC		0x0000048e
+#define MSR_IA32_VMX_TRUE_EXIT		0x0000048f
+#define MSR_IA32_VMX_TRUE_ENTRY		0x00000490
+
 
 /* AMD-V MSRs */
 
x86/cstart64.S +4 -0
index 24df5f8..0fe76da 100644
@@ -4,6 +4,10 @@
 .globl boot_idt
 boot_idt = 0
 
+.globl idt_descr
+.globl tss_descr
+.globl gdt64_desc
+
 ipi_vector = 0x20
 
 max_cpus = 64
x86/unittests.cfg +6 -0
index bc9643e..85c36aa 100644
@@ -149,3 +149,9 @@ extra_params = --append "10000000 `date +%s`"
 file = pcid.flat
 extra_params = -cpu qemu64,+pcid
 arch = x86_64
+
+[vmx]
+file = vmx.flat
+extra_params = -cpu host,+vmx
+arch = x86_64
+
x86/vmx.c new file +561 -0

561 lines not on this page · raw message

x86/vmx.h new file +406 -0

406 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw
In reply to Arthur Chunqi Li

On this commit, I delete two "TODO" lines in PATCH 2/2, and it can only run with all my previous patches.

Arthur

Quoted 28 lines · Arthur Chunqi Li

These two patches are focued on providing a basic version of VMX nested test suite. This commit provides the architecture of nested VMX similiar to x86/svm.c.

setjmp/longjmp is designed to avoid exiting VMX in call-back form.

Arthur Chunqi Li (2):
kvm-unit-tests : Add setjmp/longjmp to libcflat kvm-unit-tests : The first version of VMX nested test case

 config-x86-common.mak |    2 +
 config-x86_64.mak     |    3 +
 lib/setjmp.h          |   11 +
 lib/x86/msr.h         |    5 +
 lib/x86/setjmp64.S    |   27 +++
 x86/cstart64.S        |    4 +
 x86/unittests.cfg     |    6 +
 x86/vmx.c             |  561 +++++++++++++++++++++++++++++++++++++++++++++++++
 x86/vmx.h             |  406 +++++++++++++++++++++++++++++++++++
 9 files changed, 1025 insertions(+)
 create mode 100644 lib/setjmp.h
 create mode 100644 lib/x86/setjmp64.S
 create mode 100644 x86/vmx.c
 create mode 100644 x86/vmx.h

--
1.7.9.5

Signature · 5 lines
Arthur Chunqi Li
Department of Computer Science
School of EECS
Peking University
Beijing, China