From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH] x86: emulator: Fix h_mem usage in tests_smsw Date: Wed, 03 Dec 2014 10:15:29 +0100 Message-ID: <547ED4B1.4080805@redhat.com> References: <1417558962-28481-1-git-send-email-chris.j.arges@canonical.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: namit@cs.technion.ac.il To: Chris J Arges , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34466 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750891AbaLCJPj (ORCPT ); Wed, 3 Dec 2014 04:15:39 -0500 In-Reply-To: <1417558962-28481-1-git-send-email-chris.j.arges@canonical.com> Sender: kvm-owner@vger.kernel.org List-ID: On 02/12/2014 23:22, Chris J Arges wrote: > In emulator.c/tests_smsw, smsw (3) fails because h_mem isn't being set correctly > before smsw is called. By declaring the h_mem function parameter as volatile, > the compiler no longer optimizes out the assignment before smsw. > > Signed-off-by: Chris J Arges > --- > x86/emulator.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/x86/emulator.c b/x86/emulator.c > index 5aa4dbf..570628f 100644 > --- a/x86/emulator.c > +++ b/x86/emulator.c > @@ -337,7 +337,7 @@ void test_incdecnotneg(void *mem) > report("lock notb", *mb == vb); > } > > -void test_smsw(uint64_t *h_mem) > +void test_smsw(volatile uint64_t *h_mem) > { > char mem[16]; > unsigned short msw, msw_orig, *pmsw; > What if you change asm volatile("smsw %0" : "=m"(*h_mem)); to asm volatile("smsw %0" : "+m"(*h_mem)); Paolo