mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00

The first invocation of kernel_fpu_begin() after switching from user to kernel context will save all vector registers, even if only parts of the vector registers are used within the kernel fpu context. Given that save and restore of all vector registers is quite expensive change the current approach in several ways: - Instead of saving and restoring all user registers limit this to those registers which are actually used within an kernel fpu context. - On context switch save all remaining user fpu registers, so they can be restored when the task is rescheduled. - Saving user registers within kernel_fpu_begin() is done without disabling and enabling interrupts - which also slightly reduces runtime. In worst case (e.g. interrupt context uses the same registers) this may lead to the situation that registers are saved several times, however the assumption is that this will not happen frequently, so that the new method is faster in nearly all cases. - save_user_fpu_regs() can still be called from all contexts and saves all (or all remaining) user registers to a tasks ufpu user fpu save area. Overall this reduces the time required to save and restore the user fpu context for nearly all cases. Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef ARCH_S390_ENTRY_COMMON_H
|
|
#define ARCH_S390_ENTRY_COMMON_H
|
|
|
|
#include <linux/sched.h>
|
|
#include <linux/audit.h>
|
|
#include <linux/randomize_kstack.h>
|
|
#include <linux/processor.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/timex.h>
|
|
#include <asm/fpu.h>
|
|
#include <asm/pai.h>
|
|
|
|
#define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP)
|
|
|
|
void do_per_trap(struct pt_regs *regs);
|
|
|
|
static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
|
|
{
|
|
if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
|
|
debug_user_asce(0);
|
|
|
|
pai_kernel_enter(regs);
|
|
}
|
|
|
|
#define arch_enter_from_user_mode arch_enter_from_user_mode
|
|
|
|
static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,
|
|
unsigned long ti_work)
|
|
{
|
|
if (ti_work & _TIF_PER_TRAP) {
|
|
clear_thread_flag(TIF_PER_TRAP);
|
|
do_per_trap(regs);
|
|
}
|
|
|
|
if (ti_work & _TIF_GUARDED_STORAGE)
|
|
gs_load_bc_cb(regs);
|
|
}
|
|
|
|
#define arch_exit_to_user_mode_work arch_exit_to_user_mode_work
|
|
|
|
static __always_inline void arch_exit_to_user_mode(void)
|
|
{
|
|
load_user_fpu_regs();
|
|
|
|
if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
|
|
debug_user_asce(1);
|
|
|
|
pai_kernel_exit(current_pt_regs());
|
|
}
|
|
|
|
#define arch_exit_to_user_mode arch_exit_to_user_mode
|
|
|
|
static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
|
|
unsigned long ti_work)
|
|
{
|
|
choose_random_kstack_offset(get_tod_clock_fast() & 0xff);
|
|
}
|
|
|
|
#define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare
|
|
|
|
#endif
|