From: Avi Kivity Subject: [PATCH kvm-unit-tests] emulator: test shld, shrd Date: Tue, 13 Sep 2011 11:15:16 +0300 Message-ID: <1315901716-10010-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2136 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753596Ab1IMId6 (ORCPT ); Tue, 13 Sep 2011 04:33:58 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8D8XwwF030689 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 Sep 2011 04:33:58 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8D8FIAC026158 for ; Tue, 13 Sep 2011 04:15:19 -0400 Sender: kvm-owner@vger.kernel.org List-ID: Used to be broken in multiple ways. Signed-off-by: Avi Kivity --- 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