* [PATCH v2] kvm-unit-tests: VMX: Comments on the framework and writing test cases
@ 2013-09-23 5:21 Arthur Chunqi Li
2013-10-25 10:07 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Arthur Chunqi Li @ 2013-09-23 5:21 UTC (permalink / raw)
To: kvm; +Cc: jan.kiszka, gleb, pbonzini, Arthur Chunqi Li
Add some comments on the framework of nested VMX testing, and guides of
how to write new test cases.
Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
---
x86/vmx.c | 30 ++++++++++++++++++++++++++++++
x86/vmx_tests.c | 13 +++++++++++++
2 files changed, 43 insertions(+)
diff --git a/x86/vmx.c b/x86/vmx.c
index 9db4ef4..d5ae609 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -1,3 +1,33 @@
+/*
+ * x86/vmx.c : Framework for testing nested virtualization
+ * This is a framework to test nested VMX for KVM, which
+ * started as a project of GSoC 2013. All test cases should
+ * be located in x86/vmx_tests.c and framework related
+ * functions should be in this file.
+ *
+ * How to write test cases?
+ * Add callbacks of test suite in variant "vmx_tests". You can
+ * write:
+ * 1. init function used for initializing test suite
+ * 2. main function for codes running in L2 guest,
+ * 3. exit_handler to handle vmexit of L2 to L1
+ * 4. syscall handler to handle L2 syscall vmexit
+ * 5. vmenter fail handler to handle direct failure of vmenter
+ * 6. guest_regs is loaded when vmenter and saved when
+ * vmexit, you can read and set it in exit_handler
+ * If no special function is needed for a test suite, use
+ * coressponding basic_* functions as callback. More handlers
+ * can be added to "vmx_tests", see details of "struct vmx_test"
+ * and function test_run().
+ *
+ * Currently, vmx test framework only set up one VCPU and one
+ * concurrent guest test environment with same paging for L2 and
+ * L1. For usage of EPT, only 1:1 mapped paging is used from VFN
+ * to PFN.
+ *
+ * Author : Arthur Chunqi Li <yzt356@gmail.com>
+ */
+
#include "libcflat.h"
#include "processor.h"
#include "vm.h"
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 0759e10..5fc16a3 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -1,3 +1,8 @@
+/*
+ * All test cases of nested virtualization should be in this file
+ *
+ * Author : Arthur Chunqi Li <yzt356@gmail.com>
+ */
#include "vmx.h"
#include "msr.h"
#include "processor.h"
@@ -782,6 +787,14 @@ struct insn_table {
u32 test_field;
};
+/*
+ * Add more test cases of instruction intercept here. Elements in this
+ * table is:
+ * name/control flag/insn function/type/exit reason/exit qulification/
+ * instruction info/field to test
+ * The last field defines which fields (exit_qual and insn_info) need to be
+ * tested in exit handler. If set to 0, only "reason" is checked.
+ */
static struct insn_table insn_table[] = {
// Flags for Primary Processor-Based VM-Execution Controls
{"HLT", CPU_HLT, insn_hlt, INSN_CPU0, 12, 0, 0, 0},
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] kvm-unit-tests: VMX: Comments on the framework and writing test cases
2013-09-23 5:21 [PATCH v2] kvm-unit-tests: VMX: Comments on the framework and writing test cases Arthur Chunqi Li
@ 2013-10-25 10:07 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2013-10-25 10:07 UTC (permalink / raw)
To: Arthur Chunqi Li; +Cc: kvm, jan.kiszka, gleb
Il 23/09/2013 06:21, Arthur Chunqi Li ha scritto:
> Add some comments on the framework of nested VMX testing, and guides of
> how to write new test cases.
>
> Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
> ---
> x86/vmx.c | 30 ++++++++++++++++++++++++++++++
> x86/vmx_tests.c | 13 +++++++++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/x86/vmx.c b/x86/vmx.c
> index 9db4ef4..d5ae609 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -1,3 +1,33 @@
> +/*
> + * x86/vmx.c : Framework for testing nested virtualization
> + * This is a framework to test nested VMX for KVM, which
> + * started as a project of GSoC 2013. All test cases should
> + * be located in x86/vmx_tests.c and framework related
> + * functions should be in this file.
> + *
> + * How to write test cases?
> + * Add callbacks of test suite in variant "vmx_tests". You can
> + * write:
> + * 1. init function used for initializing test suite
> + * 2. main function for codes running in L2 guest,
> + * 3. exit_handler to handle vmexit of L2 to L1
> + * 4. syscall handler to handle L2 syscall vmexit
> + * 5. vmenter fail handler to handle direct failure of vmenter
> + * 6. guest_regs is loaded when vmenter and saved when
> + * vmexit, you can read and set it in exit_handler
> + * If no special function is needed for a test suite, use
> + * coressponding basic_* functions as callback. More handlers
> + * can be added to "vmx_tests", see details of "struct vmx_test"
> + * and function test_run().
> + *
> + * Currently, vmx test framework only set up one VCPU and one
> + * concurrent guest test environment with same paging for L2 and
> + * L1. For usage of EPT, only 1:1 mapped paging is used from VFN
> + * to PFN.
> + *
> + * Author : Arthur Chunqi Li <yzt356@gmail.com>
> + */
> +
> #include "libcflat.h"
> #include "processor.h"
> #include "vm.h"
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 0759e10..5fc16a3 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -1,3 +1,8 @@
> +/*
> + * All test cases of nested virtualization should be in this file
> + *
> + * Author : Arthur Chunqi Li <yzt356@gmail.com>
> + */
> #include "vmx.h"
> #include "msr.h"
> #include "processor.h"
> @@ -782,6 +787,14 @@ struct insn_table {
> u32 test_field;
> };
>
> +/*
> + * Add more test cases of instruction intercept here. Elements in this
> + * table is:
> + * name/control flag/insn function/type/exit reason/exit qulification/
> + * instruction info/field to test
> + * The last field defines which fields (exit_qual and insn_info) need to be
> + * tested in exit handler. If set to 0, only "reason" is checked.
> + */
> static struct insn_table insn_table[] = {
> // Flags for Primary Processor-Based VM-Execution Controls
> {"HLT", CPU_HLT, insn_hlt, INSN_CPU0, 12, 0, 0, 0},
>
I'm applying this to the VMX queue.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-25 10:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23 5:21 [PATCH v2] kvm-unit-tests: VMX: Comments on the framework and writing test cases Arthur Chunqi Li
2013-10-25 10:07 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.