From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: [PATCH] test: add inc/dec emulation testing Date: Wed, 14 Jul 2010 15:27:29 +0300 Message-ID: <20100714122729.GE4689@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: mtosatti@redhat.com, avi@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1429 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753338Ab0GNM1b (ORCPT ); Wed, 14 Jul 2010 08:27:31 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6ECRUt8001816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 14 Jul 2010 08:27:30 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Gleb Natapov diff --git a/kvm/test/x86/emulator.c b/kvm/test/x86/emulator.c index 6db1305..87ce9bc 100644 --- a/kvm/test/x86/emulator.c +++ b/kvm/test/x86/emulator.c @@ -220,6 +220,31 @@ jmpf: report("ljmp", res); } +void test_incdec(void *mem) +{ + unsigned long *m = mem; + + *m = 0; + + asm volatile ("incl %0":"+m"(*m)); + report("incl", *m == 1); + asm volatile ("decl %0":"+m"(*m)); + report("decl", *m == 0); + asm volatile ("incb %0":"+m"(*m)); + report("incb", *m == 1); + asm volatile ("decb %0":"+m"(*m)); + report("decb", *m == 0); + + asm volatile ("lock incl %0":"+m"(*m)); + report("lock incl", *m == 1); + asm volatile ("lock decl %0":"+m"(*m)); + report("lock decl", *m == 0); + asm volatile ("lock incb %0":"+m"(*m)); + report("lock incb", *m == 1); + asm volatile ("lock decb %0":"+m"(*m)); + report("lock decb", *m == 0); +} + void test_smsw(void) { char mem[16]; @@ -298,6 +323,7 @@ int main() test_lmsw(); test_ljmp(mem); test_stringio(); + test_incdec(mem); printf("\nSUMMARY: %d tests, %d failures\n", tests, fails); return fails ? 1 : 0; -- Gleb.