]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/fpu: Shift fpregs_assert_state_consistent() from arch_exit_work() to its caller
authorOleg Nesterov <oleg@redhat.com>
Sat, 3 May 2025 14:39:02 +0000 (16:39 +0200)
committerIngo Molnar <mingo@kernel.org>
Sun, 4 May 2025 08:29:25 +0000 (10:29 +0200)
If CONFIG_X86_DEBUG_FPU=Y, arch_exit_to_user_mode_prepare() calls
arch_exit_work() even if ti_work == 0. There only reason is that we
want to call fpregs_assert_state_consistent() if TIF_NEED_FPU_LOAD
is not set.

This looks confusing. arch_exit_to_user_mode_prepare() can just call
fpregs_assert_state_consistent() unconditionally, it depends on
CONFIG_X86_DEBUG_FPU and checks TIF_NEED_FPU_LOAD itself.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Chang S . Bae <chang.seok.bae@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250503143902.GA9012@redhat.com
arch/x86/include/asm/entry-common.h

index 77d20555e04de5765b392f639e0611eeaf7e423d..d535a97c728422b998cde5b08f17fcbb26230d38 100644 (file)
@@ -53,7 +53,6 @@ static inline void arch_exit_work(unsigned long ti_work)
        if (unlikely(ti_work & _TIF_IO_BITMAP))
                tss_update_io_bitmap();
 
-       fpregs_assert_state_consistent();
        if (unlikely(ti_work & _TIF_NEED_FPU_LOAD))
                switch_fpu_return();
 }
@@ -61,7 +60,9 @@ static inline void arch_exit_work(unsigned long ti_work)
 static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
                                                  unsigned long ti_work)
 {
-       if (IS_ENABLED(CONFIG_X86_DEBUG_FPU) || unlikely(ti_work))
+       fpregs_assert_state_consistent();
+
+       if (unlikely(ti_work))
                arch_exit_work(ti_work);
 
        fred_update_rsp0();