linux/arch/x86
Linus Torvalds 24b8a23638 x86/fpu: Clean up FPU switching in the middle of task switching
It happens to work, but it's very very wrong, because our 'current'
macro is magic that is supposedly loading a stable value.

It just happens to be not quite stable enough and the compilers
re-load the value enough for this code to work.  But it's wrong.

The whole

        struct fpu *prev_fpu = &prev->fpu;

thing in __switch_to() is pretty ugly. There's no reason why we
should look at that 'prev_fpu' pointer there, or pass it down.

And it only generates worse code, in how it loads 'current' when
__switch_to() has the right task pointers.

The attached patch not only cleans this up, it actually
generates better code too:

 (a) it removes one push/pop pair at entry/exit because there's one
     less register used (no 'current')

 (b) it removes that pointless load of 'current' because it just uses
     the right argument:

	-       movq    %gs:pcpu_hot(%rip), %r12
	-       testq   $16384, (%r12)
	+       testq   $16384, (%rdi)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20231018184227.446318-1-ubizjak@gmail.com
2023-10-20 11:24:22 +02:00
..
boot Misc x86 cleanups. 2023-08-28 17:05:58 -07:00
coco - Some SEV and CC platform helpers cleanup and simplifications now that 2023-06-27 13:26:30 -07:00
configs - The first, cleanup part of the microcode loader reorg tglx has been 2023-08-28 15:55:20 -07:00
crypto crypto: x86/aesni - remove unused parameter to aes_set_key_common() 2023-07-22 13:59:39 +12:00
entry x86/entry: Fix typos in comments 2023-09-27 10:05:04 +02:00
events Perf events changes for v6.6: 2023-08-28 16:35:01 -07:00
hyperv hyperv-next for v6.6 2023-09-04 11:26:29 -07:00
ia32
include x86/fpu: Clean up FPU switching in the middle of task switching 2023-10-20 11:24:22 +02:00
kernel x86/fpu: Clean up FPU switching in the middle of task switching 2023-10-20 11:24:22 +02:00
kvm * Rework apic callbacks, getting rid of unnecessary ones and 2023-08-30 10:44:46 -07:00
lib x86/lib: Address kernel-doc warnings 2023-10-03 22:46:47 +02:00
math-emu x86/fpu: Include asm/fpu/regset.h 2023-05-18 11:56:18 -07:00
mm Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
net bpf: Support new 32bit offset jmp instruction 2023-07-27 18:52:33 -07:00
pci pci-v6.6-changes 2023-08-30 20:23:07 -07:00
platform * Rework apic callbacks, getting rid of unnecessary ones and 2023-08-30 10:44:46 -07:00
power x86/topology: Remove CPU0 hotplug option 2023-05-15 13:44:49 +02:00
purgatory x86/purgatory: Include header for warn() declaration 2023-08-03 16:37:18 +02:00
ras
realmode x86/realmode: Make stack lock work in trampoline_compat() 2023-05-30 14:11:47 +02:00
tools ELF: fix all "Elf" typos 2023-04-08 13:45:37 -07:00
um um: Hard-code the result of 'uname -s' 2023-08-26 22:40:37 +02:00
video Merge drm/drm-next into drm-misc-next 2023-07-24 15:44:47 +02:00
virt/vmx/tdx
xen Add x86 shadow stack support 2023-08-31 12:20:12 -07:00
.gitignore
Kbuild
Kconfig x86/percpu: Disable named address spaces for KASAN 2023-10-10 23:57:35 +02:00
Kconfig.assembler x86/shstk: Add Kconfig option for shadow stack 2023-07-11 14:12:18 -07:00
Kconfig.cpu x86/cpu: Remove X86_FEATURE_NAMES 2023-05-15 20:03:08 +02:00
Kconfig.debug docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
Makefile Merge drm/drm-next into drm-misc-next 2023-07-24 15:44:47 +02:00
Makefile_32.cpu
Makefile.postlink x86/build: Avoid relocation information in final vmlinux 2023-06-14 19:54:40 +02:00
Makefile.um um: Only disable SSE on clang to work around old GCC bugs 2023-04-04 09:57:05 +02:00