All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests] x86: debug: test debug extensions
@ 2015-09-21 12:04 Paolo Bonzini
  2015-09-21 12:26 ` Nadav Amit
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-09-21 12:04 UTC (permalink / raw)
  To: kvm; +Cc: rth, ehabkost

Not committing this yet since KVM does not support I/O breakpoints, but posting
it because it is useful for TCG too.

TCG fails the tests because it doesn't preserve DRn_FIXED_1 on mov to dr6 and
dr7, and also because it lacks support for ICEBP, but it is easy to fix the
former and disable the ICEBP test.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 x86/debug.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/x86/debug.c b/x86/debug.c
index d04de23..a71a8ae 100644
--- a/x86/debug.c
+++ b/x86/debug.c
@@ -11,6 +11,7 @@
 
 #include "libcflat.h"
 #include "desc.h"
+#include "processor.h"
 
 static volatile unsigned long bp_addr[10], dr6[10];
 static volatile unsigned int n;
@@ -71,6 +72,8 @@ int main(int ac, char **av)
 	handle_exception(DB_VECTOR, handle_db);
 	handle_exception(BP_VECTOR, handle_bp);
 
+	write_cr4(read_cr4() | X86_CR4_DE);
+
 sw_bp:
 	asm volatile("int3");
 	report("#BP", bp_addr[0] == (unsigned long)&&sw_bp + 1);
@@ -146,5 +149,51 @@ sw_icebp:
 	       bp_addr[0] == (unsigned long)&&sw_icebp + 1 &&
 	       dr6[0] == 0xffff0ff0);
 
+	n = 0;
+	set_dr1((void *)0xe1ul);
+	set_dr7(0x0020400a);
+	set_dr6(0);
+
+	asm volatile(
+		"out %ax,$0xe0\n\t"
+		"out %al,$0xe1\n\t");
+hw_wp_out1:
+
+	set_dr1((void *)0xe0ul);
+	set_dr7(0x00e0400a);
+	asm volatile(
+		"out %al,$0xe0\n\t");
+hw_wp_out2:
+
+	report("hw I/O port watchpoint (out)",
+	       n == 3 &&
+	       bp_addr[0] == ((unsigned long)&&hw_wp_out1 - 2) &&
+	       bp_addr[1] == ((unsigned long)&&hw_wp_out1) &&
+	       bp_addr[2] == ((unsigned long)&&hw_wp_out2) &&
+	       dr6[0] == 0xffff0ff2);
+
+	n = 0;
+	set_dr1((void *)0xe1ul);
+	set_dr7(0x0020400a);
+	set_dr6(0);
+
+	asm volatile(
+		"in $0xe0,%%ax\n\t"
+		"in $0xe1,%%al\n\t" : : : "rax");
+hw_wp_in1:
+
+	set_dr1((void *)0xe0ul);
+	set_dr7(0x00e0400a);
+
+	asm volatile(
+		"in $0xe0,%%al\n\t" : : : "rax");
+hw_wp_in2:
+	report("hw I/O port watchpoint (in)",
+	       n == 3 &&
+	       bp_addr[0] == ((unsigned long)&&hw_wp_in1 - 2) &&
+	       bp_addr[1] == ((unsigned long)&&hw_wp_in1) &&
+	       bp_addr[2] == ((unsigned long)&&hw_wp_in2) &&
+	       dr6[0] == 0xffff0ff2);
+
 	return report_summary();
 }
-- 
2.5.0


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

end of thread, other threads:[~2015-09-22 12:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-21 12:04 [PATCH kvm-unit-tests] x86: debug: test debug extensions Paolo Bonzini
2015-09-21 12:26 ` Nadav Amit
2015-09-21 12:28   ` Paolo Bonzini
2015-09-22 12:26     ` Nadav Amit

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.