All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Arthur Chunqi Li <yzt356@gmail.com>
Cc: kvm <kvm@vger.kernel.org>, Jan Kiszka <jan.kiszka@web.de>,
	Gleb Natapov <gleb@redhat.com>
Subject: Re: [PATCH 2/2] kvm-unit-tests: VMX: Test cases for nested EPT
Date: Mon, 09 Sep 2013 16:26:58 +0200	[thread overview]
Message-ID: <522DDAB2.9020900@redhat.com> (raw)
In-Reply-To: <CABpY8MJJg2hCqijPK0oL+z2g5_T2kewhtR7uk5tXB_tLj47WuQ@mail.gmail.com>

Il 09/09/2013 16:11, Arthur Chunqi Li ha scritto:
>>> >> +volatile u32 stage;
>>> >> +volatile bool init_fail;
>> >
>> > Why volatile?
> Because init_fail is only set but not used later in ept_init(), and if
> I don't add volatile, compiler may optimize the setting to init_fail.
> 
> This occasion firstly occurred when I write set_stage/get_stage. If
> one variant is set in a function but not used later, the compiler
> usually optimizes this setting as redundant assignment and remove it.

No, the two are different.  "stage" is written several times in the same
function, with no code in the middle:

	stage++;
	*p = 1;
	stage++;

To the compiler, the first store is dead.  The compiler doesn't know
that "*p = 1" traps to the hypervisor.

But this is not the case for "init_fail".

Paolo

  reply	other threads:[~2013-09-09 14:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09  4:57 [PATCH 0/2] kvm-unit-tests: VMX: Test nested EPT features Arthur Chunqi Li
2013-09-09  4:57 ` [PATCH 1/2] kvm-unit-tests: VMX: The framework of EPT for nested VMX testing Arthur Chunqi Li
2013-09-09 13:45   ` Paolo Bonzini
2013-09-09  4:57 ` [PATCH 2/2] kvm-unit-tests: VMX: Test cases for nested EPT Arthur Chunqi Li
2013-09-09 13:56   ` Paolo Bonzini
2013-09-09 14:11     ` Arthur Chunqi Li
2013-09-09 14:26       ` Paolo Bonzini [this message]
2013-09-09 15:29   ` Arthur Chunqi Li
2013-09-09 16:23     ` Paolo Bonzini
2013-09-09  7:17 ` [PATCH 0/2] kvm-unit-tests: VMX: Test nested EPT features Jan Kiszka
2013-09-09  7:44   ` Arthur Chunqi Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=522DDAB2.9020900@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=yzt356@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.