From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 2/4] kvm-unit-tests: VMX: Add test cases for CR0/4 shadowing Date: Sun, 18 Aug 2013 16:07:47 +0200 Message-ID: <5210D533.1010703@redhat.com> References: <1376409368-7016-1-git-send-email-yzt356@gmail.com> <1376409368-7016-3-git-send-email-yzt356@gmail.com> <520C837E.7030407@web.de> <520C879B.30908@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Jan Kiszka , kvm , Gleb Natapov To: Arthur Chunqi Li Return-path: Received: from mail-we0-f181.google.com ([74.125.82.181]:58648 "EHLO mail-we0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755008Ab3HROIa (ORCPT ); Sun, 18 Aug 2013 10:08:30 -0400 Received: by mail-we0-f181.google.com with SMTP id q57so2148050wes.26 for ; Sun, 18 Aug 2013 07:08:29 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 15/08/2013 09:59, Arthur Chunqi Li ha scritto: >> > volatile u32 stage? And we have barrier() to avoid reordering. > Reordering here is not a big deal here, though it is actually needed > here. I occurred the following problem: > > stage = 1; > do something that causes vmexit; > stage = 2; > > Then the compiler will optimize "stage = 1" and "stage = 2" to one > instruction "stage =2", since instructions between them don't use > "stage". Can volatile solve this problem? I'm not sure if volatile stores are reordered against non-volatile stores. Better keep set_stage() but write it as barrier(); stage = s; barrier(); Paolo