Commit 24ab4cb0 authored by Chang S. Bae's avatar Chang S. Bae Committed by Lin Wang
Browse files

x86/fpu: Configure init_fpstate attributes orderly

mainline inclusion
from mainline-v6.1-rc2
commit c32d7cab
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I73H0T
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c32d7cab57e3a77af8ecc17cde7a5761a26483b8



Intel-SIG: commit c32d7cab x86/fpu: Configure init_fpstate attributes orderly.

--------------------------------

The init_fpstate setup code is spread out and out of order. The init image
is recorded before its scoped features and the buffer size are determined.

Determine the scope of init_fpstate components and its size before
recording the init state. Also move the relevant code together.

Signed-off-by: default avatarChang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatar <neelnatu@google.com>
Link: https://lore.kernel.org/r/20220824191223.1248-2-chang.seok.bae@intel.com


Signed-off-by: default avatarLin Wang <lin.x.wang@intel.com>
parent b75b6c1b
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -210,13 +210,6 @@ static void __init fpu__init_system_xstate_size_legacy(void)
	fpstate_reset(&current->thread.fpu);
}

static void __init fpu__init_init_fpstate(void)
{
	/* Bring init_fpstate size and features up to date */
	init_fpstate.size		= fpu_kernel_cfg.max_size;
	init_fpstate.xfeatures		= fpu_kernel_cfg.max_features;
}

/*
 * Called on the boot CPU once per system bootup, to set up the initial
 * FPU state that is later cloned into all processes:
@@ -236,5 +229,4 @@ void __init fpu__init_system(struct cpuinfo_x86 *c)
	fpu__init_system_xstate_size_legacy();
	fpu__init_system_xstate(fpu_kernel_cfg.max_size);
	fpu__init_task_struct_size();
	fpu__init_init_fpstate();
}
+5 −1
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ static void __init setup_init_fpu_buf(void)

	print_xstate_features();

	xstate_init_xcomp_bv(&init_fpstate.regs.xsave, fpu_kernel_cfg.max_features);
	xstate_init_xcomp_bv(&init_fpstate.regs.xsave, init_fpstate.xfeatures);

	/*
	 * Init all the features state with header.xfeatures being 0x0
@@ -857,6 +857,10 @@ void __init fpu__init_system_xstate(unsigned int legacy_size)
	update_regset_xstate_info(fpu_user_cfg.max_size,
				  fpu_user_cfg.max_features);

	/* Bring init_fpstate size and features up to date */
	init_fpstate.size		= fpu_kernel_cfg.max_size;
	init_fpstate.xfeatures		= fpu_kernel_cfg.max_features;

	setup_init_fpu_buf();

	/*