From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 9 15:15:14 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 273B0106566B; Fri, 9 Dec 2011 15:15:14 +0000 (UTC) (envelope-from raj@semihalf.com) Received: from smtp.semihalf.com (smtp.semihalf.com [213.17.239.109]) by mx1.freebsd.org (Postfix) with ESMTP id C743E8FC08; Fri, 9 Dec 2011 15:15:13 +0000 (UTC) Received: from localhost (unknown [213.17.239.109]) by smtp.semihalf.com (Postfix) with ESMTP id 47949EC333; Fri, 9 Dec 2011 16:15:12 +0100 (CET) X-Virus-Scanned: by amavisd-new at semihalf.com Received: from smtp.semihalf.com ([213.17.239.109]) by localhost (smtp.semihalf.com [213.17.239.109]) (amavisd-new, port 10024) with ESMTP id MEDU-5MXR1NL; Fri, 9 Dec 2011 16:15:11 +0100 (CET) Received: from [10.0.0.112] (nat3-133.ghnet.pl [91.150.222.133]) by smtp.semihalf.com (Postfix) with ESMTPSA id 4B74DEC330; Fri, 9 Dec 2011 16:15:11 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Rafal Jaworowski In-Reply-To: <4EE0EB8C.7050800@freebsd.org> Date: Fri, 9 Dec 2011 16:15:10 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <6D023449-EDEA-4B1C-975D-54AA2F4328CE@semihalf.com> References: <20111119100150.GA1560@reks> <20111208090159.GA1924@cq1> <4EE0EB8C.7050800@freebsd.org> To: Nathan Whitehorn X-Mailer: Apple Mail (2.1084) Cc: freebsd-hackers@freebsd.org, Gleb Kurtsou , Piotr Nowak , Arnaud Lacombe , mdf@freebsd.org 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 15:15:14 -0000 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. >>=20 >> Example shown below covers file sys/powerc/booke/pmap.c >> and function pmap_kenter. If we disassemble kernel binary >> we have: >>=20 >> c019998c: 4b ec 6a ed bl c0060478<_mtx_unlock_spin_flags> >> c0199990: 81 61 00 00 lwz r11,0(r1) >> c0199994: 80 0b 00 04 lwz r0,4(r11) >> c0199998: 7d 61 5b 78 mr r1,r11 >> c019999c: 82 ab ff d4 lwz r21,-44(r11) >> c01999a0: 7c 08 03 a6 mtlr r0 >> c01999a4: 82 cb ff d8 lwz r22,-40(r11) >> c01999a8: 82 eb ff dc lwz r23,-36(r11) >> c01999ac: 83 0b ff e0 lwz r24,-32(r11) >> c01999b0: 83 2b ff e4 lwz r25,-28(r11) >> c01999b4: 83 4b ff e8 lwz r26,-24(r11) >> c01999b8: 83 6b ff ec lwz r27,-20(r11) >>=20 >> 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. >>=20 >> The problem occures only with -fno-omit-frame-pointer >> and not every branch returns are beeing corrupted. >>=20 >> Do you think this issue may be somehow related to yours? >> Are there any patches/solutions to fix it? >=20 > Should we turn off -fno-omit-frame-frame-pointer on PPC then? It's = enabled in default kernel builds. I think that's a good idea. Even though we have managed to trigger this = only in rare cases, the problem is real and the code generated is broken = i.e. leads to corruption and panics. Rafal