Commit 419abc4d authored by Heiko Carstens's avatar Heiko Carstens
Browse files

s390/fpu: convert FPU CIF flag to regular TIF flag



The FPU state, as represented by the CIF_FPU flag reflects the FPU state of
a task, not the CPU it is running on. Therefore convert the flag to a
regular TIF flag.

This removes the magic in switch_to() where a save_fpu_regs() call for the
currently (previous) running task sets the per-cpu CIF_FPU flag, which is
required to restore FPU register contents of the next task, when it returns
to user space.

Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 918c7cad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,

static __always_inline void arch_exit_to_user_mode(void)
{
	if (test_cpu_flag(CIF_FPU))
	if (test_thread_flag(TIF_FPU))
		__load_fpu_regs();

	if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ static inline void kernel_fpu_begin(struct kernel_fpu *state, u32 flags)
{
	preempt_disable();
	state->mask = S390_lowcore.fpu_flags;
	if (!test_cpu_flag(CIF_FPU)) {
	if (!test_thread_flag(TIF_FPU)) {
		/* Save user space FPU state and register contents */
		save_fpu_regs();
	} else if (state->mask & flags) {
+0 −2
Original line number Diff line number Diff line
@@ -15,13 +15,11 @@
#include <linux/bits.h>

#define CIF_NOHZ_DELAY		2	/* delay HZ disable for a tick */
#define CIF_FPU			3	/* restore FPU registers */
#define CIF_ENABLED_WAIT	5	/* in enabled wait state */
#define CIF_MCCK_GUEST		6	/* machine check happening in guest */
#define CIF_DEDICATED_CPU	7	/* this CPU is dedicated */

#define _CIF_NOHZ_DELAY		BIT(CIF_NOHZ_DELAY)
#define _CIF_FPU		BIT(CIF_FPU)
#define _CIF_ENABLED_WAIT	BIT(CIF_ENABLED_WAIT)
#define _CIF_MCCK_GUEST		BIT(CIF_MCCK_GUEST)
#define _CIF_DEDICATED_CPU	BIT(CIF_DEDICATED_CPU)
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ void arch_setup_new_exec(void);
#define TIF_PATCH_PENDING	5	/* pending live patching update */
#define TIF_PGSTE		6	/* New mm's will use 4K page tables */
#define TIF_NOTIFY_SIGNAL	7	/* signal notifications exist */
#define TIF_FPU			8	/* restore FPU registers on exit to usermode */
#define TIF_ISOLATE_BP_GUEST	9	/* Run KVM guests with isolated BP */
#define TIF_PER_TRAP		10	/* Need to handle PER trap on exit to usermode */

@@ -92,6 +93,7 @@ void arch_setup_new_exec(void);
#define _TIF_UPROBE		BIT(TIF_UPROBE)
#define _TIF_GUARDED_STORAGE	BIT(TIF_GUARDED_STORAGE)
#define _TIF_PATCH_PENDING	BIT(TIF_PATCH_PENDING)
#define _TIF_FPU		BIT(TIF_FPU)
#define _TIF_ISOLATE_BP_GUEST	BIT(TIF_ISOLATE_BP_GUEST)
#define _TIF_PER_TRAP		BIT(TIF_PER_TRAP)

+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ SYM_FUNC_START(__sie64a)
	oi	__SIE_PROG0C+3(%r14),1		# we are going into SIE now
	tm	__SIE_PROG20+3(%r14),3		# last exit...
	jnz	.Lsie_skip
	TSTMSK	__LC_CPU_FLAGS,_CIF_FPU
	TSTMSK	__SF_SIE_FLAGS(%r15),_TIF_FPU
	jo	.Lsie_skip			# exit if fp/vx regs changed
	lg	%r14,__SF_SIE_CONTROL_PHYS(%r15)	# get sie block phys addr
	BPEXIT	__SF_SIE_FLAGS(%r15),_TIF_ISOLATE_BP_GUEST
Loading