kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm testsuite: Add test for 'shld' instruction
@ 2008-11-03 15:05 Guillaume Thouvenin
  0 siblings, 0 replies; 4+ messages in thread
From: Guillaume Thouvenin @ 2008-11-03 15:05 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, guillaume.thouvenin

Add 'shld' instruction test in real mode test harness.

Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@polymtl.ca>
--- 
 realmode.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/user/test/x86/realmode.c b/user/test/x86/realmode.c
index 2c3be1e..89857ae 100644
--- a/user/test/x86/realmode.c
+++ b/user/test/x86/realmode.c
@@ -141,6 +141,25 @@ int regs_equal(const struct regs *r1, const struct regs *r2, int ignore)
 		);				   \
 	extern u8 insn_##name[], insn_##name##_end[]
 
+void test_shld(const struct regs *inregs, struct regs *outregs)
+{
+	int shift;
+	int width = 32;
+	u32 res;
+
+	MK_INSN(shld_test, "shld $4,%ecx,%ebx\n\t");
+
+	exec_in_big_real_mode(inregs, outregs,
+			      insn_shld_test,
+			      insn_shld_test_end - insn_shld_test);
+	shift = 4;
+	res = (inregs->ebx << shift) | (inregs->ecx << (width - shift));
+	if (outregs->ebx != res)
+		print_serial("shld: failure\n");
+	else
+		print_serial("shld: success\n");
+}
+
 void test_mov_imm(const struct regs *inregs, struct regs *outregs)
 {
 	MK_INSN(mov_r32_imm_1, "mov $1234567890, %eax");
@@ -360,6 +379,11 @@ void start(void)
 	if (!regs_equal(&inregs, &outregs, 0))
 		print_serial("null test: FAIL\n");
 	test_call(&inregs, &outregs);
+
+	inregs.ebx = 0xbe;
+	inregs.ecx = 0xef000000;
+	test_shld(&inregs, &outregs);
+
 	test_mov_imm(&inregs, &outregs);
 	test_cmp_imm(&inregs, &outregs);
 	test_add_imm(&inregs, &outregs);

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

* [PATCH] kvm testsuite: Add test for 'shld' instruction
@ 2008-12-04 13:38 Guillaume Thouvenin
  2008-12-05 17:17 ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Guillaume Thouvenin @ 2008-12-04 13:38 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, guillaume.thouvenin

Add 'shld' instruction test in real mode test harness. 

Avi, on my computer this test is broken but the problem seems to be
elsewhere because test_shld() works fine alone. I'm inspecting other
test. Used alone shld gives the right values (shift is ok and bits are
added).

The error is the following:

kvm_run: failed entry, reason 7
rax 000000000000000e rbx 0000000000001fa4 rcx 0000000000000000 rdx 00000000000000f1
rsi 000000000000218d rdi 0000000000001ff4 rsp 0000000000001f84 rbp 0000000000000000
r8  0000000000000000 r9  0000000000000000 r10 0000000000000000 r11 0000000000000000
r12 0000000000000000 r13 0000000000000000 r14 0000000000000000 r15 0000000000000000
rip 000000000000004b rflags 00023646
cs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ds 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
es 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ss 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
fs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
gs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
tr 0000 (fffbd000/00002088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
ldt 0000 (00000000/0000ffff p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
gdt 2000/17
idt 0/ffff
cr0 60000010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0


Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
---
 user/test/x86/realmode.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/user/test/x86/realmode.c b/user/test/x86/realmode.c
index 2c3be1e..a65f9f2 100644
--- a/user/test/x86/realmode.c
+++ b/user/test/x86/realmode.c
@@ -141,6 +141,19 @@ int regs_equal(const struct regs *r1, const struct regs *r2, int ignore)
 		);				   \
 	extern u8 insn_##name[], insn_##name##_end[]
 
+void test_shld(const struct regs *inregs, struct regs *outregs)
+{
+	MK_INSN(shld_test, "shld $8,%edx,%eax\n\t");
+
+	exec_in_big_real_mode(inregs, outregs,
+			      insn_shld_test,
+			      insn_shld_test_end - insn_shld_test);
+	if (outregs->eax != 0xbeef)
+		print_serial("shld: failure\n");
+	else
+		print_serial("shld: success\n");
+}
+
 void test_mov_imm(const struct regs *inregs, struct regs *outregs)
 {
 	MK_INSN(mov_r32_imm_1, "mov $1234567890, %eax");
@@ -360,11 +373,17 @@ void start(void)
 	if (!regs_equal(&inregs, &outregs, 0))
 		print_serial("null test: FAIL\n");
 	test_call(&inregs, &outregs);
+
+	inregs.eax = 0xbe;
+	inregs.edx = 0xef000000;
+	test_shld(&inregs, &outregs);
+
 	test_mov_imm(&inregs, &outregs);
 	test_cmp_imm(&inregs, &outregs);
 	test_add_imm(&inregs, &outregs);
 	test_io(&inregs, &outregs);
 	test_eflags_insn(&inregs, &outregs);
+	
 	exit(0);
 }
 
-- 
1.6.0.4.623.g171d7


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

* Re: [PATCH] kvm testsuite: Add test for 'shld' instruction
  2008-12-04 13:38 [PATCH] kvm testsuite: Add test for 'shld' instruction Guillaume Thouvenin
@ 2008-12-05 17:17 ` Avi Kivity
  2008-12-10  8:49   ` Guillaume Thouvenin
  0 siblings, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2008-12-05 17:17 UTC (permalink / raw)
  To: Guillaume Thouvenin; +Cc: kvm

Guillaume Thouvenin wrote:
> Add 'shld' instruction test in real mode test harness. 
>
>   
Applied, thanks.

> Avi, on my computer this test is broken but the problem seems to be
> elsewhere because test_shld() works fine alone. I'm inspecting other
> test. Used alone shld gives the right values (shift is ok and bits are
> added).
>   

I see a different failure, due to leakage of register values from one 
test to another.  I fixed it up.  If you see the failure after the fix, 
we can reexamine it.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


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

* Re: [PATCH] kvm testsuite: Add test for 'shld' instruction
  2008-12-05 17:17 ` Avi Kivity
@ 2008-12-10  8:49   ` Guillaume Thouvenin
  0 siblings, 0 replies; 4+ messages in thread
From: Guillaume Thouvenin @ 2008-12-10  8:49 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

On Fri, 05 Dec 2008 19:17:17 +0200
Avi Kivity <avi@redhat.com> wrote:

> Guillaume Thouvenin wrote:
> > Add 'shld' instruction test in real mode test harness. 
> >
> >   
> Applied, thanks.
> 
> > Avi, on my computer this test is broken but the problem seems to be
> > elsewhere because test_shld() works fine alone. I'm inspecting other
> > test. Used alone shld gives the right values (shift is ok and bits are
> > added).
> >   
> 
> I see a different failure, due to leakage of register values from one 
> test to another.  I fixed it up.  If you see the failure after the fix, 
> we can reexamine it.
> 

Cool it works fine now. On the other hand eax and edx registers are
initialized twice now, once is enough ;)

Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
---
 user/test/x86/realmode.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/user/test/x86/realmode.c b/user/test/x86/realmode.c
index dbe34b2..f6d5326 100644
--- a/user/test/x86/realmode.c
+++ b/user/test/x86/realmode.c
@@ -146,8 +146,6 @@ void test_shld(void)
 	struct regs inregs = { .eax = 0xbe, .edx = 0xef000000 }, outregs;
 	MK_INSN(shld_test, "shld $8,%edx,%eax\n\t");
 
-	inregs.eax = 0xbe;
-	inregs.edx = 0xef000000;
 	exec_in_big_real_mode(&inregs, &outregs,
 			      insn_shld_test,
 			      insn_shld_test_end - insn_shld_test);
-- 
1.6.0.4.623.g171d7


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

end of thread, other threads:[~2008-12-10  8:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-04 13:38 [PATCH] kvm testsuite: Add test for 'shld' instruction Guillaume Thouvenin
2008-12-05 17:17 ` Avi Kivity
2008-12-10  8:49   ` Guillaume Thouvenin
  -- strict thread matches above, loose matches on Subject: below --
2008-11-03 15:05 Guillaume Thouvenin

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).