* [PATCH kvm-unit-tests] emulator: test rip-relative insn with immediate operand
@ 2011-06-19 16:50 Avi Kivity
2011-06-21 15:49 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Avi Kivity @ 2011-06-19 16:50 UTC (permalink / raw)
To: Marcelo Tosatti, kvm; +Cc: xin.li
kvm has a bug with instructions of the form
opcode $imm, displ(%%rip)
Where the effective address was not calculated correctly. Test
it now.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
x86/emulator.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/x86/emulator.c b/x86/emulator.c
index 967f2a4..d4f0363 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -627,15 +627,31 @@ static void test_sse(sse_union *mem)
report("movdqu (write)", sseeq(mem, &v));
}
+static void test_rip_relative(unsigned *mem, char *insn_ram)
+{
+ /* movb $1, mem+2(%rip) */
+ insn_ram[0] = 0xc6;
+ insn_ram[1] = 0x05;
+ *(unsigned *)&insn_ram[2] = 2 + (char *)mem - (insn_ram + 7);
+ insn_ram[6] = 0x01;
+ /* ret */
+ insn_ram[7] = 0xc3;
+
+ *mem = 0;
+ asm("callq *%1" : "+m"(*mem) : "r"(insn_ram));
+ report("movb $imm, 0(%rip)", *mem == 0x10000);
+}
int main()
{
void *mem;
+ void *insn_ram;
unsigned long t1, t2;
setup_vm();
setup_idt();
mem = vmap(IORAM_BASE_PHYS, IORAM_LEN);
+ insn_ram = vmalloc(4096);
// test mov reg, r/m and mov r/m, reg
t1 = 0x123456789abcdef;
@@ -667,6 +683,7 @@ int main()
test_imul(mem);
test_div(mem);
test_sse(mem);
+ test_rip_relative(mem, insn_ram);
printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
return fails ? 1 : 0;
--
1.7.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH kvm-unit-tests] emulator: test rip-relative insn with immediate operand
2011-06-19 16:50 [PATCH kvm-unit-tests] emulator: test rip-relative insn with immediate operand Avi Kivity
@ 2011-06-21 15:49 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2011-06-21 15:49 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, xin.li
On Sun, Jun 19, 2011 at 07:50:55PM +0300, Avi Kivity wrote:
> kvm has a bug with instructions of the form
>
> opcode $imm, displ(%%rip)
>
> Where the effective address was not calculated correctly. Test
> it now.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-21 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-19 16:50 [PATCH kvm-unit-tests] emulator: test rip-relative insn with immediate operand Avi Kivity
2011-06-21 15:49 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox