diff options
Diffstat (limited to 'recipes-kernel/linux/linux-intel/x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch')
-rw-r--r-- | recipes-kernel/linux/linux-intel/x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-intel/x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/recipes-kernel/linux/linux-intel/x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch new file mode 100644 index 00000000..3cd07c0a --- /dev/null +++ b/recipes-kernel/linux/linux-intel/x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch | |||
@@ -0,0 +1,125 @@ | |||
1 | From 5e6dca82bcaa49348f9e5fcb48df4881f6d6c4ae Mon Sep 17 00:00:00 2001 | ||
2 | From: Nick Desaulniers <ndesaulniers@google.com> | ||
3 | Date: Tue, 12 Jan 2021 11:46:24 -0800 | ||
4 | Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk | ||
5 | |||
6 | Arnd found a randconfig that produces the warning: | ||
7 | |||
8 | arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at | ||
9 | offset 0x3e | ||
10 | |||
11 | when building with LLVM_IAS=1 (Clang's integrated assembler). Josh | ||
12 | notes: | ||
13 | |||
14 | With the LLVM assembler not generating section symbols, objtool has no | ||
15 | way to reference this code when it generates ORC unwinder entries, | ||
16 | because this code is outside of any ELF function. | ||
17 | |||
18 | The limitation now being imposed by objtool is that all code must be | ||
19 | contained in an ELF symbol. And .L symbols don't create such symbols. | ||
20 | |||
21 | So basically, you can use an .L symbol *inside* a function or a code | ||
22 | segment, you just can't use the .L symbol to contain the code using a | ||
23 | SYM_*_START/END annotation pair. | ||
24 | |||
25 | Fangrui notes that this optimization is helpful for reducing image size | ||
26 | when compiling with -ffunction-sections and -fdata-sections. I have | ||
27 | observed on the order of tens of thousands of symbols for the kernel | ||
28 | images built with those flags. | ||
29 | |||
30 | A patch has been authored against GNU binutils to match this behavior | ||
31 | of not generating unused section symbols ([1]), so this will | ||
32 | also become a problem for users of GNU binutils once they upgrade to 2.36. | ||
33 | |||
34 | Omit the .L prefix on a label so that the assembler will emit an entry | ||
35 | into the symbol table for the label, with STB_LOCAL binding. This | ||
36 | enables objtool to generate proper unwind info here with LLVM_IAS=1 or | ||
37 | GNU binutils 2.36+. | ||
38 | |||
39 | [ bp: Massage commit message. ] | ||
40 | |||
41 | Reported-by: Arnd Bergmann <arnd@arndb.de> | ||
42 | Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com> | ||
43 | Suggested-by: Borislav Petkov <bp@alien8.de> | ||
44 | Suggested-by: Mark Brown <broonie@kernel.org> | ||
45 | Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> | ||
46 | Signed-off-by: Borislav Petkov <bp@suse.de> | ||
47 | Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> | ||
48 | Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> | ||
49 | Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com | ||
50 | Link: https://github.com/ClangBuiltLinux/linux/issues/1209 | ||
51 | Link: https://reviews.llvm.org/D93783 | ||
52 | Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html | ||
53 | Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1] | ||
54 | |||
55 | Upstream-Status: Backport | ||
56 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> | ||
57 | --- | ||
58 | Documentation/asm-annotations.rst | 5 +++++ | ||
59 | arch/x86/entry/thunk_64.S | 8 ++++---- | ||
60 | include/linux/linkage.h | 5 +++++ | ||
61 | 3 files changed, 14 insertions(+), 4 deletions(-) | ||
62 | |||
63 | diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst | ||
64 | index 32ea57483378d..76424e0431f4b 100644 | ||
65 | --- a/Documentation/asm-annotations.rst | ||
66 | +++ b/Documentation/asm-annotations.rst | ||
67 | @@ -100,6 +100,11 @@ Instruction Macros | ||
68 | ~~~~~~~~~~~~~~~~~~ | ||
69 | This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above. | ||
70 | |||
71 | +``objtool`` requires that all code must be contained in an ELF symbol. Symbol | ||
72 | +names that have a ``.L`` prefix do not emit symbol table entries. ``.L`` | ||
73 | +prefixed symbols can be used within a code region, but should be avoided for | ||
74 | +denoting a range of code via ``SYM_*_START/END`` annotations. | ||
75 | + | ||
76 | * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the | ||
77 | most frequent markings**. They are used for functions with standard calling | ||
78 | conventions -- global and local. Like in C, they both align the functions to | ||
79 | diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S | ||
80 | index ccd32877a3c41..c9a9fbf1655f3 100644 | ||
81 | --- a/arch/x86/entry/thunk_64.S | ||
82 | +++ b/arch/x86/entry/thunk_64.S | ||
83 | @@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name) | ||
84 | .endif | ||
85 | |||
86 | call \func | ||
87 | - jmp .L_restore | ||
88 | + jmp __thunk_restore | ||
89 | SYM_FUNC_END(\name) | ||
90 | _ASM_NOKPROBE(\name) | ||
91 | .endm | ||
92 | @@ -44,7 +44,7 @@ SYM_FUNC_END(\name) | ||
93 | #endif | ||
94 | |||
95 | #ifdef CONFIG_PREEMPTION | ||
96 | -SYM_CODE_START_LOCAL_NOALIGN(.L_restore) | ||
97 | +SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore) | ||
98 | popq %r11 | ||
99 | popq %r10 | ||
100 | popq %r9 | ||
101 | @@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore) | ||
102 | popq %rdi | ||
103 | popq %rbp | ||
104 | ret | ||
105 | - _ASM_NOKPROBE(.L_restore) | ||
106 | -SYM_CODE_END(.L_restore) | ||
107 | + _ASM_NOKPROBE(__thunk_restore) | ||
108 | +SYM_CODE_END(__thunk_restore) | ||
109 | #endif | ||
110 | diff --git a/include/linux/linkage.h b/include/linux/linkage.h | ||
111 | index 5bcfbd972e970..dbf8506decca0 100644 | ||
112 | --- a/include/linux/linkage.h | ||
113 | +++ b/include/linux/linkage.h | ||
114 | @@ -178,6 +178,11 @@ | ||
115 | * Objtool generates debug info for both FUNC & CODE, but needs special | ||
116 | * annotations for each CODE's start (to describe the actual stack frame). | ||
117 | * | ||
118 | + * Objtool requires that all code must be contained in an ELF symbol. Symbol | ||
119 | + * names that have a .L prefix do not emit symbol table entries. .L | ||
120 | + * prefixed symbols can be used within a code region, but should be avoided for | ||
121 | + * denoting a range of code via ``SYM_*_START/END`` annotations. | ||
122 | + * | ||
123 | * ALIAS -- does not generate debug info -- the aliased function will | ||
124 | */ | ||
125 | |||