Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1096645ybz; Sat, 25 Apr 2020 10:54:56 -0700 (PDT) X-Google-Smtp-Source: APiQypJwjwQIA0n6W1O1RubuLKYmH+v4P+QgV5ZbaA+D70/l68+JDMIyGcqbJd8u5q8A1S51dRmv X-Received: by 2002:a17:906:4d8f:: with SMTP id s15mr12991002eju.288.1587837296800; Sat, 25 Apr 2020 10:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587837296; cv=none; d=google.com; s=arc-20160816; b=Fz8q14u2yO8aBsTTyA5vcs1AxJtbUA/bDkdA6WRpMRTXwwQCn5BSZ8r89lYMAvz66J +N4O+V3PL10xE2KZfhGyxP7TNtfHk6MohBJSokhe0oRaCNwxKP3x2QTwXwKe4qxlXL1k aDVsEC2+otAiTmYet5brh3aLDL6ObNwaAStIHa1VTo+k/tk7qF4Jr3rzW3hX4OE5wHSD LifndIDqxpCHQtPk3Bm/UHIOmljHR7kTgkeSgJk2QfS7GvEOMHqeFVu+YsoMTOugDMSi jz7Ocm1AXUYjPKa6/bhb5RtVIplSBcWMlz9KWqMvx21kHIWHcF+TCixmw22GExjStIU2 hF/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TpVMN9srSTRxzvdHGcL8+sKPNt7gpM//pRvQmGJNb+g=; b=AVfh246f/EMlnxmuollvmbufOY+Vt0IQ8eE5mRjiiJjBwLEPWRFZRfcYXs37c8ipsq k1w+29lSk6tPU6plmsJ3RM0EdKbbxRxTBxRUb2JtNQJVuDdcYXNNJPOrPuheW+sYVypw +UVY6xPCTGI9sW89nOS83/c3Npbh0nYe1YNucMX/HAQTuZX8mWXqoQPTjJ/cgoIAI/A6 5vXWuJtvJjtEFN8WEzqtE6Z9OfWirBNdu+R1MisVy++7U1ehSDVgZnspzErfiPsO0P+D CkQT30YKz2x+zRy/HvoiEIwCvYqmHx2O0NRMPCGdw4SOZ5oz+NOs0igMxMX41Opz5Fc/ AoXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=R1myo23W; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz10si5019116ejb.167.2020.04.25.10.54.33; Sat, 25 Apr 2020 10:54:56 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=R1myo23W; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbgDYRxA (ORCPT + 99 others); Sat, 25 Apr 2020 13:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726061AbgDYRw7 (ORCPT ); Sat, 25 Apr 2020 13:52:59 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5823C09B04D for ; Sat, 25 Apr 2020 10:52:59 -0700 (PDT) Received: from zn.tnic (p200300EC2F2A1100B46A3E12B0A6AFFD.dip0.t-ipconnect.de [IPv6:2003:ec:2f2a:1100:b46a:3e12:b0a6:affd]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id D4BD71EC0CF3; Sat, 25 Apr 2020 19:52:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1587837177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=TpVMN9srSTRxzvdHGcL8+sKPNt7gpM//pRvQmGJNb+g=; b=R1myo23W52fNK5banUDGZAMqtoKEU/6DDqsccMiQpe/spVb9kuw+4clgkM6kJTQ4luTcjE uzvdFcE6YUUhVG3d5V+1sI9Tmua8HKBPjiQ7gREV6Hwe8YtF3IBCUgvz5V8OJC7itxgqx1 IsoJeTOOta5x06C5ENaQc8aSDwAfBI0= Date: Sat, 25 Apr 2020 19:52:49 +0200 From: Borislav Petkov To: Arvind Sankar Cc: Nick Desaulniers , Michael Matz , Jakub Jelinek , Sergei Trofimovich , LKML , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , x86@kernel.org, clang-built-linux , Kees Cook , Martin =?utf-8?B?TGnFoWth?= , =?utf-8?Q?Fr=C3=A9d=C3=A9ric_Pierret_=28fepitre=29?= , boris.ostrovsky@oracle.com, jgross@suse.com, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Subject: Re: [PATCH] x86: Fix early boot crash on gcc-10, next try Message-ID: <20200425175249.GC24294@zn.tnic> References: <20200422192113.GG26846@zn.tnic> <20200422212605.GI26846@zn.tnic> <20200423125300.GC26021@zn.tnic> <20200423161126.GD26021@zn.tnic> <20200425014657.GA2191784@rani.riverdale.lan> <20200425085759.GA24294@zn.tnic> <20200425150440.GA470719@rani.riverdale.lan> <20200425173140.GB24294@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200425173140.GB24294@zn.tnic> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 25, 2020 at 07:31:40PM +0200, Borislav Petkov wrote: > Hmm, that's what I was afraid of - having to sprinkle this around. Yah, let's > wait for compiler guys to have a look here and then maybe I'll convert that > thing to a macro called > > compiler_prevent_tail_call_opt() > > or so, so that it can be sprinkled around. ;-\ IOW, something like this (ontop) which takes care of the xen case too. If it needs to be used by all arches, then I'll split the patch: --- diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 73bf8450afa1..4f275ac7830b 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -273,7 +273,7 @@ static void notrace start_secondary(void *unused) * boot_init_stack_canary() and must not be checked before tail calling * another function. */ - asm (""); + prevent_tail_call_optimization(); } /** diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c index 8fb8a50a28b4..f2adb63b2d7c 100644 --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -93,6 +93,7 @@ asmlinkage __visible void cpu_bringup_and_idle(void) cpu_bringup(); boot_init_stack_canary(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); + prevent_tail_call_optimization(); } void xen_smp_intr_free_pv(unsigned int cpu) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 034b0a644efc..73f889f64513 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -356,4 +356,7 @@ static inline void *offset_to_ptr(const int *off) /* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) + +#define prevent_tail_call_optimization() asm("") + #endif /* __LINUX_COMPILER_H */ -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette