WSL2-Linux-Kernel/arch/x86/lib
Petr Pavlu 55f1cbeaa1 x86/retpoline,kprobes: Fix position of thunk sections with CONFIG_LTO_CLANG
commit 79cd2a1122 upstream.

The linker script arch/x86/kernel/vmlinux.lds.S matches the thunk
sections ".text.__x86.*" from arch/x86/lib/retpoline.S as follows:

  .text {
    [...]
    TEXT_TEXT
    [...]
    __indirect_thunk_start = .;
    *(.text.__x86.*)
    __indirect_thunk_end = .;
    [...]
  }

Macro TEXT_TEXT references TEXT_MAIN which normally expands to only
".text". However, with CONFIG_LTO_CLANG, TEXT_MAIN becomes
".text .text.[0-9a-zA-Z_]*" which wrongly matches also the thunk
sections. The output layout is then different than expected. For
instance, the currently defined range [__indirect_thunk_start,
__indirect_thunk_end] becomes empty.

Prevent the problem by using ".." as the first separator, for example,
".text..__x86.indirect_thunk". This pattern is utilized by other
explicit section names which start with one of the standard prefixes,
such as ".text" or ".data", and that need to be individually selected in
the linker script.

  [ nathan: Fix conflicts with SRSO and fold in fix issue brought up by
    Andrew Cooper in post-review:
    https://lore.kernel.org/20230803230323.1478869-1-andrew.cooper3@citrix.com ]

Fixes: dc5723b02e ("kbuild: add support for Clang LTO")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20230711091952.27944-2-petr.pavlu@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-26 14:23:40 +02:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Makefile x86: Add support for 0x22/0x23 port I/O configuration space 2021-08-10 23:31:43 +02:00
atomic64_32.c x86: Adjust asm constraints in atomic64 wrappers 2012-01-20 17:29:31 -08:00
atomic64_386_32.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
atomic64_cx8_32.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
cache-smp.c smp: Remove smp_call_function() and on_each_cpu() return values 2019-06-23 14:26:26 +02:00
checksum_32.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
clear_page_64.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
cmdline.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cmpxchg8b_emu.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
cmpxchg16b_emu.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
copy_mc.c x86, libnvdimm/test: Remove COPY_MC_TEST 2020-10-26 18:08:35 +01:00
copy_mc_64.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
copy_page_64.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
copy_user_64.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
cpu.c x86/lib/cpu: Address missing prototypes warning 2019-08-08 08:25:53 +02:00
csum-copy_64.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
csum-partial_64.c x86/lib: Fix indentation issue, remove extra tab 2019-03-21 12:24:38 +01:00
csum-wrappers_64.c amd64: switch csum_partial_copy_generic() to new calling conventions 2020-08-20 15:45:22 -04:00
delay.c x86/delay: Fix the wrong asm constraint in delay_loop() 2022-06-09 10:22:45 +02:00
error-inject.c x86: Prepare inline-asm for straight-line-speculation 2022-05-15 20:18:50 +02:00
getuser.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
hweight.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
inat.c x86/insn: Add a __ignore_sync_check__ marker 2021-03-15 11:00:57 +01:00
insn-eval.c x86/entry_32: Fix segment exceptions 2022-07-29 17:25:33 +02:00
insn.c x86/insn: Use get_unaligned() instead of memcpy() 2021-11-18 19:16:30 +01:00
iomap_copy_64.S x86/asm: Fix an assembler warning with current binutils 2023-01-24 07:22:42 +01:00
iomem.c x86: explicitly align IO accesses in memcpy_{to,from}io 2019-02-01 09:07:48 -08:00
kaslr.c x86/kaslr: Fix incorrect i8254 outb() parameters 2019-01-11 21:35:47 +01:00
memcpy_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
memcpy_64.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
memmove_64.S x86: Use return-thunk in asm code 2022-07-23 12:54:00 +02:00
memset_64.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
misc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mmx_32.c x86: Fix various typos in comments 2021-03-18 15:31:53 +01:00
msr-reg-export.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
msr-reg.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
msr-smp.c x86/msr: Fix wr/rdmsr_safe_regs_on_cpu() prototypes 2021-03-22 21:37:03 +01:00
msr.c x86/msr: Make locally used functions static 2021-04-08 11:57:40 +02:00
pc-conf-reg.c x86: Add support for 0x22/0x23 port I/O configuration space 2021-08-10 23:31:43 +02:00
putuser.S x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
retpoline.S x86/retpoline,kprobes: Fix position of thunk sections with CONFIG_LTO_CLANG 2023-08-26 14:23:40 +02:00
string_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
strstr_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
usercopy.c x86/uaccess: Document copy_from_user_nmi() 2020-11-18 13:19:01 +01:00
usercopy_32.c docs/core-api/mm: fix user memory accessors formatting 2019-03-05 21:07:20 -08:00
usercopy_64.c x86: __memcpy_flushcache: fix wrong alignment if size > 2^32 2022-05-09 09:14:40 +02:00
x86-opcode-map.txt x86/insn: Add Control-flow Enforcement (CET) instructions to the opcode map 2020-03-26 12:21:40 +01:00