All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests
@ 2014-01-04 17:59 Jan Kiszka
  2014-01-04 17:59 ` [PATCH 01/13] VMX: Add test cases around interrupt injection and halting Jan Kiszka
                   ` (14 more replies)
  0 siblings, 15 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

Highlights:
 - improved preemption timer and interrupt injection tests
   (obsoletes my two patches in vmx queue)
 - tests for IA32_APIC_BASE writes
 - test for unconditional IO exiting (VMX)
 - basic test of debug facilities (hw breakpoints etc.)

Jan Kiszka (13):
  VMX: Add test cases around interrupt injection and halting
  VMX: Extend preemption timer tests
  apic: Remove redundant enable_apic
  VMX: Fix return label in fault-triggering handlers
  lib/x86: Move exception test code into library
  x2apic: Test for invalid state transitions
  lib/x86/apic: Consolidate over MSR_IA32_APICBASE
  apic: Add test case for relocation and writing reserved bits
  VMX: Check unconditional I/O exiting
  Provide common report and report_summary services
  Ignore *.elf build outputs
  svm: Add missing build dependency
  x86: Add debug facility test case

 .gitignore            |   1 +
 Makefile              |   3 +-
 config-x86-common.mak |   4 +-
 config-x86_64.mak     |   2 +-
 lib/libcflat.h        |   4 +
 lib/report.c          |  36 +++++++
 lib/x86/apic-defs.h   |   3 +
 lib/x86/apic.c        |   7 +-
 lib/x86/desc.c        |  24 +++++
 lib/x86/desc.h        |   6 ++
 x86/apic.c            |  84 +++++++++++++---
 x86/debug.c           | 113 +++++++++++++++++++++
 x86/emulator.c        |  16 +--
 x86/eventinj.c        |  15 +--
 x86/idt_test.c        |  21 +---
 x86/msr.c             |  15 +--
 x86/pcid.c            |  14 +--
 x86/pmu.c             |  37 +++----
 x86/taskswitch2.c     |  15 +--
 x86/unittests.cfg     |   3 +
 x86/vmx.c             |  57 +++--------
 x86/vmx.h             |   4 +-
 x86/vmx_tests.c       | 264 ++++++++++++++++++++++++++++++++++++++++++++++----
 23 files changed, 548 insertions(+), 200 deletions(-)
 create mode 100644 lib/report.c
 create mode 100644 x86/debug.c

-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 01/13] VMX: Add test cases around interrupt injection and halting
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 02/13] VMX: Extend preemption timer tests Jan Kiszka
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

This checks for interrupt delivery to L2, unintercepted hlt in L2 and
explicit L2 suspension via the activity state HLT. All tests are
performed both with direct interrupt injection and external interrupt
interception.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 x86/vmx.c       |   3 +-
 x86/vmx.h       |   3 ++
 x86/vmx_tests.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index fe950e6..a475aec 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -457,7 +457,7 @@ static void init_vmcs_guest(void)
 	vmcs_write(GUEST_RFLAGS, 0x2);
 
 	/* 26.3.1.5 */
-	vmcs_write(GUEST_ACTV_STATE, 0);
+	vmcs_write(GUEST_ACTV_STATE, ACTV_ACTIVE);
 	vmcs_write(GUEST_INTR_STATE, 0);
 }
 
@@ -482,7 +482,6 @@ static int init_vmcs(struct vmcs **vmcs)
 	ctrl_pin |= PIN_EXTINT | PIN_NMI | PIN_VIRT_NMI;
 	ctrl_exit = EXI_LOAD_EFER | EXI_HOST_64;
 	ctrl_enter = (ENT_LOAD_EFER | ENT_GUEST_64);
-	ctrl_cpu[0] |= CPU_HLT;
 	/* DIsable IO instruction VMEXIT now */
 	ctrl_cpu[0] &= (~(CPU_IO | CPU_IO_BITMAP));
 	ctrl_cpu[1] = 0;
diff --git a/x86/vmx.h b/x86/vmx.h
index bc8c86f..3867793 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -500,6 +500,9 @@ enum Ctrl1 {
 #define INVEPT_SINGLE		1
 #define INVEPT_GLOBAL		2
 
+#define ACTV_ACTIVE		0
+#define ACTV_HLT		1
+
 extern struct regs regs;
 
 extern union vmx_basic basic;
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index bec34c4..70efb50 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -9,6 +9,8 @@
 #include "vm.h"
 #include "io.h"
 #include "fwcfg.h"
+#include "isr.h"
+#include "apic.h"
 
 u64 ia32_pat;
 u64 ia32_efer;
@@ -1117,6 +1119,146 @@ static int ept_exit_handler()
 	return VMX_TEST_VMEXIT;
 }
 
