[PATCH kvm-unit-tests] emulator: test shld, shrd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Used to be broken in multiple ways.

Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
---
 x86/emulator.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/x86/emulator.c b/x86/emulator.c
index d4f0363..73079f8 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -642,6 +642,16 @@ static void test_rip_relative(unsigned *mem, char *insn_ram)
     report("movb $imm, 0(%rip)", *mem == 0x10000);
 }
 
+static void test_shld_shrd(u32 *mem)
+{
+    *mem = 0x12345678;
+    asm("shld %2, %1, %0" : "+m"(*mem) : "r"(0xaaaaaaaaU), "c"((u8)3));
+    report("shld (cl)", *mem == ((0x12345678 << 3) | 5));
+    *mem = 0x12345678;
+    asm("shrd %2, %1, %0" : "+m"(*mem) : "r"(0x55555555U), "c"((u8)3));
+    report("shrd (cl)", *mem == ((0x12345678 >> 3) | (5u << 29)));
+}
+
 int main()
 {
 	void *mem;
@@ -684,6 +694,7 @@ int main()
 	test_div(mem);
 	test_sse(mem);
 	test_rip_relative(mem, insn_ram);
+	test_shld_shrd(mem);
 
 	printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
 	return fails ? 1 : 0;
-- 
1.7.6.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux