From f95f4e4bdf749bffdda0f56cd52535e871b06c5a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 23 Jul 2022 11:48:27 +0200 Subject: [PATCH] 5.10-stable patches added patches: kvm-fix-objtool-relocation-warning.patch objtool-fix-elf_create_undef_symbol-endianness.patch tools-arch-update-arch-x86-lib-mem-cpy-set-_64.s-copies-used-in-perf-bench-mem-memcpy-again.patch tools-headers-remove-broken-definition-of-__little_endian.patch --- .../kvm-fix-objtool-relocation-warning.patch | 61 ++++++++++++++ ...x-elf_create_undef_symbol-endianness.patch | 36 ++++++++ queue-5.10/series | 4 + ...-used-in-perf-bench-mem-memcpy-again.patch | 83 +++++++++++++++++++ ...broken-definition-of-__little_endian.patch | 51 ++++++++++++ 5 files changed, 235 insertions(+) create mode 100644 queue-5.10/kvm-fix-objtool-relocation-warning.patch create mode 100644 queue-5.10/objtool-fix-elf_create_undef_symbol-endianness.patch create mode 100644 queue-5.10/tools-arch-update-arch-x86-lib-mem-cpy-set-_64.s-copies-used-in-perf-bench-mem-memcpy-again.patch create mode 100644 queue-5.10/tools-headers-remove-broken-definition-of-__little_endian.patch diff --git a/queue-5.10/kvm-fix-objtool-relocation-warning.patch b/queue-5.10/kvm-fix-objtool-relocation-warning.patch new file mode 100644 index 00000000000..ce87ac3a6d0 --- /dev/null +++ b/queue-5.10/kvm-fix-objtool-relocation-warning.patch @@ -0,0 +1,61 @@ +From 291073a566b2094c7192872cc0f17ce73d83cb76 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Sun, 3 Oct 2021 13:34:19 -0700 +Subject: kvm: fix objtool relocation warning + +From: Linus Torvalds + +commit 291073a566b2094c7192872cc0f17ce73d83cb76 upstream. + +The recent change to make objtool aware of more symbol relocation types +(commit 24ff65257375: "objtool: Teach get_alt_entry() about more +relocation types") also added another check, and resulted in this +objtool warning when building kvm on x86: + + arch/x86/kvm/emulate.o: warning: objtool: __ex_table+0x4: don't know how to handle reloc symbol type: kvm_fastop_exception + +The reason seems to be that kvm_fastop_exception() is marked as a global +symbol, which causes the relocation to ke kept around for objtool. And +at the same time, the kvm_fastop_exception definition (which is done as +an inline asm statement) doesn't actually set the type of the global, +which then makes objtool unhappy. + +The minimal fix is to just not mark kvm_fastop_exception as being a +global symbol. It's only used in that one compilation unit anyway, so +it was always pointless. That's how all the other local exception table +labels are done. + +I'm not entirely happy about the kinds of games that the kvm code plays +with doing its own exception handling, and the fact that it confused +objtool is most definitely a symptom of the code being a bit too subtle +and ad-hoc. But at least this trivial one-liner makes objtool no longer +upset about what is going on. + +Fixes: 24ff65257375 ("objtool: Teach get_alt_entry() about more relocation types") +Link: https://lore.kernel.org/lkml/CAHk-=wiZwq-0LknKhXN4M+T8jbxn_2i9mcKpO+OaBSSq_Eh7tg@mail.gmail.com/ +Cc: Borislav Petkov +Cc: Paolo Bonzini +Cc: Sean Christopherson +Cc: Vitaly Kuznetsov +Cc: Wanpeng Li +Cc: Jim Mattson +Cc: Joerg Roedel +Cc: Peter Zijlstra +Cc: Josh Poimboeuf +Cc: Nathan Chancellor +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/kvm/emulate.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/arch/x86/kvm/emulate.c ++++ b/arch/x86/kvm/emulate.c +@@ -452,7 +452,6 @@ static int fastop(struct x86_emulate_ctx + ".skip " __stringify(SETCC_ALIGN) " - (.-" #op "), 0xcc \n\t" + + asm(".pushsection .fixup, \"ax\"\n" +- ".global kvm_fastop_exception \n" + "kvm_fastop_exception: xor %esi, %esi; " ASM_RET + ".popsection"); + diff --git a/queue-5.10/objtool-fix-elf_create_undef_symbol-endianness.patch b/queue-5.10/objtool-fix-elf_create_undef_symbol-endianness.patch new file mode 100644 index 00000000000..ee1fa95f451 --- /dev/null +++ b/queue-5.10/objtool-fix-elf_create_undef_symbol-endianness.patch @@ -0,0 +1,36 @@ +From 46c7405df7de8deb97229eacebcee96d61415f3f Mon Sep 17 00:00:00 2001 +From: Vasily Gorbik +Date: Wed, 12 May 2021 19:42:10 +0200 +Subject: objtool: Fix elf_create_undef_symbol() endianness + +From: Vasily Gorbik + +commit 46c7405df7de8deb97229eacebcee96d61415f3f upstream. + +Currently x86 cross-compilation fails on big endian system with: + + x86_64-cross-ld: init/main.o: invalid string offset 488112128 >= 6229 for section `.strtab' + +Mark new ELF data in elf_create_undef_symbol() as symbol, so that libelf +does endianness handling correctly. + +Fixes: 2f2f7e47f052 ("objtool: Add elf_create_undef_symbol()") +Signed-off-by: Vasily Gorbik +Signed-off-by: Ingo Molnar +Acked-by: Peter Zijlstra +Link: https://lore.kernel.org/r/patch-1.thread-6c9df9.git-d39264656387.your-ad-here.call-01620841104-ext-2554@work.hours +Signed-off-by: Greg Kroah-Hartman +--- + tools/objtool/elf.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/tools/objtool/elf.c ++++ b/tools/objtool/elf.c +@@ -961,6 +961,7 @@ static int elf_add_string(struct elf *el + data->d_buf = str; + data->d_size = strlen(str) + 1; + data->d_align = 1; ++ data->d_type = ELF_T_SYM; + + len = strtab->len; + strtab->len += data->d_size; diff --git a/queue-5.10/series b/queue-5.10/series index 06aac5d57cc..19c99cc70e7 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -142,3 +142,7 @@ tools-headers-cpufeatures-sync-with-the-kernel-sources.patch x86-bugs-remove-apostrophe-typo.patch um-add-missing-apply_returns.patch x86-use-mindirect-branch-cs-prefix-for-retpoline-builds.patch +kvm-fix-objtool-relocation-warning.patch +objtool-fix-elf_create_undef_symbol-endianness.patch +tools-arch-update-arch-x86-lib-mem-cpy-set-_64.s-copies-used-in-perf-bench-mem-memcpy-again.patch +tools-headers-remove-broken-definition-of-__little_endian.patch diff --git a/queue-5.10/tools-arch-update-arch-x86-lib-mem-cpy-set-_64.s-copies-used-in-perf-bench-mem-memcpy-again.patch b/queue-5.10/tools-arch-update-arch-x86-lib-mem-cpy-set-_64.s-copies-used-in-perf-bench-mem-memcpy-again.patch new file mode 100644 index 00000000000..5324a289d11 --- /dev/null +++ b/queue-5.10/tools-arch-update-arch-x86-lib-mem-cpy-set-_64.s-copies-used-in-perf-bench-mem-memcpy-again.patch @@ -0,0 +1,83 @@ +From fb24e308b6310541e70d11a3f19dc40742974b95 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Sun, 9 May 2021 10:19:37 -0300 +Subject: tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in 'perf bench mem memcpy' - again + +From: Arnaldo Carvalho de Melo + +commit fb24e308b6310541e70d11a3f19dc40742974b95 upstream. + +To bring in the change made in this cset: + + 5e21a3ecad1500e3 ("x86/alternative: Merge include files") + +This just silences these perf tools build warnings, no change in the tools: + + Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S' + diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S + Warning: Kernel ABI header at 'tools/arch/x86/lib/memset_64.S' differs from latest version at 'arch/x86/lib/memset_64.S' + diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S + +Cc: Borislav Petkov +Cc: Juergen Gross +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman +--- + tools/arch/x86/lib/memcpy_64.S | 2 +- + tools/arch/x86/lib/memset_64.S | 2 +- + tools/include/asm/{alternative-asm.h => alternative.h} | 0 + tools/arch/x86/lib/memcpy_64.S | 2 +- + tools/arch/x86/lib/memset_64.S | 2 +- + tools/include/asm/alternative-asm.h | 10 ---------- + tools/include/asm/alternative.h | 10 ++++++++++ + 4 files changed, 12 insertions(+), 12 deletions(-) + rename tools/include/asm/{alternative-asm.h => alternative.h} (100%) + +--- a/tools/arch/x86/lib/memcpy_64.S ++++ b/tools/arch/x86/lib/memcpy_64.S +@@ -4,7 +4,7 @@ + #include + #include + #include +-#include ++#include + #include + + .pushsection .noinstr.text, "ax" +--- a/tools/arch/x86/lib/memset_64.S ++++ b/tools/arch/x86/lib/memset_64.S +@@ -3,7 +3,7 @@ + + #include + #include +-#include ++#include + #include + + /* +--- a/tools/include/asm/alternative-asm.h ++++ /dev/null +@@ -1,10 +0,0 @@ +-/* SPDX-License-Identifier: GPL-2.0 */ +-#ifndef _TOOLS_ASM_ALTERNATIVE_ASM_H +-#define _TOOLS_ASM_ALTERNATIVE_ASM_H +- +-/* Just disable it so we can build arch/x86/lib/memcpy_64.S for perf bench: */ +- +-#define altinstruction_entry # +-#define ALTERNATIVE_2 # +- +-#endif +--- /dev/null ++++ b/tools/include/asm/alternative.h +@@ -0,0 +1,10 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++#ifndef _TOOLS_ASM_ALTERNATIVE_ASM_H ++#define _TOOLS_ASM_ALTERNATIVE_ASM_H ++ ++/* Just disable it so we can build arch/x86/lib/memcpy_64.S for perf bench: */ ++ ++#define altinstruction_entry # ++#define ALTERNATIVE_2 # ++ ++#endif diff --git a/queue-5.10/tools-headers-remove-broken-definition-of-__little_endian.patch b/queue-5.10/tools-headers-remove-broken-definition-of-__little_endian.patch new file mode 100644 index 00000000000..48a28561660 --- /dev/null +++ b/queue-5.10/tools-headers-remove-broken-definition-of-__little_endian.patch @@ -0,0 +1,51 @@ +From fa2c02e5798c17c89cbb3135940086ebe07e5c9f Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Wed, 14 Jul 2021 14:28:02 -0300 +Subject: tools headers: Remove broken definition of __LITTLE_ENDIAN + +From: Arnaldo Carvalho de Melo + +commit fa2c02e5798c17c89cbb3135940086ebe07e5c9f upstream. + +The linux/kconfig.h file was copied from the kernel but the line where +with the generated/autoconf.h include from where the CONFIG_ entries +would come from was deleted, as tools/ build system don't create that +file, so we ended up always defining just __LITTLE_ENDIAN as +CONFIG_CPU_BIG_ENDIAN was nowhere to be found. + +This in turn ended up breaking the build in some systems where +__LITTLE_ENDIAN was already defined, such as the androind NDK. + +So just ditch that block that depends on the CONFIG_CPU_BIG_ENDIAN +define. + +The kconfig.h file was copied just to get IS_ENABLED() and a +'make -C tools/all' doesn't breaks with this removal. + +Fixes: 93281c4a96572a34 ("x86/insn: Add an insn_decode() API") +Cc: Adrian Hunter +Cc: Borislav Petkov +Cc: Jiri Olsa +Cc: Namhyung Kim +Link: http://lore.kernel.org/lkml/YO8hK7lqJcIWuBzx@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman +--- + tools/include/linux/kconfig.h | 6 ------ + 1 file changed, 6 deletions(-) + +--- a/tools/include/linux/kconfig.h ++++ b/tools/include/linux/kconfig.h +@@ -4,12 +4,6 @@ + + /* CONFIG_CC_VERSION_TEXT (Do not delete this comment. See help in Kconfig) */ + +-#ifdef CONFIG_CPU_BIG_ENDIAN +-#define __BIG_ENDIAN 4321 +-#else +-#define __LITTLE_ENDIAN 1234 +-#endif +- + #define __ARG_PLACEHOLDER_1 0, + #define __take_second_arg(__ignored, val, ...) val + -- 2.47.3