From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH] test: emulator: test LOCK NEG and LOCK NOT Date: Mon, 26 Jul 2010 15:21:54 +0300 Message-ID: <1280146914-5847-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]:8704 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754567Ab0GZMV4 (ORCPT ); Mon, 26 Jul 2010 08:21:56 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6QCLtFE022764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 26 Jul 2010 08:21:56 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6QCLtaT028899 for ; Mon, 26 Jul 2010 08:21:55 -0400 Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Avi Kivity --- kvm/test/x86/emulator.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/kvm/test/x86/emulator.c b/kvm/test/x86/emulator.c index db6a134..476f86f 100644 --- a/kvm/test/x86/emulator.c +++ b/kvm/test/x86/emulator.c @@ -220,9 +220,10 @@ jmpf: report("ljmp", res); } -void test_incdec(void *mem) +void test_incdecnotneg(void *mem) { - unsigned long *m = mem; + unsigned long *m = mem, v = 1234; + unsigned char *mb = mem, vb = 66; *m = 0; @@ -243,6 +244,20 @@ void test_incdec(void *mem) report("lock incb", *m == 1); asm volatile ("lock decb %0":"+m"(*m)); report("lock decb", *m == 0); + + *m = v; + + asm ("lock negq %0" : "+m"(*m)); v = -v; + report("lock negl", *m == v); + asm ("lock notq %0" : "+m"(*m)); v = ~v; + report("lock notl", *m == v); + + *mb = vb; + + asm ("lock negb %0" : "+m"(*mb)); vb = -vb; + report("lock negb", *mb == vb); + asm ("lock notb %0" : "+m"(*mb)); vb = ~vb; + report("lock notb", *mb == vb); } void test_smsw(void) @@ -375,7 +390,7 @@ int main() test_lmsw(); test_ljmp(mem); test_stringio(); - test_incdec(mem); + test_incdecnotneg(mem); printf("\nSUMMARY: %d tests, %d failures\n", tests, fails); return fails ? 1 : 0; -- 1.7.1