kvm.vger.kernel.org archive mirror
 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

* Re: [PATCH kvm-unit-tests] x86: debug: test debug extensions
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Nadav Amit @ 2015-09-21 12:26 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, rth, ehabkost

Paolo,

Two students here implemented emulated I/O and data breakpoints support for
KVM under my supervision. I mistakenly graded their project before they
actually sent the patches, and at this point (surprisingly) they
disappeared. The patches are relatively ok and include unit-tests. I also
ran some Intel tests to check the patches, which they (eventually) passed.

I don’t know if I can find the time to rebase them (they are based on 3.19),
but let me know if you are interested.

Nadav

Paolo Bonzini <pbonzini@redhat.com> wrote:

> 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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

* Re: [PATCH kvm-unit-tests] x86: debug: test debug extensions
  2015-09-21 12:26 ` Nadav Amit
@ 2015-09-21 12:28   ` Paolo Bonzini
  2015-09-22 12:26     ` Nadav Amit
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-09-21 12:28 UTC (permalink / raw)
  To: Nadav Amit; +Cc: kvm, rth, ehabkost



On 21/09/2015 14:26, Nadav Amit wrote:
> Paolo,
> 
> Two students here implemented emulated I/O and data breakpoints support for
> KVM under my supervision. I mistakenly graded their project before they
> actually sent the patches, and at this point (surprisingly) they
> disappeared. The patches are relatively ok and include unit-tests. I also
> ran some Intel tests to check the patches, which they (eventually) passed.
> 
> I don’t know if I can find the time to rebase them (they are based on 3.19),
> but let me know if you are interested.

Yes, I am.  Worst case just send them based on 3.19, I owe you enough
bugfixes that I can do the rebase myself. :)

Paolo

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

* Re: [PATCH kvm-unit-tests] x86: debug: test debug extensions
  2015-09-21 12:28   ` Paolo Bonzini
@ 2015-09-22 12:26     ` Nadav Amit
  0 siblings, 0 replies; 4+ messages in thread
From: Nadav Amit @ 2015-09-22 12:26 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm list, rth, ehabkost

Sorry for misleading. I forgot there are several issues with the patches, so
I cannot send them. If I find the time (and you don’t implement it first),
I’ll fix and send them.

Nadav

Paolo Bonzini <pbonzini@redhat.com> wrote:

> 
> 
> On 21/09/2015 14:26, Nadav Amit wrote:
>> Paolo,
>> 
>> Two students here implemented emulated I/O and data breakpoints support for
>> KVM under my supervision. I mistakenly graded their project before they
>> actually sent the patches, and at this point (surprisingly) they
>> disappeared. The patches are relatively ok and include unit-tests. I also
>> ran some Intel tests to check the patches, which they (eventually) passed.
>> 
>> I don’t know if I can find the time to rebase them (they are based on 3.19),
>> but let me know if you are interested.
> 
> Yes, I am.  Worst case just send them based on 3.19, I owe you enough
> bugfixes that I can do the rebase myself. :)
> 
> Paolo



^ permalink raw reply	[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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).