From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 8 09:46:21 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 7F1681065673; Thu, 8 Dec 2011 09:46:21 +0000 (UTC) (envelope-from gleb.kurtsou@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id C3D048FC12; Thu, 8 Dec 2011 09:46:20 +0000 (UTC) Received: by lagv3 with SMTP id v3so854886lag.13 for ; Thu, 08 Dec 2011 01:46:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=RR0OtEp4MnicPtpyDAMc/0Mdh24FJpQHvZyz/Nk90pk=; b=UmpB0ti/f3t8OQ/bkC06lC69ywS1AWMHhuH4tgIpYOqJKMZ4CgGN9MbrZH0p6os8nh 7nBKiJ1vJGkIbRmw8jUYne6zYKsfIkY9MLLFpSVqmQZEeJTmxd8kB0wugI8Zz7dzMDBj Aid4HFDSrsWVF8KasR8KnruODA8xt6H0gJcQQ= Received: by 10.152.104.206 with SMTP id gg14mr1396976lab.41.1323337578765; Thu, 08 Dec 2011 01:46:18 -0800 (PST) Received: from localhost ([78.157.92.5]) by mx.google.com with ESMTPS id no9sm4182289lab.0.2011.12.08.01.46.16 (version=SSLv3 cipher=OTHER); Thu, 08 Dec 2011 01:46:18 -0800 (PST) Date: Thu, 8 Dec 2011 11:46:18 +0200 From: Gleb Kurtsou To: Piotr Nowak Message-ID: <20111208094618.GA11139@reks> References: <20111119100150.GA1560@reks> <20111208090159.GA1924@cq1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20111208090159.GA1924@cq1> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Rafal Jaworowski , mdf@freebsd.org, Arnaud Lacombe , freebsd-hackers@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: Thu, 08 Dec 2011 09:46:21 -0000 On (08/12/2011 10: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: 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) > > 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? Adding -finline-functions fixed/masked issue for me. Unfortunately building kernel with -finline-functions is not supported. You can try tweaking conf/files to change build options for this file only. Issue not sra-related, but sra is also known to be buggy in gcc 4.2. > > Regards, > Piotr