From: Bill Davidsen <davidsen@tmr.com>
To: kvm@vger.kernel.org
Cc: Avi Kivity <avi@qumranet.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Alexandre Oliva <aoliva@redhat.com>,
kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: pvmmu breakage with gcc 4.3.0
Date: Fri, 27 Jun 2008 12:11:38 -0400 [thread overview]
Message-ID: <4865113A.40805@tmr.com> (raw)
In-Reply-To: <48638FE2.1020005@codemonkey.ws>
Anthony Liguori wrote:
> Avi Kivity wrote:
>> Marcelo Tosatti wrote:
>>> Some pvmmu functions store their commands on stack, and newer GCC
>>> versions conclude that these commands are unused.
>>>
>>> So stick an inline asm statement to convince the compiler otherwise.
>>>
>>> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>>>
>>>
>>> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
>>> index 8b7a3cf..c892752 100644
>>> --- a/arch/x86/kernel/kvm.c
>>> +++ b/arch/x86/kernel/kvm.c
>>> @@ -55,6 +55,12 @@ static void kvm_mmu_op(void *buffer, unsigned len)
>>> int r;
>>> unsigned long a1, a2;
>>>
>>> + /*
>>> + * GCC 4.3.0 concludes that on-stack kvm_mmu_op* is unused and
>>> + * optimizes its initialization away.
>>> + */
>>> + asm ("" : : "p" (buffer));
>>> +
>>>
>>
>> I don't think "p" should force the contents into memory? Perhaps
>> "m"(*(char *)buffer)?
>>
>> Anthony, I don't see why a memory clobber would tell gcc that the
>> variables is actually used.
>
> It doesn't, but it seems to me that it should force GCC to assume
> everything is live. It's a big stick to hit the problem with but it
> seems like the right thing semantically.
>
In general the right stick to hit a compiler with is 'volatile,' which
should tell the compiler that outside forces are in play. Without really
digging into the code I don't want to suggest just where this should be
used, but clearly Christian had the same thought.
>> The problem is with the void * -> unsigned long cast (__pa), once
>> that happens gcc loses track. It's probably needed anyway since
>> hypercalls _do_ clobber memory.
>
> Right, it's not telling GCC that we touch a particular variable, but
> rather that we may have touched any variable.
>
--
Bill Davidsen <davidsen@tmr.com>
"We have more to fear from the bungling of the incompetent than from
the machinations of the wicked." - from Slashdot
next prev parent reply other threads:[~2008-06-27 16:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-26 2:10 KVM: pvmmu breakage with gcc 4.3.0 Marcelo Tosatti
2008-06-26 3:10 ` Anthony Liguori
2008-06-26 13:18 ` Christian Borntraeger
2008-06-26 18:06 ` Alexandre Oliva
2008-06-29 8:56 ` Avi Kivity
2008-06-26 11:43 ` Avi Kivity
2008-06-26 12:47 ` Anthony Liguori
2008-06-27 16:11 ` Bill Davidsen [this message]
2008-06-26 15:08 ` Christian Borntraeger
2008-06-26 15:21 ` Anthony Liguori
2008-06-26 15:41 ` Anthony Liguori
2008-06-26 16:34 ` Christian Borntraeger
2008-06-29 10:16 ` Avi Kivity
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=4865113A.40805@tmr.com \
--to=davidsen@tmr.com \
--cc=aliguori@us.ibm.com \
--cc=aoliva@redhat.com \
--cc=avi@qumranet.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox