Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2585688ybh; Mon, 16 Mar 2020 06:07:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuwmmr9Rnpe76i3o3EpgL1iFIwTGYc45AjeclkaFNW4ZUiDfJL6kqk+jDfd67cAHH4qUsMN X-Received: by 2002:aca:190f:: with SMTP id l15mr6498221oii.48.1584364046062; Mon, 16 Mar 2020 06:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584364046; cv=none; d=google.com; s=arc-20160816; b=BLlIG/Vm3nyAkX8uKra5rpgMWVNrDigFUJRdpZQd4Ob3qySUEBe/DP4Qh8HXfOl1e8 mJMd2A2n/bZnbLjfQVR1x+yjccVQFaONkYRd6hC5bTfg8Ql7k9Wqktwa2XakNx2VLkbG f5qHd4Z6o39JAMq0eotsHPXRas8zWohMC9SLr9ZvIrhHe6uspYaDlkdXhk1AdV8M1vYI Nf44R35z+DyLj0gxGCnenXEBnCnaMV1rGBGlD35mUFKxo435z3l9TpCbzfmRoxRDvvDv M4mpYf5bbieqv6rcakD+zeVzVLpXVuawbk//cwND8gal7R1xo2D38X8n1gQZ3fo5vk2U KRYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=XYP4eLWlmurw/yjHmjNfN5IFqsjDCm9io3qRKcZbPcU=; b=TWf0kiFjGQ0/mA2EM0nKGTOAPfK/0ZGLMsQcxaJSBJOJLrE083OIykPQGN2ONkRxko SVScgkbgAs0qjVYV5gkIBT4rgDbpBpuEEgURzV0o+a7omAn4is+55arkIhs/0UTJ/H2C 900K9Zm7JsI+zI5oaAmu77+xcL3dODIpGIKsxeVAEU3OdfOEro2bWRZbWal9cxP0i4nz I4VUROQdGF3CUvICWdD/copQssOSJpYGe7dO3HXkFgO0AcZTskwPu9Tr7F/jMgtlpYSD UztlAPIipn+RiYK4Zty65dITjssLktIWGuSd6frIYuU2KbEJZ6WaY9q6HeVCqNm10ZYO 7sEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=J1gGejFz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si9400896otn.285.2020.03.16.06.07.04; Mon, 16 Mar 2020 06:07:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=J1gGejFz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731100AbgCPNEV (ORCPT + 99 others); Mon, 16 Mar 2020 09:04:21 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58246 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730974AbgCPNEV (ORCPT ); Mon, 16 Mar 2020 09:04:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XYP4eLWlmurw/yjHmjNfN5IFqsjDCm9io3qRKcZbPcU=; b=J1gGejFzBgU3ABPLGZfeahlXVA zICDn6wUZjBvXMTn1D5zLCm4wnGBns+fC2OyK+s03CmqmOcPjuqkRd/DqyhgqYCDT69VMy6dcdnP3 0ajKpBhHRv7s6v+9kodIxjs51HfoX/KmdkO6orXQB6UIGtELw8rsXgyJZea2el3rAH0m8TiJy5s2x SwZNZPlwcVr7RWlf6fmw7XXWmPNfph2iiLl38jtf9OjD9Y5WCXDpGVmjjEb49nQTfZ5flsuzGl9B8 wNUbZTVWCTXRFPeaRY1rNGPfbbNRsQJzVParhzZqWoJfUV5kv2qstm3qB7aY4E7AgA63UgOZ6Eudz gjrvHiVA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDpPk-0001Zo-Ro; Mon, 16 Mar 2020 13:04:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 6CE3D30138D; Mon, 16 Mar 2020 14:04:14 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 570E220B151F4; Mon, 16 Mar 2020 14:04:14 +0100 (CET) Date: Mon, 16 Mar 2020 14:04:14 +0100 From: Peter Zijlstra To: Sergei Trofimovich Cc: linux-kernel@vger.kernel.org, Jakub Jelinek , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Andy Lutomirski , x86@kernel.org Subject: Re: [PATCH] x86: fix early boot crash on gcc-10 Message-ID: <20200316130414.GC12561@hirez.programming.kicks-ass.net> References: <20200314164451.346497-1-slyfox@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200314164451.346497-1-slyfox@gentoo.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 14, 2020 at 04:44:51PM +0000, Sergei Trofimovich wrote: > The change fixes boot failure on physical machine where kernel > is built with gcc-10 with stack-protector enabled by default: > This happens because `start_secondary()` is responsible for setting > up initial stack canary value in `smpboot.c`, but nothing prevents > gcc from inserting stack canary into `start_secondary()` itself > before `boot_init_stack_canary()` call. > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile > index 9b294c13809a..da9f4ea9bf4c 100644 > --- a/arch/x86/kernel/Makefile > +++ b/arch/x86/kernel/Makefile > @@ -11,6 +11,12 @@ extra-y += vmlinux.lds > > CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) > > +# smpboot's init_secondary initializes stack canary. > +# Make sure we don't emit stack checks before it's > +# initialized. > +nostackp := $(call cc-option, -fno-stack-protector) > +CFLAGS_smpboot.o := $(nostackp) What makes GCC10 insert this while GCC9 does not. Also, I would much rather GCC10 add a function attrbute to kill this: __attribute__((no_stack_protect)) Then we can explicitly clear this one function and keep it on for the rest of the file.