+#define TIMER_VECTOR	222
+
+static volatile bool timer_fired;
+
+static void timer_isr(isr_regs_t *regs)
+{
+	timer_fired = true;
+	apic_write(APIC_EOI, 0);
+}
+
+static int interrupt_init(struct vmcs *vmcs)
+{
+	msr_bmp_init();
+	vmcs_write(PIN_CONTROLS, vmcs_read(PIN_CONTROLS) & ~PIN_EXTINT);
+	handle_irq(TIMER_VECTOR, timer_isr);
+	return VMX_TEST_START;
+}
+
+static void interrupt_main(void)
+{
+	long long start, loops;
+
+	set_stage(0);
+
+	apic_write(APIC_LVTT, TIMER_VECTOR);
+	irq_enable();
+
+	apic_write(APIC_TMICT, 1);
+	for (loops = 0; loops < 10000000 && !timer_fired; loops++)
+		asm volatile ("nop");
+	report("direct interrupt while running guest", timer_fired);
+
+	apic_write(APIC_TMICT, 0);
+	irq_disable();
+	vmcall();
+	timer_fired = false;
+	apic_write(APIC_TMICT, 1);
+	for (loops = 0; loops < 10000000 && !timer_fired; loops++)
+		asm volatile ("nop");
+	report("intercepted interrupt while running guest", timer_fired);
+
+	irq_enable();
+	apic_write(APIC_TMICT, 0);
+	irq_disable();
+	vmcall();
+	timer_fired = false;
+	start = rdtsc();
+	apic_write(APIC_TMICT, 1000000);
+
+	asm volatile ("sti; hlt");
+
+	report("direct interrupt + hlt",
+	       rdtsc() - start > 1000000 && timer_fired);
+
+	apic_write(APIC_TMICT, 0);
+	irq_disable();
+	vmcall();
+	timer_fired = false;
+	start = rdtsc();
+	apic_write(APIC_TMICT, 1000000);
+
+	asm volatile ("sti; hlt");
+
+	report("intercepted interrupt + hlt",
+	       rdtsc() - start > 10000 && timer_fired);
+
+	apic_write(APIC_TMICT, 0);
+	irq_disable();
+	vmcall();
+	timer_fired = false;
+	start = rdtsc();
+	apic_write(APIC_TMICT, 1000000);
+
+	irq_enable();
+	asm volatile ("nop");
+	vmcall();
+
+	report("direct interrupt + activity state hlt",
+	       rdtsc() - start > 10000 && timer_fired);
+
+	apic_write(APIC_TMICT, 0);
+	irq_disable();
+	vmcall();
+	timer_fired = false;
+	start = rdtsc();
+	apic_write(APIC_TMICT, 1000000);
+
+	irq_enable();
+	asm volatile ("nop");
+	vmcall();
+
+	report("intercepted interrupt + activity state hlt",
+	       rdtsc() - start > 10000 && timer_fired);
+}
+
+static int interrupt_exit_handler(void)
+{
+	u64 guest_rip = vmcs_read(GUEST_RIP);
+	ulong reason = vmcs_read(EXI_REASON) & 0xff;
+	u32 insn_len = vmcs_read(EXI_INST_LEN);
+
+	switch (reason) {
+	case VMX_VMCALL:
+		switch (get_stage()) {
+		case 0:
+		case 2:
+		case 5:
+			vmcs_write(PIN_CONTROLS,
+				   vmcs_read(PIN_CONTROLS) | PIN_EXTINT);
+			break;
+		case 1:
+		case 3:
+			vmcs_write(PIN_CONTROLS,
+				   vmcs_read(PIN_CONTROLS) & ~PIN_EXTINT);
+			break;
+		case 4:
+		case 6:
+			vmcs_write(GUEST_ACTV_STATE, ACTV_HLT);
+			break;
+		}
+		set_stage(get_stage() + 1);
+		vmcs_write(GUEST_RIP, guest_rip + insn_len);
+		return VMX_TEST_RESUME;
+	case VMX_EXTINT:
+		irq_enable();
+		asm volatile ("nop");
+		irq_disable();
+		if (get_stage() >= 2) {
+			vmcs_write(GUEST_ACTV_STATE, ACTV_ACTIVE);
+			vmcs_write(GUEST_RIP, guest_rip + insn_len);
+		}
+		return VMX_TEST_RESUME;
+	default:
+		printf("Unknown exit reason, %d\n", reason);
+		print_vmexit_info();
+	}
+
+	return VMX_TEST_VMEXIT;
+}
+
 /* name/init/guest_main/exit_handler/syscall_handler/guest_regs */
 struct vmx_test vmx_tests[] = {
 	{ "null", NULL, basic_guest_main, basic_exit_handler, NULL, {0} },
@@ -1134,5 +1276,7 @@ struct vmx_test vmx_tests[] = {
 	{ "instruction intercept", insn_intercept_init, insn_intercept_main,
 		insn_intercept_exit_handler, NULL, {0} },
 	{ "EPT framework", ept_init, ept_main, ept_exit_handler, NULL, {0} },
+	{ "interrupt", interrupt_init, interrupt_main,
+		interrupt_exit_handler, NULL, {0} },
 	{ NULL, NULL, NULL, NULL, NULL, {0} },
 };
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 02/13] VMX: Extend preemption timer tests
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
  2014-01-04 17:59 ` [PATCH 01/13] VMX: Add test cases around interrupt injection and halting Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 03/13] apic: Remove redundant enable_apic Jan Kiszka
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

This checks that we properly expire the preemption timer while the guest
is in HLT state and that we do not progress guest execution of the
preemption timer is activated with a timer value of 0.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 x86/vmx_tests.c | 84 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 64 insertions(+), 20 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 70efb50..0077f3f 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -99,6 +99,7 @@ int vmenter_exit_handler()
 u32 preempt_scale;
 volatile unsigned long long tsc_val;
 volatile u32 preempt_val;
+u64 saved_rip;
 
 int preemption_timer_init()
 {
@@ -126,17 +127,24 @@ void preemption_timer_main()
 		if (get_stage() == 1)
 			vmcall();
 	}
-	while (1) {
+	set_stage(1);
+	while (get_stage() == 1) {
 		if (((rdtsc() - tsc_val) >> preempt_scale)
 				> 10 * preempt_val) {
 			set_stage(2);
 			vmcall();
 		}
 	}
+	tsc_val = rdtsc();
+	asm volatile ("hlt");
+	vmcall();
+	set_stage(5);
+	vmcall();
 }
 
 int preemption_timer_exit_handler()
 {
+	bool guest_halted;
 	u64 guest_rip;
 	ulong reason;
 	u32 insn_len;
@@ -147,33 +155,69 @@ int preemption_timer_exit_handler()
 	insn_len = vmcs_read(EXI_INST_LEN);
 	switch (reason) {
 	case VMX_PREEMPT:
-		if (((rdtsc() - tsc_val) >> preempt_scale) < preempt_val)
-			report("Preemption timer", 0);
-		else
-			report("Preemption timer", 1);
+		switch (get_stage()) {
+		case 1:
+		case 2:
+			report("busy-wait for preemption timer",
+			       ((rdtsc() - tsc_val) >> preempt_scale) >=
+			       preempt_val);
+			set_stage(3);
+			vmcs_write(PREEMPT_TIMER_VALUE, preempt_val);
+			return VMX_TEST_RESUME;
+		case 3:
+			guest_halted =
+				(vmcs_read(GUEST_ACTV_STATE) == ACTV_HLT);
+			report("preemption timer during hlt",
+			       ((rdtsc() - tsc_val) >> preempt_scale) >=
+			       preempt_val && guest_halted);
+			set_stage(4);
+			vmcs_write(PIN_CONTROLS,
+				   vmcs_read(PIN_CONTROLS) & ~PIN_PREEMPT);
+			vmcs_write(GUEST_ACTV_STATE, ACTV_ACTIVE);
+			return VMX_TEST_RESUME;
+		case 4:
+			report("preemption timer with 0 value",
+			       saved_rip == guest_rip);
+			break;
+		default:
+			printf("Invalid stage.\n");
+			print_vmexit_info();
+			break;
+		}
 		break;
 	case VMX_VMCALL:
+		vmcs_write(GUEST_RIP, guest_rip + insn_len);
 		switch (get_stage()) {
 		case 0:
-			if (vmcs_read(PREEMPT_TIMER_VALUE) != preempt_val)
-				report("Save preemption value", 0);
-			else {
-				set_stage(get_stage() + 1);
-				ctrl_exit = (vmcs_read(EXI_CONTROLS) |
-					EXI_SAVE_PREEMPT) & ctrl_exit_rev.clr;
-				vmcs_write(EXI_CONTROLS, ctrl_exit);
-			}
-			vmcs_write(GUEST_RIP, guest_rip + insn_len);
+			report("Keep preemption value",
+			       vmcs_read(PREEMPT_TIMER_VALUE) == preempt_val);
+			set_stage(1);
+			vmcs_write(PREEMPT_TIMER_VALUE, preempt_val);
+			ctrl_exit = (vmcs_read(EXI_CONTROLS) |
+				EXI_SAVE_PREEMPT) & ctrl_exit_rev.clr;
+			vmcs_write(EXI_CONTROLS, ctrl_exit);
 			return VMX_TEST_RESUME;
 		case 1:
-			if (vmcs_read(PREEMPT_TIMER_VALUE) >= preempt_val)
-				report("Save preemption value", 0);
-			else
-				report("Save preemption value", 1);
-			vmcs_write(GUEST_RIP, guest_rip + insn_len);
+			report("Save preemption value",
+			       vmcs_read(PREEMPT_TIMER_VALUE) < preempt_val);
 			return VMX_TEST_RESUME;
 		case 2:
-			report("Preemption timer", 0);
+			report("busy-wait for preemption timer", 0);
+			set_stage(3);
+			vmcs_write(PREEMPT_TIMER_VALUE, preempt_val);
+			return VMX_TEST_RESUME;
+		case 3:
+			report("preemption timer during hlt", 0);
+			set_stage(4);
+			/* fall through */
+		case 4:
+			vmcs_write(PIN_CONTROLS,
+				   vmcs_read(PIN_CONTROLS) | PIN_PREEMPT);
+			vmcs_write(PREEMPT_TIMER_VALUE, 0);
+			saved_rip = guest_rip + insn_len;
+			return VMX_TEST_RESUME;
+		case 5:
+			report("preemption timer with 0 value (vmcall stage 5)", 0);
 			break;
 		default:
 			// Should not reach here
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 03/13] apic: Remove redundant enable_apic
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
  2014-01-04 17:59 ` [PATCH 01/13] VMX: Add test cases around interrupt injection and halting Jan Kiszka
  2014-01-04 17:59 ` [PATCH 02/13] VMX: Extend preemption timer tests Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 04/13] VMX: Fix return label in fault-triggering handlers Jan Kiszka
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Already called by the bootstrap code.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 x86/apic.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/x86/apic.c b/x86/apic.c
index 50e77fc..d06153f 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -326,7 +326,6 @@ int main()
     test_lapic_existence();
 
     mask_pic_interrupts();
-    enable_apic();
     test_enable_x2apic();
 
     test_self_ipi();
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/13] VMX: Fix return label in fault-triggering handlers
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (2 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 03/13] apic: Remove redundant enable_apic Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-22 15:00   ` Paolo Bonzini
  2014-01-04 17:59 ` [PATCH 05/13] lib/x86: Move exception test code into library Jan Kiszka
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Some compiler versions (seen with gcc 4.8.1) move the resume label after
the return statement which, of course, causes sever problems.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 x86/vmx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index a475aec..f9d5493 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -563,7 +563,7 @@ static void do_vmxon_off(void)
 	vmx_on();
 	vmx_off();
 resume:
-	return;
+	barrier();
 }
 
 static void do_write_feature_control(void)
@@ -572,7 +572,7 @@ static void do_write_feature_control(void)
 	barrier();
 	wrmsr(MSR_IA32_FEATURE_CONTROL, 0);
 resume:
-	return;
+	barrier();
 }
 
 static int test_vmx_feature_control(void)
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 05/13] lib/x86: Move exception test code into library
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (3 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 04/13] VMX: Fix return label in fault-triggering handlers Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 06/13] x2apic: Test for invalid state transitions Jan Kiszka
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Will also be used by the APIC test. Moving exception_return assignment
out of line, we can drop the explicit compiler barrier.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 lib/x86/desc.c | 24 ++++++++++++++++++++++++
 lib/x86/desc.h |  4 ++++
 x86/vmx.c      | 34 +++++++---------------------------
 3 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/lib/x86/desc.c b/lib/x86/desc.c
index 7c5c721..f75ec1d 100644
--- a/lib/x86/desc.c
+++ b/lib/x86/desc.c
@@ -353,3 +353,27 @@ void print_current_tss_info(void)
                tr, tss[0].prev, tss[i].prev);
 }
 #endif
+
+static bool exception;
+static void *exception_return;
+
+static void exception_handler(struct ex_regs *regs)
+{
+	exception = true;
+	regs->rip = (unsigned long)exception_return;
+}
+
+bool test_for_exception(unsigned int ex, void (*trigger_func)(void *data),
+			void *data)
+{
+	handle_exception(ex, exception_handler);
+	exception = false;
+	trigger_func(data);
+	handle_exception(ex, NULL);
+	return exception;
+}
+
+void set_exception_return(void *addr)
+{
+	exception_return = addr;
+}
diff --git a/lib/x86/desc.h b/lib/x86/desc.h
index f819452..5c850b2 100644
--- a/lib/x86/desc.h
+++ b/lib/x86/desc.h
@@ -84,4 +84,8 @@ void set_intr_task_gate(int e, void *fn);
 void print_current_tss_info(void);
 void handle_exception(u8 v, void (*func)(struct ex_regs *regs));
 
+bool test_for_exception(unsigned int ex, void (*trigger_func)(void *data),
+			void *data);
+void set_exception_return(void *addr);
+
 #endif
diff --git a/x86/vmx.c b/x86/vmx.c
index f9d5493..4f0bb8d 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -538,38 +538,18 @@ static void init_vmx(void)
 	memset(guest_syscall_stack, 0, PAGE_SIZE);
 }
 
-static bool exception;
-static void *exception_return;
-
-static void exception_handler(struct ex_regs *regs)
+static void do_vmxon_off(void *data)
 {
-	exception = true;
-	regs->rip = (u64)exception_return;
-}
-
-static int test_for_exception(unsigned int ex, void (*func)(void))
-{
-	handle_exception(ex, exception_handler);
-	exception = false;
-	func();
-	handle_exception(ex, NULL);
-	return exception;
-}
-
-static void do_vmxon_off(void)
-{
-	exception_return = &&resume;
-	barrier();
+	set_exception_return(&&resume);
 	vmx_on();
 	vmx_off();
 resume:
 	barrier();
 }
 
-static void do_write_feature_control(void)
+static void do_write_feature_control(void *data)
 {
-	exception_return = &&resume;
-	barrier();
+	set_exception_return(&&resume);
 	wrmsr(MSR_IA32_FEATURE_CONTROL, 0);
 resume:
 	barrier();
@@ -592,18 +572,18 @@ static int test_vmx_feature_control(void)
 
 	wrmsr(MSR_IA32_FEATURE_CONTROL, 0);
 	report("test vmxon with FEATURE_CONTROL cleared",
-	       test_for_exception(GP_VECTOR, &do_vmxon_off));
+	       test_for_exception(GP_VECTOR, &do_vmxon_off, NULL));
 
 	wrmsr(MSR_IA32_FEATURE_CONTROL, 0x4);
 	report("test vmxon without FEATURE_CONTROL lock",
-	       test_for_exception(GP_VECTOR, &do_vmxon_off));
+	       test_for_exception(GP_VECTOR, &do_vmxon_off, NULL));
 
 	wrmsr(MSR_IA32_FEATURE_CONTROL, 0x5);
 	vmx_enabled = ((rdmsr(MSR_IA32_FEATURE_CONTROL) & 0x5) == 0x5);
 	report("test enable VMX in FEATURE_CONTROL", vmx_enabled);
 
 	report("test FEATURE_CONTROL lock bit",
-	       test_for_exception(GP_VECTOR, &do_write_feature_control));
+	       test_for_exception(GP_VECTOR, &do_write_feature_control, NULL));
 
 	return !vmx_enabled;
 }
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 06/13] x2apic: Test for invalid state transitions
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (4 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 05/13] lib/x86: Move exception test code into library Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 07/13] lib/x86/apic: Consolidate over MSR_IA32_APICBASE Jan Kiszka
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

This checks if KVM properly acknowledges invalid state transitions on
MSR_APIC_BASE writes with a #GP.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 lib/x86/apic-defs.h |  3 +++
 x86/apic.c          | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/lib/x86/apic-defs.h b/lib/x86/apic-defs.h
index c061e3d..94112b4 100644
--- a/lib/x86/apic-defs.h
+++ b/lib/x86/apic-defs.h
@@ -9,6 +9,9 @@
  */
 
 #define	APIC_DEFAULT_PHYS_BASE	0xfee00000
+#define APIC_BSP		(1UL << 8)
+#define APIC_EXTD		(1UL << 10)
+#define APIC_EN			(1UL << 11)
 
 #define	APIC_ID		0x20
 
diff --git a/x86/apic.c b/x86/apic.c
index d06153f..4ebcd4f 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -4,6 +4,7 @@
 #include "smp.h"
 #include "desc.h"
 #include "isr.h"
+#include "msr.h"
 
 static int g_fail;
 static int g_tests;
@@ -70,14 +71,52 @@ static void test_tsc_deadline_timer(void)
     }
 }
 
-#define MSR_APIC_BASE 0x0000001b
+static void do_write_apicbase(void *data)
+{
+    set_exception_return(&&resume);
+    wrmsr(MSR_IA32_APICBASE, *(u64 *)data);
+resume:
+    barrier();
+}
 
 void test_enable_x2apic(void)
 {
+    u64 invalid_state = APIC_DEFAULT_PHYS_BASE | APIC_BSP | APIC_EXTD;
+    u64 apic_enabled = APIC_DEFAULT_PHYS_BASE | APIC_BSP | APIC_EN;
+    u64 x2apic_enabled =
+        APIC_DEFAULT_PHYS_BASE | APIC_BSP | APIC_EN | APIC_EXTD;
+
     if (enable_x2apic()) {
         printf("x2apic enabled\n");
+
+        report("x2apic enabled to invalid state",
+               test_for_exception(GP_VECTOR, do_write_apicbase,
+                                  &invalid_state));
+        report("x2apic enabled to apic enabled",
+               test_for_exception(GP_VECTOR, do_write_apicbase,
+                                  &apic_enabled));
+
+        wrmsr(MSR_IA32_APICBASE, APIC_DEFAULT_PHYS_BASE | APIC_BSP);
+        report("disabled to invalid state",
+               test_for_exception(GP_VECTOR, do_write_apicbase,
+                                  &invalid_state));
+        report("disabled to x2apic enabled",
+               test_for_exception(GP_VECTOR, do_write_apicbase,
+                                  &x2apic_enabled));
+
+        wrmsr(MSR_IA32_APICBASE, apic_enabled);
+        report("apic enabled to invalid state",
+               test_for_exception(GP_VECTOR, do_write_apicbase,
+                                  &invalid_state));
+
+        wrmsr(MSR_IA32_APICBASE, x2apic_enabled);
+        apic_write(APIC_SPIV, 0x1ff);
     } else {
         printf("x2apic not detected\n");
+
+        report("enable unsupported x2apic",
+               test_for_exception(GP_VECTOR, do_write_apicbase,
+                                  &x2apic_enabled));
     }
 }
 
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 07/13] lib/x86/apic: Consolidate over MSR_IA32_APICBASE
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (5 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 06/13] x2apic: Test for invalid state transitions Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 08/13] apic: Add test case for relocation and writing reserved bits Jan Kiszka
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 lib/x86/apic.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/x86/apic.c b/lib/x86/apic.c
index 7bb98ed..6876d85 100644
--- a/lib/x86/apic.c
+++ b/lib/x86/apic.c
@@ -1,5 +1,6 @@
 #include "libcflat.h"
 #include "apic.h"
+#include "msr.h"
 
 static void *g_apic = (void *)0xfee00000;
 static void *g_ioapic = (void *)0xfec00000;
@@ -99,8 +100,6 @@ uint32_t apic_id(void)
     return apic_ops->id();
 }
 
-#define MSR_APIC_BASE 0x0000001b
-
 int enable_x2apic(void)
 {
     unsigned a, b, c, d;
@@ -108,9 +107,9 @@ int enable_x2apic(void)
     asm ("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1));
 
     if (c & (1 << 21)) {
-        asm ("rdmsr" : "=a"(a), "=d"(d) : "c"(MSR_APIC_BASE));
+        asm ("rdmsr" : "=a"(a), "=d"(d) : "c"(MSR_IA32_APICBASE));
         a |= 1 << 10;
-        asm ("wrmsr" : : "a"(a), "d"(d), "c"(MSR_APIC_BASE));
+        asm ("wrmsr" : : "a"(a), "d"(d), "c"(MSR_IA32_APICBASE));
         apic_ops = &x2apic_ops;
         return 1;
     } else {
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 08/13] apic: Add test case for relocation and writing reserved bits
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (6 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 07/13] lib/x86/apic: Consolidate over MSR_IA32_APICBASE Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 09/13] VMX: Check unconditional I/O exiting Jan Kiszka
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Check that the xAPIC is relocatable and that writing a reserved bit to
MSR_IA32_APICBASE triggers a #GP.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 x86/apic.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/x86/apic.c b/x86/apic.c
index 4ebcd4f..8febfa2 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -120,6 +120,32 @@ void test_enable_x2apic(void)
     }
 }
 
+#define ALTERNATE_APIC_BASE	0x42000000
+
+static void test_apicbase(void)
+{
+    u64 orig_apicbase = rdmsr(MSR_IA32_APICBASE);
+    u32 lvr = apic_read(APIC_LVR);
+    u64 value;
+
+    wrmsr(MSR_IA32_APICBASE, orig_apicbase & ~(APIC_EN | APIC_EXTD));
+    wrmsr(MSR_IA32_APICBASE, ALTERNATE_APIC_BASE | APIC_BSP | APIC_EN);
+
+    report("relocate apic",
+           *(volatile u32 *)(ALTERNATE_APIC_BASE + APIC_LVR) == lvr);
+
+    value = orig_apicbase | (1UL << (cpuid(0x80000008).a & 0xff));
+    report("apicbase: reserved physaddr bits",
+           test_for_exception(GP_VECTOR, do_write_apicbase, &value));
+
+    value = orig_apicbase | 1;
+    report("apicbase: reserved low bits",
+           test_for_exception(GP_VECTOR, do_write_apicbase, &value));
+
+    wrmsr(MSR_IA32_APICBASE, orig_apicbase);
+    apic_write(APIC_SPIV, 0x1ff);
+}
+
 static void eoi(void)
 {
     apic_write(APIC_EOI, 0);
@@ -366,6 +392,7 @@ int main()
 
     mask_pic_interrupts();
     test_enable_x2apic();
+    test_apicbase();
 
     test_self_ipi();
 
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 09/13] VMX: Check unconditional I/O exiting
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (7 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 08/13] apic: Add test case for relocation and writing reserved bits Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 10/13] Provide common report and report_summary services Jan Kiszka
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Test if we ignore "unconditional I/O exiting" as long as "use I/O
bitmap" is enabled. Also test if unconditional exiting itself works.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 x86/vmx_tests.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 0077f3f..2c2d6c4 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -701,13 +701,21 @@ static void iobmp_main()
 		report("I/O bitmap - overrun", 1);
 	else
 		report("I/O bitmap - overrun", 0);
+	set_stage(9);
+	vmcall();
+	outb(0x0, 0x0);
+	report("I/O bitmap - ignore unconditional exiting", stage == 9);
+	set_stage(10);
+	vmcall();
+	outb(0x0, 0x0);
+	report("I/O bitmap - unconditional exiting", stage == 11);
 }
 
 static int iobmp_exit_handler()
 {
 	u64 guest_rip;
 	ulong reason, exit_qual;
-	u32 insn_len;
+	u32 insn_len, ctrl_cpu0;
 
 	guest_rip = vmcs_read(GUEST_RIP);
 	reason = vmcs_read(EXI_REASON) & 0xff;
@@ -765,6 +773,32 @@ static int iobmp_exit_handler()
 			if (((exit_qual & VMX_IO_PORT_MASK) >> VMX_IO_PORT_SHIFT) == 0xFFFF)
 				set_stage(stage + 1);
 			break;
+		case 9:
+		case 10:
+			ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0);
+			vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0 & ~CPU_IO);
+			set_stage(stage + 1);
+			break;
+		default:
+			// Should not reach here
+			printf("ERROR : unexpected stage, %d\n", get_stage());
+			print_vmexit_info();
+			return VMX_TEST_VMEXIT;
+		}
+		vmcs_write(GUEST_RIP, guest_rip + insn_len);
+		return VMX_TEST_RESUME;
+	case VMX_VMCALL:
+		switch (get_stage()) {
+		case 9:
+			ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0);
+			ctrl_cpu0 |= CPU_IO | CPU_IO_BITMAP;
+			vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0);
+			break;
+		case 10:
+			ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0);
+			ctrl_cpu0 = (ctrl_cpu0 & ~CPU_IO_BITMAP) | CPU_IO;
+			vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0);
+			break;
 		default:
 			// Should not reach here
 			printf("ERROR : unexpected stage, %d\n", get_stage());
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 10/13] Provide common report and report_summary services
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (8 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 09/13] VMX: Check unconditional I/O exiting Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 11/13] Ignore *.elf build outputs Jan Kiszka
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

This both reduces code duplication and standardizes the output format a
bit more.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 Makefile          |  3 ++-
 lib/libcflat.h    |  4 ++++
 lib/report.c      | 36 ++++++++++++++++++++++++++++++++++++
 x86/apic.c        | 15 +--------------
 x86/emulator.c    | 16 +---------------
 x86/eventinj.c    | 15 +--------------
 x86/idt_test.c    | 21 ++++-----------------
 x86/msr.c         | 15 +--------------
 x86/pcid.c        | 14 +-------------
 x86/pmu.c         | 37 +++++++++++++++----------------------
 x86/taskswitch2.c | 15 +--------------
 x86/vmx.c         | 16 +---------------
 x86/vmx.h         |  1 -
 13 files changed, 68 insertions(+), 140 deletions(-)
 create mode 100644 lib/report.c

diff --git a/Makefile b/Makefile
index b6e8759..f5eccc7 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,8 @@ libcflat := lib/libcflat.a
 cflatobjs := \
 	lib/panic.o \
 	lib/printf.o \
-	lib/string.o
+	lib/string.o \
+	lib/report.o
 cflatobjs += lib/argv.o
 
 #include architecure specific make rules
diff --git a/lib/libcflat.h b/lib/libcflat.h
index fadc33d..f734fde 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -45,6 +45,7 @@ extern char *strcat(char *dest, const char *src);
 extern int strcmp(const char *a, const char *b);
 
 extern int printf(const char *fmt, ...);
+extern int snprintf(char *buf, int size, const char *fmt, ...);
 extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
 
 extern void puts(const char *s);
@@ -58,4 +59,7 @@ extern long atol(const char *ptr);
 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
 
 #define NULL ((void *)0UL)
+
+void report(const char *msg_fmt, bool pass, ...);
+int report_summary(void);
 #endif
diff --git a/lib/report.c b/lib/report.c
new file mode 100644
index 0000000..ff562a1
--- /dev/null
+++ b/lib/report.c
@@ -0,0 +1,36 @@
+/*
+ * Test result reporting
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * Authors:
+ *  Jan Kiszka <jan.kiszka@siemens.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+#include "libcflat.h"
+
+static unsigned int tests, failures;
+
+void report(const char *msg_fmt, bool pass, ...)
+{
+	char buf[2000];
+	va_list va;
+
+	tests++;
+	printf("%s: ", pass ? "PASS" : "FAIL");
+	va_start(va, pass);
+	vsnprintf(buf, sizeof(buf), msg_fmt, va);
+	va_end(va);
+	puts(buf);
+	puts("\n");
+	if (!pass)
+		failures++;
+}
+
+int report_summary(void)
+{
+	printf("\nSUMMARY: %d tests, %d failures\n", tests, failures);
+	return failures > 0 ? 1 : 0;
+}
diff --git a/x86/apic.c b/x86/apic.c
index 8febfa2..487c248 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -6,17 +6,6 @@
 #include "isr.h"
 #include "msr.h"
 
-static int g_fail;
-static int g_tests;
-
-static void report(const char *msg, int pass)
-{
-    ++g_tests;
-    printf("%s: %s\n", msg, (pass ? "PASS" : "FAIL"));
-    if (!pass)
-        ++g_fail;
-}
-
 static void test_lapic_existence(void)
 {
     u32 lvr;
@@ -403,7 +392,5 @@ int main()
 
     test_tsc_deadline_timer();
 
-    printf("\nsummary: %d tests, %d failures\n", g_tests, g_fail);
-
-    return g_fail != 0;
+    return report_summary();
 }
diff --git a/x86/emulator.c b/x86/emulator.c
index b70e540..2e25dd8 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -7,8 +7,6 @@
 #define memset __builtin_memset
 #define TESTDEV_IO_PORT 0xe0
 
-int fails, tests;
-
 static int exceptions;
 
 struct regs {
@@ -25,17 +23,6 @@ struct insn_desc {
 	size_t len;
 };
 
-void report(const char *name, int result)
-{
-	++tests;
-	if (result)
-		printf("PASS: %s\n", name);
-	else {
-		printf("FAIL: %s\n", name);
-		++fails;
-	}
-}
-
 static char st1[] = "abcdefghijklmnop";
 
 void test_stringio()
@@ -1022,6 +1009,5 @@ int main()
 
 	test_string_io_mmio(mem);
 
-	printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
-	return fails ? 1 : 0;
+	return report_summary();
 }
diff --git a/x86/eventinj.c b/x86/eventinj.c
index 9d4392c..a218aaf 100644
--- a/x86/eventinj.c
+++ b/x86/eventinj.c
@@ -12,9 +12,6 @@
 #  define R "e"
 #endif
 
-static int g_fail;
-static int g_tests;
-
 static inline void io_delay(void)
 {
 }
@@ -24,14 +21,6 @@ static inline void outl(int addr, int val)
         asm volatile ("outl %1, %w0" : : "d" (addr), "a" (val));
 }
 
-static void report(const char *msg, int pass)
-{
-    ++g_tests;
-    printf("%s: %s\n", msg, (pass ? "PASS" : "FAIL"));
-    if (!pass)
-        ++g_fail;
-}
-
 void apic_self_ipi(u8 v)
 {
 	apic_icr_write(APIC_DEST_SELF | APIC_DEST_PHYSICAL | APIC_DM_FIXED |
@@ -416,7 +405,5 @@ int main()
 	printf("After int 33 with shadowed stack\n");
 	report("int 33 with shadowed stack", test_count == 1);
 
-	printf("\nsummary: %d tests, %d failures\n", g_tests, g_fail);
-
-	return g_fail != 0;
+	return report_summary();
 }
diff --git a/x86/idt_test.c b/x86/idt_test.c
index 2d2e0c2..ecb76bb 100644
--- a/x86/idt_test.c
+++ b/x86/idt_test.c
@@ -21,19 +21,6 @@ int test_gp(void)
     return exception_vector();
 }
 
-static int nr_fail, nr_test;
-
-static void report(int cond, const char *name)
-{
-    ++nr_test;
-    if (!cond) {
-        ++nr_fail;
-        printf("%s: FAIL\n", name);
-    } else {
-        printf("%s: PASS\n", name);
-    }
-}
-
 int main(void)
 {
     int r;
@@ -41,9 +28,9 @@ int main(void)
     printf("Starting IDT test\n");
     setup_idt();
     r = test_gp();
-    report(r == GP_VECTOR, "Testing #GP");
+    report("Testing #GP", r == GP_VECTOR);
     r = test_ud2();
-    report(r == UD_VECTOR, "Testing #UD");
-    printf("%d failures of %d tests\n", nr_fail, nr_test);
-    return !nr_fail ? 0 : 1;
+    report("Testing #UD", r == UD_VECTOR);
+
+    return report_summary();
 }
diff --git a/x86/msr.c b/x86/msr.c
index de7573d..db08a8d 100644
--- a/x86/msr.c
+++ b/x86/msr.c
@@ -80,17 +80,6 @@ static int find_msr_info(int msr_index)
     return -1;
 }
 
-
-int nr_passed, nr_tests;
-
-static void report(const char *name, int passed)
-{
-	++nr_tests;
-	if (passed)
-		++nr_passed;
-	printf("%s: %s\n", name, passed ? "PASS" : "FAIL");
-}
-
 static void test_msr_rw(int msr_index, unsigned long long input, unsigned long long expected)
 {
     unsigned long long r = 0;
@@ -142,8 +131,6 @@ int main(int ac, char **av)
 
     test_syscall_lazy_load();
 
-    printf("%d tests, %d failures\n", nr_tests, nr_tests - nr_passed);
-
-    return nr_passed == nr_tests ? 0 : 1;
+    return report_summary();
 }
 
diff --git a/x86/pcid.c b/x86/pcid.c
index 8bfeba2..45adfd5 100644
--- a/x86/pcid.c
+++ b/x86/pcid.c
@@ -4,8 +4,6 @@
 #include "processor.h"
 #include "desc.h"
 
-int nr_passed, nr_tests;
-
 #define X86_FEATURE_PCID       (1 << 17)
 #define X86_FEATURE_INVPCID    (1 << 10)
 
@@ -22,14 +20,6 @@ struct invpcid_desc {
     unsigned long addr : 64;
 };
 
-static void report(const char *name, int passed)
-{
-    ++nr_tests;
-    if (passed)
-        ++nr_passed;
-    printf("%s: %s\n", name, passed ? "PASS" : "FAIL");
-}
-
 int write_cr0_checking(unsigned long val)
 {
     asm volatile(ASM_TRY("1f")
@@ -180,7 +170,5 @@ int main(int ac, char **av)
     else
         test_invpcid_disabled();
 
-    printf("%d tests, %d failures\n", nr_tests, nr_tests - nr_passed);
-
-    return nr_passed == nr_tests ? 0 : 1;
+    return report_summary();
 }
diff --git a/x86/pmu.c b/x86/pmu.c
index 42b5a59..5c85146 100644
--- a/x86/pmu.c
+++ b/x86/pmu.c
@@ -92,7 +92,6 @@ struct pmu_event {
 };
 
 static int num_counters;
-static int tests, failures;
 
 char *buf;
 
@@ -211,13 +210,6 @@ static void measure(pmu_counter_t *evt, int count)
 		stop_event(&evt[i]);
 }
 
-static void report(const char *name, int n, bool pass)
-{
-    printf("%s: pmu %s-%d\n", pass ? "PASS" : "FAIL", name, n);
-    tests += 1;
-    failures += !pass;
-}
-
 static bool verify_event(uint64_t count, struct pmu_event *e)
 {
 	// printf("%lld >= %lld <= %lld\n", e->min, count, e->max);
@@ -236,12 +228,14 @@ static void check_gp_counter(struct pmu_event *evt)
 		.ctr = MSR_IA32_PERFCTR0,
 		.config = EVNTSEL_OS | EVNTSEL_USR | evt->unit_sel,
 	};
+	char fmt[100];
 	int i;
 
 	for (i = 0; i < num_counters; i++, cnt.ctr++) {
 		cnt.count = 0;
 		measure(&cnt, 1);
-		report(evt->name, i, verify_event(cnt.count, evt));
+		snprintf(fmt, sizeof(fmt), "%s-%%d", evt->name);
+		report(fmt, verify_event(cnt.count, evt), i);
 	}
 }
 
@@ -268,7 +262,7 @@ static void check_fixed_counters(void)
 		cnt.count = 0;
 		cnt.ctr = fixed_events[i].unit_sel;
 		measure(&cnt, 1);
-		report("fixed", i, verify_event(cnt.count, &fixed_events[i]));
+		report("fixed-%d", verify_event(cnt.count, &fixed_events[i]), i);
 	}
 }
 
@@ -299,7 +293,7 @@ static void check_counters_many(void)
 		if (!verify_counter(&cnt[i]))
 			break;
 
-	report("all counters", 0, i == n);
+	report("all counters", i == n);
 }
 
 static void check_counter_overflow(void)
@@ -329,13 +323,13 @@ static void check_counter_overflow(void)
 		idx = event_to_global_idx(&cnt);
 		cnt.count = 1 - count;
 		measure(&cnt, 1);
-		report("overflow", i, cnt.count == 1);
+		report("overflow-%d", cnt.count == 1, i);
 		status = rdmsr(MSR_CORE_PERF_GLOBAL_STATUS);
-		report("overflow status", i, status & (1ull << idx));
+		report("overflow status-%d", status & (1ull << idx), i);
 		wrmsr(MSR_CORE_PERF_GLOBAL_OVF_CTRL, status);
 		status = rdmsr(MSR_CORE_PERF_GLOBAL_STATUS);
-		report("overflow status clear", i, !(status & (1ull << idx)));
-		report("overflow irq", i, check_irq() == (i % 2));
+		report("overflow status clear-%d", !(status & (1ull << idx)), i);
+		report("overflow irq-%d", check_irq() == (i % 2), i);
 	}
 }
 
@@ -348,7 +342,7 @@ static void check_gp_counter_cmask(void)
 	};
 	cnt.config |= (0x2 << EVNTSEL_CMASK_SHIFT);
 	measure(&cnt, 1);
-	report("cmask", 0, cnt.count < gp_events[1].min);
+	report("cmask", cnt.count < gp_events[1].min);
 }
 
 static void check_rdpmc(void)
@@ -360,15 +354,15 @@ static void check_rdpmc(void)
 		uint64_t x = (val & 0xffffffff) |
 			((1ull << (eax.split.bit_width - 32)) - 1) << 32;
 		wrmsr(MSR_IA32_PERFCTR0 + i, val);
-		report("rdpmc", i, rdpmc(i) == x);
-		report("rdpmc fast", i, rdpmc(i | (1<<31)) == (u32)val);
+		report("rdpmc-%d", rdpmc(i) == x, i);
+		report("rdpmc fast-%d", rdpmc(i | (1<<31)) == (u32)val, i);
 	}
 	for (i = 0; i < edx.split.num_counters_fixed; i++) {
 		uint64_t x = (val & 0xffffffff) |
 			((1ull << (edx.split.bit_width_fixed - 32)) - 1) << 32;
 		wrmsr(MSR_CORE_PERF_FIXED_CTR0 + i, val);
-		report("rdpmc fixed", i, rdpmc(i | (1 << 30)) == x);
-		report("rdpmc fixed fast", i, rdpmc(i | (3<<30)) == (u32)val);
+		report("rdpmc fixed-%d", rdpmc(i | (1 << 30)) == x, i);
+		report("rdpmc fixed fast-%d", rdpmc(i | (3<<30)) == (u32)val, i);
 	}
 }
 
@@ -409,6 +403,5 @@ int main(int ac, char **av)
 	check_counter_overflow();
 	check_gp_counter_cmask();
 
-	printf("\n%d tests, %d failures\n", tests, failures);
-	return !failures ? 0 : 1;
+	return report_summary();
 }
diff --git a/x86/taskswitch2.c b/x86/taskswitch2.c
index 6573696..3c8418e 100644
--- a/x86/taskswitch2.c
+++ b/x86/taskswitch2.c
@@ -18,21 +18,10 @@ static volatile unsigned int test_divider;
 static char *fault_addr;
 static ulong fault_phys;
 
-static int g_fail;
-static int g_tests;
-
 static inline void io_delay(void)
 {
 }
 
-static void report(const char *msg, int pass)
-{
-    ++g_tests;
-    printf("%s: %s\n", msg, (pass ? "PASS" : "FAIL"));
-    if (!pass)
-        ++g_fail;
-}
-
 static void nmi_tss(void)
 {
 start:
@@ -273,7 +262,5 @@ int main()
 	test_kernel_mode_int();
 	test_vm86_switch();
 
-	printf("\nsummary: %d tests, %d failures\n", g_tests, g_fail);
-
-	return g_fail != 0;
+	return report_summary();
 }
diff --git a/x86/vmx.c b/x86/vmx.c
index 4f0bb8d..2278078 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -37,7 +37,6 @@
 #include "smp.h"
 #include "io.h"
 
-int fails, tests;
 u32 *vmxon_region;
 struct vmcs *vmcs_root;
 u32 vpid_cnt;
@@ -63,17 +62,6 @@ extern void *vmx_return;
 extern void *entry_sysenter;
 extern void *guest_entry;
 
-void report(const char *name, int result)
-{
-	++tests;
-	if (result)
-		printf("PASS: %s\n", name);
-	else {
-		printf("FAIL: %s\n", name);
-		++fails;
-	}
-}
-
 static int make_vmcs_current(struct vmcs *vmcs)
 {
 	bool ret;
@@ -786,7 +774,6 @@ int main(void)
 
 	setup_vm();
 	setup_idt();
-	fails = tests = 0;
 	hypercall_field = 0;
 
 	if (!(cpuid(1).c & (1 << 5))) {
@@ -815,6 +802,5 @@ int main(void)
 			goto exit;
 
 exit:
-	printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
-	return fails ? 1 : 0;
+	return report_summary();
 }
diff --git a/x86/vmx.h b/x86/vmx.h
index 3867793..351c3d9 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -550,7 +550,6 @@ static inline void invept(unsigned long type, u64 eptp)
 	asm volatile("invept %0, %1\n" ::"m"(operand),"r"(type));
 }
 
-void report(const char *name, int result);
 void print_vmexit_info();
 void install_ept_entry(unsigned long *pml4, int pte_level,
 		unsigned long guest_addr, unsigned long pte,
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 11/13] Ignore *.elf build outputs
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (9 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 10/13] Provide common report and report_summary services Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 12/13] svm: Add missing build dependency Jan Kiszka
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index ed857b7..d6663ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
 *.d
 *.o
 *.flat
+*.elf
 .pc
 patches
 .stgit-*
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 12/13] svm: Add missing build dependency
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (10 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 11/13] Ignore *.elf build outputs Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-04 17:59 ` [PATCH 13/13] x86: Add debug facility test case Jan Kiszka
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 config-x86-common.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config-x86-common.mak b/config-x86-common.mak
index bf88c67..32da7fb 100644
--- a/config-x86-common.mak
+++ b/config-x86-common.mak
@@ -86,7 +86,7 @@ $(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o
 
 $(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o
 
-$(TEST_DIR)/svm.elf: $(cstart.o)
+$(TEST_DIR)/svm.elf: $(cstart.o) $(TEST_DIR)/svm.o
 
 $(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \
                                 $(TEST_DIR)/kvmclock_test.o
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 13/13] x86: Add debug facility test case
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (11 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 12/13] svm: Add missing build dependency Jan Kiszka
@ 2014-01-04 17:59 ` Jan Kiszka
  2014-01-22 17:23 ` [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Paolo Bonzini
  2014-02-25 14:35 ` Paolo Bonzini
  14 siblings, 0 replies; 18+ messages in thread
From: Jan Kiszka @ 2014-01-04 17:59 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

This adds a basic test for INT3/#BP, hardware breakpoints, hardware
watchpoints and single-stepping.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 config-x86-common.mak |   2 +
 config-x86_64.mak     |   2 +-
 lib/x86/desc.h        |   2 +
 x86/debug.c           | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++
 x86/unittests.cfg     |   3 ++
 5 files changed, 121 insertions(+), 1 deletion(-)
 create mode 100644 x86/debug.c

diff --git a/config-x86-common.mak b/config-x86-common.mak
index 32da7fb..aa5a439 100644
--- a/config-x86-common.mak
+++ b/config-x86-common.mak
@@ -103,6 +103,8 @@ $(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o
 
 $(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o
 
+$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o
+
 arch_clean:
 	$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
 	$(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
diff --git a/config-x86_64.mak b/config-x86_64.mak
index bb8ee89..a9a2a9e 100644
--- a/config-x86_64.mak
+++ b/config-x86_64.mak
@@ -7,7 +7,7 @@ CFLAGS += -D__x86_64__
 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 \
-	  $(TEST_DIR)/pcid.flat
+	  $(TEST_DIR)/pcid.flat $(TEST_DIR)/debug.flat
 tests += $(TEST_DIR)/svm.flat
 tests += $(TEST_DIR)/vmx.flat
 
diff --git a/lib/x86/desc.h b/lib/x86/desc.h
index 5c850b2..b795aad 100644
--- a/lib/x86/desc.h
+++ b/lib/x86/desc.h
@@ -66,6 +66,8 @@ typedef struct {
     ".popsection \n\t"                                  \
     "1111:"
 
+#define DB_VECTOR   1
+#define BP_VECTOR   3
 #define UD_VECTOR   6
 #define GP_VECTOR   13
 
diff --git a/x86/debug.c b/x86/debug.c
new file mode 100644
index 0000000..154c7fe
--- /dev/null
+++ b/x86/debug.c
@@ -0,0 +1,113 @@
+/*
+ * Test for x86 debugging facilities
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * Authors:
+ *  Jan Kiszka <jan.kiszka@siemens.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ */
+
+#include "libcflat.h"
+#include "desc.h"
+
+static volatile unsigned long bp_addr[10], dr6[10];
+static volatile unsigned int n;
+static volatile unsigned long value;
+
+static unsigned long get_dr6(void)
+{
+	unsigned long value;
+
+	asm volatile("mov %%dr6,%0" : "=r" (value));
+	return value;
+}
+
+static void set_dr0(void *value)
+{
+	asm volatile("mov %0,%%dr0" : : "r" (value));
+}
+
+static void set_dr1(void *value)
+{
+	asm volatile("mov %0,%%dr1" : : "r" (value));
+}
+
+static void set_dr7(unsigned long value)
+{
+	asm volatile("mov %0,%%dr7" : : "r" (value));
+}
+
+static void handle_db(struct ex_regs *regs)
+{
+	bp_addr[n] = regs->rip;
+	dr6[n] = get_dr6();
+
+	if (dr6[n] & 0x1)
+		regs->rflags |= (1 << 16);
+
+	if (++n >= 10) {
+		regs->rflags &= ~(1 << 8);
+		set_dr7(0x00000400);
+	}
+}
+
+static void handle_bp(struct ex_regs *regs)
+{
+	bp_addr[0] = regs->rip;
+}
+
+int main(int ac, char **av)
+{
+	unsigned long start;
+
+	setup_idt();
+	handle_exception(DB_VECTOR, handle_db);
+	handle_exception(BP_VECTOR, handle_bp);
+
+sw_bp:
+	asm volatile("int3");
+	report("#BP", bp_addr[0] == (unsigned long)&&sw_bp + 1);
+
+	set_dr0(&&hw_bp);
+	set_dr7(0x00000402);
+hw_bp:
+	asm volatile("nop");
+	report("hw breakpoint",
+	       n == 1 &&
+	       bp_addr[0] == ((unsigned long)&&hw_bp) && dr6[0] == 0xffff0ff1);
+
+	n = 0;
+	asm volatile(
+		"pushf\n\t"
+		"pop %%rax\n\t"
+		"or $(1<<8),%%rax\n\t"
+		"push %%rax\n\t"
+		"lea (%%rip),%0\n\t"
+		"popf\n\t"
+		"and $~(1<<8),%%rax\n\t"
+		"push %%rax\n\t"
+		"popf\n\t"
+		: "=g" (start) : : "rax");
+	report("single step",
+	       n == 3 &&
+	       bp_addr[0] == start+1+6 && dr6[0] == 0xffff4ff0 &&
+	       bp_addr[1] == start+1+6+1 && dr6[1] == 0xffff4ff0 &&
+	       bp_addr[2] == start+1+6+1+1 && dr6[2] == 0xffff4ff0);
+
+	n = 0;
+	set_dr1((void *)&value);
+	set_dr7(0x00d0040a);
+
+	asm volatile(
+		"mov $42,%%rax\n\t"
+		"mov %%rax,%0\n\t"
+		: "=m" (value) : : "rax");
+hw_wp:
+	report("hw watchpoint",
+	       n == 1 &&
+	       bp_addr[0] == ((unsigned long)&&hw_wp) && dr6[0] == 0xffff4ff2);
+
+	return 0;
+}
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 85c36aa..7930c02 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -155,3 +155,6 @@ file = vmx.flat
 extra_params = -cpu host,+vmx
 arch = x86_64
 
+[debug]
+file = debug.flag
+arch = x86_64
-- 
1.8.1.1.298.ge7eed54


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/13] VMX: Fix return label in fault-triggering handlers
  2014-01-04 17:59 ` [PATCH 04/13] VMX: Fix return label in fault-triggering handlers Jan Kiszka
@ 2014-01-22 15:00   ` Paolo Bonzini
  2014-01-22 17:21     ` Paolo Bonzini
  0 siblings, 1 reply; 18+ messages in thread
From: Paolo Bonzini @ 2014-01-22 15:00 UTC (permalink / raw)
  To: Jan Kiszka, Gleb Natapov, Marcelo Tosatti; +Cc: kvm

Il 04/01/2014 18:59, Jan Kiszka ha scritto:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Some compiler versions (seen with gcc 4.8.1) move the resume label after
> the return statement which, of course, causes sever problems.

Can you include the assembly output?  Do you mean after the "ret" 
instruction?

The return should not be needed except for the rule that a label must be 
followed by a statement.  But I would not except any difference between 
a ";" and a barrier in this case.

Paolo

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  x86/vmx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/x86/vmx.c b/x86/vmx.c
> index a475aec..f9d5493 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -563,7 +563,7 @@ static void do_vmxon_off(void)
>  	vmx_on();
>  	vmx_off();
>  resume:
> -	return;
> +	barrier();
>  }
>
>  static void do_write_feature_control(void)
> @@ -572,7 +572,7 @@ static void do_write_feature_control(void)
>  	barrier();
>  	wrmsr(MSR_IA32_FEATURE_CONTROL, 0);
>  resume:
> -	return;
> +	barrier();
>  }
>
>  static int test_vmx_feature_control(void)
>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/13] VMX: Fix return label in fault-triggering handlers
  2014-01-22 15:00   ` Paolo Bonzini
@ 2014-01-22 17:21     ` Paolo Bonzini
  0 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2014-01-22 17:21 UTC (permalink / raw)
  To: Jan Kiszka, Gleb Natapov, Marcelo Tosatti; +Cc: kvm

Il 22/01/2014 16:00, Paolo Bonzini ha scritto:
> Il 04/01/2014 18:59, Jan Kiszka ha scritto:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> Some compiler versions (seen with gcc 4.8.1) move the resume label after
>> the return statement which, of course, causes sever problems.
>
> Can you include the assembly output?  Do you mean after the "ret"
> instruction?

Reproduced now, I think it's a compiler bug... with -O2 it's even weird, 
&&resume points to the *first* instruction in the function.

I'll report it to GCC.


Paolo


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (12 preceding siblings ...)
  2014-01-04 17:59 ` [PATCH 13/13] x86: Add debug facility test case Jan Kiszka
@ 2014-01-22 17:23 ` Paolo Bonzini
  2014-02-25 14:35 ` Paolo Bonzini
  14 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2014-01-22 17:23 UTC (permalink / raw)
  To: Jan Kiszka, Gleb Natapov, Marcelo Tosatti; +Cc: kvm

Il 04/01/2014 18:59, Jan Kiszka ha scritto:
> Highlights:
>  - improved preemption timer and interrupt injection tests
>    (obsoletes my two patches in vmx queue)
>  - tests for IA32_APIC_BASE writes
>  - test for unconditional IO exiting (VMX)
>  - basic test of debug facilities (hw breakpoints etc.)
>
> Jan Kiszka (13):
>   VMX: Add test cases around interrupt injection and halting
>   VMX: Extend preemption timer tests
>   apic: Remove redundant enable_apic
>   VMX: Fix return label in fault-triggering handlers
>   lib/x86: Move exception test code into library
>   x2apic: Test for invalid state transitions
>   lib/x86/apic: Consolidate over MSR_IA32_APICBASE
>   apic: Add test case for relocation and writing reserved bits
>   VMX: Check unconditional I/O exiting
>   Provide common report and report_summary services
>   Ignore *.elf build outputs
>   svm: Add missing build dependency
>   x86: Add debug facility test case
>
>  .gitignore            |   1 +
>  Makefile              |   3 +-
>  config-x86-common.mak |   4 +-
>  config-x86_64.mak     |   2 +-
>  lib/libcflat.h        |   4 +
>  lib/report.c          |  36 +++++++
>  lib/x86/apic-defs.h   |   3 +
>  lib/x86/apic.c        |   7 +-
>  lib/x86/desc.c        |  24 +++++
>  lib/x86/desc.h        |   6 ++
>  x86/apic.c            |  84 +++++++++++++---
>  x86/debug.c           | 113 +++++++++++++++++++++
>  x86/emulator.c        |  16 +--
>  x86/eventinj.c        |  15 +--
>  x86/idt_test.c        |  21 +---
>  x86/msr.c             |  15 +--
>  x86/pcid.c            |  14 +--
>  x86/pmu.c             |  37 +++----
>  x86/taskswitch2.c     |  15 +--
>  x86/unittests.cfg     |   3 +
>  x86/vmx.c             |  57 +++--------
>  x86/vmx.h             |   4 +-
>  x86/vmx_tests.c       | 264 ++++++++++++++++++++++++++++++++++++++++++++++----
>  23 files changed, 548 insertions(+), 200 deletions(-)
>  create mode 100644 lib/report.c
>  create mode 100644 x86/debug.c
>

I'm applying patches 3-13 to the master branch, and patches 1-2 to the 
vmx branch.

Thanks!

Paolo

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests
  2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
                   ` (13 preceding siblings ...)
  2014-01-22 17:23 ` [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Paolo Bonzini
@ 2014-02-25 14:35 ` Paolo Bonzini
  14 siblings, 0 replies; 18+ messages in thread
