From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bill Davidsen Subject: Re: KVM: pvmmu breakage with gcc 4.3.0 Date: Fri, 27 Jun 2008 12:11:38 -0400 Message-ID: <4865113A.40805@tmr.com> References: <20080626021047.GA10263@dmt.cnet> <486380DB.9070905@qumranet.com> <48638FE2.1020005@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Marcelo Tosatti , Anthony Liguori , Alexandre Oliva , kvm-devel To: kvm@vger.kernel.org Return-path: Received: from main.gmane.org ([80.91.229.2]:54918 "EHLO ciao.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752865AbYF0QMB (ORCPT ); Fri, 27 Jun 2008 12:12:01 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KCGYF-0005rP-4j for kvm@vger.kernel.org; Fri, 27 Jun 2008 16:11:55 +0000 Received: from pool-68-236-140-141.alb.east.verizon.net ([68.236.140.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Jun 2008 16:11:55 +0000 Received: from davidsen by pool-68-236-140-141.alb.east.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 Jun 2008 16:11:55 +0000 In-Reply-To: <48638FE2.1020005@codemonkey.ws> Sender: kvm-owner@vger.kernel.org List-ID: 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 >>> >>> >>> 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 "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot