Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp754797ybz; Wed, 15 Apr 2020 18:14:29 -0700 (PDT) X-Google-Smtp-Source: APiQypLlMbcFvK3UtjpTZ8gu9LmHaj0W45eW4pw92Al9rdw9BmUxzk7Slg4ZQwCEc3wVprFKOuL4 X-Received: by 2002:a17:906:1ecd:: with SMTP id m13mr7518934ejj.277.1586999668905; Wed, 15 Apr 2020 18:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586999668; cv=none; d=google.com; s=arc-20160816; b=W/wpKcCgNKePC95TdGn9eAFKc6qlxZGwf+xhsN5fqunhVVkK3hpZ4UDkAMB6RXtYyO CHwmd8/b3kKCusP49HjKmzSk32aI0r4fuYXdqSUgtFXoCCkp/HgsoKERMCOq5RaHrkDG VH/y1BTIKBxQqLeSrw2ZkGzdzXFv9uZdXY8ycDcbB1fgE2wd9jRYuqKhuQRQrabAP8ec 59vLL/qOTMpw4hT3/3kzHJ8i+d4zQ+fgJVVErTvHF5SCb4FSenhQgRQHoyFpjJjvnvAb E2u1hpr6mZWQMzfk/hTFZ3dN82k1hdl5ieyV6M4VzHX1fOm8gM/32CyaB31UsbHeqYfO UbqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=hN7ylzvVrWnkPuop8wanQFxOQ5+SXTNcCQ5pATiJNK0=; b=PY+eRPOw0RTfR0ecXiBOp1GyEYiF9HlVuHETZRJF+SGOhY8LcIpYv7WDkFI/Sd9ZL0 iNK8eQ/JkJxMVB5k2iVyvTrbX9S+/oEIwf5y+CzaA0V2LnMX60YLUXzHhvuYdOCVlrE2 LD04ofy8hBQKodIbjZaw7RGuixHFQTsmOi2DWRz9nhYL2LlxZSyP0NcfXCT7pyC54WQY XRKQmZNvdjOj3ND1B7ETPbl2rilLb7zI+33sRETvbvKYfqYeMeK5qNjUNlD7u/+xPljc foO34G3XkNTyjUPNAZTO673qWbXSgHRRpS7Kmxvp3fhTZo9TFnsVWQN4Ow8OAipVLYeQ yCPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb14si9912671ejb.80.2020.04.15.18.14.05; Wed, 15 Apr 2020 18:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731836AbgDOWTq (ORCPT + 99 others); Wed, 15 Apr 2020 18:19:46 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:46544 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729180AbgDOWTi (ORCPT ); Wed, 15 Apr 2020 18:19:38 -0400 Received: from sf (tunnel547699-pt.tunnel.tserv1.lon2.ipv6.he.net [IPv6:2001:470:1f1c:3e6::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: slyfox) by smtp.gentoo.org (Postfix) with ESMTPSA id 0D3C834F114; Wed, 15 Apr 2020 22:19:33 +0000 (UTC) Date: Wed, 15 Apr 2020 23:19:30 +0100 From: Sergei Trofimovich To: Michael Matz Cc: Borislav Petkov , Jakub Jelinek , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , x86@kernel.org Subject: Re: [PATCH v2] x86: fix early boot crash on gcc-10 Message-ID: <20200415231930.19755bc7@sf> In-Reply-To: References: <20200326223501.GK11398@zn.tnic> <20200328084858.421444-1-slyfox@gentoo.org> <20200413163540.GD3772@zn.tnic> <20200415074842.GA31016@zn.tnic> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 Apr 2020 14:53:45 +0000 (UTC) Michael Matz wrote: > Hello, > > On Wed, 15 Apr 2020, Borislav Petkov wrote: > > > On Tue, Apr 14, 2020 at 01:50:29PM +0000, Michael Matz wrote: > > > So this part expects that the caller (!) of trace_hardirqs_on was compiled > > > with a frame pointer (in %ebp). > > > > /me looks at the .s file... > > > > options passed comment at the top has -fno-omit-frame-pointer > > > > > Obviously that's not the case as you traced above. Is start_secondary > > > the immediate caller in the above case? > > > > Yes, start_secondary() is the function which is marked as > > __attribute__((optimize("-fno-stack-protector"))) and it does: > > > > # arch/x86/kernel/smpboot.c:264: local_irq_enable(); > > call trace_hardirqs_on # > > > > (the local_irq_enable() is a macro which has the call to > > trace_hardirqs_on(). > > > > > Look at it's disassembly. If it doesn't have the usual push > > > %ebp/mov%esp,%ebp prologue it probably doesn't use a frame pointer. > > > > Here's the preamble: > > > > .text > > .p2align 4 > > .type start_secondary, @function > > start_secondary: > > pushl %esi # > > pushl %ebx # > > Right. So meanwhile it became clear: the optimize function attribute > doesn't work cumulative but rather replaces all cmdline args (the > optimization ones, but that roughly translates to -fxxx options). In this > case an 'optimize("-fno-stack-protector")' also disables the crucial > -fno-omit-frame-pointer, reverting to the compilers default, which, > depending on version, is also to omit the frame pointer on 32bit. You > could fix that by adding ',-fno-omit-frame-pointer' to the attribute > string. But that quickly gets out of hand, considering all the options > you carefully need to set in Makefiles to get the right behaviour. (Note > that e.g. the optimization level is reset to -O0 as well!). > > (I'll admit that I was somewhat surprised by this behaviour, even though > it makes sense in the abstract; resetting to a clean slate and > everything). > > I think in its current form the optimize attribute is not useful for the > purposes you need, and you're better off to disable the stack protector > for the whole compilation unit from the Makefile. > > (That attribute is also documented as "not suitable in production code", > so go figure ;-) ) > > I think it will be possible to make that attribute a bit more useful > in the future, but for the time being I think you'll just want to live > without it. Ah, that makes sense. Borislav, should I send a fix forward against x86 tree to move -fno-stack-protector as it was in v1 patch? Or you'll revert v2 and apply v1 ~as is? Or should I send those myself? -- Sergei