From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM: pvmmu breakage with gcc 4.3.0 Date: Thu, 26 Jun 2008 14:43:23 +0300 Message-ID: <486380DB.9070905@qumranet.com> References: <20080626021047.GA10263@dmt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Anthony Liguori , Alexandre Oliva , kvm-devel To: Marcelo Tosatti Return-path: Received: from il.qumranet.com ([212.179.150.194]:17401 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757680AbYFZLnP (ORCPT ); Thu, 26 Jun 2008 07:43:15 -0400 In-Reply-To: <20080626021047.GA10263@dmt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: 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 > > > 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. 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. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.