* [PATCH v2 1/3] test: Add imul real mode test
@ 2010-08-08 18:13 Mohammed Gamal
2010-08-08 18:13 ` [PATCH v2 2/3] test: Add real mode test for mul instruction Mohammed Gamal
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mohammed Gamal @ 2010-08-08 18:13 UTC (permalink / raw)
To: avi; +Cc: mtosatti, kvm, Mohammed Gamal
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
x86/realmode.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/x86/realmode.c b/x86/realmode.c
index 3bbd630..5878396 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -733,6 +733,7 @@ void test_long_jmp()
else
print_serial("Long JMP Test: PASS\n");
}
+
void test_push_pop()
{
struct regs inregs = { 0 }, outregs;
@@ -975,6 +976,90 @@ void test_int()
print_serial("int Test 1: PASS\n");
}
+void test_imul()
+{
+ struct regs inregs = { 0 }, outregs;
+
+ MK_INSN(imul8_1, "mov $2, %al\n\t"
+ "mov $-4, %cx\n\t"
+ "imul %cl\n\t");
+
+ MK_INSN(imul16_1, "mov $2, %ax\n\t"
+ "mov $-4, %cx\n\t"
+ "imul %cx\n\t");
+
+ MK_INSN(imul32_1, "mov $2, %eax\n\t"
+ "mov $-4, %ecx\n\t"
+ "imul %ecx\n\t");
+
+ MK_INSN(imul8_2, "mov $0x12340002, %eax\n\t"
+ "mov $4, %cx\n\t"
+ "imul %cl\n\t");
+
+ MK_INSN(imul16_2, "mov $2, %ax\n\t"
+ "mov $4, %cx\n\t"
+ "imul %cx\n\t");
+
+ MK_INSN(imul32_2, "mov $2, %eax\n\t"
+ "mov $4, %ecx\n\t"
+ "imul %ecx\n\t");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_imul8_1,
+ insn_imul8_1_end - insn_imul8_1);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || (outregs.eax & 0xff) != (u8)-8)
+ print_serial("imul Test 1: FAIL\n");
+ else
+ print_serial("imul Test 1: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_imul16_1,
+ insn_imul16_1_end - insn_imul16_1);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != (u16)-8)
+ print_serial("imul Test 2: FAIL\n");
+ else
+ print_serial("imul Test 2: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_imul32_1,
+ insn_imul32_1_end - insn_imul32_1);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != (u32)-8)
+ print_serial("imul Test 3: FAIL\n");
+ else
+ print_serial("imul Test 3: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_imul8_2,
+ insn_imul8_2_end - insn_imul8_2);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || (outregs.eax & 0xffff) != 8 ||
+ (outregs.eax & 0xffff0000) != 0x12340000)
+ print_serial("imul Test 4: FAIL\n");
+ else
+ print_serial("imul Test 4: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_imul16_2,
+ insn_imul16_2_end - insn_imul16_2);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8)
+ print_serial("imul Test 5: FAIL\n");
+ else
+ print_serial("imul Test 5: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_imul32_2,
+ insn_imul32_2_end - insn_imul32_2);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8)
+ print_serial("imul Test 6: FAIL\n");
+ else
+ print_serial("imul Test 6: PASS\n");
+}
+
void realmode_start(void)
{
test_null();
@@ -998,6 +1083,7 @@ void realmode_start(void)
test_xchg();
test_iret();
test_int();
+ test_imul();
exit(0);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] test: Add real mode test for mul instruction
2010-08-08 18:13 [PATCH v2 1/3] test: Add imul real mode test Mohammed Gamal
@ 2010-08-08 18:13 ` Mohammed Gamal
2010-08-08 18:13 ` [PATCH v2 3/3] test: Add real mode tests for div and idiv Mohammed Gamal
2010-08-17 11:25 ` [PATCH v2 1/3] test: Add imul real mode test Avi Kivity
2 siblings, 0 replies; 4+ messages in thread
From: Mohammed Gamal @ 2010-08-08 18:13 UTC (permalink / raw)
To: avi; +Cc: mtosatti, kvm, Mohammed Gamal
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
x86/realmode.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/x86/realmode.c b/x86/realmode.c
index 5878396..582d0be 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1060,6 +1060,50 @@ void test_imul()
print_serial("imul Test 6: PASS\n");
}
+void test_mul()
+{
+ struct regs inregs = { 0 }, outregs;
+
+ MK_INSN(mul8, "mov $2, %al\n\t"
+ "mov $4, %cx\n\t"
+ "imul %cl\n\t");
+
+ MK_INSN(mul16, "mov $2, %ax\n\t"
+ "mov $4, %cx\n\t"
+ "imul %cx\n\t");
+
+ MK_INSN(mul32, "mov $2, %eax\n\t"
+ "mov $4, %ecx\n\t"
+ "imul %ecx\n\t");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_mul8,
+ insn_mul8_end - insn_mul8);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || (outregs.eax & 0xff) != 8)
+ print_serial("mul Test 1: FAIL\n");
+ else
+ print_serial("mul Test 1: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_mul16,
+ insn_mul16_end - insn_mul16);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8)
+ print_serial("mul Test 2: FAIL\n");
+ else
+ print_serial("mul Test 2: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_mul32,
+ insn_mul32_end - insn_mul32);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8)
+ print_serial("mul Test 3: FAIL\n");
+ else
+ print_serial("mul Test 3: PASS\n");
+}
+
void realmode_start(void)
{
test_null();
@@ -1084,6 +1128,7 @@ void realmode_start(void)
test_iret();
test_int();
test_imul();
+ test_mul();
exit(0);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] test: Add real mode tests for div and idiv
2010-08-08 18:13 [PATCH v2 1/3] test: Add imul real mode test Mohammed Gamal
2010-08-08 18:13 ` [PATCH v2 2/3] test: Add real mode test for mul instruction Mohammed Gamal
@ 2010-08-08 18:13 ` Mohammed Gamal
2010-08-17 11:25 ` [PATCH v2 1/3] test: Add imul real mode test Avi Kivity
2 siblings, 0 replies; 4+ messages in thread
From: Mohammed Gamal @ 2010-08-08 18:13 UTC (permalink / raw)
To: avi; +Cc: mtosatti, kvm, Mohammed Gamal
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
x86/realmode.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/x86/realmode.c b/x86/realmode.c
index 582d0be..603fd1f 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1104,6 +1104,96 @@ void test_mul()
print_serial("mul Test 3: PASS\n");
}
+void test_div()
+{
+ struct regs inregs = { 0 }, outregs;
+
+ MK_INSN(div8, "mov $257, %ax\n\t"
+ "mov $2, %cl\n\t"
+ "div %cl\n\t");
+
+ MK_INSN(div16, "mov $512, %ax\n\t"
+ "mov $5, %cx\n\t"
+ "div %cx\n\t");
+
+ MK_INSN(div32, "mov $512, %eax\n\t"
+ "mov $5, %ecx\n\t"
+ "div %ecx\n\t");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_div8,
+ insn_div8_end - insn_div8);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 384)
+ print_serial("div Test 1: FAIL\n");
+ else
+ print_serial("div Test 1: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_div16,
+ insn_div16_end - insn_div16);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 102 ||
+ outregs.edx != 2)
+ print_serial("div Test 2: FAIL\n");
+ else
+ print_serial("div Test 2: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_div32,
+ insn_div32_end - insn_div32);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 102 ||
+ outregs.edx != 2)
+ print_serial("div Test 3: FAIL\n");
+ else
+ print_serial("div Test 3: PASS\n");
+}
+
+void test_idiv()
+{
+ struct regs inregs = { 0 }, outregs;
+
+ MK_INSN(idiv8, "mov $256, %ax\n\t"
+ "mov $-2, %cl\n\t"
+ "idiv %cl\n\t");
+
+ MK_INSN(idiv16, "mov $512, %ax\n\t"
+ "mov $-2, %cx\n\t"
+ "idiv %cx\n\t");
+
+ MK_INSN(idiv32, "mov $512, %eax\n\t"
+ "mov $-2, %ecx\n\t"
+ "idiv %ecx\n\t");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_idiv8,
+ insn_idiv8_end - insn_idiv8);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != (u8)-128)
+ print_serial("idiv Test 1: FAIL\n");
+ else
+ print_serial("idiv Test 1: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_idiv16,
+ insn_idiv16_end - insn_idiv16);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != (u16)-256)
+ print_serial("idiv Test 2: FAIL\n");
+ else
+ print_serial("idiv Test 2: PASS\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_idiv32,
+ insn_idiv32_end - insn_idiv32);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != (u32)-256)
+ print_serial("idiv Test 3: FAIL\n");
+ else
+ print_serial("idiv Test 3: PASS\n");
+}
+
void realmode_start(void)
{
test_null();
@@ -1129,6 +1219,8 @@ void realmode_start(void)
test_int();
test_imul();
test_mul();
+ test_div();
+ test_idiv();
exit(0);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] test: Add imul real mode test
2010-08-08 18:13 [PATCH v2 1/3] test: Add imul real mode test Mohammed Gamal
2010-08-08 18:13 ` [PATCH v2 2/3] test: Add real mode test for mul instruction Mohammed Gamal
2010-08-08 18:13 ` [PATCH v2 3/3] test: Add real mode tests for div and idiv Mohammed Gamal
@ 2010-08-17 11:25 ` Avi Kivity
2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2010-08-17 11:25 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: mtosatti, kvm
On 08/08/2010 09:13 PM, Mohammed Gamal wrote:
> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
Applied, thanks. Note it is better to use emulator.flat for
instructions that access memory, since it is a lot easier to use that
framework.
Also, you don't IDIV #DE exceptions (and we currently don't emulate that
condition correctly).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-17 11:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-08 18:13 [PATCH v2 1/3] test: Add imul real mode test Mohammed Gamal
2010-08-08 18:13 ` [PATCH v2 2/3] test: Add real mode test for mul instruction Mohammed Gamal
2010-08-08 18:13 ` [PATCH v2 3/3] test: Add real mode tests for div and idiv Mohammed Gamal
2010-08-17 11:25 ` [PATCH v2 1/3] test: Add imul real mode test Avi Kivity
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).