x86: Remove anonymous out-of-line fixups
Peter Zijlstra
maintainerv2 cover x86: Remove anonymous out-of-line fixups
Hi,
Direct counterpart to the arm64 series from Mark:
https://lkml.kernel.org/r/[email protected]
Since he already put it rather well:
"We recently realised that out-of-line extable fixups cause a number of problems for backtracing (mattering both for developers and for RELIABLE_STACKTRACE and LIVEPATCH). Dmitry spotted a confusing backtrace, which we identified was due to problems with unwinding fixups, as summarized in:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
The gist is that while backtracing through a fixup, the fixup gets symbolized as an offset from the nearest prior symbol (which happens to be __entry_tramp_text_end), and we the backtrace misses the function that was being fixed up (because the fixup handling adjusts the PC, then the fixup does a direct branch back to the original function). We can't reliably map from an arbitrary PC in the fixup text back to the original function.
The way we create fixups is a bit unfortunate: most fixups are generated from common templates, and only differ in register to be poked and the address to branch back to, leading to redundant copies of the same logic that must pollute Since the fixups are all written in assembly, and duplicated for each fixup site, we can only perform very simple fixups, and can't handle any complex triage that we might need for some exceptions (e.g. MTE faults)."
Also available here:
git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/wip.extable
Changes since v1:
- Dropped using __cold on labels, because clang. Also gcc doesn't actually generate different code with it. The intent was for the code to end up in .text.cold but that doesn't happen.
- Fixed the vmread constraints to disallow %0 == %1.
- Added a asm-goto-output variant to vmx's vmread implementation.
- Audited Xen and FPU code and converted them from -1 to -EFAULT, as a concequence EX_TYPE_NEG_REG no longer exists.
- Fixed the EX_DATA_*_MASK macros to include an explicit 'int' cast, such that FIELD_GET() will sign-extend the top field.
--- arch/x86/entry/entry_32.S | 28 ++----- arch/x86/entry/entry_64.S | 13 ++- arch/x86/entry/vdso/vdso-layout.lds.S | 1 - arch/x86/include/asm/asm.h | 33 ++++++++ arch/x86/include/asm/extable.h | 6 +- arch/x86/include/asm/extable_fixup_types.h | 50 ++++++++++-- arch/x86/include/asm/futex.h | 28 ++----- arch/x86/include/asm/insn-eval.h | 2 + arch/x86/include/asm/msr.h | 26 ++---- arch/x86/include/asm/segment.h | 9 +-- arch/x86/include/asm/sgx.h | 18 +++++ arch/x86/include/asm/uaccess.h | 39 ++++----- arch/x86/include/asm/word-at-a-time.h | 66 ++++++++++----- arch/x86/include/asm/xen/page.h | 14 +--- arch/x86/kernel/cpu/sgx/encls.h | 36 ++------- arch/x86/kernel/fpu/legacy.h | 6 +- arch/x86/kernel/fpu/xstate.h | 6 +- arch/x86/kernel/vmlinux.lds.S | 1 - arch/x86/kvm/emulate.c | 16 +--- arch/x86/kvm/vmx/vmx_ops.h | 43 +++++++--- arch/x86/lib/checksum_32.S | 19 +---- arch/x86/lib/copy_mc_64.S | 12 +-- arch/x86/lib/copy_user_64.S | 32 +++----- arch/x86/lib/insn-eval.c | 66 +++++++++------ arch/x86/lib/mmx_32.c | 86 +++++++------------- arch/x86/lib/usercopy_32.c | 66 ++++++--------- arch/x86/lib/usercopy_64.c | 8 +- arch/x86/mm/extable.c | 124 ++++++++++++++++++++++------- arch/x86/net/bpf_jit_comp.c | 2 +- include/linux/bitfield.h | 19 ++++- tools/objtool/check.c | 8 +- 31 files changed, 477 insertions(+), 406 deletions(-)
Peter Zijlstra
maintainerPATCH v2 1/23 bitfield.h: Fix "type of reg too small for mask" test
The test: 'mask > (typeof(_reg))~0ull' only works correctly when both sides are unsigned, consider:
- 0xff000000 vs (int)~0ull
- 0x000000ff vs (int)~0ull
--- include/linux/bitfield.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
include/linux/bitfield.h +18 -1
@@ -41,6 +41,22 @@#define __bf_shf (x) (__builtin_ffsll(x) - 1) +#define __scalar_type_to_unsigned_cases (type) \ + unsigned type: (unsigned type)0, \ + signed type: (unsigned type)0 + +#define __unsigned_scalar_typeof (x) typeof( \ + _Generic((x), \ + char: (unsigned char)0, \ + __scalar_type_to_unsigned_cases(char), \ + __scalar_type_to_unsigned_cases(short), \ + __scalar_type_to_unsigned_cases(int), \ + __scalar_type_to_unsigned_cases(long), \ + __scalar_type_to_unsigned_cases(long long), \ + default: (x))) + +#define __bf_cast_unsigned (type, x) ((__unsigned_scalar_typeof(type))(x)) +#define __BF_FIELD_CHECK (_mask, _reg, _val, _pfx) \ ({ \ BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \
@@ -49,7 +65,8 @@BUILD_BUG_ON_MSG (__builtin_constant_p (_val) ? \ ~((_mask) >>__bf_shf (_mask)) & (_val) :0 , \ _pfx"value too large for the field" ); \ -BUILD_BUG_ON_MSG ((_mask) > (typeof (_reg ))~0ull , \ +BUILD_BUG_ON_MSG (__bf_cast_unsigned (_mask, _mask) > \ +__bf_cast_unsigned (_reg, ~0ull ), \ _pfx"type of reg too small for mask" ); \__BUILD_BUG_ON_NOT_POWER_OF_2 ((_mask) + \ (1ULL <<__bf_shf (_mask))); \
[tip: x86/core] bitfield.h: Fix "type of reg too small for mask" test
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: bff8c3848e071d387d8b0784dc91fa49cd563774 Gitweb: https://git.kernel.org/tip/bff8c3848e071d387d8b0784dc91fa49cd563774 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:03 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:45 +01:00
bitfield.h: Fix "type of reg too small for mask" test
The test: 'mask > (typeof(_reg))~0ull' only works correctly when both sides are unsigned, consider:
- 0xff000000 vs (int)~0ull
- 0x000000ff vs (int)~0ull
--- include/linux/bitfield.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
include/linux/bitfield.h +18 -1
@@ -41,6 +41,22 @@#define __bf_shf (x) (__builtin_ffsll(x) - 1) +#define __scalar_type_to_unsigned_cases (type) \ + unsigned type: (unsigned type)0, \ + signed type: (unsigned type)0 + +#define __unsigned_scalar_typeof (x) typeof( \ + _Generic((x), \ + char: (unsigned char)0, \ + __scalar_type_to_unsigned_cases(char), \ + __scalar_type_to_unsigned_cases(short), \ + __scalar_type_to_unsigned_cases(int), \ + __scalar_type_to_unsigned_cases(long), \ + __scalar_type_to_unsigned_cases(long long), \ + default: (x))) + +#define __bf_cast_unsigned (type, x) ((__unsigned_scalar_typeof(type))(x)) +#define __BF_FIELD_CHECK (_mask, _reg, _val, _pfx) \ ({ \ BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \
@@ -49,7 +65,8 @@BUILD_BUG_ON_MSG (__builtin_constant_p (_val) ? \ ~((_mask) >>__bf_shf (_mask)) & (_val) :0 , \ _pfx"value too large for the field" ); \ -BUILD_BUG_ON_MSG ((_mask) > (typeof (_reg ))~0ull , \ +BUILD_BUG_ON_MSG (__bf_cast_unsigned (_mask, _mask) > \ +__bf_cast_unsigned (_reg, ~0ull ), \ _pfx"type of reg too small for mask" ); \__BUILD_BUG_ON_NOT_POWER_OF_2 ((_mask) + \ (1ULL <<__bf_shf (_mask))); \
Peter Zijlstra
maintainerPATCH v2 2/23 x86,mmx_32: Remove .fixup usage
In reply to Peter ZijlstraThis code puts an exception table entry on the PREFETCH instruction to overwrite it with a JMP.d8 when it triggers an exception. Except of course, our code is no longer writable, also SMP.
Replace it with ALTERNATIVE, the 'new' way of doing these things.
--- arch/x86/lib/mmx_32.c | 86 +++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 56 deletions(-)
arch/x86/lib/mmx_32.c +30 -56
@@ -50,23 +50,18 @@ void *_mmx_memcpy(void *to, const void *kernel_fpu_begin_mask (KFPU_387 ); __asm__ __volatile__ ( -"1: prefetch (%0)\n" /* This set is 28 bytes */ -" prefetch 64(%0)\n" -" prefetch 128(%0)\n" -" prefetch 192(%0)\n" -" prefetch 256(%0)\n" -"2: \n" -".section .fixup, \"ax\"\n" -"3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */ -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) - : : "r" (from)); + ALTERNATIVE "", + "prefetch (%0)\n" + "prefetch 64(%0)\n" + "prefetch 128(%0)\n" + "prefetch 192(%0)\n" + "prefetch 256(%0)\n", X86_FEATURE_3DNOWPREFETCH + : : "r" (from));for ( ; i >5 ; i--) { __asm__ __volatile__ ( -"1: prefetch 320(%0)\n" -"2: movq (%0), %%mm0\n" + ALTERNATIVE "", "prefetch 320(%0)\n", X86_FEATURE_3DNOWPREFETCH +" movq (%0), %%mm0\n" " movq 8(%0), %%mm1\n" " movq 16(%0), %%mm2\n" " movq 24(%0), %%mm3\n"
@@ -82,11 +77,6 @@ void *_mmx_memcpy(void *to, const void * " movq %%mm1, 40(%1)\n" " movq %%mm2, 48(%1)\n" " movq %%mm3, 56(%1)\n" -".section .fixup, \"ax\"\n" -"3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */ -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b ,3b ) : : "r" (from), "r" (to) : "memory"); from +=64 ;
@@ -177,22 +167,18 @@ static void fast_copy_page(void *to, voi* but that is for later. -AV */ __asm__ __volatile__( -"1: prefetch (%0)\n" -" prefetch 64(%0)\n" -" prefetch 128(%0)\n" -" prefetch 192(%0)\n" -" prefetch 256(%0)\n" -"2: \n" -".section .fixup, \"ax\"\n" -"3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */ -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) : : "r" (from)); + ALTERNATIVE "", + "prefetch (%0)\n" + "prefetch 64(%0)\n" + "prefetch 128(%0)\n" + "prefetch 192(%0)\n" + "prefetch 256(%0)\n", X86_FEATURE_3DNOWPREFETCH + : : "r" (from));for (i =0 ; i < (4096 -320 )/64 ; i++) { __asm__ __volatile__ ( -"1: prefetch 320(%0)\n" -"2: movq (%0), %%mm0\n" + ALTERNATIVE "", "prefetch 320(%0)\n", X86_FEATURE_3DNOWPREFETCH +" movq (%0), %%mm0\n" " movntq %%mm0, (%1)\n" " movq 8(%0), %%mm1\n" " movntq %%mm1, 8(%1)\n"
@@ -208,11 +194,7 @@ static void fast_copy_page(void *to, voi " movntq %%mm6, 48(%1)\n" " movq 56(%0), %%mm7\n" " movntq %%mm7, 56(%1)\n" -".section .fixup, \"ax\"\n" -"3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */ -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory"); + : : "r" (from), "r" (to) : "memory"); from +=64 ; to +=64 ;
@@ -220,7 +202,7 @@ static void fast_copy_page(void *to, voifor (i = (4096 -320 )/64 ; i <4096 /64 ; i++) { __asm__ __volatile__ ( -"2: movq (%0), %%mm0\n" +" movq (%0), %%mm0\n" " movntq %%mm0, (%1)\n" " movq 8(%0), %%mm1\n" " movntq %%mm1, 8(%1)\n"
@@ -237,6 +219,7 @@ static void fast_copy_page(void *to, voi " movq 56(%0), %%mm7\n" " movntq %%mm7, 56(%1)\n" : : "r" (from), "r" (to) : "memory"); + from +=64 ; to +=64 ; }
@@ -295,22 +278,18 @@ static void fast_copy_page(void *to, voikernel_fpu_begin_mask (KFPU_387 ); __asm__ __volatile__ ( -"1: prefetch (%0)\n" -" prefetch 64(%0)\n" -" prefetch 128(%0)\n" -" prefetch 192(%0)\n" -" prefetch 256(%0)\n" -"2: \n" -".section .fixup, \"ax\"\n" -"3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */ -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) : : "r" (from)); + ALTERNATIVE "", + "prefetch (%0)\n" + "prefetch 64(%0)\n" + "prefetch 128(%0)\n" + "prefetch 192(%0)\n" + "prefetch 256(%0)\n", X86_FEATURE_3DNOWPREFETCH + : : "r" (from));for (i =0 ; i <4096 /64 ; i++) { __asm__ __volatile__ ( -"1: prefetch 320(%0)\n" -"2: movq (%0), %%mm0\n" + ALTERNATIVE "", "prefetch 320(%0)\n", X86_FEATURE_3DNOWPREFETCH +" movq (%0), %%mm0\n" " movq 8(%0), %%mm1\n" " movq 16(%0), %%mm2\n" " movq 24(%0), %%mm3\n"
@@ -326,11 +305,6 @@ static void fast_copy_page(void *to, voi " movq %%mm1, 40(%1)\n" " movq %%mm2, 48(%1)\n" " movq %%mm3, 56(%1)\n" -".section .fixup, \"ax\"\n" -"3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */ -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b ,3b ) : : "r" (from), "r" (to) : "memory"); from +=64 ;
Peter Zijlstra
maintainerPATCH v2 2/23 x86/mmx_32: Remove X86_USE_3DNOW
The alternative (har har) for this patch is the below, which seems favoured by Boris.
---
Subject: x86/mmx_32: Remove X86_USE_3DNOW
From: Peter Zijlstra <[email protected]>
Date: Mon Nov 15 17:46:39 CET 2021
This code puts an exception table entry on the PREFETCH instruction to overwrite it with a JMP.d8 when it triggers an exception. Except of course, our code is no longer writable, also SMP.
Instead of fixing this broken mess, simply take it out.
--- arch/x86/Kconfig | 2 arch/x86/Kconfig.cpu | 4 arch/x86/include/asm/mmx.h | 15 arch/x86/include/asm/page_32.h | 14 arch/x86/include/asm/required-features.h | 4 arch/x86/include/asm/string_32.h | 33 -- arch/x86/lib/Makefile | 1 arch/x86/lib/memcpy_32.c | 4 arch/x86/lib/mmx_32.c | 388 ------------------------- arch/x86/lib/usercopy_32.c | 1 tools/arch/x86/include/asm/required-features.h | 4 11 files changed, 1 insertion(+), 469 deletions(-)
arch/x86/Kconfig +1 -1
@@ -1945,7 +1945,7 @@ config EFI config EFI_STUB bool "EFI stub support" - depends on EFI && !X86_USE_3DNOW + depends on EFI depends on $(cc-option,-mabi=ms) || X86_32 select RELOCATABLE help
arch/x86/Kconfig.cpu +0 -4
@@ -342,10 +342,6 @@ config X86_USE_PPRO_CHECKSUM def_bool y depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM -config X86_USE_3DNOW - def_bool y - depends on (MCYRIXIII || MK7 || MGEODE_LX) && !UML - # # P6_NOPs are a relatively minor optimization that require a family >= # 6 processor, except that it is broken on certain VIA chips.
arch/x86/include/asm/mmx.h +0 -15
@@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_MMX_H -#define _ASM_X86_MMX_H - -/* -* MMX 3Dnow! helper operations -*/ - -#include <linux/types.h> - -extern void *_mmx_memcpy (void *to,const void *from,size_t size); -extern void mmx_clear_page (void *page); -extern void mmx_copy_page (void *to,void *from); - -#endif /* _ASM_X86_MMX_H */
arch/x86/include/asm/page_32.h +0 -14
@@ -19,19 +19,6 @@ extern unsigned long __phys_addr(unsigne#define pfn_valid (pfn) ((pfn) < max_mapnr)#endif /* CONFIG_FLATMEM */ -#ifdef CONFIG_X86_USE_3DNOW -#include <asm/mmx.h> - -static inline void clear_page (void *page) -{ -mmx_clear_page (page); -} - -static inline void copy_page (void *to,void *from) -{ -mmx_copy_page (to, from); -} -#else /* !CONFIG_X86_USE_3DNOW */ #include <linux/string.h> static inline void clear_page (void *page)
@@ -43,7 +30,6 @@ static inline void copy_page(void *to, v {memcpy (to, from,PAGE_SIZE ); } -#endif /* CONFIG_X86_USE_3DNOW */ #endif /* !__ASSEMBLY__ */ #endif /* _ASM_X86_PAGE_32_H */
arch/x86/include/asm/required-features.h +0 -4
@@ -35,11 +35,7 @@# define NEED_CMOV 0#endif -#ifdef CONFIG_X86_USE_3DNOW -# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) -#else # define NEED_3DNOW 0 -#endif #if defined(CONFIG_X86_P6_NOP ) || defined(CONFIG_X86_64 )# define NEED_NOPL (1<<(X86_FEATURE_NOPL & 31))
arch/x86/include/asm/string_32.h +0 -33
@@ -146,42 +146,9 @@ static __always_inline void *__constant_extern void *memcpy (void *,const void *,size_t );#ifndef CONFIG_FORTIFY_SOURCE -#ifdef CONFIG_X86_USE_3DNOW - -#include <asm/mmx.h> - -/* -* This CPU favours 3DNow strongly (eg AMD Athlon) -*/ - -static inline void *__constant_memcpy3d (void *to,const void *from,size_t len) -{ -if (len <512 ) -return __constant_memcpy (to, from, len); -return _mmx_memcpy (to, from, len); -} - -static inline void *__memcpy3d (void *to,const void *from,size_t len) -{ -if (len <512 ) -return __memcpy (to, from, len); -return _mmx_memcpy (to, from, len); -} - -#define memcpy (t, f, n) \ - (__builtin_constant_p((n)) \ - ? __constant_memcpy3d((t), (f), (n)) \ - : __memcpy3d((t), (f), (n))) - -#else - -/* -* No 3D Now! -*/ #define memcpy (t, f, n) __builtin_memcpy(t, f, n) -#endif #endif /* !CONFIG_FORTIFY_SOURCE */ #define __HAVE_ARCH_MEMMOVE
arch/x86/lib/Makefile +0 -1
@@ -63,7 +63,6 @@ ifeq ($(CONFIG_X86_32),y) ifneq ($(CONFIG_X86_CMPXCHG64),y) lib-y += cmpxchg8b_emu.o atomic64_386_32.o endif - lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o else obj-y += iomap_copy_64.o lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
arch/x86/lib/memcpy_32.c +0 -4
@@ -7,11 +7,7 @@ __visible void *memcpy(void *to, const void *from, size_t n) { -#if defined(CONFIG_X86_USE_3DNOW ) && !defined(CONFIG_FORTIFY_SOURCE ) -return __memcpy3d (to, from, n); -#else return __memcpy (to, from, n); -#endif }EXPORT_SYMBOL (memcpy);
arch/x86/lib/mmx_32.c +0 -388
388 lines not on this page · raw message
arch/x86/lib/usercopy_32.c +0 -1
@@ -8,7 +8,6 @@*/ #include <linux/export.h> #include <linux/uaccess.h> -#include <asm/mmx.h> #include <asm/asm.h> #ifdef CONFIG_X86_INTEL_USERCOPY
tools/arch/x86/include/asm/required-features.h +0 -4
@@ -35,11 +35,7 @@# define NEED_CMOV 0#endif -#ifdef CONFIG_X86_USE_3DNOW -# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) -#else # define NEED_3DNOW 0 -#endif #if defined(CONFIG_X86_P6_NOP ) || defined(CONFIG_X86_64 )# define NEED_NOPL (1<<(X86_FEATURE_NOPL & 31))
Re: [PATCH v2.1 02/23] x86/mmx_32: Remove X86_USE_3DNOW
Quoted 17 lines · Peter Zijlstra
The alternative (har har) for this patch is the below, which seems favoured by Boris.
---
Subject: x86/mmx_32: RemoveX86_USE_3DNOW
From: Peter Zijlstra <[email protected]>
Date: Mon Nov 15 17:46:39 CET 2021This code puts an exception table entry on the PREFETCH instruction to overwrite it with a JMP.d8 when it triggers an exception. Except of course, our code is no longer writable, also SMP.
Instead of fixing this broken mess, simply take it out.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Quoted 13 lines
--- arch/x86/Kconfig | 2 arch/x86/Kconfig.cpu | 4 arch/x86/include/asm/mmx.h | 15 arch/x86/include/asm/page_32.h | 14 arch/x86/include/asm/required-features.h | 4 arch/x86/include/asm/string_32.h | 33 -- arch/x86/lib/Makefile | 1 arch/x86/lib/memcpy_32.c | 4 arch/x86/lib/mmx_32.c | 388 ------------------------- arch/x86/lib/usercopy_32.c | 1 tools/arch/x86/include/asm/required-features.h | 4 11 files changed, 1 insertion(+), 469 deletions(-)
Obviously. :-)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[tip: x86/core] x86/mmx_32: Remove X86_USE_3DNOW
In reply to Peter ZijlstraThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: c6dbd3e5e69cf3ca47a3864115d4cbdd44619243 Gitweb: https://git.kernel.org/tip/c6dbd3e5e69cf3ca47a3864115d4cbdd44619243 Author: Peter Zijlstra <[email protected]> AuthorDate: Mon, 15 Nov 2021 17:46:39 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:45 +01:00
x86/mmx_32: Remove X86_USE_3DNOW
This code puts an exception table entry on the PREFETCH instruction to overwrite it with a JMP.d8 when it triggers an exception. Except of course, our code is no longer writable, also SMP.
Instead of fixing this broken mess, simply take it out.
--- arch/x86/Kconfig | 2 +- arch/x86/Kconfig.cpu | 4 +- arch/x86/include/asm/mmx.h | 15 +- arch/x86/include/asm/page_32.h | 14 +- arch/x86/include/asm/required-features.h | 4 +- arch/x86/include/asm/string_32.h | 33 +- arch/x86/lib/Makefile | 1 +- arch/x86/lib/memcpy_32.c | 4 +- arch/x86/lib/mmx_32.c | 388 +---------------- arch/x86/lib/usercopy_32.c | 1 +- tools/arch/x86/include/asm/required-features.h | 4 +- 11 files changed, 1 insertion(+), 469 deletions(-)
arch/x86/Kconfig +1 -1
@@ -1957,7 +1957,7 @@ config EFI config EFI_STUB bool "EFI stub support" - depends on EFI && !X86_USE_3DNOW + depends on EFI depends on $(cc-option,-mabi=ms) || X86_32 select RELOCATABLE help
arch/x86/Kconfig.cpu +0 -4
@@ -342,10 +342,6 @@ config X86_USE_PPRO_CHECKSUM def_bool y depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM -config X86_USE_3DNOW - def_bool y - depends on (MCYRIXIII || MK7 || MGEODE_LX) && !UML - # # P6_NOPs are a relatively minor optimization that require a family >= # 6 processor, except that it is broken on certain VIA chips.
arch/x86/include/asm/mmx.h +0 -15
@@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_MMX_H -#define _ASM_X86_MMX_H - -/* -* MMX 3Dnow! helper operations -*/ - -#include <linux/types.h> - -extern void *_mmx_memcpy (void *to,const void *from,size_t size); -extern void mmx_clear_page (void *page); -extern void mmx_copy_page (void *to,void *from); - -#endif /* _ASM_X86_MMX_H */
arch/x86/include/asm/page_32.h +0 -14
@@ -19,19 +19,6 @@ extern unsigned long __phys_addr(unsigned long);#define pfn_valid (pfn) ((pfn) < max_mapnr)#endif /* CONFIG_FLATMEM */ -#ifdef CONFIG_X86_USE_3DNOW -#include <asm/mmx.h> - -static inline void clear_page (void *page) -{ -mmx_clear_page (page); -} - -static inline void copy_page (void *to,void *from) -{ -mmx_copy_page (to, from); -} -#else /* !CONFIG_X86_USE_3DNOW */ #include <linux/string.h> static inline void clear_page (void *page)
@@ -43,7 +30,6 @@ static inline void copy_page(void *to, void *from) {memcpy (to, from,PAGE_SIZE ); } -#endif /* CONFIG_X86_USE_3DNOW */ #endif /* !__ASSEMBLY__ */ #endif /* _ASM_X86_PAGE_32_H */
arch/x86/include/asm/required-features.h +0 -4
@@ -35,11 +35,7 @@# define NEED_CMOV 0#endif -#ifdef CONFIG_X86_USE_3DNOW -# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) -#else # define NEED_3DNOW 0 -#endif #if defined(CONFIG_X86_P6_NOP ) || defined(CONFIG_X86_64 )# define NEED_NOPL (1<<(X86_FEATURE_NOPL & 31))
arch/x86/include/asm/string_32.h +0 -33
@@ -146,42 +146,9 @@ static __always_inline void *__constant_memcpy(void *to, const void *from,extern void *memcpy (void *,const void *,size_t );#ifndef CONFIG_FORTIFY_SOURCE -#ifdef CONFIG_X86_USE_3DNOW - -#include <asm/mmx.h> - -/* -* This CPU favours 3DNow strongly (eg AMD Athlon) -*/ - -static inline void *__constant_memcpy3d (void *to,const void *from,size_t len) -{ -if (len <512 ) -return __constant_memcpy (to, from, len); -return _mmx_memcpy (to, from, len); -} - -static inline void *__memcpy3d (void *to,const void *from,size_t len) -{ -if (len <512 ) -return __memcpy (to, from, len); -return _mmx_memcpy (to, from, len); -} - -#define memcpy (t, f, n) \ - (__builtin_constant_p((n)) \ - ? __constant_memcpy3d((t), (f), (n)) \ - : __memcpy3d((t), (f), (n))) - -#else - -/* -* No 3D Now! -*/ #define memcpy (t, f, n) __builtin_memcpy(t, f, n) -#endif #endif /* !CONFIG_FORTIFY_SOURCE */ #define __HAVE_ARCH_MEMMOVE
arch/x86/lib/Makefile +0 -1
@@ -63,7 +63,6 @@ ifeq ($(CONFIG_X86_32),y) ifneq ($(CONFIG_X86_CMPXCHG64),y) lib-y += cmpxchg8b_emu.o atomic64_386_32.o endif - lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o else obj-y += iomap_copy_64.o lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
arch/x86/lib/memcpy_32.c +0 -4
@@ -7,11 +7,7 @@ __visible void *memcpy(void *to, const void *from, size_t n) { -#if defined(CONFIG_X86_USE_3DNOW ) && !defined(CONFIG_FORTIFY_SOURCE ) -return __memcpy3d (to, from, n); -#else return __memcpy (to, from, n); -#endif }EXPORT_SYMBOL (memcpy);
arch/x86/lib/mmx_32.c +0 -388
388 lines not on this page · raw message
arch/x86/lib/usercopy_32.c +0 -1
@@ -8,7 +8,6 @@*/ #include <linux/export.h> #include <linux/uaccess.h> -#include <asm/mmx.h> #include <asm/asm.h> #ifdef CONFIG_X86_INTEL_USERCOPY
tools/arch/x86/include/asm/required-features.h +0 -4
@@ -35,11 +35,7 @@# define NEED_CMOV 0#endif -#ifdef CONFIG_X86_USE_3DNOW -# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) -#else # define NEED_3DNOW 0 -#endif #if defined(CONFIG_X86_P6_NOP ) || defined(CONFIG_X86_64 )# define NEED_NOPL (1<<(X86_FEATURE_NOPL & 31))
Peter Zijlstra
maintainerPATCH v2 3/23 x86,copy_user_64: Remove .fixup usage
In reply to Peter ZijlstraPlace the anonymous .fixup code at the tail of the regular functions.
--- arch/x86/lib/copy_user_64.S | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
arch/x86/lib/copy_user_64.S +11 -21
@@ -32,14 +32,10 @@ decl %ecx jnz 100b 102: - .section .fixup,"ax" -103: addl %ecx,%edx /* ecx is zerorest also */ - jmp .Lcopy_user_handle_tail - .previous - _ASM_EXTABLE_CPY(100b, 103b) - _ASM_EXTABLE_CPY(101b, 103b) - .endm + _ASM_EXTABLE_CPY(100b, .Lcopy_user_handle_align) + _ASM_EXTABLE_CPY(101b, .Lcopy_user_handle_align) +.endm /* * copy_user_generic_unrolled - memory copy with exception handling.
@@ -107,7 +103,6 @@ SYM_FUNC_START(copy_user_generic_unrolle ASM_CLAC ret - .section .fixup,"ax" 30: shll $6,%ecx addl %ecx,%edx jmp 60f
@@ -115,7 +110,6 @@ SYM_FUNC_START(copy_user_generic_unrolle jmp 60f 50: movl %ecx,%edx 60: jmp .Lcopy_user_handle_tail /* ecx is zerorest also */ - .previous _ASM_EXTABLE_CPY(1b, 30b) _ASM_EXTABLE_CPY(2b, 30b)
@@ -166,20 +160,16 @@ SYM_FUNC_START(copy_user_generic_string) movl %edx,%ecx shrl $3,%ecx andl $7,%edx -1: rep - movsq +1: rep movsq 2: movl %edx,%ecx -3: rep - movsb +3: rep movsb xorl %eax,%eax ASM_CLAC ret - .section .fixup,"ax" 11: leal (%rdx,%rcx,8),%ecx 12: movl %ecx,%edx /* ecx is zerorest also */ jmp .Lcopy_user_handle_tail - .previous _ASM_EXTABLE_CPY(1b, 11b) _ASM_EXTABLE_CPY(3b, 12b)
@@ -203,16 +193,13 @@ SYM_FUNC_START(copy_user_enhanced_fast_s cmpl $64,%edx jb .L_copy_short_string /* less then 64 bytes, avoid the costly 'rep' */ movl %edx,%ecx -1: rep - movsb +1: rep movsb xorl %eax,%eax ASM_CLAC ret - .section .fixup,"ax" 12: movl %ecx,%edx /* ecx is zerorest also */ jmp .Lcopy_user_handle_tail - .previous _ASM_EXTABLE_CPY(1b, 12b) SYM_FUNC_END(copy_user_enhanced_fast_string)
@@ -240,6 +227,11 @@ SYM_CODE_START_LOCAL(.Lcopy_user_handle_ ret _ASM_EXTABLE_CPY(1b, 2b) + +.Lcopy_user_handle_align: + addl %ecx,%edx /* ecx is zerorest also */ + jmp .Lcopy_user_handle_tail + SYM_CODE_END(.Lcopy_user_handle_tail) /*
@@ -350,7 +342,6 @@ SYM_FUNC_START(__copy_user_nocache) sfence ret - .section .fixup,"ax" .L_fixup_4x8b_copy: shll $6,%ecx addl %ecx,%edx
@@ -366,7 +357,6 @@ SYM_FUNC_START(__copy_user_nocache) .L_fixup_handle_tail: sfence jmp .Lcopy_user_handle_tail - .previous _ASM_EXTABLE_CPY(1b, .L_fixup_4x8b_copy) _ASM_EXTABLE_CPY(2b, .L_fixup_4x8b_copy)
Re: [PATCH v2 03/23] x86,copy_user_64: Remove .fixup usage
Quoted 6 lines · Peter Zijlstra
Place the anonymous .fixup code at the tail of the regular functions.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- arch/x86/lib/copy_user_64.S | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[tip: x86/core] x86/copy_user_64: Remove .fixup usage
In reply to Peter ZijlstraThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: acba44d2436d463f60a54bf934d378dcf384a965 Gitweb: https://git.kernel.org/tip/acba44d2436d463f60a54bf934d378dcf384a965 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:05 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:45 +01:00
x86/copy_user_64: Remove .fixup usage
Place the anonymous .fixup code at the tail of the regular functions.
--- arch/x86/lib/copy_user_64.S | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
arch/x86/lib/copy_user_64.S +11 -21
@@ -32,14 +32,10 @@ decl %ecx jnz 100b 102: - .section .fixup,"ax" -103: addl %ecx,%edx /* ecx is zerorest also */ - jmp .Lcopy_user_handle_tail - .previous - _ASM_EXTABLE_CPY(100b, 103b) - _ASM_EXTABLE_CPY(101b, 103b) - .endm + _ASM_EXTABLE_CPY(100b, .Lcopy_user_handle_align) + _ASM_EXTABLE_CPY(101b, .Lcopy_user_handle_align) +.endm /* * copy_user_generic_unrolled - memory copy with exception handling.
@@ -107,7 +103,6 @@ SYM_FUNC_START(copy_user_generic_unrolled) ASM_CLAC RET - .section .fixup,"ax" 30: shll $6,%ecx addl %ecx,%edx jmp 60f
@@ -115,7 +110,6 @@ SYM_FUNC_START(copy_user_generic_unrolled) jmp 60f 50: movl %ecx,%edx 60: jmp .Lcopy_user_handle_tail /* ecx is zerorest also */ - .previous _ASM_EXTABLE_CPY(1b, 30b) _ASM_EXTABLE_CPY(2b, 30b)
@@ -166,20 +160,16 @@ SYM_FUNC_START(copy_user_generic_string) movl %edx,%ecx shrl $3,%ecx andl $7,%edx -1: rep - movsq +1: rep movsq 2: movl %edx,%ecx -3: rep - movsb +3: rep movsb xorl %eax,%eax ASM_CLAC RET - .section .fixup,"ax" 11: leal (%rdx,%rcx,8),%ecx 12: movl %ecx,%edx /* ecx is zerorest also */ jmp .Lcopy_user_handle_tail - .previous _ASM_EXTABLE_CPY(1b, 11b) _ASM_EXTABLE_CPY(3b, 12b)
@@ -203,16 +193,13 @@ SYM_FUNC_START(copy_user_enhanced_fast_string) cmpl $64,%edx jb .L_copy_short_string /* less then 64 bytes, avoid the costly 'rep' */ movl %edx,%ecx -1: rep - movsb +1: rep movsb xorl %eax,%eax ASM_CLAC RET - .section .fixup,"ax" 12: movl %ecx,%edx /* ecx is zerorest also */ jmp .Lcopy_user_handle_tail - .previous _ASM_EXTABLE_CPY(1b, 12b) SYM_FUNC_END(copy_user_enhanced_fast_string)
@@ -240,6 +227,11 @@ SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail) RET _ASM_EXTABLE_CPY(1b, 2b) + +.Lcopy_user_handle_align: + addl %ecx,%edx /* ecx is zerorest also */ + jmp .Lcopy_user_handle_tail + SYM_CODE_END(.Lcopy_user_handle_tail) /*
@@ -350,7 +342,6 @@ SYM_FUNC_START(__copy_user_nocache) sfence RET - .section .fixup,"ax" .L_fixup_4x8b_copy: shll $6,%ecx addl %ecx,%edx
@@ -366,7 +357,6 @@ SYM_FUNC_START(__copy_user_nocache) .L_fixup_handle_tail: sfence jmp .Lcopy_user_handle_tail - .previous _ASM_EXTABLE_CPY(1b, .L_fixup_4x8b_copy) _ASM_EXTABLE_CPY(2b, .L_fixup_4x8b_copy)
Peter Zijlstra
maintainerPATCH v2 4/23 x86,copy_mc_64: Remove .fixup usage
In reply to Peter ZijlstraPlace the anonymous .fixup code at the tail of the regular functions.
--- arch/x86/lib/copy_mc_64.S | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/x86/lib/copy_mc_64.S +4 -8
@@ -78,9 +78,7 @@ SYM_FUNC_START(copy_mc_fragile) xorl %eax, %eax .L_done: ret -SYM_FUNC_END(copy_mc_fragile) - .section .fixup, "ax" /* * Return number of bytes not copied for any failure. Note that * there is no "tail" handling since the source buffer is 8-byte
@@ -105,14 +103,14 @@ SYM_FUNC_END(copy_mc_fragile) movl %ecx, %edx jmp copy_mc_fragile_handle_tail - .previous - _ASM_EXTABLE_TYPE(.L_read_leading_bytes, .E_leading_bytes, EX_TYPE_DEFAULT_MCE_SAFE) _ASM_EXTABLE_TYPE(.L_read_words, .E_read_words, EX_TYPE_DEFAULT_MCE_SAFE) _ASM_EXTABLE_TYPE(.L_read_trailing_bytes, .E_trailing_bytes, EX_TYPE_DEFAULT_MCE_SAFE) _ASM_EXTABLE(.L_write_leading_bytes, .E_leading_bytes) _ASM_EXTABLE(.L_write_words, .E_write_words) _ASM_EXTABLE(.L_write_trailing_bytes, .E_trailing_bytes) + +SYM_FUNC_END(copy_mc_fragile) #endif /* CONFIG_X86_MCE */ /*
@@ -133,9 +131,7 @@ SYM_FUNC_START(copy_mc_enhanced_fast_str /* Copy successful. Return zero */ xorl %eax, %eax ret -SYM_FUNC_END(copy_mc_enhanced_fast_string) - .section .fixup, "ax" .E_copy: /* * On fault %rcx is updated such that the copy instruction could
@@ -147,7 +143,7 @@ SYM_FUNC_END(copy_mc_enhanced_fast_strin movq %rcx, %rax ret - .previous - _ASM_EXTABLE_TYPE(.L_copy, .E_copy, EX_TYPE_DEFAULT_MCE_SAFE) + +SYM_FUNC_END(copy_mc_enhanced_fast_string) #endif /* !CONFIG_UML */
Re: [PATCH v2 04/23] x86,copy_mc_64: Remove .fixup usage
Quoted 6 lines · Peter Zijlstra
Place the anonymous .fixup code at the tail of the regular functions.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- arch/x86/lib/copy_mc_64.S | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[tip: x86/core] x86/copy_mc_64: Remove .fixup usage
In reply to Peter ZijlstraThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: ab0fedcc714aafaac6ac996b51791aee0d1cd8fd Gitweb: https://git.kernel.org/tip/ab0fedcc714aafaac6ac996b51791aee0d1cd8fd Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:06 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:46 +01:00
x86/copy_mc_64: Remove .fixup usage
Place the anonymous .fixup code at the tail of the regular functions.
--- arch/x86/lib/copy_mc_64.S | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/x86/lib/copy_mc_64.S +4 -8
@@ -78,9 +78,7 @@ SYM_FUNC_START(copy_mc_fragile) xorl %eax, %eax .L_done: RET -SYM_FUNC_END(copy_mc_fragile) - .section .fixup, "ax" /* * Return number of bytes not copied for any failure. Note that * there is no "tail" handling since the source buffer is 8-byte
@@ -105,14 +103,14 @@ SYM_FUNC_END(copy_mc_fragile) movl %ecx, %edx jmp copy_mc_fragile_handle_tail - .previous - _ASM_EXTABLE_TYPE(.L_read_leading_bytes, .E_leading_bytes, EX_TYPE_DEFAULT_MCE_SAFE) _ASM_EXTABLE_TYPE(.L_read_words, .E_read_words, EX_TYPE_DEFAULT_MCE_SAFE) _ASM_EXTABLE_TYPE(.L_read_trailing_bytes, .E_trailing_bytes, EX_TYPE_DEFAULT_MCE_SAFE) _ASM_EXTABLE(.L_write_leading_bytes, .E_leading_bytes) _ASM_EXTABLE(.L_write_words, .E_write_words) _ASM_EXTABLE(.L_write_trailing_bytes, .E_trailing_bytes) + +SYM_FUNC_END(copy_mc_fragile) #endif /* CONFIG_X86_MCE */ /*
@@ -133,9 +131,7 @@ SYM_FUNC_START(copy_mc_enhanced_fast_string) /* Copy successful. Return zero */ xorl %eax, %eax RET -SYM_FUNC_END(copy_mc_enhanced_fast_string) - .section .fixup, "ax" .E_copy: /* * On fault %rcx is updated such that the copy instruction could
@@ -147,7 +143,7 @@ SYM_FUNC_END(copy_mc_enhanced_fast_string) movq %rcx, %rax RET - .previous - _ASM_EXTABLE_TYPE(.L_copy, .E_copy, EX_TYPE_DEFAULT_MCE_SAFE) + +SYM_FUNC_END(copy_mc_enhanced_fast_string) #endif /* !CONFIG_UML */
Peter Zijlstra
maintainerPATCH v2 5/23 x86,entry_64: Remove .fixup usage
In reply to Peter ZijlstraPlace the anonymous .fixup code at the tail of the regular functions.
--- arch/x86/entry/entry_64.S | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
arch/x86/entry/entry_64.S +6 -7
@@ -735,13 +735,9 @@ SYM_FUNC_START(asm_load_gs_index) swapgs FRAME_END ret -SYM_FUNC_END(asm_load_gs_index) -EXPORT_SYMBOL(asm_load_gs_index) - _ASM_EXTABLE(.Lgs_change, .Lbad_gs) - .section .fixup, "ax" /* running with kernelgs */ -SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) +.Lbad_gs: swapgs /* switch back to user gs */ .macro ZAP_GS /* This can't be a string because the preprocessor needs to see it. */
@@ -752,8 +748,11 @@ SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) xorl %eax, %eax movl %eax, %gs jmp 2b -SYM_CODE_END(.Lbad_gs) - .previous + + _ASM_EXTABLE(.Lgs_change, .Lbad_gs) + +SYM_FUNC_END(asm_load_gs_index) +EXPORT_SYMBOL(asm_load_gs_index) #ifdef CONFIG_XEN_PV /*
Re: [PATCH v2 05/23] x86,entry_64: Remove .fixup usage
Quoted 28 lines · Peter Zijlstra
Place the anonymous .fixup code at the tail of the regular functions.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- arch/x86/entry/entry_64.S | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)arch/x86/entry/entry_64.S +1
-5@@ -735,13 +735,9 @@ SYM_FUNC_START(asm_load_gs_index) swapgs FRAME_END ret -SYM_FUNC_END(asm_load_gs_index) -EXPORT_SYMBOL(asm_load_gs_index) - _ASM_EXTABLE(.Lgs_change, .Lbad_gs) - .section .fixup, "ax" /* running with kernelgs */ -SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) +.Lbad_gs: swapgs /* switch back to user gs */ .macro ZAP_GS /* This can't be a string because the preprocessor needs to see it. */@@ -752,8 +748,11 @@ SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) xorl %eax, %eax movl %eax, %gs jmp 2b
arch/x86/entry/entry_64.S SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) · line 758
Quoted 10 lines
arch/x86/entry/entry_64.S +5
-2-SYM_CODE_END(.Lbad_gs) - .previous + + _ASM_EXTABLE(.Lgs_change, .Lbad_gs) + +SYM_FUNC_END(asm_load_gs_index) +EXPORT_SYMBOL(asm_load_gs_index) #ifdef CONFIG_XEN_PV /*
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v2 05/23] x86,entry_64: Remove .fixup usage
In reply to Peter ZijlstraQuoted 4 lines · Peter Zijlstra
Place the anonymous .fixup code at the tail of the regular functions.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Quoted 37 lines
--- arch/x86/entry/entry_64.S | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)arch/x86/entry/entry_64.S +6
-7@@ -735,13 +735,9 @@ SYM_FUNC_START(asm_load_gs_index) swapgs FRAME_END ret -SYM_FUNC_END(asm_load_gs_index) -EXPORT_SYMBOL(asm_load_gs_index) - _ASM_EXTABLE(.Lgs_change, .Lbad_gs) - .section .fixup, "ax" /* running with kernelgs */ -SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) +.Lbad_gs: swapgs /* switch back to user gs */ .macro ZAP_GS /* This can't be a string because the preprocessor needs to see it. */@@ -752,8 +748,11 @@ SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) xorl %eax, %eax movl %eax, %gs jmp 2b -SYM_CODE_END(.Lbad_gs) - .previous + + _ASM_EXTABLE(.Lgs_change, .Lbad_gs) + +SYM_FUNC_END(asm_load_gs_index) +EXPORT_SYMBOL(asm_load_gs_index) #ifdef CONFIG_XEN_PV /*
[tip: x86/core] x86/entry_64: Remove .fixup usage
In reply to Peter ZijlstraThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 16e617d05ef0c521d000c989796412ce713f28c9 Gitweb: https://git.kernel.org/tip/16e617d05ef0c521d000c989796412ce713f28c9 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:07 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:46 +01:00
x86/entry_64: Remove .fixup usage
Place the anonymous .fixup code at the tail of the regular functions.
--- arch/x86/entry/entry_64.S | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
arch/x86/entry/entry_64.S +6 -7
@@ -739,13 +739,9 @@ SYM_FUNC_START(asm_load_gs_index) swapgs FRAME_END RET -SYM_FUNC_END(asm_load_gs_index) -EXPORT_SYMBOL(asm_load_gs_index) - _ASM_EXTABLE(.Lgs_change, .Lbad_gs) - .section .fixup, "ax" /* running with kernelgs */ -SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) +.Lbad_gs: swapgs /* switch back to user gs */ .macro ZAP_GS /* This can't be a string because the preprocessor needs to see it. */
@@ -756,8 +752,11 @@ SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) xorl %eax, %eax movl %eax, %gs jmp 2b -SYM_CODE_END(.Lbad_gs) - .previous + + _ASM_EXTABLE(.Lgs_change, .Lbad_gs) + +SYM_FUNC_END(asm_load_gs_index) +EXPORT_SYMBOL(asm_load_gs_index) #ifdef CONFIG_XEN_PV /*
Peter Zijlstra
maintainerPATCH v2 6/23 x86,entry_32: Remove .fixup usage
In reply to Peter ZijlstraWhere possible, push the .fixup into code, at the tail of functions.
This is hard for macros since they're used in multiple functions, therefore introduce a new extable handler to pop zeros.
--- arch/x86/entry/entry_32.S | 28 ++++++++-------------------- arch/x86/include/asm/extable_fixup_types.h | 2 ++ arch/x86/mm/extable.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 20 deletions(-)
arch/x86/entry/entry_32.S +8 -20
@@ -270,17 +270,9 @@ 3: popl %fs addl $(4 + \pop), %esp /* pop the unused "gs" slot */ IRET_FRAME -.pushsection .fixup, "ax" -4: movl $0, (%esp) - jmp 1b -5: movl $0, (%esp) - jmp 2b -6: movl $0, (%esp) - jmp 3b -.popsection - _ASM_EXTABLE(1b, 4b) - _ASM_EXTABLE(2b, 5b) - _ASM_EXTABLE(3b, 6b) + _ASM_EXTABLE_TYPE(1b, 1b, EX_TYPE_POP_ZERO) + _ASM_EXTABLE_TYPE(2b, 2b, EX_TYPE_POP_ZERO) + _ASM_EXTABLE_TYPE(3b, 3b, EX_TYPE_POP_ZERO) .endm .macro RESTORE_ALL_NMI cr3_reg:req pop=0
@@ -925,10 +917,8 @@ SYM_FUNC_START(entry_SYSENTER_32) sti sysexit -.pushsection .fixup, "ax" -2: movl $0, PT_FS(%esp) - jmp 1b -.popsection +2: movl $0, PT_FS(%esp) + jmp 1b _ASM_EXTABLE(1b, 2b) .Lsysenter_fix_flags:
@@ -996,8 +986,7 @@ SYM_FUNC_START(entry_INT80_32) */ iret -.section .fixup, "ax" -SYM_CODE_START(asm_iret_error) +.Lasm_iret_error: pushl $0 # no error code pushl $iret_error
@@ -1014,9 +1003,8 @@ SYM_CODE_START(asm_iret_error) #endif jmp handle_exception -SYM_CODE_END(asm_iret_error) -.previous - _ASM_EXTABLE(.Lirq_return, asm_iret_error) + + _ASM_EXTABLE(.Lirq_return, .Lasm_iret_error) SYM_FUNC_END(entry_INT80_32) .macro FIXUP_ESPFIX_STACK
arch/x86/include/asm/extable_fixup_types.h +2 -0
@@ -19,4 +19,6 @@#define EX_TYPE_DEFAULT_MCE_SAFE 12#define EX_TYPE_FAULT_MCE_SAFE 13 +#define EX_TYPE_POP_ZERO 14 +#endif
arch/x86/mm/extable.c +14 -0
@@ -99,6 +99,18 @@ static bool ex_handler_clear_fs(const streturn ex_handler_default (fixup, regs); } +static bool ex_handler_pop_zero (const struct exception_table_entry *fixup, +struct pt_regs *regs) +{ +/* +* Typically used for when "pop %seg" traps, in which case we'll clear +* the stack slot and re-try the instruction, which will then succeed +* to pop zero. +*/ + *((unsigned long *)regs->sp) =0 ; +return ex_handler_default (fixup, regs); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip);
@@ -156,6 +168,8 @@ int fixup_exception(struct pt_regs *regscase EX_TYPE_WRMSR_IN_MCE :ex_handler_msr_mce (regs, true);break ; +case EX_TYPE_POP_ZERO : +return ex_handler_pop_zero (e, regs); }BUG (); }
[tip: x86/core] x86/entry_32: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: aa93e2ad7464ffb90155a5ffdde963816f86d5dc Gitweb: https://git.kernel.org/tip/aa93e2ad7464ffb90155a5ffdde963816f86d5dc Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:08 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:46 +01:00
x86/entry_32: Remove .fixup usage
Where possible, push the .fixup into code, at the tail of functions.
This is hard for macros since they're used in multiple functions, therefore introduce a new extable handler to pop zeros.
--- arch/x86/entry/entry_32.S | 28 ++++++--------------- arch/x86/include/asm/extable_fixup_types.h | 2 ++- arch/x86/mm/extable.c | 14 +++++++++++- 3 files changed, 24 insertions(+), 20 deletions(-)
arch/x86/entry/entry_32.S +8 -20
@@ -270,17 +270,9 @@ 3: popl %fs addl $(4 + \pop), %esp /* pop the unused "gs" slot */ IRET_FRAME -.pushsection .fixup, "ax" -4: movl $0, (%esp) - jmp 1b -5: movl $0, (%esp) - jmp 2b -6: movl $0, (%esp) - jmp 3b -.popsection - _ASM_EXTABLE(1b, 4b) - _ASM_EXTABLE(2b, 5b) - _ASM_EXTABLE(3b, 6b) + _ASM_EXTABLE_TYPE(1b, 1b, EX_TYPE_POP_ZERO) + _ASM_EXTABLE_TYPE(2b, 2b, EX_TYPE_POP_ZERO) + _ASM_EXTABLE_TYPE(3b, 3b, EX_TYPE_POP_ZERO) .endm .macro RESTORE_ALL_NMI cr3_reg:req pop=0
@@ -925,10 +917,8 @@ SYM_FUNC_START(entry_SYSENTER_32) sti sysexit -.pushsection .fixup, "ax" -2: movl $0, PT_FS(%esp) - jmp 1b -.popsection +2: movl $0, PT_FS(%esp) + jmp 1b _ASM_EXTABLE(1b, 2b) .Lsysenter_fix_flags:
@@ -996,8 +986,7 @@ restore_all_switch_stack: */ iret -.section .fixup, "ax" -SYM_CODE_START(asm_iret_error) +.Lasm_iret_error: pushl $0 # no error code pushl $iret_error
@@ -1014,9 +1003,8 @@ SYM_CODE_START(asm_iret_error) #endif jmp handle_exception -SYM_CODE_END(asm_iret_error) -.previous - _ASM_EXTABLE(.Lirq_return, asm_iret_error) + + _ASM_EXTABLE(.Lirq_return, .Lasm_iret_error) SYM_FUNC_END(entry_INT80_32) .macro FIXUP_ESPFIX_STACK
arch/x86/include/asm/extable_fixup_types.h +2 -0
@@ -19,4 +19,6 @@#define EX_TYPE_DEFAULT_MCE_SAFE 12#define EX_TYPE_FAULT_MCE_SAFE 13 +#define EX_TYPE_POP_ZERO 14 +#endif
arch/x86/mm/extable.c +14 -0
@@ -99,6 +99,18 @@ static bool ex_handler_clear_fs(const struct exception_table_entry *fixup,return ex_handler_default (fixup, regs); } +static bool ex_handler_pop_zero (const struct exception_table_entry *fixup, +struct pt_regs *regs) +{ +/* +* Typically used for when "pop %seg" traps, in which case we'll clear +* the stack slot and re-try the instruction, which will then succeed +* to pop zero. +*/ + *((unsigned long *)regs->sp) =0 ; +return ex_handler_default (fixup, regs); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip);
@@ -156,6 +168,8 @@ int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,case EX_TYPE_WRMSR_IN_MCE :ex_handler_msr_mce (regs, true);break ; +case EX_TYPE_POP_ZERO : +return ex_handler_pop_zero (e, regs); }BUG (); }
Peter Zijlstra
maintainerPATCH v2 7/23 x86,extable: Extend extable functionality
In reply to Peter ZijlstraIn order to remove further .fixup usage, extend the extable infrastructure to take additional information from the extable entry sites.
Specifically add _ASM_EXTABLE_TYPE_REG() and EX_TYPE_IMM_REG that extend the existing _ASM_EXTABLE_TYPE() by taking an additional register argument and encoding that and an s16 immediate into the existing s32 type field. This limits the actual types to the first byte, 255 seem plenty.
Also add a few flags into the type word, specifically CLEAR_AX and CLEAR_DX which clear the return and extended return register.
Notes:
- due to the % in our register names it's hard to make it more generally usable as arm64 did.
- the s16 is far larger than used in these patches, future extentions can easily shrink this to get more bits.
- without the bitfield fix this will not compile, because: 0xFF > -1 and we can't even extract the TYPE field.
--- arch/x86/include/asm/asm.h | 33 ++++++++++++++ arch/x86/include/asm/extable.h | 6 +- arch/x86/include/asm/extable_fixup_types.h | 24 ++++++++++ arch/x86/include/asm/insn-eval.h | 2 arch/x86/lib/insn-eval.c | 66 ++++++++++++++++++----------- arch/x86/mm/extable.c | 40 +++++++++++++++-- arch/x86/net/bpf_jit_comp.c | 2 7 files changed, 141 insertions(+), 32 deletions(-)
arch/x86/include/asm/asm.h +33 -0
@@ -152,6 +152,31 @@#else /* ! __ASSEMBLY__ */ +asm( +" .macro extable_type_reg type:req reg:req\n" +" .set found, 0\n" +" .set regnr, 0\n" +" .irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n" +" .ifc \\reg, %\\rs\n" +" .set found, found+1\n" +" .long \\type + (regnr << 8)\n" +" .endif\n" +" .set regnr, regnr+1\n" +" .endr\n" +" .set regnr, 0\n" +" .irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d,r15d\n" +" .ifc \\reg, %\\rs\n" +" .set found, found+1\n" +" .long \\type + (regnr << 8)\n" +" .endif\n" +" .set regnr, regnr+1\n" +" .endr\n" +" .if (found != 1)\n" +" .error \"extable_type_reg: bad register argument\"\n" +" .endif\n" +" .endm\n" +); +# define _ASM_EXTABLE_TYPE (from, to, type) \ " .pushsection \"__ex_table\",\"a\"\n" \ " .balign 4\n" \
@@ -160,6 +185,14 @@ " .long " __stringify(type) " \n" \ " .popsection\n" +# define _ASM_EXTABLE_TYPE_REG (from, to, type, reg) \ + " .pushsection \"__ex_table\",\"a\"\n" \ + " .balign 4\n" \ + " .long (" #from ") - .\n" \ + " .long (" #to ") - .\n" \ + "extable_type_reg reg=" __stringify(reg) ", type=" __stringify(type) " \n"\ + " .popsection\n" +/* For C file, we already have NOKPROBE_SYMBOL macro */ /*
arch/x86/include/asm/extable.h +3 -3
@@ -21,7 +21,7 @@*/ struct exception_table_entry { -int insn, fixup, type; +int insn, fixup, data; };struct pt_regs ;
@@ -31,8 +31,8 @@ struct pt_regs;do { \ (a)->fixup = (b)->fixup + (delta); \ (b)->fixup = (tmp).fixup - (delta); \ - (a)->type = (b)->type; \ - (b)->type = (tmp).type; \ + (a)->data = (b)->data; \ + (b)->data = (tmp).data; \ } while (0) extern int fixup_exception(struct pt_regs *regs, int trapnr,
arch/x86/include/asm/extable_fixup_types.h +24 -0
@@ -2,6 +2,29 @@#ifndef _ASM_X86_EXTABLE_FIXUP_TYPES_H#define _ASM_X86_EXTABLE_FIXUP_TYPES_H +/* +* Our IMM is signed, as such it must live at the top end of the word. Also, +* since C99 hex constants are of ambigious type, force cast the mask to 'int' +* so that FIELD_GET() will DTRT and sign extend the value when it extracts it. +*/ +#define EX_DATA_TYPE_MASK ((int)0x000000FF) +#define EX_DATA_REG_MASK ((int)0x00000F00) +#define EX_DATA_FLAG_MASK ((int)0x0000F000) +#define EX_DATA_IMM_MASK ((int)0xFFFF0000) + +#define EX_DATA_REG_SHIFT 8 +#define EX_DATA_FLAG_SHIFT 12 +#define EX_DATA_IMM_SHIFT 16 + +#define EX_DATA_FLAG (flag) ((flag) << EX_DATA_FLAG_SHIFT) +#define EX_DATA_IMM (imm) ((imm) << EX_DATA_IMM_SHIFT) + +/* flags */ +#define EX_FLAG_CLEAR_AX EX_DATA_FLAG(1) +#define EX_FLAG_CLEAR_DX EX_DATA_FLAG(2) +#define EX_FLAG_CLEAR_AX_DX EX_DATA_FLAG(3) + +/* types */ #define EX_TYPE_NONE 0#define EX_TYPE_DEFAULT 1#define EX_TYPE_FAULT 2
@@ -20,5 +43,6 @@#define EX_TYPE_FAULT_MCE_SAFE 13#define EX_TYPE_POP_ZERO 14 +#define EX_TYPE_IMM_REG 15/* reg := (long)imm */ #endif
arch/x86/include/asm/insn-eval.h +2 -0
@@ -15,6 +15,8 @@#define INSN_CODE_SEG_OPND_SZ (params) (params & 0xf)#define INSN_CODE_SEG_PARAMS (oper_sz, addr_sz) (oper_sz | (addr_sz << 4)) +int pt_regs_offset (struct pt_regs *regs,int regno); +bool insn_has_rep_prefix (struct insn *insn);void __user *insn_get_addr_ref (struct insn *insn,struct pt_regs *regs);int insn_get_modrm_rm_off (struct insn *insn,struct pt_regs *regs);
arch/x86/lib/insn-eval.c +42 -24
81 lines not on this page · raw message
arch/x86/mm/extable.c +36 -4
@@ -2,12 +2,25 @@#include <linux/extable.h> #include <linux/uaccess.h> #include <linux/sched/debug.h> +#include <linux/bitfield.h> #include <xen/xen.h> #include <asm/fpu/api.h> #include <asm/sev.h> #include <asm/traps.h> #include <asm/kdebug.h> +#include <asm/insn-eval.h> + +static inline unsigned long *pt_regs_nr (struct pt_regs *regs,int nr) +{ +int reg_offset =pt_regs_offset (regs, nr); +static unsigned long __dummy; + +if (WARN_ON_ONCE (reg_offset <0 )) +return &__dummy; + +return (unsigned long *)((unsigned long )regs + reg_offset); +}static inline unsigned long ex_fixup_addr (const struct exception_table_entry *x)
@@ -15,10 +28,15 @@ ex_fixup_addr(const struct exception_tabreturn (unsigned long )&x->fixup + x->fixup; } -static bool ex_handler_default (const struct exception_table_entry *fixup, +static bool ex_handler_default (const struct exception_table_entry *e,struct pt_regs *regs) { - regs->ip =ex_fixup_addr (fixup); +if (e->data &EX_FLAG_CLEAR_AX ) + regs->ax =0 ; +if (e->data &EX_FLAG_CLEAR_DX ) + regs->dx =0 ; + + regs->ip =ex_fixup_addr (e);return true; }
@@ -111,17 +129,25 @@ static bool ex_handler_pop_zero(const streturn ex_handler_default (fixup, regs); } +static bool ex_handler_imm_reg (const struct exception_table_entry *fixup, +struct pt_regs *regs,int reg,int imm) +{ + *pt_regs_nr (regs, reg) = (long )imm; +return ex_handler_default (fixup, regs); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip); -return e ? e->type :EX_TYPE_NONE ; +return e ?FIELD_GET (EX_DATA_TYPE_MASK , e->data) :EX_TYPE_NONE ; }int fixup_exception (struct pt_regs *regs,int trapnr,unsigned long error_code,unsigned long fault_addr) {const struct exception_table_entry *e; +int type, reg, imm;#ifdef CONFIG_PNPBIOS if (unlikely (SEGMENT_IS_PNP_CODE (regs->cs))) {
@@ -141,7 +167,11 @@ int fixup_exception(struct pt_regs *regsif (!e)return 0 ; -switch (e->type) { + type =FIELD_GET (EX_DATA_TYPE_MASK , e->data); + reg =FIELD_GET (EX_DATA_REG_MASK , e->data); + imm =FIELD_GET (EX_DATA_IMM_MASK , e->data); + +switch (type) {case EX_TYPE_DEFAULT :case EX_TYPE_DEFAULT_MCE_SAFE :return ex_handler_default (e, regs);
@@ -170,6 +200,8 @@ int fixup_exception(struct pt_regs *regsbreak ;case EX_TYPE_POP_ZERO :return ex_handler_pop_zero (e, regs); +case EX_TYPE_IMM_REG : +return ex_handler_imm_reg (e, regs, reg, imm); }BUG (); }
arch/x86/net/bpf_jit_comp.c +1 -1
@@ -1291,7 +1291,7 @@ st: if (is_imm8(insn->off)) } ex->insn = delta; - ex->type =EX_TYPE_BPF ; + ex->data =EX_TYPE_BPF ;if (dst_reg >BPF_REG_9 ) {pr_err ("verifier error\n" );
[tip: x86/core] x86/extable: Extend extable functionality
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 4b5305decc8436bfe363d1c1773e8fa1c828b14d Gitweb: https://git.kernel.org/tip/4b5305decc8436bfe363d1c1773e8fa1c828b14d Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:09 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:46 +01:00
x86/extable: Extend extable functionality
In order to remove further .fixup usage, extend the extable infrastructure to take additional information from the extable entry sites.
Specifically add _ASM_EXTABLE_TYPE_REG() and EX_TYPE_IMM_REG that extend the existing _ASM_EXTABLE_TYPE() by taking an additional register argument and encoding that and an s16 immediate into the existing s32 type field. This limits the actual types to the first byte, 255 seem plenty.
Also add a few flags into the type word, specifically CLEAR_AX and CLEAR_DX which clear the return and extended return register.
Notes:
- due to the % in our register names it's hard to make it more generally usable as arm64 did.
- the s16 is far larger than used in these patches, future extentions can easily shrink this to get more bits.
- without the bitfield fix this will not compile, because: 0xFF > -1 and we can't even extract the TYPE field.
[nathanchance: Build fix for clang-lto builds:
https://lkml.kernel.org/r/[email protected]
]
--- arch/x86/include/asm/asm.h | 37 ++++++++++++- arch/x86/include/asm/extable.h | 6 +- arch/x86/include/asm/extable_fixup_types.h | 24 ++++++++- arch/x86/include/asm/insn-eval.h | 2 +- arch/x86/lib/insn-eval.c | 66 +++++++++++++-------- arch/x86/mm/extable.c | 40 +++++++++++-- arch/x86/net/bpf_jit_comp.c | 2 +- 7 files changed, 145 insertions(+), 32 deletions(-)
arch/x86/include/asm/asm.h +37 -0
@@ -152,6 +152,33 @@#else /* ! __ASSEMBLY__ */ +# define DEFINE_EXTABLE_TYPE_REG \ + ".macro extable_type_reg type:req reg:req\n" \ + ".set found, 0\n" \ + ".set regnr, 0\n" \ + ".irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n" \ + ".ifc \\reg, %%\\rs\n" \ + ".set found, found+1\n" \ + ".long \\type + (regnr << 8)\n" \ + ".endif\n" \ + ".set regnr, regnr+1\n" \ + ".endr\n" \ + ".set regnr, 0\n" \ + ".irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d,r15d\n" \ + ".ifc \\reg, %%\\rs\n" \ + ".set found, found+1\n" \ + ".long \\type + (regnr << 8)\n" \ + ".endif\n" \ + ".set regnr, regnr+1\n" \ + ".endr\n" \ + ".if (found != 1)\n" \ + ".error \"extable_type_reg: bad register argument\"\n" \ + ".endif\n" \ + ".endm\n" + +# define UNDEFINE_EXTABLE_TYPE_REG \ + ".purgem extable_type_reg\n" +# define _ASM_EXTABLE_TYPE (from, to, type) \ " .pushsection \"__ex_table\",\"a\"\n" \ " .balign 4\n" \
@@ -160,6 +187,16 @@ " .long " __stringify(type) " \n" \ " .popsection\n" +# define _ASM_EXTABLE_TYPE_REG (from, to, type, reg) \ + " .pushsection \"__ex_table\",\"a\"\n" \ + " .balign 4\n" \ + " .long (" #from ") - .\n" \ + " .long (" #to ") - .\n" \ + DEFINE_EXTABLE_TYPE_REG \ + "extable_type_reg reg=" __stringify(reg) ", type=" __stringify(type) " \n"\ + UNDEFINE_EXTABLE_TYPE_REG \ + " .popsection\n" +/* For C file, we already have NOKPROBE_SYMBOL macro */ /*
arch/x86/include/asm/extable.h +3 -3
@@ -21,7 +21,7 @@*/ struct exception_table_entry { -int insn, fixup, type; +int insn, fixup, data; };struct pt_regs ;
@@ -31,8 +31,8 @@ struct pt_regs;do { \ (a)->fixup = (b)->fixup + (delta); \ (b)->fixup = (tmp).fixup - (delta); \ - (a)->type = (b)->type; \ - (b)->type = (tmp).type; \ + (a)->data = (b)->data; \ + (b)->data = (tmp).data; \ } while (0) extern int fixup_exception(struct pt_regs *regs, int trapnr,
arch/x86/include/asm/extable_fixup_types.h +24 -0
@@ -2,6 +2,29 @@#ifndef _ASM_X86_EXTABLE_FIXUP_TYPES_H#define _ASM_X86_EXTABLE_FIXUP_TYPES_H +/* +* Our IMM is signed, as such it must live at the top end of the word. Also, +* since C99 hex constants are of ambigious type, force cast the mask to 'int' +* so that FIELD_GET() will DTRT and sign extend the value when it extracts it. +*/ +#define EX_DATA_TYPE_MASK ((int)0x000000FF) +#define EX_DATA_REG_MASK ((int)0x00000F00) +#define EX_DATA_FLAG_MASK ((int)0x0000F000) +#define EX_DATA_IMM_MASK ((int)0xFFFF0000) + +#define EX_DATA_REG_SHIFT 8 +#define EX_DATA_FLAG_SHIFT 12 +#define EX_DATA_IMM_SHIFT 16 + +#define EX_DATA_FLAG (flag) ((flag) << EX_DATA_FLAG_SHIFT) +#define EX_DATA_IMM (imm) ((imm) << EX_DATA_IMM_SHIFT) + +/* flags */ +#define EX_FLAG_CLEAR_AX EX_DATA_FLAG(1) +#define EX_FLAG_CLEAR_DX EX_DATA_FLAG(2) +#define EX_FLAG_CLEAR_AX_DX EX_DATA_FLAG(3) + +/* types */ #define EX_TYPE_NONE 0#define EX_TYPE_DEFAULT 1#define EX_TYPE_FAULT 2
@@ -20,5 +43,6 @@#define EX_TYPE_FAULT_MCE_SAFE 13#define EX_TYPE_POP_ZERO 14 +#define EX_TYPE_IMM_REG 15/* reg := (long)imm */ #endif
arch/x86/include/asm/insn-eval.h +2 -0
@@ -15,6 +15,8 @@#define INSN_CODE_SEG_OPND_SZ (params) (params & 0xf)#define INSN_CODE_SEG_PARAMS (oper_sz, addr_sz) (oper_sz | (addr_sz << 4)) +int pt_regs_offset (struct pt_regs *regs,int regno); +bool insn_has_rep_prefix (struct insn *insn);void __user *insn_get_addr_ref (struct insn *insn,struct pt_regs *regs);int insn_get_modrm_rm_off (struct insn *insn,struct pt_regs *regs);
arch/x86/lib/insn-eval.c +42 -24
81 lines not on this page · raw message
arch/x86/mm/extable.c +36 -4
@@ -2,12 +2,25 @@#include <linux/extable.h> #include <linux/uaccess.h> #include <linux/sched/debug.h> +#include <linux/bitfield.h> #include <xen/xen.h> #include <asm/fpu/api.h> #include <asm/sev.h> #include <asm/traps.h> #include <asm/kdebug.h> +#include <asm/insn-eval.h> + +static inline unsigned long *pt_regs_nr (struct pt_regs *regs,int nr) +{ +int reg_offset =pt_regs_offset (regs, nr); +static unsigned long __dummy; + +if (WARN_ON_ONCE (reg_offset <0 )) +return &__dummy; + +return (unsigned long *)((unsigned long )regs + reg_offset); +}static inline unsigned long ex_fixup_addr (const struct exception_table_entry *x)
@@ -15,10 +28,15 @@ ex_fixup_addr(const struct exception_table_entry *x)return (unsigned long )&x->fixup + x->fixup; } -static bool ex_handler_default (const struct exception_table_entry *fixup, +static bool ex_handler_default (const struct exception_table_entry *e,struct pt_regs *regs) { - regs->ip =ex_fixup_addr (fixup); +if (e->data &EX_FLAG_CLEAR_AX ) + regs->ax =0 ; +if (e->data &EX_FLAG_CLEAR_DX ) + regs->dx =0 ; + + regs->ip =ex_fixup_addr (e);return true; }
@@ -111,17 +129,25 @@ static bool ex_handler_pop_zero(const struct exception_table_entry *fixup,return ex_handler_default (fixup, regs); } +static bool ex_handler_imm_reg (const struct exception_table_entry *fixup, +struct pt_regs *regs,int reg,int imm) +{ + *pt_regs_nr (regs, reg) = (long )imm; +return ex_handler_default (fixup, regs); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip); -return e ? e->type :EX_TYPE_NONE ; +return e ?FIELD_GET (EX_DATA_TYPE_MASK , e->data) :EX_TYPE_NONE ; }int fixup_exception (struct pt_regs *regs,int trapnr,unsigned long error_code,unsigned long fault_addr) {const struct exception_table_entry *e; +int type, reg, imm;#ifdef CONFIG_PNPBIOS if (unlikely (SEGMENT_IS_PNP_CODE (regs->cs))) {
@@ -141,7 +167,11 @@ int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,if (!e)return 0 ; -switch (e->type) { + type =FIELD_GET (EX_DATA_TYPE_MASK , e->data); + reg =FIELD_GET (EX_DATA_REG_MASK , e->data); + imm =FIELD_GET (EX_DATA_IMM_MASK , e->data); + +switch (type) {case EX_TYPE_DEFAULT :case EX_TYPE_DEFAULT_MCE_SAFE :return ex_handler_default (e, regs);
@@ -170,6 +200,8 @@ int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,break ;case EX_TYPE_POP_ZERO :return ex_handler_pop_zero (e, regs); +case EX_TYPE_IMM_REG : +return ex_handler_imm_reg (e, regs, reg, imm); }BUG (); }
arch/x86/net/bpf_jit_comp.c +1 -1
@@ -1291,7 +1291,7 @@ st: if (is_imm8(insn->off)) } ex->insn = delta; - ex->type =EX_TYPE_BPF ; + ex->data =EX_TYPE_BPF ;if (dst_reg >BPF_REG_9 ) {pr_err ("verifier error\n" );
Peter Zijlstra
maintainerPATCH v2 8/23 x86,msr: Remove .fixup usage
In reply to Peter ZijlstraRework the MSR accessors to remove .fixup usage. Add two new extable types (to the 4 already existing msr ones) using the new register infrastructure to record which register should get the error value.
--- arch/x86/include/asm/extable_fixup_types.h | 23 ++++++------- arch/x86/include/asm/msr.h | 26 ++++---------- arch/x86/mm/extable.c | 51 +++++++++++++++-------------- 3 files changed, 47 insertions(+), 53 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +11 -12
@@ -27,17 +27,16 @@#define EX_TYPE_COPY 4#define EX_TYPE_CLEAR_FS 5#define EX_TYPE_FPU_RESTORE 6 -#define EX_TYPE_WRMSR 7 -#define EX_TYPE_RDMSR 8 -#define EX_TYPE_BPF 9 - -#define EX_TYPE_WRMSR_IN_MCE 10 -#define EX_TYPE_RDMSR_IN_MCE 11 - -#define EX_TYPE_DEFAULT_MCE_SAFE 12 -#define EX_TYPE_FAULT_MCE_SAFE 13 - -#define EX_TYPE_POP_ZERO 14 -#define EX_TYPE_IMM_REG 15/* reg := (long)imm */ +#define EX_TYPE_BPF 7 +#define EX_TYPE_WRMSR 8 +#define EX_TYPE_RDMSR 9 +#define EX_TYPE_WRMSR_SAFE 10/* reg := -EIO */ +#define EX_TYPE_RDMSR_SAFE 11/* reg := -EIO */ +#define EX_TYPE_WRMSR_IN_MCE 12 +#define EX_TYPE_RDMSR_IN_MCE 13 +#define EX_TYPE_DEFAULT_MCE_SAFE 14 +#define EX_TYPE_FAULT_MCE_SAFE 15 +#define EX_TYPE_POP_ZERO 16 +#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ #endif
arch/x86/include/asm/msr.h +8 -18
@@ -137,17 +137,11 @@ static inline unsigned long long native_ {DECLARE_ARGS (val, low, high); - asmvolatile ("2: rdmsr ; xor %[err],%[err]\n" -"1:\n\t" -".section .fixup,\"ax\"\n\t" -"3: mov %[fault],%[err]\n\t" -"xorl %%eax, %%eax\n\t" -"xorl %%edx, %%edx\n\t" -"jmp 1b\n\t" -".previous\n\t" - _ASM_EXTABLE(2b, 3b) + asmvolatile ("1: rdmsr ; xor %[err],%[err]\n" +"2:\n\t" + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_RDMSR_SAFE, %[err]) : [err] "=r" (*err), EAX_EDX_RET(val, low, high) - : "c" (msr), [fault] "i" (-EIO)); + : "c" (msr)); if (tracepoint_enabled(read_msr))do_trace_read_msr (msr,EAX_EDX_VAL (val, low, high), *err);return EAX_EDX_VAL (val, low, high);
@@ -169,15 +163,11 @@ native_write_msr_safe(unsigned int msr, {int err; - asmvolatile ("2: wrmsr ; xor %[err],%[err]\n" -"1:\n\t" -".section .fixup,\"ax\"\n\t" -"3: mov %[fault],%[err] ; jmp 1b\n\t" -".previous\n\t" - _ASM_EXTABLE(2b, 3b) + asmvolatile ("1: wrmsr ; xor %[err],%[err]\n" +"2:\n\t" + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_WRMSR_SAFE, %[err]) : [err] "=a" (err) - : "c" (msr), "0" (low), "d" (high), - [fault] "i" (-EIO) + : "c" (msr), "0" (low), "d" (high) : "memory"); if (tracepoint_enabled(write_msr))do_trace_write_msr (msr, ((u64 )high <<32 | low), err);
arch/x86/mm/extable.c +28 -23
74 lines not on this page · raw message
[tip: x86/core] x86/msr: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: d52a7344bdfa9c3442d3f86fb3501d9343726c76 Gitweb: https://git.kernel.org/tip/d52a7344bdfa9c3442d3f86fb3501d9343726c76 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:10 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:47 +01:00
x86/msr: Remove .fixup usage
Rework the MSR accessors to remove .fixup usage. Add two new extable types (to the 4 already existing msr ones) using the new register infrastructure to record which register should get the error value.
--- arch/x86/include/asm/extable_fixup_types.h | 23 ++++----- arch/x86/include/asm/msr.h | 26 +++-------- arch/x86/mm/extable.c | 51 +++++++++++---------- 3 files changed, 47 insertions(+), 53 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +11 -12
@@ -32,17 +32,16 @@#define EX_TYPE_COPY 4#define EX_TYPE_CLEAR_FS 5#define EX_TYPE_FPU_RESTORE 6 -#define EX_TYPE_WRMSR 7 -#define EX_TYPE_RDMSR 8 -#define EX_TYPE_BPF 9 - -#define EX_TYPE_WRMSR_IN_MCE 10 -#define EX_TYPE_RDMSR_IN_MCE 11 - -#define EX_TYPE_DEFAULT_MCE_SAFE 12 -#define EX_TYPE_FAULT_MCE_SAFE 13 - -#define EX_TYPE_POP_ZERO 14 -#define EX_TYPE_IMM_REG 15/* reg := (long)imm */ +#define EX_TYPE_BPF 7 +#define EX_TYPE_WRMSR 8 +#define EX_TYPE_RDMSR 9 +#define EX_TYPE_WRMSR_SAFE 10/* reg := -EIO */ +#define EX_TYPE_RDMSR_SAFE 11/* reg := -EIO */ +#define EX_TYPE_WRMSR_IN_MCE 12 +#define EX_TYPE_RDMSR_IN_MCE 13 +#define EX_TYPE_DEFAULT_MCE_SAFE 14 +#define EX_TYPE_FAULT_MCE_SAFE 15 +#define EX_TYPE_POP_ZERO 16 +#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ #endif
arch/x86/include/asm/msr.h +8 -18
@@ -137,17 +137,11 @@ static inline unsigned long long native_read_msr_safe(unsigned int msr, {DECLARE_ARGS (val, low, high); - asmvolatile ("2: rdmsr ; xor %[err],%[err]\n" -"1:\n\t" -".section .fixup,\"ax\"\n\t" -"3: mov %[fault],%[err]\n\t" -"xorl %%eax, %%eax\n\t" -"xorl %%edx, %%edx\n\t" -"jmp 1b\n\t" -".previous\n\t" - _ASM_EXTABLE(2b, 3b) + asmvolatile ("1: rdmsr ; xor %[err],%[err]\n" +"2:\n\t" + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_RDMSR_SAFE, %[err]) : [err] "=r" (*err), EAX_EDX_RET(val, low, high) - : "c" (msr), [fault] "i" (-EIO)); + : "c" (msr)); if (tracepoint_enabled(read_msr))do_trace_read_msr (msr,EAX_EDX_VAL (val, low, high), *err);return EAX_EDX_VAL (val, low, high);
@@ -169,15 +163,11 @@ native_write_msr_safe(unsigned int msr, u32 low, u32 high) {int err; - asmvolatile ("2: wrmsr ; xor %[err],%[err]\n" -"1:\n\t" -".section .fixup,\"ax\"\n\t" -"3: mov %[fault],%[err] ; jmp 1b\n\t" -".previous\n\t" - _ASM_EXTABLE(2b, 3b) + asmvolatile ("1: wrmsr ; xor %[err],%[err]\n" +"2:\n\t" + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_WRMSR_SAFE, %[err]) : [err] "=a" (err) - : "c" (msr), "0" (low), "d" (high), - [fault] "i" (-EIO) + : "c" (msr), "0" (low), "d" (high) : "memory"); if (tracepoint_enabled(write_msr))do_trace_write_msr (msr, ((u64 )high <<32 | low), err);
arch/x86/mm/extable.c +28 -23
74 lines not on this page · raw message
Peter Zijlstra
maintainerPATCH v2 9/23 x86,futex: Remove .fixup usage
In reply to Peter ZijlstraUse the new EX_TYPE_IMM_REG to store -EFAULT into the designated 'ret' register, this removes the need for anonymous .fixup code.
--- arch/x86/include/asm/extable_fixup_types.h | 2 ++ arch/x86/include/asm/futex.h | 28 ++++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +2 -0
@@ -32,6 +32,8 @@#define EX_TYPE_DEFAULT_MCE_SAFE 14#define EX_TYPE_FAULT_MCE_SAFE 15#define EX_TYPE_POP_ZERO 16 +#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ +#define EX_TYPE_EFAULT_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(-EFAULT))#endif
arch/x86/include/asm/futex.h +8 -20
@@ -17,13 +17,9 @@ do { \int oldval =0 , ret; \ asmvolatile ("1:\t" insn"\n" \"2:\n" \ -"\t.section .fixup,\"ax\"\n" \ -"3:\tmov\t%3, %1\n" \ -"\tjmp\t2b\n" \ -"\t.previous\n" \ - _ASM_EXTABLE_UA(1b, 3b) \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %1) \ : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \ - : "i" (-EFAULT), "0" (oparg), "1" (0)); \ + : "0" (oparg), "1" (0)); \if (ret) \ goto label; \ *oval = oldval; \
@@ -39,15 +35,11 @@ do { \"3:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \"\tjnz\t2b\n" \"4:\n" \ -"\t.section .fixup,\"ax\"\n" \ -"5:\tmov\t%5, %1\n" \ -"\tjmp\t4b\n" \ -"\t.previous\n" \ - _ASM_EXTABLE_UA(1b, 5b) \ -_ASM_EXTABLE_UA (3b ,5b ) \ + _ASM_EXTABLE_TYPE_REG(1b, 4b, EX_TYPE_EFAULT_REG, %1) \ + _ASM_EXTABLE_TYPE_REG(3b, 4b, EX_TYPE_EFAULT_REG, %1) \ : "=&a" (oldval), "=&r" (ret), \ "+m" (*uaddr), "=&r" (tem) \ - : "r" (oparg), "i" (-EFAULT), "1" (0)); \ + : "r" (oparg), "1" (0)); \if (ret) \ goto label; \ *oval = oldval; \
@@ -95,15 +87,11 @@ static inline int futex_atomic_cmpxchg_iif (!user_access_begin (uaddr,sizeof (u32)))return -EFAULT ; asmvolatile ("\n" -"1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" +"1:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" "2:\n" -"\t.section .fixup, \"ax\"\n" -"3:\tmov %3, %0\n" -"\tjmp 2b\n" -"\t.previous\n" - _ASM_EXTABLE_UA(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %0) \ : "+r" (ret), "=a" (oldval), "+m" (*uaddr) - : "i" (-EFAULT), "r" (newval), "1" (oldval) + : "r" (newval), "1" (oldval) : "memory" );user_access_end ();
[tip: x86/core] x86/futex: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 4c132d1d844a53fc4e4b5c34e36ef10d6124b783 Gitweb: https://git.kernel.org/tip/4c132d1d844a53fc4e4b5c34e36ef10d6124b783 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:11 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:47 +01:00
x86/futex: Remove .fixup usage
Use the new EX_TYPE_IMM_REG to store -EFAULT into the designated 'ret' register, this removes the need for anonymous .fixup code.
--- arch/x86/include/asm/extable_fixup_types.h | 2 ++- arch/x86/include/asm/futex.h | 28 ++++++--------------- 2 files changed, 10 insertions(+), 20 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +2 -0
@@ -42,6 +42,8 @@#define EX_TYPE_DEFAULT_MCE_SAFE 14#define EX_TYPE_FAULT_MCE_SAFE 15#define EX_TYPE_POP_ZERO 16 +#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ +#define EX_TYPE_EFAULT_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(-EFAULT))#endif
arch/x86/include/asm/futex.h +8 -20
@@ -17,13 +17,9 @@ do { \int oldval =0 , ret; \ asmvolatile ("1:\t" insn"\n" \"2:\n" \ -"\t.section .fixup,\"ax\"\n" \ -"3:\tmov\t%3, %1\n" \ -"\tjmp\t2b\n" \ -"\t.previous\n" \ - _ASM_EXTABLE_UA(1b, 3b) \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %1) \ : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \ - : "i" (-EFAULT), "0" (oparg), "1" (0)); \ + : "0" (oparg), "1" (0)); \if (ret) \ goto label; \ *oval = oldval; \
@@ -39,15 +35,11 @@ do { \"3:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \"\tjnz\t2b\n" \"4:\n" \ -"\t.section .fixup,\"ax\"\n" \ -"5:\tmov\t%5, %1\n" \ -"\tjmp\t4b\n" \ -"\t.previous\n" \ - _ASM_EXTABLE_UA(1b, 5b) \ -_ASM_EXTABLE_UA (3b ,5b ) \ + _ASM_EXTABLE_TYPE_REG(1b, 4b, EX_TYPE_EFAULT_REG, %1) \ + _ASM_EXTABLE_TYPE_REG(3b, 4b, EX_TYPE_EFAULT_REG, %1) \ : "=&a" (oldval), "=&r" (ret), \ "+m" (*uaddr), "=&r" (tem) \ - : "r" (oparg), "i" (-EFAULT), "1" (0)); \ + : "r" (oparg), "1" (0)); \if (ret) \ goto label; \ *oval = oldval; \
@@ -95,15 +87,11 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,if (!user_access_begin (uaddr,sizeof (u32)))return -EFAULT ; asmvolatile ("\n" -"1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" +"1:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" "2:\n" -"\t.section .fixup, \"ax\"\n" -"3:\tmov %3, %0\n" -"\tjmp 2b\n" -"\t.previous\n" - _ASM_EXTABLE_UA(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %0) \ : "+r" (ret), "=a" (oldval), "+m" (*uaddr) - : "i" (-EFAULT), "r" (newval), "1" (oldval) + : "r" (newval), "1" (oldval) : "memory" );user_access_end ();
Peter Zijlstra
maintainerPATCH v2 10/23 x86,uaccess: Remove .fixup usage
In reply to Peter ZijlstraFor the !CC_AS_ASM_GOTO_OUTPUT (aka. the legacy codepath), remove the .fixup usage by employing both EX_TYPE_EFAULT_REG and EX_FLAG_CLEAR. Like was already done for X86_32's version of __get_user_asm_u64() use the "a" register for output, specifically so we can use CLEAR_AX.
--- arch/x86/include/asm/uaccess.h | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-)
arch/x86/include/asm/uaccess.h +17 -22
@@ -351,24 +351,22 @@ do { \"1: movl %[lowbits],%%eax\n" \"2: movl %[highbits],%%edx\n" \"3:\n" \ -".section .fixup,\"ax\"\n" \ -"4: mov %[efault],%[errout]\n" \ -" xorl %%eax,%%eax\n" \ -" xorl %%edx,%%edx\n" \ -" jmp 3b\n" \ -".previous\n" \ - _ASM_EXTABLE_UA(1b, 4b) \ -_ASM_EXTABLE_UA (2b ,4b ) \ + _ASM_EXTABLE_TYPE_REG(1b ,3b ,EX_TYPE_EFAULT_REG | \ +EX_FLAG_CLEAR_AX_DX , \ + %[errout]) \ +_ASM_EXTABLE_TYPE_REG (2b ,3b ,EX_TYPE_EFAULT_REG | \ +EX_FLAG_CLEAR_AX_DX , \ + %[errout]) \ : [errout] "=r" (retval), \ [output] "=&A"(x) \: [lowbits] " m" (__m(__ptr)), \ [highbits] " m" __m(((u32 __user *)(__ptr)) + 1), \ - [efault] "i" (-EFAULT), "0" (retval)); \ + "0" (retval)); \ }) #else #define __get_user_asm_u64(x, ptr, retval) \ - __get_user_asm(x, ptr, retval, "q", "=r") + __get_user_asm(x, ptr, retval, "q")#endif #define __get_user_size (x, ptr, size, retval) \
@@ -379,14 +377,14 @@ do { \__chk_user_ptr (ptr); \switch (size) { \case 1 : \ -__get_user_asm (x_u8__, ptr, retval,"b" ,"=q" ); \ +__get_user_asm (x_u8__, ptr, retval,"b" ); \ (x) = x_u8__; \break ; \case 2 : \ -__get_user_asm (x, ptr, retval,"w" ,"=r" ); \ +__get_user_asm (x, ptr, retval,"w" ); \break ; \case 4 : \ -__get_user_asm (x, ptr, retval,"l" ,"=r" ); \ +__get_user_asm (x, ptr, retval,"l" ); \break ; \case 8 : \__get_user_asm_u64 (x, ptr, retval); \
@@ -396,20 +394,17 @@ do { \ } \ } while (0) -#define __get_user_asm (x, addr, err, itype, ltype) \ +#define __get_user_asm (x, addr, err, itype) \ asm volatile("\n" \ "1: mov"itype" %[umem],%[output]\n" \ "2:\n" \ - ".section .fixup,\"ax\"\n" \ - "3: mov %[efault],%[errout]\n" \ - " xorl %k[output],%k[output]\n" \ - " jmp 2b\n" \ - ".previous\n" \ - _ASM_EXTABLE_UA(1b, 3b) \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG | \ + EX_FLAG_CLEAR_AX, \ + %[errout]) \ : [errout] "=r" (err), \ - [output] ltype(x) \ + [output] "=a" (x) \ : [umem] "m" (__m(addr)), \ - [efault] "i" (-EFAULT), "0" (err)) + "0" (err))#endif // CONFIG_CC_HAS_ASM_GOTO_OUTPUT
[tip: x86/core] x86/uaccess: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 99641e094d6ccf547b3eba833aea9a34fdf5681e Gitweb: https://git.kernel.org/tip/99641e094d6ccf547b3eba833aea9a34fdf5681e Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:12 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:47 +01:00
x86/uaccess: Remove .fixup usage
For the !CC_AS_ASM_GOTO_OUTPUT (aka. the legacy codepath), remove the .fixup usage by employing both EX_TYPE_EFAULT_REG and EX_FLAG_CLEAR. Like was already done for X86_32's version of __get_user_asm_u64() use the "a" register for output, specifically so we can use CLEAR_AX.
--- arch/x86/include/asm/uaccess.h | 39 ++++++++++++++------------------- 1 file changed, 17 insertions(+), 22 deletions(-)
arch/x86/include/asm/uaccess.h +17 -22
@@ -351,24 +351,22 @@ do { \"1: movl %[lowbits],%%eax\n" \"2: movl %[highbits],%%edx\n" \"3:\n" \ -".section .fixup,\"ax\"\n" \ -"4: mov %[efault],%[errout]\n" \ -" xorl %%eax,%%eax\n" \ -" xorl %%edx,%%edx\n" \ -" jmp 3b\n" \ -".previous\n" \ - _ASM_EXTABLE_UA(1b, 4b) \ -_ASM_EXTABLE_UA (2b ,4b ) \ + _ASM_EXTABLE_TYPE_REG(1b ,3b ,EX_TYPE_EFAULT_REG | \ +EX_FLAG_CLEAR_AX_DX , \ + %[errout]) \ +_ASM_EXTABLE_TYPE_REG (2b ,3b ,EX_TYPE_EFAULT_REG | \ +EX_FLAG_CLEAR_AX_DX , \ + %[errout]) \ : [errout] "=r" (retval), \ [output] "=&A"(x) \: [lowbits] " m" (__m(__ptr)), \ [highbits] " m" __m(((u32 __user *)(__ptr)) + 1), \ - [efault] "i" (-EFAULT), "0" (retval)); \ + "0" (retval)); \ }) #else #define __get_user_asm_u64(x, ptr, retval) \ - __get_user_asm(x, ptr, retval, "q", "=r") + __get_user_asm(x, ptr, retval, "q")#endif #define __get_user_size (x, ptr, size, retval) \
@@ -379,14 +377,14 @@ do { \__chk_user_ptr (ptr); \switch (size) { \case 1 : \ -__get_user_asm (x_u8__, ptr, retval,"b" ,"=q" ); \ +__get_user_asm (x_u8__, ptr, retval,"b" ); \ (x) = x_u8__; \break ; \case 2 : \ -__get_user_asm (x, ptr, retval,"w" ,"=r" ); \ +__get_user_asm (x, ptr, retval,"w" ); \break ; \case 4 : \ -__get_user_asm (x, ptr, retval,"l" ,"=r" ); \ +__get_user_asm (x, ptr, retval,"l" ); \break ; \case 8 : \__get_user_asm_u64 (x, ptr, retval); \
@@ -396,20 +394,17 @@ do { \ } \ } while (0) -#define __get_user_asm (x, addr, err, itype, ltype) \ +#define __get_user_asm (x, addr, err, itype) \ asm volatile("\n" \ "1: mov"itype" %[umem],%[output]\n" \ "2:\n" \ - ".section .fixup,\"ax\"\n" \ - "3: mov %[efault],%[errout]\n" \ - " xorl %k[output],%k[output]\n" \ - " jmp 2b\n" \ - ".previous\n" \ - _ASM_EXTABLE_UA(1b, 3b) \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG | \ + EX_FLAG_CLEAR_AX, \ + %[errout]) \ : [errout] "=r" (err), \ - [output] ltype(x) \ + [output] "=a" (x) \ : [umem] "m" (__m(addr)), \ - [efault] "i" (-EFAULT), "0" (err)) + "0" (err))#endif // CONFIG_CC_HAS_ASM_GOTO_OUTPUT
Peter Zijlstra
maintainerPATCH v2 11/23 x86,xen: Remove .fixup usage
In reply to Peter ZijlstraEmploy the fancy new EX_TYPE_IMM_REG to store -EFAULT in the return register and use this to remove some Xen .fixup usage.
All callers of these functions only test for 0 return, so the actual return value change from -1 to -EFAULT is immaterial.
--- arch/x86/include/asm/xen/page.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
arch/x86/include/asm/xen/page.h +3 -11
@@ -96,11 +96,7 @@ static inline int xen_safe_write_ulong(u asmvolatile ("1: mov %[val], %[ptr]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[ret]) : [ret] "+r" (ret), [ptr] "=m" (*addr) : [val] "r" (val));
@@ -110,16 +106,12 @@ static inline int xen_safe_write_ulong(ustatic inline int xen_safe_read_ulong (const unsigned long *addr,unsigned long *val) { -int ret =0 ;unsigned long rval = ~0ul ; +int ret =0 ; asmvolatile ("1: mov %[ptr], %[rval]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAUL_REG, %[ret]) : [ret] "+r" (ret), [rval] "+r" (rval) : [ptr] "m" (*addr)); *val = rval;
Juergen Gross
maintainerRe: [PATCH v2 11/23] x86,xen: Remove .fixup usage
Quoted 27 lines · Peter Zijlstra
Employ the fancy new
EX_TYPE_IMM_REGto store-EFAULTin the return register and use this to remove some Xen .fixup usage.All callers of these functions only test for 0 return, so the actual return value change from -1 to
-EFAULTis immaterial.Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- arch/x86/include/asm/xen/page.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)arch/x86/include/asm/xen/page.h +1
-5@@ -96,11 +96,7 @@ static inline int xen_safe_write_ulong(u asmvolatile ("1: mov %[val], %[ptr]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[ret]) : [ret] "+r" (ret), [ptr] "=m" (*addr) : [val] "r" (val));
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 110
Quoted 6 lines
arch/x86/include/asm/xen/page.h +1
-1@@ -110,16 +106,12 @@ static inline int xen_safe_write_ulong(ustatic inline int xen_safe_read_ulong (const unsigned long *addr,unsigned long *val) { -int ret =0 ;unsigned long rval = ~0ul ; +int ret =0 ;
Spurious change.
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 114
Quoted 9 lines
arch/x86/include/asm/xen/page.h +1
-5asmvolatile ("1: mov %[ptr], %[rval]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAUL_REG, %[ret])
I guess you didn't compile that? There is a typo: s/EFAUL/EFAULT/
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u
Quoted 5 lines
arch/x86/include/asm/xen/page.h +0
-0: [ret] "+r" (ret), [rval] "+r" (rval) : [ptr] "m" (*addr)); *val = rval;
Juergen
Peter Zijlstra
maintainerRe: [PATCH v2 11/23] x86,xen: Remove .fixup usage
Quoted 26 lines · Juergen Gross
Quoted 25 lines · Peter Zijlstra
Employ the fancy new
EX_TYPE_IMM_REGto store-EFAULTin the return register and use this to remove some Xen .fixup usage.All callers of these functions only test for 0 return, so the actual return value change from -1 to
-EFAULTis immaterial.Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- arch/x86/include/asm/xen/page.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)arch/x86/include/asm/xen/page.h +1
-5@@ -96,11 +96,7 @@ static inline int xen_safe_write_ulong(u asmvolatile ("1: mov %[val], %[ptr]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[ret]) : [ret] "+r" (ret), [ptr] "=m" (*addr) : [val] "r" (val));@@ -110,16 +106,12 @@ static inline int xen_safe_write_ulong(u
Quoted 8 lines
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 110
Quoted 6 lines
arch/x86/include/asm/xen/page.h +1
-1static inline int xen_safe_read_ulong (const unsigned long *addr,unsigned long *val) { -int ret =0 ;unsigned long rval = ~0ul ; +int ret =0 ;Spurious change.
Yeah, can't help myself, must be reverse xmas tree :-)
Quoted 10 lines
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 114
Quoted 8 lines
arch/x86/include/asm/xen/page.h +1
-5asmvolatile ("1: mov %[ptr], %[rval]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAUL_REG, %[ret])I guess you didn't compile that? There is a typo: s/EFAUL/EFAULT/
Damn.. I figure that must've gotten lost in the robot spam telling me clang can't do __cold on labels :/
Peter Zijlstra
maintainerRe: [PATCH v2 11/23] x86,xen: Remove .fixup usage
Quoted 8 lines · Peter Zijlstra
Quoted 3 lines · Juergen Gross
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 114
Quoted 1 line
arch/x86/include/asm/xen/page.h +1
-0+ _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAUL_REG, %[ret])I guess you didn't compile that? There is a typo: s/EFAUL/EFAULT/
Damn.. I figure that must've gotten lost in the robot spam telling me clang can't do
__coldon labels :/
new patch at:
Juergen Gross
maintainerRe: [PATCH v2 11/23] x86,xen: Remove .fixup usage
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Peter Zijlstra
Quoted 3 lines · Juergen Gross
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 114
Quoted 1 line
arch/x86/include/asm/xen/page.h +1
-0+ _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAUL_REG, %[ret])I guess you didn't compile that? There is a typo: s/EFAUL/EFAULT/
Quoted 7 lines
Quoted 2 lines
Damn.. I figure that must've gotten lost in the robot spam telling me clang can't do
__coldon labels :/new patch at:
"not found"
Peter Zijlstra
maintainerRe: [PATCH v2 11/23] x86,xen: Remove .fixup usage
Quoted 11 lines · Juergen Gross
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · Peter Zijlstra
Quoted 3 lines · Juergen Gross
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 114
Quoted 1 line
arch/x86/include/asm/xen/page.h +1
-0+ _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAUL_REG, %[ret])I guess you didn't compile that? There is a typo: s/EFAUL/EFAULT/
Damn.. I figure that must've gotten lost in the robot spam telling me clang can't do
__coldon labels :/
Quoted 6 lines
Quoted 4 lines
new patch at:
"not found"
Argh.. msgid contains '/' and that doesn't really work with URLs.
https://lore.kernel.org/lkml/YYu%2FAteC%[email protected]/
is the right url, in case you hand't yet found the actual email.
Re: [PATCH v2 11/23] x86,xen: Remove .fixup usage
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Juergen Gross
Quoted 14 lines · Peter Zijlstra
Quoted 8 lines · Peter Zijlstra
Quoted 3 lines · Juergen Gross
arch/x86/include/asm/xen/page.h static inline int xen_safe_write_ulong(u · line 114
Quoted 1 line
arch/x86/include/asm/xen/page.h +1
-0+ _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAUL_REG, %[ret])I guess you didn't compile that? There is a typo: s/EFAUL/EFAULT/
Damn.. I figure that must've gotten lost in the robot spam telling me clang can't do
__coldon labels :/new patch at:
Quoted 7 lines
Quoted 1 line
"not found"
Argh.. msgid contains '/' and that doesn't really work with URLs.
https://lore.kernel.org/lkml/YYu%2FAteC%[email protected]/
is the right url, in case you hand't yet found the actual email.
Looks good, you can add my:
Juergen
Peter Zijlstra
maintainerPATCH v2 11/23 x86,xen: Remove .fixup usage
In reply to Peter Zijlstrax86_64-allyesconfig now actually builds...
---
Subject: x86,xen: Remove .fixup usage
From: Peter Zijlstra <[email protected]>
Employ the fancy new EX_TYPE_IMM_REG to store -EFAULT in the return register and use this to remove some Xen .fixup usage.
All callers of these functions only test for 0 return, so the actual return value change from -1 to -EFAULT is immaterial.
--- arch/x86/include/asm/xen/page.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
arch/x86/include/asm/xen/page.h +3 -11
@@ -96,11 +96,7 @@ static inline int xen_safe_write_ulong(u asmvolatile ("1: mov %[val], %[ptr]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[ret]) : [ret] "+r" (ret), [ptr] "=m" (*addr) : [val] "r" (val));
@@ -110,16 +106,12 @@ static inline int xen_safe_write_ulong(ustatic inline int xen_safe_read_ulong (const unsigned long *addr,unsigned long *val) { -int ret =0 ;unsigned long rval = ~0ul ; +int ret =0 ; asmvolatile ("1: mov %[ptr], %[rval]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[ret]) : [ret] "+r" (ret), [rval] "+r" (rval) : [ptr] "m" (*addr)); *val = rval;
[tip: x86/core] x86/xen: Remove .fixup usage
In reply to Peter ZijlstraThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: e2b48e43284c0916ebf8e4240199b9d9747e337a Gitweb: https://git.kernel.org/tip/e2b48e43284c0916ebf8e4240199b9d9747e337a Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:13 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:48 +01:00
x86/xen: Remove .fixup usage
Employ the fancy new EX_TYPE_IMM_REG to store -EFAULT in the return register and use this to remove some Xen .fixup usage.
All callers of these functions only test for 0 return, so the actual return value change from -1 to -EFAULT is immaterial.
--- arch/x86/include/asm/xen/page.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
arch/x86/include/asm/xen/page.h +3 -11
@@ -96,11 +96,7 @@ static inline int xen_safe_write_ulong(unsigned long *addr, unsigned long val) asmvolatile ("1: mov %[val], %[ptr]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[ret]) : [ret] "+r" (ret), [ptr] "=m" (*addr) : [val] "r" (val));
@@ -110,16 +106,12 @@ static inline int xen_safe_write_ulong(unsigned long *addr, unsigned long val)static inline int xen_safe_read_ulong (const unsigned long *addr,unsigned long *val) { -int ret =0 ;unsigned long rval = ~0ul ; +int ret =0 ; asmvolatile ("1: mov %[ptr], %[rval]\n" "2:\n" -".section .fixup, \"ax\"\n" -"3: sub $1, %[ret]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[ret]) : [ret] "+r" (ret), [rval] "+r" (rval) : [ptr] "m" (*addr)); *val = rval;
Peter Zijlstra
maintainerPATCH v2 12/23 x86,fpu: Remove .fixup usage
In reply to Peter ZijlstraEmploy EX_TYPE_EFAULT_REG to store '-EFAULT' into the %[err] register on exception. All the callers only ever test for 0, so the change from -1 to -EFAULT is immaterial.
--- arch/x86/kernel/fpu/legacy.h | 6 +----- arch/x86/kernel/fpu/xstate.h | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-)
arch/x86/kernel/fpu/legacy.h +1 -5
@@ -35,11 +35,7 @@ static inline void ldmxcsr(u32 mxcsr)int err; \ asm volatile("1:" #insn "\n\t" \ "2:\n" \ - ".section .fixup,\"ax\"\n" \ - "3: movl $-1,%[err]\n" \ - " jmp 2b\n" \ - ".previous\n" \ - _ASM_EXTABLE(1b, 3b) \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[err]) \ : [err] "=r" (err), output \ : "0"(0), input); \ err; \
arch/x86/kernel/fpu/xstate.h +1 -5
@@ -108,11 +108,7 @@ static inline u64 xfeatures_mask_indepen"\n" \"xor %[err], %[err]\n" \"3:\n" \ -".pushsection .fixup,\"ax\"\n" \ -"4: movl $-2, %[err]\n" \ -"jmp 3b\n" \ -".popsection\n" \ - _ASM_EXTABLE(661b ,4b ) \ + _ASM_EXTABLE_TYPE_REG(661b, 3b, EX_TYPE_EFAULT_REG, %[err]) \ : [err] "=r" (err) \: " D " (st), " m" (*st), " a" (lmask), " d" (hmask) \ : "memory")
[tip: x86/core] x86/fpu: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 1c3b9091d084d92c70a4260553853509637276b9 Gitweb: https://git.kernel.org/tip/1c3b9091d084d92c70a4260553853509637276b9 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:14 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:48 +01:00
x86/fpu: Remove .fixup usage
Employ EX_TYPE_EFAULT_REG to store '-EFAULT' into the %[err] register on exception. All the callers only ever test for 0, so the change from -1 to -EFAULT is immaterial.
--- arch/x86/kernel/fpu/legacy.h | 6 +----- arch/x86/kernel/fpu/xstate.h | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-)
arch/x86/kernel/fpu/legacy.h +1 -5
@@ -35,11 +35,7 @@ static inline void ldmxcsr(u32 mxcsr)int err; \ asm volatile("1:" #insn "\n\t" \ "2:\n" \ - ".section .fixup,\"ax\"\n" \ - "3: movl $-1,%[err]\n" \ - " jmp 2b\n" \ - ".previous\n" \ - _ASM_EXTABLE(1b, 3b) \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %[err]) \ : [err] "=r" (err), output \ : "0"(0), input); \ err; \
arch/x86/kernel/fpu/xstate.h +1 -5
@@ -108,11 +108,7 @@ static inline u64 xfeatures_mask_independent(void)"\n" \"xor %[err], %[err]\n" \"3:\n" \ -".pushsection .fixup,\"ax\"\n" \ -"4: movl $-2, %[err]\n" \ -"jmp 3b\n" \ -".popsection\n" \ - _ASM_EXTABLE(661b ,4b ) \ + _ASM_EXTABLE_TYPE_REG(661b, 3b, EX_TYPE_EFAULT_REG, %[err]) \ : [err] "=r" (err) \: " D " (st), " m" (*st), " a" (lmask), " d" (hmask) \ : "memory")
Peter Zijlstra
maintainerPATCH v2 13/23 x86,segment: Remove .fixup usage
In reply to Peter ZijlstraCreate and use EX_TYPE_ZERO_REG to clear the register and retry the segment load on exception.
--- arch/x86/include/asm/extable_fixup_types.h | 1 + arch/x86/include/asm/segment.h | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +1 -0
@@ -45,5 +45,6 @@#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ #define EX_TYPE_EFAULT_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(-EFAULT)) +#define EX_TYPE_ZERO_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(0))#endif
arch/x86/include/asm/segment.h +1 -8
@@ -307,14 +307,7 @@ do { \ \ asm volatile(" \n" \ "1: movl %k0,%%" #seg " \n" \ - \ - ".section .fixup,\"ax\" \n" \ - "2: xorl %k0,%k0 \n" \ - " jmp 1b \n" \ - ".previous \n" \ - \ - _ASM_EXTABLE(1b, 2b) \ - \ + _ASM_EXTABLE_TYPE_REG(1b, 1b, EX_TYPE_ZERO_REG, %k0)\ : "+r" (__val) : : "memory"); \ } while (0)
[tip: x86/core] x86/segment: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 5fc77b916cb82fe476ae2344e0ec37445227a4f8 Gitweb: https://git.kernel.org/tip/5fc77b916cb82fe476ae2344e0ec37445227a4f8 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:15 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:48 +01:00
x86/segment: Remove .fixup usage
Create and use EX_TYPE_ZERO_REG to clear the register and retry the segment load on exception.
--- arch/x86/include/asm/extable_fixup_types.h | 1 + arch/x86/include/asm/segment.h | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +1 -0
@@ -45,5 +45,6 @@#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ #define EX_TYPE_EFAULT_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(-EFAULT)) +#define EX_TYPE_ZERO_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(0))#endif
arch/x86/include/asm/segment.h +1 -8
@@ -307,14 +307,7 @@ do { \ \ asm volatile(" \n" \ "1: movl %k0,%%" #seg " \n" \ - \ - ".section .fixup,\"ax\" \n" \ - "2: xorl %k0,%k0 \n" \ - " jmp 1b \n" \ - ".previous \n" \ - \ - _ASM_EXTABLE(1b, 2b) \ - \ + _ASM_EXTABLE_TYPE_REG(1b, 1b, EX_TYPE_ZERO_REG, %k0)\ : "+r" (__val) : : "memory"); \ } while (0)
Peter Zijlstra
maintainerPATCH v2 14/23 x86,kvm: Remove .fixup usage
In reply to Peter ZijlstraKVM instruction emulation has a gnarly hack where the .fixup does a return, however there's already a ret right after the 10b label, so mark that as 11 and have the exception clear %esi to remove the .fixup.
--- arch/x86/include/asm/extable_fixup_types.h | 1 + arch/x86/kvm/emulate.c | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +1 -0
@@ -46,5 +46,6 @@#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ #define EX_TYPE_EFAULT_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(-EFAULT))#define EX_TYPE_ZERO_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(0)) +#define EX_TYPE_ONE_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(1))#endif
arch/x86/kvm/emulate.c +4 -12
@@ -315,7 +315,7 @@ static int fastop(struct x86_emulate_ctx __FOP_FUNC(#name)#define __FOP_RET (name) \ - "ret \n\t" \ + "11: ret \n\t" \ ".size " name ", .-" name "\n\t"#define FOP_RET (name) \
@@ -344,7 +344,7 @@ static int fastop(struct x86_emulate_ctx __FOP_RET(#op "_" #dst)#define FOP1EEX (op, dst) \ - FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception) + FOP1E(op, dst) _ASM_EXTABLE_TYPE_REG(10b, 11b, EX_TYPE_ZERO_REG, %esi)#define FASTOP1 (op) \ FOP_START(op) \
@@ -434,10 +434,6 @@ static int fastop(struct x86_emulate_ctx#op " %al \n\t" \ __FOP_RET(#op) -asm(".pushsection .fixup, \"ax\"\n" -"kvm_fastop_exception: xor %esi, %esi; ret\n" -".popsection" ); - FOP_START(setcc) FOP_SETCC(seto) FOP_SETCC(setno)
@@ -473,12 +469,8 @@ FOP_END; \ asmvolatile ("1:" insn"\n" \"2:\n" \ -".pushsection .fixup, \"ax\"\n" \ -"3: movl $1, %[_fault]\n" \ -" jmp 2b\n" \ -".popsection\n" \ - _ASM_EXTABLE(1b, 3b) \ - : [_fault] "+qm"(_fault) inoutclob ); \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %[_fault]) \ + : [_fault] "+r"(_fault) inoutclob ); \\ _fault ? X86EMUL_UNHANDLEABLE : X86EMUL_CONTINUE; \ })
[tip: x86/core] x86/kvm: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: c9a34c3f4ece192f6d804039fe6aac9618f0d236 Gitweb: https://git.kernel.org/tip/c9a34c3f4ece192f6d804039fe6aac9618f0d236 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:16 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:48 +01:00
x86/kvm: Remove .fixup usage
KVM instruction emulation has a gnarly hack where the .fixup does a return, however there's already a ret right after the 10b label, so mark that as 11 and have the exception clear %esi to remove the .fixup.
--- arch/x86/include/asm/extable_fixup_types.h | 1 + arch/x86/kvm/emulate.c | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +1 -0
@@ -46,5 +46,6 @@#define EX_TYPE_IMM_REG 17/* reg := (long)imm */ #define EX_TYPE_EFAULT_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(-EFAULT))#define EX_TYPE_ZERO_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(0)) +#define EX_TYPE_ONE_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(1))#endif
arch/x86/kvm/emulate.c +4 -12
@@ -315,7 +315,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); __FOP_FUNC(#name)#define __FOP_RET (name) \ - ASM_RET \ + "11: " ASM_RET \ ".size " name ", .-" name "\n\t"#define FOP_RET (name) \
@@ -344,7 +344,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); __FOP_RET(#op "_" #dst)#define FOP1EEX (op, dst) \ - FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception) + FOP1E(op, dst) _ASM_EXTABLE_TYPE_REG(10b, 11b, EX_TYPE_ZERO_REG, %%esi)#define FASTOP1 (op) \ FOP_START(op) \
@@ -434,10 +434,6 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);#op " %al \n\t" \ __FOP_RET(#op) -asm(".pushsection .fixup, \"ax\"\n" -"kvm_fastop_exception: xor %esi, %esi; " ASM_RET -".popsection" ); - FOP_START(setcc) FOP_SETCC(seto) FOP_SETCC(setno)
@@ -473,12 +469,8 @@ FOP_END; \ asmvolatile ("1:" insn"\n" \"2:\n" \ -".pushsection .fixup, \"ax\"\n" \ -"3: movl $1, %[_fault]\n" \ -" jmp 2b\n" \ -".popsection\n" \ - _ASM_EXTABLE(1b, 3b) \ - : [_fault] "+qm"(_fault) inoutclob ); \ + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %[_fault]) \ + : [_fault] "+r"(_fault) inoutclob ); \\ _fault ? X86EMUL_UNHANDLEABLE : X86EMUL_CONTINUE; \ })
Peter Zijlstra
maintainerPATCH v2 15/23 x86,vmx: Remove .fixup usage
In reply to Peter ZijlstraIn the vmread exceptin path, use the, thus far, unused output register to push the @fault argument onto the stack. This, in turn, enables the exception handler to not do pushes and only modify that register when an exception does occur.
As noted by Sean the input constraint needs to be changed to "=&r" to avoid the value and field occupying the same register.
--- arch/x86/kvm/vmx/vmx_ops.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
arch/x86/kvm/vmx/vmx_ops.h +7 -9
@@ -80,9 +80,11 @@ static __always_inline unsigned long __v* @field, and bounce through the trampoline to preserve * volatile registers. */ -"push $0\n\t" +"xorl %k1, %k1\n\t" +"2:\n\t" +"push %1\n\t" "push %2\n\t" -"2:call vmread_error_trampoline\n\t" +"call vmread_error_trampoline\n\t" /* * Unwind the stack. Note, the trampoline zeros out the
@@ -93,13 +95,9 @@ static __always_inline unsigned long __v"3:\n\t" /* VMREAD faulted. As above, except push '1' for @fault. */ -".pushsection .fixup, \"ax\"\n\t" -"4: push $1\n\t" -"push %2\n\t" -"jmp 2b\n\t" -".popsection\n\t" - _ASM_EXTABLE(1b ,4b ) - : ASM_CALL_CONSTRAINT, "=r"(value) : "r"(field) : "cc"); + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %1) + + : ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc"); return value; }
[tip: x86/core] x86/vmx: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 3e8ea7803a1dedf19120a2fef12c590e90e4b469 Gitweb: https://git.kernel.org/tip/3e8ea7803a1dedf19120a2fef12c590e90e4b469 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:17 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:49 +01:00
x86/vmx: Remove .fixup usage
In the vmread exceptin path, use the, thus far, unused output register to push the @fault argument onto the stack. This, in turn, enables the exception handler to not do pushes and only modify that register when an exception does occur.
As noted by Sean the input constraint needs to be changed to "=&r" to avoid the value and field occupying the same register.
--- arch/x86/kvm/vmx/vmx_ops.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
arch/x86/kvm/vmx/vmx_ops.h +7 -9
@@ -80,9 +80,11 @@ static __always_inline unsigned long __vmcs_readl(unsigned long field)* @field, and bounce through the trampoline to preserve * volatile registers. */ -"push $0\n\t" +"xorl %k1, %k1\n\t" +"2:\n\t" +"push %1\n\t" "push %2\n\t" -"2:call vmread_error_trampoline\n\t" +"call vmread_error_trampoline\n\t" /* * Unwind the stack. Note, the trampoline zeros out the
@@ -93,13 +95,9 @@ static __always_inline unsigned long __vmcs_readl(unsigned long field)"3:\n\t" /* VMREAD faulted. As above, except push '1' for @fault. */ -".pushsection .fixup, \"ax\"\n\t" -"4: push $1\n\t" -"push %2\n\t" -"jmp 2b\n\t" -".popsection\n\t" - _ASM_EXTABLE(1b ,4b ) - : ASM_CALL_CONSTRAINT, "=r"(value) : "r"(field) : "cc"); + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %1) + + : ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc"); return value; }
Peter Zijlstra
maintainerPATCH v2 16/23 x86,vmx: Provide asm-goto-output vmread
In reply to Peter ZijlstraUse asm-goto-output for smaller fast path code.
--- arch/x86/kvm/vmx/vmx_ops.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/x86/kvm/vmx/vmx_ops.h +27 -0
@@ -71,6 +71,31 @@ static __always_inline unsigned long __v {unsigned long value; +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT + +asm_volatile_goto ("1: vmread %[field], %[output]\n\t" +"jna %l[do_fail]\n\t" + + _ASM_EXTABLE(1b, %l[do_exception]) + + : ASM_CALL_CONSTRAINT, [output] "=r" (value) + : [field] "r" (field) + : "cc" + : do_fail, do_exception); + +return value; + +do_fail: +WARN_ONCE (1 ,"kvm: vmread failed: field=%lx\n" , field); +pr_warn_ratelimited ("kvm: vmread failed: field=%lx\n" , field); +return 0 ; + +do_exception: +kvm_spurious_fault (); +return 0 ; + +#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ + asmvolatile ("1: vmread %2, %1\n\t" ".byte 0x3e\n\t" /* branch taken hint */ "ja 3f\n\t"
@@ -99,6 +124,8 @@ static __always_inline unsigned long __v : ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc");return value; + +#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ } static __always_inline u16 vmcs_read16(unsigned long field)
Re: [PATCH v2 16/23] x86,vmx: Provide asm-goto-output vmread
Here's a version that doesn't make clang ICE..
Paolo, since this doesn't really depend on the .fixup removal series, feel free to collect it in the kvm tree or somesuch.
---
Subject: x86/vmx: Provide asm-goto-output vmread
From: Peter Zijlstra <[email protected]>
Date: Wed, 10 Nov 2021 11:01:18 +0100
Use asm-goto-output for smaller fast path code.
--- arch/x86/kvm/vmx/vmx_ops.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/x86/kvm/vmx/vmx_ops.h +27 -0
@@ -71,6 +71,31 @@ static __always_inline unsigned long __v {unsigned long value; +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT + +asm_volatile_goto ("1: vmread %[field], %[output]\n\t" +"jna %l[do_fail]\n\t" + + _ASM_EXTABLE(1b, %l[do_exception]) + + : [output] "=r" (value) + : [field] "r" (field) + : "cc" + : do_fail, do_exception); + +return value; + +do_fail: +WARN_ONCE (1 ,"kvm: vmread failed: field=%lx\n" , field); +pr_warn_ratelimited ("kvm: vmread failed: field=%lx\n" , field); +return 0 ; + +do_exception: +kvm_spurious_fault (); +return 0 ; + +#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ + asmvolatile ("1: vmread %2, %1\n\t" ".byte 0x3e\n\t" /* branch taken hint */ "ja 3f\n\t"
@@ -99,6 +124,8 @@ static __always_inline unsigned long __v : ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc");return value; + +#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ } static __always_inline u16 vmcs_read16(unsigned long field)
Sean Christopherson
maintainerRe: [PATCH v2 16/23] x86,vmx: Provide asm-goto-output vmread
Quoted 32 lines · Peter Zijlstra
Here's a version that doesn't make clang ICE..
Paolo, since this doesn't really depend on the .fixup removal series, feel free to collect it in the kvm tree or somesuch.
---
Subject: x86/vmx: Provide asm-goto-output vmread
From: Peter Zijlstra <[email protected]>
Date: Wed, 10 Nov 2021 11:01:18 +0100Use asm-goto-output for smaller fast path code.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>Reviewed-by Josh Poimboeuf <[email protected]>--- arch/x86/kvm/vmx/vmx_ops.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)arch/x86/kvm/vmx/vmx_ops.h +7
-0@@ -71,6 +71,31 @@ static __always_inline unsigned long __v {unsigned long value; +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT + +asm_volatile_goto ("1: vmread %[field], %[output]\n\t" +"jna %l[do_fail]\n\t" + + _ASM_EXTABLE(1b, %l[do_exception]) +
arch/x86/kvm/vmx/vmx_ops.h static __always_inline unsigned long __v · line 90
Quoted 10 lines
arch/x86/kvm/vmx/vmx_ops.h +10
-0+ : [output] "=r" (value) + : [field] "r" (field) + : "cc" + : do_fail, do_exception); + +return value; + +do_fail: +WARN_ONCE (1 ,"kvm: vmread failed: field=%lx\n" , field); +pr_warn_ratelimited ("kvm: vmread failed: field=%lx\n" , field);
This needs to route through a noinline vmread_error(), the intent is that KVM only does WARN once for all VMREAD failures, whereas having this inline will WARN once on each unique vmcs_read*(). And at that point, we might as well hide the asm trampoline too. The amount of ifdeffery gets a bit gross, but in for a penny in for a pound?
And like the other VMX instruction, I assume it's safe to annotate the failure path as instrumentation safe.
So this?
--- arch/x86/kvm/vmx/vmenter.S | 2 ++ arch/x86/kvm/vmx/vmx.c | 7 +++++++ arch/x86/kvm/vmx/vmx_ops.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+)
arch/x86/kvm/vmx/vmenter.S +2 -0
@@ -238,6 +238,7 @@ SYM_FUNC_END(__vmx_vcpu_run) .section .text, "ax" +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT /** * vmread_error_trampoline - Trampoline from inline asm to vmread_error() * @field: VMCS field encoding that failed
@@ -295,6 +296,7 @@ SYM_FUNC_START(vmread_error_trampoline) ret SYM_FUNC_END(vmread_error_trampoline) +#endif SYM_FUNC_START(vmx_do_interrupt_nmi_irqoff) /*
arch/x86/kvm/vmx/vmx.c +7 -0
@@ -373,6 +373,12 @@ do { \pr_warn_ratelimited (fmt); \ } while (0) +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT +noinline void vmread_error(unsigned long field) +{ +vmx_insn_failed ("kvm: vmread failed: field=%lx\n" , field); +} +#else asmlinkage void vmread_error(unsigned long field, bool fault) {if (fault)
@@ -380,6 +386,7 @@ asmlinkage void vmread_error(unsigned long field, bool fault) else vmx_insn_failed("kvm: vmread failed: field=%lx\n", field); } +#endif noinline void vmwrite_error(unsigned long field, unsigned long value) {
arch/x86/kvm/vmx/vmx_ops.h +31 -0
@@ -10,9 +10,13 @@#include "vmcs.h" #include "x86.h" +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT +noinline void vmread_error(unsigned long field); +#else asmlinkage void vmread_error(unsigned long field, bool fault); __attribute__((regparm (0 )))void vmread_error_trampoline (unsigned long field,bool fault); +#endif void vmwrite_error (unsigned long field,unsigned long value);void vmclear_error (struct vmcs *vmcs,u64 phys_addr);void vmptrld_error (struct vmcs *vmcs,u64 phys_addr);
@@ -71,6 +75,31 @@ static __always_inline unsigned long __vmcs_readl(unsigned long field) {unsigned long value; +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT +asm_volatile_goto ("1: vmread %[field], %[output]\n\t" +"jna %l[do_fail]\n\t" + + _ASM_EXTABLE(1b, %l[do_exception]) + + : [output] "=r" (value) + : [field] "r" (field) + : "cc" + : do_fail, do_exception); + +return value; + +do_fail: +instrumentation_begin (); +vmread_error (field); +instrumentation_end (); +return 0 ; + +do_exception: +kvm_spurious_fault (); +return 0 ; + +#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ + asmvolatile ("1: vmread %2, %1\n\t" ".byte 0x3e\n\t" /* branch taken hint */ "ja 3f\n\t"
@@ -101,6 +130,8 @@ static __always_inline unsigned long __vmcs_readl(unsigned long field) _ASM_EXTABLE(1b, 4b) : ASM_CALL_CONSTRAINT, "=r"(value) : "r"(field) : "cc"); return value; + +#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ } static __always_inline u16 vmcs_read16(unsigned long field)
--
Peter Zijlstra
maintainerRe: [PATCH v2 16/23] x86,vmx: Provide asm-goto-output vmread
Quoted 3 lines · Sean Christopherson
This needs to route through a noinline
vmread_error(), the intent is that KVM only does WARN once for all VMREAD failures, whereas having this inline will WARN once on each unique vmcs_read*().
Oh, fair enough.
Quoted 8 lines
And at that point, we might as well hide the asm
trampoline too. The amount of ifdeffery gets a bit gross, but in for a penny in for a pound?And like the other VMX instruction, I assume it's safe to annotate the failure path as instrumentation safe.
So this?
Yep, think so.
Quoted 11 lines
--- arch/x86/kvm/vmx/vmenter.S | 2 ++ arch/x86/kvm/vmx/vmx.c | 7 +++++++ arch/x86/kvm/vmx/vmx_ops.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+)arch/x86/kvm/vmx/vmenter.S +0
-0
arch/x86/kvm/vmx/vmenter.S SYM_FUNC_END(__vmx_vcpu_run) · line 241
Quoted 4 lines
arch/x86/kvm/vmx/vmenter.S +1
-0@@ -238,6 +238,7 @@ SYM_FUNC_END(__vmx_vcpu_run) .section .text, "ax" +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
#ifndef ?
Quoted 3 lines
arch/x86/kvm/vmx/vmenter.S +0
-0/** * vmread_error_trampoline - Trampoline from inline asm to vmread_error() * @field: VMCS field encoding that failed
Sean Christopherson
maintainerRe: [PATCH v2 16/23] x86,vmx: Provide asm-goto-output vmread
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Sean Christopherson
--- arch/x86/kvm/vmx/vmenter.S | 2 ++ arch/x86/kvm/vmx/vmx.c | 7 +++++++ arch/x86/kvm/vmx/vmx_ops.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+)arch/x86/kvm/vmx/vmenter.S +0
-0@@ -238,6 +238,7 @@ SYM_FUNC_END(__vmx_vcpu_run)
Quoted 5 lines
arch/x86/kvm/vmx/vmenter.S SYM_FUNC_END(__vmx_vcpu_run) · line 241
Quoted 3 lines
arch/x86/kvm/vmx/vmenter.S +1
-0.section .text, "ax" +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT#ifndef ?
Huh. Yes. Could have sworn my gcc version doesn't have goto with output.
Peter Zijlstra
maintainerPATCH v2 17/23 x86,checksum_32: Remove .fixup usage
In reply to Peter ZijlstraSimply add EX_FLAG_CLEAR_AX to do as the .fixup used to do.
--- arch/x86/lib/checksum_32.S | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
arch/x86/lib/checksum_32.S +3 -16
@@ -260,9 +260,9 @@ unsigned int csum_partial_copy_generic ( * Copy from ds while checksumming, otherwise like csum_partial */ -#define EXC(y...) \ - 9999: y; \ - _ASM_EXTABLE_UA(9999b, 6001f) +#define EXC(y...) \ + 9999: y; \ + _ASM_EXTABLE_TYPE(9999b, 7f, EX_TYPE_UACCESS | EX_FLAG_CLEAR_AX) #ifndef CONFIG_X86_USE_PPRO_CHECKSUM
@@ -358,15 +358,6 @@ EXC( movb %cl, (%edi) ) adcl $0, %eax 7: -# Exception handler: -.section .fixup, "ax" - -6001: - xorl %eax, %eax - jmp 7b - -.previous - popl %ebx popl %esi popl %edi
@@ -439,10 +430,6 @@ EXC( movb %dl, (%edi) ) 6: addl %edx, %eax adcl $0, %eax 7: -.section .fixup, "ax" -6001: xorl %eax, %eax - jmp 7b -.previous popl %esi popl %edi
[tip: x86/core] x86/checksum_32: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: fedb24cda1ca5407e1965b261e349ea85d6c03dc Gitweb: https://git.kernel.org/tip/fedb24cda1ca5407e1965b261e349ea85d6c03dc Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:19 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:49 +01:00
x86/checksum_32: Remove .fixup usage
Simply add EX_FLAG_CLEAR_AX to do as the .fixup used to do.
--- arch/x86/lib/checksum_32.S | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
arch/x86/lib/checksum_32.S +3 -16
@@ -260,9 +260,9 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst, * Copy from ds while checksumming, otherwise like csum_partial */ -#define EXC(y...) \ - 9999: y; \ - _ASM_EXTABLE_UA(9999b, 6001f) +#define EXC(y...) \ + 9999: y; \ + _ASM_EXTABLE_TYPE(9999b, 7f, EX_TYPE_UACCESS | EX_FLAG_CLEAR_AX) #ifndef CONFIG_X86_USE_PPRO_CHECKSUM
@@ -358,15 +358,6 @@ EXC( movb %cl, (%edi) ) adcl $0, %eax 7: -# Exception handler: -.section .fixup, "ax" - -6001: - xorl %eax, %eax - jmp 7b - -.previous - popl %ebx popl %esi popl %edi
@@ -439,10 +430,6 @@ EXC( movb %dl, (%edi) ) 6: addl %edx, %eax adcl $0, %eax 7: -.section .fixup, "ax" -6001: xorl %eax, %eax - jmp 7b -.previous popl %esi popl %edi
Peter Zijlstra
maintainerPATCH v2 18/23 x86,sgx: Remove .fixup usage
In reply to Peter ZijlstraCreate EX_TYPE_FAULT_SGX which does as EX_TYPE_FAULT does, except adds this extra bit that SGX really fancies having.
--- arch/x86/include/asm/extable_fixup_types.h | 2 + arch/x86/include/asm/sgx.h | 18 ++++++++++++++ arch/x86/kernel/cpu/sgx/encls.h | 36 ++++------------------------- arch/x86/mm/extable.c | 10 ++++++++ 4 files changed, 35 insertions(+), 31 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +2 -0
@@ -44,4 +44,6 @@#define EX_TYPE_ZERO_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(0))#define EX_TYPE_ONE_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(1)) +#define EX_TYPE_FAULT_SGX 18 +#endif
arch/x86/include/asm/sgx.h +18 -0
@@ -46,6 +46,24 @@ enum sgx_encls_function { };/** +* SGX_ENCLS_FAULT_FLAG - flag signifying an ENCLS return code is a trapnr +* +* ENCLS has its own (positive value) error codes and also generates +* ENCLS specific #GP and #PF faults. And the ENCLS values get munged +* with system error codes as everything percolates back up the stack. +* Unfortunately (for us), we need to precisely identify each unique +* error code, e.g. the action taken if EWB fails varies based on the +* type of fault and on the exact SGX error code, i.e. we can't simply +* convert all faults to -EFAULT. +* +* To make all three error types coexist, we set bit 30 to identify an +* ENCLS fault. Bit 31 (technically bits N:31) is used to differentiate +* between positive (faults and SGX error codes) and negative (system +* error codes) values. +*/ +#define SGX_ENCLS_FAULT_FLAG 0x40000000 + +/** * enum sgx_return_code - The return code type for ENCLS, ENCLU and ENCLV * %SGX_NOT_TRACKED: Previous ETRACK's shootdown sequence has not * been completed yet.
arch/x86/kernel/cpu/sgx/encls.h +5 -31
@@ -11,26 +11,8 @@#include <asm/traps.h> #include "sgx.h" -/** -* ENCLS_FAULT_FLAG - flag signifying an ENCLS return code is a trapnr -* -* ENCLS has its own (positive value) error codes and also generates -* ENCLS specific #GP and #PF faults. And the ENCLS values get munged -* with system error codes as everything percolates back up the stack. -* Unfortunately (for us), we need to precisely identify each unique -* error code, e.g. the action taken if EWB fails varies based on the -* type of fault and on the exact SGX error code, i.e. we can't simply -* convert all faults to -EFAULT. -* -* To make all three error types coexist, we set bit 30 to identify an -* ENCLS fault. Bit 31 (technically bits N:31) is used to differentiate -* between positive (faults and SGX error codes) and negative (system -* error codes) values. -*/ -#define ENCLS_FAULT_FLAG 0x40000000 -/* Retrieve the encoded trapnr from the specified return code. */ -#define ENCLS_TRAPNR (r) ((r) & ~ENCLS_FAULT_FLAG) +#define ENCLS_TRAPNR (r) ((r) & ~SGX_ENCLS_FAULT_FLAG)/* Issue a WARN() about an ENCLS function. */ #define ENCLS_WARN (r, name) { \
@@ -50,7 +32,7 @@*/ static inline bool encls_faulted (int ret) { -return ret &ENCLS_FAULT_FLAG ; +return ret &SGX_ENCLS_FAULT_FLAG ; }/**
@@ -88,11 +70,7 @@ static inline bool encls_failed(int ret) asmvolatile ( \"1: .byte 0x0f, 0x01, 0xcf;\n\t" \"2:\n" \ -".section .fixup,\"ax\"\n" \ - "3: orl $"__stringify(ENCLS_FAULT_FLAG)",%%eax\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_FAULT(1b ,3b ) \ + _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX) \ : "=a"(ret) \: " a"(rax), inputs \ : " memory", " cc"); \
@@ -127,7 +105,7 @@ static inline bool encls_failed(int ret)* * Return: * 0 on success, -* trapnr with ENCLS_FAULT_FLAG set on fault +* trapnr with SGX_ENCLS_FAULT_FLAG set on fault */ #define __encls_N(rax, rbx_out, inputs...) \ ({ \
@@ -136,11 +114,7 @@ static inline bool encls_failed(int ret)"1: .byte 0x0f, 0x01, 0xcf;\n\t" \" xor %%eax,%%eax;\n" \"2:\n" \ -".section .fixup,\"ax\"\n" \ - "3: orl $"__stringify(ENCLS_FAULT_FLAG)",%%eax\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_FAULT(1b ,3b ) \ + _ASM_EXTABLE_TYPE(1b ,2b ,EX_TYPE_FAULT_SGX ) \ : "=a"(ret), "=b"(rbx_out) \: " a"(rax), inputs \ : " memory"); \
arch/x86/mm/extable.c +10 -0
@@ -10,6 +10,7 @@#include <asm/traps.h> #include <asm/kdebug.h> #include <asm/insn-eval.h> +#include <asm/sgx.h> static inline unsigned long *pt_regs_nr (struct pt_regs *regs,int nr) {
@@ -47,6 +48,13 @@ static bool ex_handler_fault(const strucreturn ex_handler_default (fixup, regs); } +static bool ex_handler_sgx (const struct exception_table_entry *fixup, +struct pt_regs *regs,int trapnr) +{ + regs->ax = trapnr |SGX_ENCLS_FAULT_FLAG ; +return ex_handler_default (fixup, regs); +} +/* * Handler for when we fail to restore a task's FPU state. We should never get * here because the FPU state of a task using the FPU (task->thread.fpu.state)
@@ -207,6 +215,8 @@ int fixup_exception(struct pt_regs *regsreturn ex_handler_pop_zero (e, regs);case EX_TYPE_IMM_REG :return ex_handler_imm_reg (e, regs, reg, imm); +case EX_TYPE_FAULT_SGX : +return ex_handler_sgx (e, regs, trapnr); }BUG (); }
[tip: x86/core] x86/sgx: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 5ce8e39f55521c762f0e6d1bba9597284b1f2e69 Gitweb: https://git.kernel.org/tip/5ce8e39f55521c762f0e6d1bba9597284b1f2e69 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:20 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:49 +01:00
x86/sgx: Remove .fixup usage
Create EX_TYPE_FAULT_SGX which does as EX_TYPE_FAULT does, except adds this extra bit that SGX really fancies having.
--- arch/x86/include/asm/extable_fixup_types.h | 2 +- arch/x86/include/asm/sgx.h | 18 +++++++++++- arch/x86/kernel/cpu/sgx/encls.h | 36 ++------------------- arch/x86/mm/extable.c | 10 ++++++- 4 files changed, 35 insertions(+), 31 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +2 -0
@@ -48,4 +48,6 @@#define EX_TYPE_ZERO_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(0))#define EX_TYPE_ONE_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(1)) +#define EX_TYPE_FAULT_SGX 18 +#endif
arch/x86/include/asm/sgx.h +18 -0
@@ -46,6 +46,24 @@ enum sgx_encls_function { };/** +* SGX_ENCLS_FAULT_FLAG - flag signifying an ENCLS return code is a trapnr +* +* ENCLS has its own (positive value) error codes and also generates +* ENCLS specific #GP and #PF faults. And the ENCLS values get munged +* with system error codes as everything percolates back up the stack. +* Unfortunately (for us), we need to precisely identify each unique +* error code, e.g. the action taken if EWB fails varies based on the +* type of fault and on the exact SGX error code, i.e. we can't simply +* convert all faults to -EFAULT. +* +* To make all three error types coexist, we set bit 30 to identify an +* ENCLS fault. Bit 31 (technically bits N:31) is used to differentiate +* between positive (faults and SGX error codes) and negative (system +* error codes) values. +*/ +#define SGX_ENCLS_FAULT_FLAG 0x40000000 + +/** * enum sgx_return_code - The return code type for ENCLS, ENCLU and ENCLV * %SGX_NOT_TRACKED: Previous ETRACK's shootdown sequence has not * been completed yet.
arch/x86/kernel/cpu/sgx/encls.h +5 -31
@@ -11,26 +11,8 @@#include <asm/traps.h> #include "sgx.h" -/** -* ENCLS_FAULT_FLAG - flag signifying an ENCLS return code is a trapnr -* -* ENCLS has its own (positive value) error codes and also generates -* ENCLS specific #GP and #PF faults. And the ENCLS values get munged -* with system error codes as everything percolates back up the stack. -* Unfortunately (for us), we need to precisely identify each unique -* error code, e.g. the action taken if EWB fails varies based on the -* type of fault and on the exact SGX error code, i.e. we can't simply -* convert all faults to -EFAULT. -* -* To make all three error types coexist, we set bit 30 to identify an -* ENCLS fault. Bit 31 (technically bits N:31) is used to differentiate -* between positive (faults and SGX error codes) and negative (system -* error codes) values. -*/ -#define ENCLS_FAULT_FLAG 0x40000000 -/* Retrieve the encoded trapnr from the specified return code. */ -#define ENCLS_TRAPNR (r) ((r) & ~ENCLS_FAULT_FLAG) +#define ENCLS_TRAPNR (r) ((r) & ~SGX_ENCLS_FAULT_FLAG)/* Issue a WARN() about an ENCLS function. */ #define ENCLS_WARN (r, name) { \
@@ -50,7 +32,7 @@*/ static inline bool encls_faulted (int ret) { -return ret &ENCLS_FAULT_FLAG ; +return ret &SGX_ENCLS_FAULT_FLAG ; }/**
@@ -88,11 +70,7 @@ static inline bool encls_failed(int ret) asmvolatile ( \"1: .byte 0x0f, 0x01, 0xcf;\n\t" \"2:\n" \ -".section .fixup,\"ax\"\n" \ - "3: orl $"__stringify(ENCLS_FAULT_FLAG)",%%eax\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_FAULT(1b ,3b ) \ + _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_SGX) \ : "=a"(ret) \: " a"(rax), inputs \ : " memory", " cc"); \
@@ -127,7 +105,7 @@ static inline bool encls_failed(int ret)* * Return: * 0 on success, -* trapnr with ENCLS_FAULT_FLAG set on fault +* trapnr with SGX_ENCLS_FAULT_FLAG set on fault */ #define __encls_N(rax, rbx_out, inputs...) \ ({ \
@@ -136,11 +114,7 @@ static inline bool encls_failed(int ret)"1: .byte 0x0f, 0x01, 0xcf;\n\t" \" xor %%eax,%%eax;\n" \"2:\n" \ -".section .fixup,\"ax\"\n" \ - "3: orl $"__stringify(ENCLS_FAULT_FLAG)",%%eax\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_FAULT(1b ,3b ) \ + _ASM_EXTABLE_TYPE(1b ,2b ,EX_TYPE_FAULT_SGX ) \ : "=a"(ret), "=b"(rbx_out) \: " a"(rax), inputs \ : " memory"); \
arch/x86/mm/extable.c +10 -0
@@ -10,6 +10,7 @@#include <asm/traps.h> #include <asm/kdebug.h> #include <asm/insn-eval.h> +#include <asm/sgx.h> static inline unsigned long *pt_regs_nr (struct pt_regs *regs,int nr) {
@@ -47,6 +48,13 @@ static bool ex_handler_fault(const struct exception_table_entry *fixup,return ex_handler_default (fixup, regs); } +static bool ex_handler_sgx (const struct exception_table_entry *fixup, +struct pt_regs *regs,int trapnr) +{ + regs->ax = trapnr |SGX_ENCLS_FAULT_FLAG ; +return ex_handler_default (fixup, regs); +} +/* * Handler for when we fail to restore a task's FPU state. We should never get * here because the FPU state of a task using the FPU (task->thread.fpu.state)
@@ -207,6 +215,8 @@ int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,return ex_handler_pop_zero (e, regs);case EX_TYPE_IMM_REG :return ex_handler_imm_reg (e, regs, reg, imm); +case EX_TYPE_FAULT_SGX : +return ex_handler_sgx (e, regs, trapnr); }BUG (); }
Peter Zijlstra
maintainerPATCH v2 19/23 x86,usercopy_32: Simplify __copy_user_intel_nocache()
In reply to Peter ZijlstraHave an exception jump to a .fixup to only immediately jump out is daft, jump to the right place in one go.
--- arch/x86/lib/usercopy_32.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
arch/x86/lib/usercopy_32.c +20 -20
@@ -257,28 +257,28 @@ static unsigned long __copy_user_intel_n"8:\n" ".section .fixup,\"ax\"\n" "9: lea 0(%%eax,%0,4),%0\n" -"16: jmp 8b\n" +" jmp 8b\n" ".previous\n" - _ASM_EXTABLE_UA(0b, 16b) - _ASM_EXTABLE_UA(1b, 16b) - _ASM_EXTABLE_UA(2b, 16b) - _ASM_EXTABLE_UA(21b, 16b) - _ASM_EXTABLE_UA(3b, 16b) - _ASM_EXTABLE_UA(31b, 16b) - _ASM_EXTABLE_UA(4b, 16b) - _ASM_EXTABLE_UA(41b, 16b) - _ASM_EXTABLE_UA(10b, 16b) - _ASM_EXTABLE_UA(51b, 16b) - _ASM_EXTABLE_UA(11b, 16b) - _ASM_EXTABLE_UA(61b, 16b) - _ASM_EXTABLE_UA(12b, 16b) - _ASM_EXTABLE_UA(71b, 16b) - _ASM_EXTABLE_UA(13b, 16b) - _ASM_EXTABLE_UA(81b, 16b) - _ASM_EXTABLE_UA(14b, 16b) - _ASM_EXTABLE_UA(91b, 16b) + _ASM_EXTABLE_UA(0b, 8b) + _ASM_EXTABLE_UA(1b, 8b) + _ASM_EXTABLE_UA(2b, 8b) + _ASM_EXTABLE_UA(21b, 8b) + _ASM_EXTABLE_UA(3b, 8b) + _ASM_EXTABLE_UA(31b, 8b) + _ASM_EXTABLE_UA(4b, 8b) + _ASM_EXTABLE_UA(41b, 8b) + _ASM_EXTABLE_UA(10b, 8b) + _ASM_EXTABLE_UA(51b, 8b) + _ASM_EXTABLE_UA(11b, 8b) + _ASM_EXTABLE_UA(61b, 8b) + _ASM_EXTABLE_UA(12b, 8b) + _ASM_EXTABLE_UA(71b, 8b) + _ASM_EXTABLE_UA(13b, 8b) + _ASM_EXTABLE_UA(81b, 8b) + _ASM_EXTABLE_UA(14b, 8b) + _ASM_EXTABLE_UA(91b, 8b) _ASM_EXTABLE_UA(6b, 9b) -_ASM_EXTABLE_UA (7b ,16b ) +_ASM_EXTABLE_UA (7b ,8b ) : "=&c"(size), "=&D" (d0), "=&S" (d1) : "1"(to), "2"(from), "0"(size) : "eax", "edx", "memory");
[tip: x86/core] x86/usercopy_32: Simplify __copy_user_intel_nocache()
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 13e4bf1bddcb65dd028aaa492789e8d61efaafa1 Gitweb: https://git.kernel.org/tip/13e4bf1bddcb65dd028aaa492789e8d61efaafa1 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:21 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:50 +01:00
x86/usercopy_32: Simplify __copy_user_intel_nocache()
Have an exception jump to a .fixup to only immediately jump out is daft, jump to the right place in one go.
--- arch/x86/lib/usercopy_32.c | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
arch/x86/lib/usercopy_32.c +20 -20
@@ -256,28 +256,28 @@ static unsigned long __copy_user_intel_nocache(void *to,"8:\n" ".section .fixup,\"ax\"\n" "9: lea 0(%%eax,%0,4),%0\n" -"16: jmp 8b\n" +" jmp 8b\n" ".previous\n" - _ASM_EXTABLE_UA(0b, 16b) - _ASM_EXTABLE_UA(1b, 16b) - _ASM_EXTABLE_UA(2b, 16b) - _ASM_EXTABLE_UA(21b, 16b) - _ASM_EXTABLE_UA(3b, 16b) - _ASM_EXTABLE_UA(31b, 16b) - _ASM_EXTABLE_UA(4b, 16b) - _ASM_EXTABLE_UA(41b, 16b) - _ASM_EXTABLE_UA(10b, 16b) - _ASM_EXTABLE_UA(51b, 16b) - _ASM_EXTABLE_UA(11b, 16b) - _ASM_EXTABLE_UA(61b, 16b) - _ASM_EXTABLE_UA(12b, 16b) - _ASM_EXTABLE_UA(71b, 16b) - _ASM_EXTABLE_UA(13b, 16b) - _ASM_EXTABLE_UA(81b, 16b) - _ASM_EXTABLE_UA(14b, 16b) - _ASM_EXTABLE_UA(91b, 16b) + _ASM_EXTABLE_UA(0b, 8b) + _ASM_EXTABLE_UA(1b, 8b) + _ASM_EXTABLE_UA(2b, 8b) + _ASM_EXTABLE_UA(21b, 8b) + _ASM_EXTABLE_UA(3b, 8b) + _ASM_EXTABLE_UA(31b, 8b) + _ASM_EXTABLE_UA(4b, 8b) + _ASM_EXTABLE_UA(41b, 8b) + _ASM_EXTABLE_UA(10b, 8b) + _ASM_EXTABLE_UA(51b, 8b) + _ASM_EXTABLE_UA(11b, 8b) + _ASM_EXTABLE_UA(61b, 8b) + _ASM_EXTABLE_UA(12b, 8b) + _ASM_EXTABLE_UA(71b, 8b) + _ASM_EXTABLE_UA(13b, 8b) + _ASM_EXTABLE_UA(81b, 8b) + _ASM_EXTABLE_UA(14b, 8b) + _ASM_EXTABLE_UA(91b, 8b) _ASM_EXTABLE_UA(6b, 9b) -_ASM_EXTABLE_UA (7b ,16b ) +_ASM_EXTABLE_UA (7b ,8b ) : "=&c"(size), "=&D" (d0), "=&S" (d1) : "1"(to), "2"(from), "0"(size) : "eax", "edx", "memory");
Peter Zijlstra
maintainerPATCH v2 20/23 x86,usercopy: Remove .fixup usage
In reply to Peter ZijlstraTypically usercopy does whole word copies followed by a number of byte copies to finish the tail. This means that on exception it needs to compute the remaining length as: words*sizeof(long) + bytes.
Create a new extable handler to do just this.
--- arch/x86/include/asm/extable_fixup_types.h | 5 +++++ arch/x86/lib/usercopy_32.c | 28 +++++----------------------- arch/x86/lib/usercopy_64.c | 8 +++----- arch/x86/mm/extable.c | 9 +++++++++ 4 files changed, 22 insertions(+), 28 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +5 -0
@@ -46,4 +46,9 @@#define EX_TYPE_FAULT_SGX 18 +#define EX_TYPE_UCOPY_LEN 19/* cx := reg + imm*cx */ +#define EX_TYPE_UCOPY_LEN1 (EX_TYPE_UCOPY_LEN | EX_DATA_IMM(1)) +#define EX_TYPE_UCOPY_LEN4 (EX_TYPE_UCOPY_LEN | EX_DATA_IMM(4)) +#define EX_TYPE_UCOPY_LEN8 (EX_TYPE_UCOPY_LEN | EX_DATA_IMM(8)) +#endif
arch/x86/lib/usercopy_32.c +5 -23
@@ -43,11 +43,7 @@ do { \" movl %2,%0\n" \"1: rep; stosb\n" \"2: " ASM_CLAC "\n" \ -".section .fixup,\"ax\"\n" \ -"3: lea 0(%2,%0,4),%0\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_UA(0b, 3b) \ + _ASM_EXTABLE_TYPE_REG(0b, 2b, EX_TYPE_UCOPY_LEN4, %2) \_ASM_EXTABLE_UA (1b ,2b ) \ : "=&c"(size), "=&D" (__d0) \ : "r"(size & 3), "0"(size / 4), "1"(addr), "a"(0)); \
@@ -149,10 +145,6 @@ __copy_user_intel(void __user *to, const"36: movl %%eax, %0\n" "37: rep; movsb\n" "100:\n" -".section .fixup,\"ax\"\n" -"101: lea 0(%%eax,%0,4),%0\n" -" jmp 100b\n" -".previous\n" _ASM_EXTABLE_UA(1b, 100b) _ASM_EXTABLE_UA(2b, 100b)_ASM_EXTABLE_UA (3b ,100b )
@@ -190,7 +182,7 @@ __copy_user_intel(void __user *to, const _ASM_EXTABLE_UA(35b, 100b) _ASM_EXTABLE_UA(36b, 100b) _ASM_EXTABLE_UA(37b, 100b) -_ASM_EXTABLE_UA (99b ,101b ) + _ASM_EXTABLE_TYPE_REG(99b, 100b, EX_TYPE_UCOPY_LEN4, %%eax) : "=&c"(size), "=&D" (d0), "=&S" (d1) : "1"(to), "2"(from), "0"(size) : "eax", "edx", "memory");
@@ -255,10 +247,6 @@ static unsigned long __copy_user_intel_n" movl %%eax,%0\n" "7: rep; movsb\n" "8:\n" -".section .fixup,\"ax\"\n" -"9: lea 0(%%eax,%0,4),%0\n" -" jmp 8b\n" -".previous\n" _ASM_EXTABLE_UA(0b, 8b) _ASM_EXTABLE_UA(1b, 8b)_ASM_EXTABLE_UA (2b ,8b )
@@ -277,7 +265,7 @@ static unsigned long __copy_user_intel_n _ASM_EXTABLE_UA(81b, 8b) _ASM_EXTABLE_UA(14b, 8b) _ASM_EXTABLE_UA(91b, 8b) - _ASM_EXTABLE_UA(6b, 9b) + _ASM_EXTABLE_TYPE_REG(6b, 8b, EX_TYPE_UCOPY_LEN4, %%eax)_ASM_EXTABLE_UA (7b ,8b ) : "=&c"(size), "=&D" (d0), "=&S" (d1) : "1"(to), "2"(from), "0"(size)
@@ -315,14 +303,8 @@ do { \" movl %3,%0\n" \"1: rep; movsb\n" \"2:\n" \ -".section .fixup,\"ax\"\n" \ -"5: addl %3,%0\n" \ -" jmp 2b\n" \ -"3: lea 0(%3,%0,4),%0\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_UA(4b, 5b) \ - _ASM_EXTABLE_UA(0b, 3b) \ + _ASM_EXTABLE_TYPE_REG(4b, 2b, EX_TYPE_UCOPY_LEN1, %3) \ + _ASM_EXTABLE_TYPE_REG(0b, 2b, EX_TYPE_UCOPY_LEN4, %3) \_ASM_EXTABLE_UA (1b ,2b ) \ : "=&c"(size), "=&D" (__d0), "=&S" (__d1), "=r"(__d2) \ : "3"(size), "0"(size), "1"(to), "2"(from) \
arch/x86/lib/usercopy_64.c +3 -5
@@ -35,12 +35,10 @@ unsigned long __clear_user(void __user *" incq %[dst]\n" " decl %%ecx ; jnz 1b\n" "2:\n" -".section .fixup,\"ax\"\n" -"3: lea 0(%[size1],%[size8],8),%[size8]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE_UA(0b, 3b) + + _ASM_EXTABLE_TYPE_REG(0b, 2b, EX_TYPE_UCOPY_LEN8, %[size1])_ASM_EXTABLE_UA (1b ,2b ) + : [size8] "=&c"(size), [dst] "=&D" (__d0) : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr));clac ();
arch/x86/mm/extable.c +9 -0
@@ -145,6 +145,13 @@ static bool ex_handler_imm_reg(const strreturn ex_handler_default (fixup, regs); } +static bool ex_handler_ucopy_leng (const struct exception_table_entry *fixup, +struct pt_regs *regs,int trapnr,int reg,int imm) +{ + regs->cx = imm * regs->cx + *pt_regs_nr (regs, reg); +return ex_handler_uaccess (fixup, regs, trapnr); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip);
@@ -217,6 +224,8 @@ int fixup_exception(struct pt_regs *regsreturn ex_handler_imm_reg (e, regs, reg, imm);case EX_TYPE_FAULT_SGX :return ex_handler_sgx (e, regs, trapnr); +case EX_TYPE_UCOPY_LEN : +return ex_handler_ucopy_leng (e, regs, trapnr, reg, imm); }BUG (); }
Re: [PATCH v2 20/23] x86,usercopy: Remove .fixup usage
Quoted 11 lines · Peter Zijlstra
arch/x86/mm/extable.c +7
-0+static bool ex_handler_ucopy_leng (const struct exception_table_entry *fixup, +struct pt_regs *regs,int trapnr,int reg,int imm) +{ + regs->cx = imm * regs->cx + *pt_regs_nr (regs, reg); +return ex_handler_uaccess (fixup, regs, trapnr); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip);
arch/x86/mm/extable.c int fixup_exception(struct pt_regs *regs · line 228
Quoted 5 lines
arch/x86/mm/extable.c +2
-0@@ -217,6 +224,8 @@ int fixup_exception(struct pt_regs *regsreturn ex_handler_imm_reg (e, regs, reg, imm);case EX_TYPE_FAULT_SGX :return ex_handler_sgx (e, regs, trapnr); +case EX_TYPE_UCOPY_LEN : +return ex_handler_ucopy_leng (e, regs, trapnr, reg, imm);
"leng"?
Signature · 1 line
Josh
Peter Zijlstra
maintainerRe: [PATCH v2 20/23] x86,usercopy: Remove .fixup usage
Quoted 11 lines · Josh Poimboeuf
Quoted 10 lines · Peter Zijlstra
arch/x86/mm/extable.c +7
-0+static bool ex_handler_ucopy_leng (const struct exception_table_entry *fixup, +struct pt_regs *regs,int trapnr,int reg,int imm) +{ + regs->cx = imm * regs->cx + *pt_regs_nr (regs, reg); +return ex_handler_uaccess (fixup, regs, trapnr); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip);
Quoted 8 lines
arch/x86/mm/extable.c int fixup_exception(struct pt_regs *regs · line 228
Quoted 6 lines
arch/x86/mm/extable.c +2
-0@@ -217,6 +224,8 @@ int fixup_exception(struct pt_regs *regsreturn ex_handler_imm_reg (e, regs, reg, imm);case EX_TYPE_FAULT_SGX :return ex_handler_sgx (e, regs, trapnr); +case EX_TYPE_UCOPY_LEN : +return ex_handler_ucopy_leng (e, regs, trapnr, reg, imm);"leng"?
OMG, I really should just take a break or something :/ I'll go fix.
[tip: x86/core] x86/usercopy: Remove .fixup usage
In reply to Peter ZijlstraThe following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: d5d797dcbd781cb7c526ad32f31c7fd96babfdb2 Gitweb: https://git.kernel.org/tip/d5d797dcbd781cb7c526ad32f31c7fd96babfdb2 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:22 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:50 +01:00
x86/usercopy: Remove .fixup usage
Typically usercopy does whole word copies followed by a number of byte copies to finish the tail. This means that on exception it needs to compute the remaining length as: words*sizeof(long) + bytes.
Create a new extable handler to do just this.
--- arch/x86/include/asm/extable_fixup_types.h | 5 ++++- arch/x86/lib/usercopy_32.c | 28 +++------------------ arch/x86/lib/usercopy_64.c | 8 ++---- arch/x86/mm/extable.c | 9 +++++++- 4 files changed, 22 insertions(+), 28 deletions(-)
arch/x86/include/asm/extable_fixup_types.h +5 -0
@@ -50,4 +50,9 @@#define EX_TYPE_FAULT_SGX 18 +#define EX_TYPE_UCOPY_LEN 19/* cx := reg + imm*cx */ +#define EX_TYPE_UCOPY_LEN1 (EX_TYPE_UCOPY_LEN | EX_DATA_IMM(1)) +#define EX_TYPE_UCOPY_LEN4 (EX_TYPE_UCOPY_LEN | EX_DATA_IMM(4)) +#define EX_TYPE_UCOPY_LEN8 (EX_TYPE_UCOPY_LEN | EX_DATA_IMM(8)) +#endif
arch/x86/lib/usercopy_32.c +5 -23
@@ -42,11 +42,7 @@ do { \" movl %2,%0\n" \"1: rep; stosb\n" \"2: " ASM_CLAC "\n" \ -".section .fixup,\"ax\"\n" \ -"3: lea 0(%2,%0,4),%0\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_UA(0b, 3b) \ + _ASM_EXTABLE_TYPE_REG(0b, 2b, EX_TYPE_UCOPY_LEN4, %2) \_ASM_EXTABLE_UA (1b ,2b ) \ : "=&c"(size), "=&D" (__d0) \ : "r"(size & 3), "0"(size / 4), "1"(addr), "a"(0)); \
@@ -148,10 +144,6 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)"36: movl %%eax, %0\n" "37: rep; movsb\n" "100:\n" -".section .fixup,\"ax\"\n" -"101: lea 0(%%eax,%0,4),%0\n" -" jmp 100b\n" -".previous\n" _ASM_EXTABLE_UA(1b, 100b) _ASM_EXTABLE_UA(2b, 100b)_ASM_EXTABLE_UA (3b ,100b )
@@ -189,7 +181,7 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size) _ASM_EXTABLE_UA(35b, 100b) _ASM_EXTABLE_UA(36b, 100b) _ASM_EXTABLE_UA(37b, 100b) -_ASM_EXTABLE_UA (99b ,101b ) + _ASM_EXTABLE_TYPE_REG(99b, 100b, EX_TYPE_UCOPY_LEN4, %%eax) : "=&c"(size), "=&D" (d0), "=&S" (d1) : "1"(to), "2"(from), "0"(size) : "eax", "edx", "memory");
@@ -254,10 +246,6 @@ static unsigned long __copy_user_intel_nocache(void *to," movl %%eax,%0\n" "7: rep; movsb\n" "8:\n" -".section .fixup,\"ax\"\n" -"9: lea 0(%%eax,%0,4),%0\n" -" jmp 8b\n" -".previous\n" _ASM_EXTABLE_UA(0b, 8b) _ASM_EXTABLE_UA(1b, 8b)_ASM_EXTABLE_UA (2b ,8b )
@@ -276,7 +264,7 @@ static unsigned long __copy_user_intel_nocache(void *to, _ASM_EXTABLE_UA(81b, 8b) _ASM_EXTABLE_UA(14b, 8b) _ASM_EXTABLE_UA(91b, 8b) - _ASM_EXTABLE_UA(6b, 9b) + _ASM_EXTABLE_TYPE_REG(6b, 8b, EX_TYPE_UCOPY_LEN4, %%eax)_ASM_EXTABLE_UA (7b ,8b ) : "=&c"(size), "=&D" (d0), "=&S" (d1) : "1"(to), "2"(from), "0"(size)
@@ -314,14 +302,8 @@ do { \" movl %3,%0\n" \"1: rep; movsb\n" \"2:\n" \ -".section .fixup,\"ax\"\n" \ -"5: addl %3,%0\n" \ -" jmp 2b\n" \ -"3: lea 0(%3,%0,4),%0\n" \ -" jmp 2b\n" \ -".previous\n" \ - _ASM_EXTABLE_UA(4b, 5b) \ - _ASM_EXTABLE_UA(0b, 3b) \ + _ASM_EXTABLE_TYPE_REG(4b, 2b, EX_TYPE_UCOPY_LEN1, %3) \ + _ASM_EXTABLE_TYPE_REG(0b, 2b, EX_TYPE_UCOPY_LEN4, %3) \_ASM_EXTABLE_UA (1b ,2b ) \ : "=&c"(size), "=&D" (__d0), "=&S" (__d1), "=r"(__d2) \ : "3"(size), "0"(size), "1"(to), "2"(from) \
arch/x86/lib/usercopy_64.c +3 -5
@@ -35,12 +35,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)" incq %[dst]\n" " decl %%ecx ; jnz 1b\n" "2:\n" -".section .fixup,\"ax\"\n" -"3: lea 0(%[size1],%[size8],8),%[size8]\n" -" jmp 2b\n" -".previous\n" - _ASM_EXTABLE_UA(0b, 3b) + + _ASM_EXTABLE_TYPE_REG(0b, 2b, EX_TYPE_UCOPY_LEN8, %[size1])_ASM_EXTABLE_UA (1b ,2b ) + : [size8] "=&c"(size), [dst] "=&D" (__d0) : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr));clac ();
arch/x86/mm/extable.c +9 -0
@@ -145,6 +145,13 @@ static bool ex_handler_imm_reg(const struct exception_table_entry *fixup,return ex_handler_default (fixup, regs); } +static bool ex_handler_ucopy_len (const struct exception_table_entry *fixup, +struct pt_regs *regs,int trapnr,int reg,int imm) +{ + regs->cx = imm * regs->cx + *pt_regs_nr (regs, reg); +return ex_handler_uaccess (fixup, regs, trapnr); +} +int ex_get_fixup_type (unsigned long ip) {const struct exception_table_entry *e =search_exception_tables (ip);
@@ -217,6 +224,8 @@ int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,return ex_handler_imm_reg (e, regs, reg, imm);case EX_TYPE_FAULT_SGX :return ex_handler_sgx (e, regs, trapnr); +case EX_TYPE_UCOPY_LEN : +return ex_handler_ucopy_len (e, regs, trapnr, reg, imm); }BUG (); }
Peter Zijlstra
maintainerPATCH v2 21/23 x86,word-at-a-time: Remove .fixup usage
In reply to Peter ZijlstraRewrite load_unaligned_zeropad() to not require .fixup text.
This is easiest done using asm-goto-output, where we can stick a C label in the exception table entry. The fallback version isn't nearly so nice but should work.
--- arch/x86/include/asm/word-at-a-time.h | 66 ++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 19 deletions(-)
arch/x86/include/asm/word-at-a-time.h +47 -19
@@ -77,30 +77,58 @@ static inline unsigned long find_zero(un* and the next page not being mapped, take the exception and * return zeroes in the non-existing part. */ +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT +static inline unsigned long load_unaligned_zeropad (const void *addr) { -unsigned long ret, dummy; +unsigned long offset, data; +unsigned long ret; + +asm_volatile_goto ( +"1: mov %[mem], %[ret]\n" + + _ASM_EXTABLE(1b, %l[do_exception]) + + : [ret] "=r" (ret) + : [mem] "m" (*(unsigned long *)addr) + : : do_exception); + +return ret; + +do_exception: + offset = (unsigned long )addr & (sizeof (long ) -1 ); + addr = (void *)((unsigned long )addr & ~(sizeof (long ) -1 )); + data = *(unsigned long *)addr; + ret = data >> offset *8 ; + +return ret; +} - asm( -"1:\tmov %2,%0\n" +#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ + +static inline unsigned long load_unaligned_zeropad (const void *addr) +{ +unsigned long offset, data; +unsigned long ret, err =0 ; + + asm("1: mov %[mem], %[ret]\n" "2:\n" -".section .fixup,\"ax\"\n" -"3:\t" -"lea %2,%1\n\t" -"and %3,%1\n\t" -"mov (%1),%0\n\t" -"leal %2,%%ecx\n\t" -"andl %4,%%ecx\n\t" -"shll $3,%%ecx\n\t" -"shr %%cl,%0\n\t" -"jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) - :"=&r" (ret),"=&c" (dummy) - :"m" (*(unsigned long *)addr), -" i" (-sizeof(unsigned long)), - "i" (sizeof(unsigned long)-1)); + + _ASM_EXTABLE_FAULT(1b, 2b) + + : [ret] "=&r" (ret), "+a" (err) + : [mem] "m" (*(unsigned long *)addr)); + +if (unlikely (err)) { + offset = (unsigned long )addr & (sizeof (long ) -1 ); + addr = (void *)((unsigned long )addr & ~(sizeof (long ) -1 )); + data = *(unsigned long *)addr; + ret = data >> offset *8 ; + } +return ret; } +#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ +#endif /* _ASM_WORD_AT_A_TIME_H */
[tip: x86/core] x86/word-at-a-time: Remove .fixup usage
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: b7760780257354bb14de62abed868405b844fa13 Gitweb: https://git.kernel.org/tip/b7760780257354bb14de62abed868405b844fa13 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:23 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:50 +01:00
x86/word-at-a-time: Remove .fixup usage
Rewrite load_unaligned_zeropad() to not require .fixup text.
This is easiest done using asm-goto-output, where we can stick a C label in the exception table entry. The fallback version isn't nearly so nice but should work.
--- arch/x86/include/asm/word-at-a-time.h | 66 ++++++++++++++++++-------- 1 file changed, 47 insertions(+), 19 deletions(-)
arch/x86/include/asm/word-at-a-time.h +47 -19
@@ -77,30 +77,58 @@ static inline unsigned long find_zero(unsigned long mask)* and the next page not being mapped, take the exception and * return zeroes in the non-existing part. */ +#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT +static inline unsigned long load_unaligned_zeropad (const void *addr) { -unsigned long ret, dummy; +unsigned long offset, data; +unsigned long ret; + +asm_volatile_goto ( +"1: mov %[mem], %[ret]\n" + + _ASM_EXTABLE(1b, %l[do_exception]) + + : [ret] "=r" (ret) + : [mem] "m" (*(unsigned long *)addr) + : : do_exception); + +return ret; + +do_exception: + offset = (unsigned long )addr & (sizeof (long ) -1 ); + addr = (void *)((unsigned long )addr & ~(sizeof (long ) -1 )); + data = *(unsigned long *)addr; + ret = data >> offset *8 ; + +return ret; +} - asm( -"1:\tmov %2,%0\n" +#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ + +static inline unsigned long load_unaligned_zeropad (const void *addr) +{ +unsigned long offset, data; +unsigned long ret, err =0 ; + + asm("1: mov %[mem], %[ret]\n" "2:\n" -".section .fixup,\"ax\"\n" -"3:\t" -"lea %2,%1\n\t" -"and %3,%1\n\t" -"mov (%1),%0\n\t" -"leal %2,%%ecx\n\t" -"andl %4,%%ecx\n\t" -"shll $3,%%ecx\n\t" -"shr %%cl,%0\n\t" -"jmp 2b\n" -".previous\n" - _ASM_EXTABLE(1b, 3b) - :"=&r" (ret),"=&c" (dummy) - :"m" (*(unsigned long *)addr), -" i" (-sizeof(unsigned long)), - "i" (sizeof(unsigned long)-1)); + + _ASM_EXTABLE_FAULT(1b, 2b) + + : [ret] "=&r" (ret), "+a" (err) + : [mem] "m" (*(unsigned long *)addr)); + +if (unlikely (err)) { + offset = (unsigned long )addr & (sizeof (long ) -1 ); + addr = (void *)((unsigned long )addr & ~(sizeof (long ) -1 )); + data = *(unsigned long *)addr; + ret = data >> offset *8 ; + } +return ret; } +#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT */ +#endif /* _ASM_WORD_AT_A_TIME_H */
Peter Zijlstra
maintainerPATCH v2 22/23 x86: Remove .fixup section
In reply to Peter ZijlstraNo moar users, kill it dead.
--- arch/x86/entry/vdso/vdso-layout.lds.S | 1 - arch/x86/kernel/vmlinux.lds.S | 1 - 2 files changed, 2 deletions(-)
arch/x86/entry/vdso/vdso-layout.lds.S +0 -1
@@ -77,7 +77,6 @@ SECTIONS .text : { *(.text*) - *(.fixup) } :text =0x90909090,
arch/x86/kernel/vmlinux.lds.S +0 -1
@@ -137,7 +137,6 @@ SECTIONS ALIGN_ENTRY_TEXT_END SOFTIRQENTRY_TEXT STATIC_CALL_TEXT - *(.fixup) *(.gnu.warning) #ifdef CONFIG_RETPOLINE
[tip: x86/core] x86: Remove .fixup section
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: e5eefda5aa51f3178821b58806e1dddd798c0934 Gitweb: https://git.kernel.org/tip/e5eefda5aa51f3178821b58806e1dddd798c0934 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:24 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:50 +01:00
x86: Remove .fixup section
No moar users, kill it dead.
--- arch/x86/entry/vdso/vdso-layout.lds.S | 1 - arch/x86/kernel/vmlinux.lds.S | 1 - 2 files changed, 2 deletions(-)
arch/x86/entry/vdso/vdso-layout.lds.S +0 -1
@@ -77,7 +77,6 @@ SECTIONS .text : { *(.text*) - *(.fixup) } :text =0x90909090,
arch/x86/kernel/vmlinux.lds.S +0 -1
@@ -137,7 +137,6 @@ SECTIONS ALIGN_ENTRY_TEXT_END SOFTIRQENTRY_TEXT STATIC_CALL_TEXT - *(.fixup) *(.gnu.warning) #ifdef CONFIG_RETPOLINE
Peter Zijlstra
maintainerPATCH v2 23/23 objtool: Remove .fixup handling
In reply to Peter ZijlstraThe .fixup has gone the way of the Dodo, that test will always be false.
--- tools/objtool/check.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
tools/objtool/check.c +2 -6
@@ -3296,14 +3296,10 @@ static bool ignore_unreachable_insn(strureturn true;/* -* Ignore any unused exceptions. This can happen when a whitelisted -* function has an exception table entry. -* -* Also ignore alternative replacement instructions. This can happen +* Ignore alternative replacement instructions. This can happen * when a whitelisted function uses one of the ALTERNATIVE macros. */ -if (!strcmp (insn->sec->name,".fixup" ) || - !strcmp (insn->sec->name,".altinstr_replacement" ) || +if (!strcmp (insn->sec->name,".altinstr_replacement" ) || !strcmp (insn->sec->name,".altinstr_aux" ))return true;
[tip: x86/core] objtool: Remove .fixup handling
The following commit has been merged into the x86/core branch of tip:
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 82a8954acd93ae95d6252fb93a3d210c8f71b093 Gitweb: https://git.kernel.org/tip/82a8954acd93ae95d6252fb93a3d210c8f71b093 Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 10 Nov 2021 11:01:25 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Sat, 11 Dec 2021 09:09:51 +01:00
objtool: Remove .fixup handling
The .fixup has gone the way of the Dodo, that test will always be false.
--- tools/objtool/check.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
tools/objtool/check.c +2 -6
@@ -3310,14 +3310,10 @@ static bool ignore_unreachable_insn(struct objtool_file *file, struct instructioreturn true;/* -* Ignore any unused exceptions. This can happen when a whitelisted -* function has an exception table entry. -* -* Also ignore alternative replacement instructions. This can happen +* Ignore alternative replacement instructions. This can happen * when a whitelisted function uses one of the ALTERNATIVE macros. */ -if (!strcmp (insn->sec->name,".fixup" ) || - !strcmp (insn->sec->name,".altinstr_replacement" ) || +if (!strcmp (insn->sec->name,".altinstr_replacement" ) || !strcmp (insn->sec->name,".altinstr_aux" ))return true;
Quoted 11 lines · Peter Zijlstra
Changes since v1:
- Dropped using
__coldon labels, because clang. Also gcc doesn't actually generate different code with it. The intent was for the code to end up in .text.cold but that doesn't happen.
- Fixed the vmread constraints to disallow %0 == %1.
- Added a asm-goto-output variant to vmx's vmread implementation.
- Audited Xen and FPU code and converted them from -1 to-EFAULT, as a concequenceEX_TYPE_NEG_REGno longer exists.
- Fixed the EX_DATA_*_MASK macros to include an explicit 'int' cast, such thatFIELD_GET()will sign-extend the top field.
I didn't (yet) get the chance to properly review the alignment math in patches 20 & 21. Otherwise it looks great to me.
Signature · 1 line
Josh