Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a133207 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

x86/fpu: Remove fpstate_xstate_init_size() boot quirk



fpstate_xstate_init_size() is called in fpu__cpu_init(), which is
run on every CPU, every time they are brought online.

But we want to call fpstate_xstate_init_size() only once. Move it to
fpu__detect(), which only runs once, on the boot CPU.

Also clean up the flow of fpstate_xstate_init_size() a bit, by
removing a 'return' from the middle of the function.

Reviewed-by: default avatarBorislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 66af8e27
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -109,14 +109,13 @@ static void fpstate_xstate_init_size(void)
		setup_clear_cpu_cap(X86_FEATURE_XSAVE);
		setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
		xstate_size = sizeof(struct i387_soft_struct);
		return;
	}

	} else {
		if (cpu_has_fxsr)
			xstate_size = sizeof(struct i387_fxsave_struct);
		else
			xstate_size = sizeof(struct i387_fsave_struct);
	}
}

/*
 * Called on the boot CPU at bootup to set up the initial FPU state that
@@ -151,12 +150,6 @@ void fpu__cpu_init(void)
		cr0 |= X86_CR0_EM;
	write_cr0(cr0);

	/*
	 * fpstate_xstate_init_size() is only called once, to avoid overriding
	 * 'xstate_size' during (secondary CPU) bootup or during CPU hotplug.
	 */
	if (xstate_size == 0)
		fpstate_xstate_init_size();

	mxcsr_feature_mask_init();
	xsave_init();
@@ -194,5 +187,7 @@ void fpu__detect(struct cpuinfo_x86 *c)
	else
		clear_cpu_cap(c, X86_FEATURE_FPU);

	/* The final cr0 value is set in fpu_init() */
	/* The final cr0 value is set later, in fpu_init() */

	fpstate_xstate_init_size();
}