* [PATCH] kvm: testsuite: Add test for 'call near absolute'
@ 2008-09-09 14:39 Mohammed Gamal
2008-09-10 15:31 ` Avi Kivity
0 siblings, 1 reply; 4+ messages in thread
From: Mohammed Gamal @ 2008-09-09 14:39 UTC (permalink / raw)
To: kvm; +Cc: avi
Adds 'call near absolute' to the real mode test harness
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
user/test/x86/realmode.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/user/test/x86/realmode.c b/user/test/x86/realmode.c
index 5f0ca0f..7da22a9 100644
--- a/user/test/x86/realmode.c
+++ b/user/test/x86/realmode.c
@@ -5,6 +5,14 @@ typedef unsigned short u16;
typedef unsigned u32;
typedef unsigned long long u64;
+void test_function(void);
+
+asm(
+ "test_function: \n\t"
+ "mov $0x1234, %eax \n\t"
+ "ret"
+ );
+
static int strlen(const char *str)
{
int n;
@@ -279,6 +287,18 @@ void test_io(struct regs *inregs, struct regs *outregs)
}
+void test_call(struct regs *inregs, struct regs *outregs)
+{
+ MK_INSN(call1, "mov $test_function, %eax \n\t"
+ "call *%eax\n\t");
+
+ exec_in_big_real_mode(inregs, outregs,
+ insn_call1,
+ insn_call1_end - insn_call1);
+ if(!regs_equal(inregs, outregs, R_AX) || outregs->eax != 0x1234)
+ print_serial("Call Test 1: FAIL\n");
+}
+
void start(void)
{
struct regs inregs = { 0 }, outregs;
@@ -287,6 +307,7 @@ void start(void)
exec_in_big_real_mode(&inregs, &outregs, 0, 0);
if (!regs_equal(&inregs, &outregs, 0))
print_serial("null test: FAIL\n");
+ test_call(&inregs, &outregs);
test_mov_imm(&inregs, &outregs);
test_io(&inregs, &outregs);
test_eflags_insn(&inregs, &outregs);
--
1.5.4.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] kvm: testsuite: Add test for 'call near absolute'
@ 2008-09-08 18:46 Mohammed Gamal
2008-09-09 13:39 ` Avi Kivity
0 siblings, 1 reply; 4+ messages in thread
From: Mohammed Gamal @ 2008-09-08 18:46 UTC (permalink / raw)
To: kvm; +Cc: avi
Add test for 'call near abolsute' instruction to the real mode test harness
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
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 5f0ca0f..756725f 100644
--- a/user/test/x86/realmode.c
+++ b/user/test/x86/realmode.c
@@ -279,6 +279,24 @@ void test_io(struct regs *inregs, struct regs *outregs)
}
+void test_call(struct regs *inregs, struct regs *outregs)
+{
+ MK_INSN(call1, "mov $0x4000, %eax \n\t"
+ "call *%eax\n\t");
+
+ exec_in_big_real_mode(inregs, outregs,
+ insn_call1,
+ insn_call1_end - insn_call1);
+}
+
+void line_out()
+{
+ /* Just output a blank line */
+ asm(".org 0x4000 \n\t"
+ "mov $10, %al \n\t"
+ "out %al, $0xf1 \n\t");
+}
+
void start(void)
{
struct regs inregs = { 0 }, outregs;
@@ -287,6 +305,7 @@ void start(void)
exec_in_big_real_mode(&inregs, &outregs, 0, 0);
if (!regs_equal(&inregs, &outregs, 0))
print_serial("null test: FAIL\n");
+ test_call(&inregs, &outregs);
test_mov_imm(&inregs, &outregs);
test_io(&inregs, &outregs);
test_eflags_insn(&inregs, &outregs);
--
1.5.4.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] kvm: testsuite: Add test for 'call near absolute'
2008-09-08 18:46 Mohammed Gamal
@ 2008-09-09 13:39 ` Avi Kivity
0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2008-09-09 13:39 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: kvm
Mohammed Gamal wrote:
> Add test for 'call near abolsute' instruction to the real mode test harness
>
>
> +void test_call(struct regs *inregs, struct regs *outregs)
> +{
> + MK_INSN(call1, "mov $0x4000, %eax \n\t"
> + "call *%eax\n\t");
> +
> + exec_in_big_real_mode(inregs, outregs,
> + insn_call1,
> + insn_call1_end - insn_call1);
>
Please test registers for damage (using regs_equal).
> +}
> +
> +void line_out()
> +{
> + /* Just output a blank line */
> + asm(".org 0x4000 \n\t"
> + "mov $10, %al \n\t"
> + "out %al, $0xf1 \n\t");
> +}
>
When the code grows and occupies address 0x4000, this will break.
I suggest:
void test_function(void);
asm ("test_function: mov $1234, %eax; ret");
This sets up a register to see that the call actually did something, and
avoids the gcc function prologue/epilogue which may clobber registers.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-10 15:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-09 14:39 [PATCH] kvm: testsuite: Add test for 'call near absolute' Mohammed Gamal
2008-09-10 15:31 ` Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2008-09-08 18:46 Mohammed Gamal
2008-09-09 13:39 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox