Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754742Ab1CANyV (ORCPT ); Tue, 1 Mar 2011 08:54:21 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:53976 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753640Ab1CANyT (ORCPT ); Tue, 1 Mar 2011 08:54:19 -0500 Subject: Re: [PATCH 2/4] msm: scm: Fix improper register assignment From: Will Deacon To: Nicolas Pitre Cc: David Brown , Russell King - ARM Linux , Saravana Kannan , linux-arm-msm@vger.kernel.org, Stephen Boyd , lkml , linux-arm-kernel@lists.infradead.org In-Reply-To: References: <1298573085-23217-1-git-send-email-sboyd@codeaurora.org> <1298573085-23217-3-git-send-email-sboyd@codeaurora.org> <1298640219.958.74.camel@e102144-lin.cambridge.arm.com> <4D688AF1.1090607@codeaurora.org> <20110226084736.GB3640@n2100.arm.linux.org.uk> <8yazkpi3cfa.fsf@huya.qualcomm.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 01 Mar 2011 13:54:05 +0000 Message-ID: <1298987645.8741.172.camel@e102144-lin.cambridge.arm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1410 Lines: 47 Nicolas, On Sat, 2011-02-26 at 20:04 +0000, Nicolas Pitre wrote: > Right. A minimal test case may look like this if someone feels like > filling a gcc bug report: > > extern int foo(int x); > > int bar(int x) > { > register int a asm("r0") = 1; > x = foo(x); > asm ("add %0, %1, %2" : "=r" (x) : "r" (a), "r" (x)); > return x; > } > > And the produced code is: > > bar: > stmfd sp!, {r3, lr} > bl foo > #APP > add r0, r0, r0 > ldmfd sp!, {r3, pc} > > So this is clearly bogus. I've had a chat with the compiler guys and they confirmed that this is a known bug. There's a really hairy bug report here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38815 It looks like the GCC stance will change in the future so that register variables will only be guaranteed to live in the specified register during asm blocks which use them. If the register is required elsewhere, spill/reload code will be emitted as necessary. This might break some weird and wonderful code (passing hidden operands to functions?) but I don't think we rely on the current behaviour anywhere in the kernel. Will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/