kvm-unit-tests: VMX: Split VMX test suites to separate file
PATCH v2 1/1 kvm-unit-tests: VMX: Split VMX test suites to separate file
Reconstruct VMX codes and put all VMX test suites in x86/vmx_tests.c.
---
ChangeLog to v1:
Reassign places of global variants. Move vmx_tests to vmx_tests.c.
config-x86-common.mak | 2 +- x86/vmx.c | 108 ++++++++----------------------------------------- x86/vmx.h | 47 ++++++++++++++------- x86/vmx_tests.c | 88 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+), 107 deletions(-) create mode 100644 x86/vmx_tests.c
config-x86-common.mak +1 -1
@@ -101,7 +101,7 @@ $(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 +$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o arch_clean: $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
x86/vmx.c +16 -92
154 lines not on this page · raw message
x86/vmx.h +33 -14
100 lines not on this page · raw message
x86/vmx_tests.c new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
1.7.9.5
x86/vmx.h enum Ctrl1 { · line 442
Quoted 12 lines · Arthur Chunqi Li
x86/vmx.h +8
-0@@ -432,6 +432,22 @@ enum Ctrl1 {#define HYPERCALL_MASK 0xFFF#define HYPERCALL_VMEXIT 0x1 + +extern u64 hypercall_field; +extern u32 vpid_cnt; +extern ulong fix_cr0_set, fix_cr0_clr; +extern ulong fix_cr4_set, fix_cr4_clr; +extern struct regs regs; +extern struct vmx_test *current; +extern bool launched;
You didn't address my question if we need them all to write test cases or if some are actually core internal.
The rest looks good.
Jan
Quoted 5 lines · 在 2013-8-5,2:08,Jan Kiszka <[email protected]> 写道:
Quoted 4 lines · Arthur Chunqi Li
x86/vmx.h +0
-0@@ -432,6 +432,22 @@ enum Ctrl1 {#define HYPERCALL_MASK 0xFFF#define HYPERCALL_VMEXIT 0x1
Quoted 11 lines
x86/vmx.h enum Ctrl1 { · line 442
Quoted 8 lines
x86/vmx.h +8
-0+ +extern u64 hypercall_field; +extern u32 vpid_cnt; +extern ulong fix_cr0_set, fix_cr0_clr; +extern ulong fix_cr4_set, fix_cr4_clr; +extern struct regs regs; +extern struct vmx_test *current; +extern bool launched;You didn't address my question if we need them all to write test cases or if some are actually core internal.
You are right. Not all global variants in last version is necessary for test cases, so I move some of them to vmx.c internal. The rest ones in this version are needed by tests to identify some states.
Arthur.
Quoted 6 lines
The rest looks good.
Jan
Quoted 18 lines · Gmail
Quoted 5 lines · 在 2013-8-5,2:08,Jan Kiszka <[email protected]> 写道:
Quoted 4 lines · Arthur Chunqi Li
x86/vmx.h +0
-0@@ -432,6 +432,22 @@ enum Ctrl1 {#define HYPERCALL_MASK 0xFFF#define HYPERCALL_VMEXIT 0x1Quoted 11 lines
x86/vmx.h enum Ctrl1 { · line 442
Quoted 8 lines
x86/vmx.h +8
-0+ +extern u64 hypercall_field; +extern u32 vpid_cnt; +extern ulong fix_cr0_set, fix_cr0_clr; +extern ulong fix_cr4_set, fix_cr4_clr; +extern struct regs regs; +extern struct vmx_test *current; +extern bool launched;You didn't address my question if we need them all to write test cases or if some are actually core internal.
Quoted 1 line
You are right. Not all global variants in last version is necessary for test cases, so I move some of them to
vmx.cinternal. The rest ones in this version are needed by tests to identify some states.
I can imagine 'regs' very well, but I've doubt about the rest. 'current', 'launched'? Again, rather export on demand than in advance.
Two additional questions, not directly related to the patch:
1. hypercall_field - why not passing this parameter via a register? Helps in case you have multiple guests running.
2. vpid_cnt - what's the purpose, why writing VPID at all? It's not needed, and not even supported on some CPUs.
Jan
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Gmail
Quoted 16 lines · 在 2013-8-5,2:08,Jan Kiszka <[email protected]> 写道:
x86/vmx.h enum Ctrl1 { · line 442
Quoted 12 lines · Arthur Chunqi Li
x86/vmx.h +8
-0@@ -432,6 +432,22 @@ enum Ctrl1 {#define HYPERCALL_MASK 0xFFF#define HYPERCALL_VMEXIT 0x1 + +extern u64 hypercall_field; +extern u32 vpid_cnt; +extern ulong fix_cr0_set, fix_cr0_clr; +extern ulong fix_cr4_set, fix_cr4_clr; +extern struct regs regs; +extern struct vmx_test *current; +extern bool launched;You didn't address my question if we need them all to write test cases or if some are actually core internal.
Quoted 4 lines
Quoted 1 line
You are right. Not all global variants in last version is necessary for test cases, so I move some of them to
vmx.cinternal. The rest ones in this version are needed by tests to identify some states.I can imagine 'regs' very well, but I've doubt about the rest. 'current', 'launched'? Again, rather export on demand than in advance.
Yes, currently we only use 'regs'. I supposed that some of them "may" used in the future. It's better to export on demand than in advance.
Quoted 5 lines
Two additional questions, not directly related to the patch:
1.
hypercall_field- why not passing this parameter via a register? Helps in case you have multiple guests running.
Passing param via registers will use at least one register and thus the handling codes in exit handler will not get the whole registers state. For multiple guests, we can simply move hypercall_field to the guest related structure and every guest has its own one.
Quoted 3 lines
2.
vpid_cnt- what's the purpose, why writing VPID at all? It's not needed, and not even supported on some CPUs.
Well, I was not quite sure if this is necessary when I write the first version, while SDM says some initial affairs about it so I reserved such a variant.
Arthur
Quoted 4 lines
Jan