linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: "Jakub Jelinek" <jakub@redhat.com>,
	jgross@suse.com, x86@kernel.org,
	"Kees Cook" <keescook@chromium.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	linuxppc-dev@lists.ozlabs.org, "Michael Matz" <matz@suse.de>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Sergei Trofimovich" <slyfox@gentoo.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Paul Mackerras" <paulus@samba.org>,
	"Andy Lutomirski" <luto@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Frédéric Pierret (fepitre)" <frederic.pierret@qubes-os.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Martin Liška" <mliska@suse.cz>,
	boris.ostrovsky@oracle.com
Subject: Re: [PATCH] x86: Fix early boot crash on gcc-10, next try
Date: Sat, 25 Apr 2020 19:52:49 +0200	[thread overview]
Message-ID: <20200425175249.GC24294@zn.tnic> (raw)
In-Reply-To: <20200425173140.GB24294@zn.tnic>

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

  reply	other threads:[~2020-04-25 17:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200422102309.GA26846@zn.tnic>
     [not found] ` <CAKwvOd=Dza3UBfeUzs2RW6ko5fDr3jYeGQAYpJXqyEVns6DJHg@mail.gmail.com>
     [not found]   ` <20200422192113.GG26846@zn.tnic>
     [not found]     ` <CAKwvOdkbcO8RzoafON2mGiSy5P96P5+aY8GySysF2my7q+nTqw@mail.gmail.com>
     [not found]       ` <20200422212605.GI26846@zn.tnic>
     [not found]         ` <CAKwvOd=exxhfb8N6=1Q=wBUaYcRDEq3L1+TiHDLz+pxWg8OuwQ@mail.gmail.com>
     [not found]           ` <20200423125300.GC26021@zn.tnic>
     [not found]             ` <20200423161126.GD26021@zn.tnic>
     [not found]               ` <20200425014657.GA2191784@rani.riverdale.lan>
     [not found]                 ` <20200425085759.GA24294@zn.tnic>
2020-04-25 15:04                   ` [PATCH] x86: Fix early boot crash on gcc-10, next try Arvind Sankar
2020-04-25 17:31                     ` Borislav Petkov
2020-04-25 17:52                       ` Borislav Petkov [this message]
2020-04-27 17:07                         ` David Laight
2020-04-25 18:37                       ` Segher Boessenkool
2020-04-25 18:53                         ` Borislav Petkov
2020-04-25 19:15                           ` Segher Boessenkool
2020-04-25 22:17                             ` Borislav Petkov
2020-04-25 22:25                             ` Arvind Sankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200425175249.GC24294@zn.tnic \
    --to=bp@alien8.de \
    --cc=boris.ostrovsky@oracle.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=frederic.pierret@qubes-os.org \
    --cc=hpa@zytor.com \
    --cc=jakub@redhat.com \
    --cc=jgross@suse.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=luto@kernel.org \
    --cc=matz@suse.de \
    --cc=mingo@redhat.com \
    --cc=mliska@suse.cz \
    --cc=ndesaulniers@google.com \
    --cc=nivedita@alum.mit.edu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=slyfox@gentoo.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).