From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 9 17:49:58 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAE521065676; Fri, 9 Dec 2011 17:49:58 +0000 (UTC) (envelope-from lacombar@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 1288D8FC14; Fri, 9 Dec 2011 17:49:57 +0000 (UTC) Received: by wgbdr11 with SMTP id dr11so6045331wgb.31 for ; Fri, 09 Dec 2011 09:49:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=10XqQNsdfhwg6N4rZ9G4ocnsp+jPm12xB4rPdQ3qxqk=; b=RkHAyk08MHEHr1VJifgThBMNP4uJMwsROXq+KIkWPQyJV7BUl0HFbQQSasKJ+IZWdP d34kLtuAPjqgdby0uczdJh8LROuBUR7+F613ODGUde7ckroutIvlO6ewyG1S4nQeMYaj CNJnq3cgu6hYoNMTKc0nZVY3DRc347mKDeOC8= MIME-Version: 1.0 Received: by 10.216.49.1 with SMTP id w1mr324610web.29.1323452997074; Fri, 09 Dec 2011 09:49:57 -0800 (PST) Received: by 10.180.94.2 with HTTP; Fri, 9 Dec 2011 09:49:57 -0800 (PST) In-Reply-To: <6D023449-EDEA-4B1C-975D-54AA2F4328CE@semihalf.com> References: <20111119100150.GA1560@reks> <20111208090159.GA1924@cq1> <4EE0EB8C.7050800@freebsd.org> <6D023449-EDEA-4B1C-975D-54AA2F4328CE@semihalf.com> Date: Fri, 9 Dec 2011 12:49:57 -0500 Message-ID: From: Arnaud Lacombe To: Rafal Jaworowski Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, Gleb Kurtsou , Nathan Whitehorn , mdf@freebsd.org, Piotr Nowak Subject: Re: gcc 4.2 miscompilation with -O2 -fno-omit-frame-pointer on amd64 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2011 17:49:59 -0000 Hi, On Fri, Dec 9, 2011 at 10:15 AM, Rafal Jaworowski wrote: > > On 2011-12-08, at 17:53, Nathan Whitehorn wrote: > >> On 12/08/11 03:01, Piotr Nowak wrote: >>> We're working on PowerPC target using GCC 4.2.1 >>> and FreeBSD 6.1. It seems like we have similar >>> problem. In our case GCC sometimes very unfortunately >>> optimize code with -fno-omit-frame-pointer. >>> >>> Example shown below covers file sys/powerc/booke/pmap.c >>> and function pmap_kenter. If we disassemble kernel binary >>> we have: >>> >>> c019998c: =A0 4b ec 6a ed =A0 =A0 bl =A0 =A0 =A0c0060478<_mtx_unlock_sp= in_flags> >>> c0199990: =A0 81 61 00 00 =A0 =A0 lwz =A0 =A0 r11,0(r1) >>> c0199994: =A0 80 0b 00 04 =A0 =A0 lwz =A0 =A0 r0,4(r11) >>> c0199998: =A0 7d 61 5b 78 =A0 =A0 mr =A0 =A0 =A0r1,r11 >>> c019999c: =A0 82 ab ff d4 =A0 =A0 lwz =A0 =A0 r21,-44(r11) >>> c01999a0: =A0 7c 08 03 a6 =A0 =A0 mtlr =A0 =A0r0 >>> c01999a4: =A0 82 cb ff d8 =A0 =A0 lwz =A0 =A0 r22,-40(r11) >>> c01999a8: =A0 82 eb ff dc =A0 =A0 lwz =A0 =A0 r23,-36(r11) >>> c01999ac: =A0 83 0b ff e0 =A0 =A0 lwz =A0 =A0 r24,-32(r11) >>> c01999b0: =A0 83 2b ff e4 =A0 =A0 lwz =A0 =A0 r25,-28(r11) >>> c01999b4: =A0 83 4b ff e8 =A0 =A0 lwz =A0 =A0 r26,-24(r11) >>> c01999b8: =A0 83 6b ff ec =A0 =A0 lwz =A0 =A0 r27,-20(r11) >>> >>> As you can see stack pointer on R1 is being updated >>> before stashed data were pulled off stack. (mr r1,r11) >>> As a result of this we have chance to get crash when >>> any interrupt hit shortly after stack pointer update. >>> The interrupt prologue will override not yet pulled off >>> pmap_kenter function data. >>> >>> The problem occures only with -fno-omit-frame-pointer >>> and not every branch returns are beeing corrupted. >>> >>> Do you think this issue may be somehow related to yours? >>> Are there any patches/solutions to fix it? >> >> Should we turn off -fno-omit-frame-frame-pointer on PPC then? It's enabl= ed in default kernel builds. > > I think that's a good idea. Even though we have managed to trigger this o= nly in rare cases, the problem is real and the code generated is broken i.e= . leads to corruption and panics. > How can you make any conclusion without having seen a single line of code actually triggering the problem ? That sounds very irresponsible... - Arnaud