From: Paolo Bonzini @ 2014-02-25 14:35 UTC (permalink / raw)
  To: Jan Kiszka, Gleb Natapov, Marcelo Tosatti; +Cc: kvm

Il 04/01/2014 18:59, Jan Kiszka ha scritto:
> Highlights:
>  - improved preemption timer and interrupt injection tests
>    (obsoletes my two patches in vmx queue)
>  - tests for IA32_APIC_BASE writes
>  - test for unconditional IO exiting (VMX)
>  - basic test of debug facilities (hw breakpoints etc.)
>
> Jan Kiszka (13):
>   VMX: Add test cases around interrupt injection and halting
>   VMX: Extend preemption timer tests
>   apic: Remove redundant enable_apic
>   VMX: Fix return label in fault-triggering handlers
>   lib/x86: Move exception test code into library
>   x2apic: Test for invalid state transitions
>   lib/x86/apic: Consolidate over MSR_IA32_APICBASE
>   apic: Add test case for relocation and writing reserved bits
>   VMX: Check unconditional I/O exiting
>   Provide common report and report_summary services
>   Ignore *.elf build outputs
>   svm: Add missing build dependency
>   x86: Add debug facility test case

Applied patches 3-13 for now.  Will go back to 1 and 2 when I look at 
your pending KVM patches.

Thanks, and sorry for the delay.  I was sure I had already pushed this 
(and I had been testing with them for one month).

Paolo

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-02-25 14:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-04 17:59 [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Jan Kiszka
2014-01-04 17:59 ` [PATCH 01/13] VMX: Add test cases around interrupt injection and halting Jan Kiszka
2014-01-04 17:59 ` [PATCH 02/13] VMX: Extend preemption timer tests Jan Kiszka
2014-01-04 17:59 ` [PATCH 03/13] apic: Remove redundant enable_apic Jan Kiszka
2014-01-04 17:59 ` [PATCH 04/13] VMX: Fix return label in fault-triggering handlers Jan Kiszka
2014-01-22 15:00   ` Paolo Bonzini
2014-01-22 17:21     ` Paolo Bonzini
2014-01-04 17:59 ` [PATCH 05/13] lib/x86: Move exception test code into library Jan Kiszka
2014-01-04 17:59 ` [PATCH 06/13] x2apic: Test for invalid state transitions Jan Kiszka
2014-01-04 17:59 ` [PATCH 07/13] lib/x86/apic: Consolidate over MSR_IA32_APICBASE Jan Kiszka
2014-01-04 17:59 ` [PATCH 08/13] apic: Add test case for relocation and writing reserved bits Jan Kiszka
2014-01-04 17:59 ` [PATCH 09/13] VMX: Check unconditional I/O exiting Jan Kiszka
2014-01-04 17:59 ` [PATCH 10/13] Provide common report and report_summary services Jan Kiszka
2014-01-04 17:59 ` [PATCH 11/13] Ignore *.elf build outputs Jan Kiszka
2014-01-04 17:59 ` [PATCH 12/13] svm: Add missing build dependency Jan Kiszka
2014-01-04 17:59 ` [PATCH 13/13] x86: Add debug facility test case Jan Kiszka
2014-01-22 17:23 ` [PATCH 00/13] kvm-unit-tests: Various improvements for x86 tests Paolo Bonzini
2014-02-25 14:35 ` 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.