public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@linux.intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <andi@firstfloor.org>,
	x86@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [PATCH 02/17] x86, lto: Mark all top level asm statements as .text
Date: Wed, 27 Mar 2019 07:59:18 -0700	[thread overview]
Message-ID: <20190327145918.GU18020@tassilo.jf.intel.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1903270820530.1789@nanos.tec.linutronix.de>

On Wed, Mar 27, 2019 at 03:20:08PM +0100, Thomas Gleixner wrote:
> +void __init foo(void)
> +{
> +       pr_info("foo\n");
> +}
> 
> right before the kretprobe_trampoline and compiling it with GCC 6.
> 
> So one would assume that kretprobe_trampoline now ends up in
> .init.text. But it ends up in the .text section because it's reordered and
> ends up at the top of .text.

You would see the breakage with -fno-toplevel-reorder

> We also need a way to detect such wreckage automatically. This can happen
> again and as the GCC behaviour is random there is no guarantee that it's
> noticed right away. Josh, can objtool help here or do we need some other
> form of checking that?

It would surprise me if objtool could do it generally because the toplevel
assembler could be anything and may not be distinguishable from
C code. I guess it could catch cases of code ending up in initdata,
but it probably wouldn't work for inittext, which could happen too.

Code review is enough hopefully? Just every top level asm needs
a section.

> Because it is NOT text.

Makes sense.

I guess module loading needs it, otherwise it could just be initdata.

> But that's not the only thing which is wrong here. DEF_NATIVE is only used
> in paravirt_patch_32/64.c and the resulting labels are not used outside of
> this either. So why are these labels global and the c declaration __visible
> extern?

LTO needs any C symbols that are referenced from assembler to be global
and visible because the asm statement could end up in a different
assembler file. This is a different issue from the section
problem.

> This clearly shows that it was never analyzed proper and even the current
> patch lacks any form of proper root cause analysis as the "changelog"
> clearly shows:

This wasn't because of the section problem, just the orthogonal 
file reordering problem described above. Given the changelogs could have
been better.  But the root cause is/was clear.

> --- a/arch/x86/include/asm/paravirt_types.h
> +++ b/arch/x86/include/asm/paravirt_types.h
> @@ -367,11 +367,15 @@ extern struct paravirt_patch_template pv
>  	_paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
>  
>  /* Simple instruction patching code. */
> -#define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t"
> +#define NATIVE_LABEL(a,x,b) "\n" a #x "_" #b ":\n\t"
>  
>  #define DEF_NATIVE(ops, name, code)					\
> -	__visible extern const char start_##ops##_##name[], end_##ops##_##name[];	\
> -	asm(NATIVE_LABEL("start_", ops, name) code NATIVE_LABEL("end_", ops, name))
> +	static const char start_##ops##_##name[], end_##ops##_##name[]; \

Please don't apply the static/__visible removal hunk, I will just need to
revert it again for LTO.

> +	asm(".pushsection .rodata, \"a\"\n"				\
> +	    NATIVE_LABEL("start_", ops, name)				\
> +	    code							\
> +	    NATIVE_LABEL("end_", ops, name)				\
> +	    ".popsection\n")

That part looks good.


-Andi


  parent reply	other threads:[~2019-03-27 14:59 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 21:59 Fixes and cleanup from LTO tree Andi Kleen
2019-03-21 21:59 ` [PATCH 01/17] kbuild: Disable -Waddress-of-packed-member for gcc 9 Andi Kleen
2019-03-22 13:58   ` Arnd Bergmann
2019-03-22 16:31     ` Andi Kleen
2019-03-22 16:39     ` Peter Zijlstra
2019-03-22 16:57       ` Arnd Bergmann
2019-03-22 16:58       ` Andi Kleen
2019-03-25 16:27         ` David Laight
2019-04-01  1:04     ` Masahiro Yamada
2019-03-21 21:59 ` [PATCH 02/17] x86, lto: Mark all top level asm statements as .text Andi Kleen
2019-03-26 17:03   ` Thomas Gleixner
2019-03-26 21:38     ` Andi Kleen
2019-03-26 22:25       ` Thomas Gleixner
2019-03-27  0:55         ` Andi Kleen
2019-03-27  1:08           ` Andi Kleen
2019-03-27 14:20           ` Thomas Gleixner
2019-03-27 14:39             ` Ingo Molnar
2019-03-27 14:59             ` Andi Kleen [this message]
2019-03-27 15:08               ` Thomas Gleixner
2019-03-27 15:45                 ` Andi Kleen
2019-03-27 19:08                   ` Thomas Gleixner
2019-03-27 20:40                     ` Andi Kleen
2019-03-27 21:55                       ` Thomas Gleixner
2019-03-27 22:29                         ` Andi Kleen
2019-03-27 22:50                           ` Thomas Gleixner
2019-04-02  8:54                             ` Thomas Gleixner
2019-03-21 21:59 ` [PATCH 03/17] x86: Don't inline __const_udelay Andi Kleen
2019-03-21 21:59 ` [PATCH 04/17] init: Add __noreorder and mark initcalls __noreorder Andi Kleen
2019-03-21 21:59 ` [PATCH 05/17] Use C version for SYSCALL_ALIAS Andi Kleen
2019-03-21 21:59 ` [PATCH 06/17] locking/core: Mark spinlocks noinline when inline spinlocks are disabled Andi Kleen
2019-03-21 21:59 ` [PATCH 07/17] amdkfd: Fix extern declaration Andi Kleen
2019-03-21 22:00 ` [PATCH 08/17] x86/speculation: Fix __initconst in bugs.c Andi Kleen
2019-03-26 17:24   ` Thomas Gleixner
2019-03-21 22:00 ` [PATCH 09/17] x86/kvm: Make steal_time visible Andi Kleen
2019-03-21 22:00 ` [PATCH 10/17] delta: Fix buffer overrun in delta_ipc_open Andi Kleen
2019-04-01 13:37   ` Hugues FRUCHET
2019-04-01 16:54     ` Andi Kleen
2019-04-02  9:56       ` Hugues FRUCHET
2019-03-21 22:00 ` [PATCH 11/17] x86/kprobes: Make trampoline_handler global and visible Andi Kleen
2019-03-23  9:45   ` Masami Hiramatsu
2019-03-23 14:35     ` Andi Kleen
2019-03-25  1:53       ` Masami Hiramatsu
2019-03-21 22:00 ` [PATCH 12/17] afs: Avoid section confusion in CM_NAME Andi Kleen
2019-03-22  8:34   ` David Howells
2019-03-21 22:00 ` [PATCH 13/17] ASoC: AMD: Fix incorrect extern Andi Kleen
2019-03-21 22:00 ` [PATCH 14/17] crypto: Don't mark AES tables const and cacheline_aligned Andi Kleen
2019-03-26  8:42   ` Rasmus Villemoes
2019-03-26 18:30     ` Andi Kleen
2019-03-21 22:00 ` [PATCH 15/17] x86/hyperv: Make hv_vcpu_is_preempted visible Andi Kleen
2019-03-26  8:15   ` Yi Sun
2019-03-21 22:00 ` [PATCH 16/17] x86/xen: Mark xen_vcpu_stolen as __visible Andi Kleen
2019-03-21 22:00 ` [PATCH 17/17] dm: Fix const confusion in dm Andi Kleen
2019-03-26 17:00 ` Fixes and cleanup from LTO tree Thomas Gleixner

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=20190327145918.GU18020@tassilo.jf.intel.com \
    --to=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.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