hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/arch/x86/kernel/fpu/init.c
....@@ -1,10 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * x86 FPU boot time init code:
34 */
45 #include <asm/fpu/internal.h>
56 #include <asm/tlbflush.h>
67 #include <asm/setup.h>
7
-#include <asm/cmdline.h>
88
99 #include <linux/sched.h>
1010 #include <linux/sched/task.h>
....@@ -49,7 +49,7 @@
4949 fpu__init_cpu_xstate();
5050 }
5151
52
-static bool fpu__probe_without_cpuid(void)
52
+static bool __init fpu__probe_without_cpuid(void)
5353 {
5454 unsigned long cr0;
5555 u16 fsw, fcw;
....@@ -67,7 +67,7 @@
6767 return fsw == 0 && (fcw & 0x103f) == 0x003f;
6868 }
6969
70
-static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
70
+static void __init fpu__init_system_early_generic(void)
7171 {
7272 if (!boot_cpu_has(X86_FEATURE_CPUID) &&
7373 !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
....@@ -138,9 +138,6 @@
138138 unsigned int fpu_kernel_xstate_size;
139139 EXPORT_SYMBOL_GPL(fpu_kernel_xstate_size);
140140
141
-/* Get alignment of the TYPE. */
142
-#define TYPE_ALIGN(TYPE) offsetof(struct { char x; TYPE test; }, test)
143
-
144141 /*
145142 * Enforce that 'MEMBER' is the last field of 'TYPE'.
146143 *
....@@ -148,8 +145,8 @@
148145 * because that's how C aligns structs.
149146 */
150147 #define CHECK_MEMBER_AT_END_OF(TYPE, MEMBER) \
151
- BUILD_BUG_ON(sizeof(TYPE) != ALIGN(offsetofend(TYPE, MEMBER), \
152
- TYPE_ALIGN(TYPE)))
148
+ BUILD_BUG_ON(sizeof(TYPE) != \
149
+ ALIGN(offsetofend(TYPE, MEMBER), _Alignof(TYPE)))
153150
154151 /*
155152 * We append the 'struct fpu' to the task_struct:
....@@ -203,12 +200,6 @@
203200 */
204201
205202 if (!boot_cpu_has(X86_FEATURE_FPU)) {
206
- /*
207
- * Disable xsave as we do not support it if i387
208
- * emulation is enabled.
209
- */
210
- setup_clear_cpu_cap(X86_FEATURE_XSAVE);
211
- setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
212203 fpu_kernel_xstate_size = sizeof(struct swregs_state);
213204 } else {
214205 if (boot_cpu_has(X86_FEATURE_FXSR))
....@@ -229,7 +220,8 @@
229220 */
230221 u64 __init fpu__get_supported_xfeatures_mask(void)
231222 {
232
- return XCNTXT_MASK;
223
+ return XFEATURE_MASK_USER_SUPPORTED |
224
+ XFEATURE_MASK_SUPERVISOR_SUPPORTED;
233225 }
234226
235227 /* Legacy code to initialize eager fpu mode. */
....@@ -239,68 +231,15 @@
239231
240232 WARN_ON_FPU(!on_boot_cpu);
241233 on_boot_cpu = 0;
242
-
243
- WARN_ON_FPU(current->thread.fpu.initialized);
244
-}
245
-
246
-/*
247
- * We parse fpu parameters early because fpu__init_system() is executed
248
- * before parse_early_param().
249
- */
250
-static void __init fpu__init_parse_early_param(void)
251
-{
252
- char arg[128];
253
- char *argptr = arg;
254
- int arglen, res, bit;
255
-
256
- if (cmdline_find_option_bool(boot_command_line, "no387"))
257
- setup_clear_cpu_cap(X86_FEATURE_FPU);
258
-
259
- if (cmdline_find_option_bool(boot_command_line, "nofxsr")) {
260
- setup_clear_cpu_cap(X86_FEATURE_FXSR);
261
- setup_clear_cpu_cap(X86_FEATURE_FXSR_OPT);
262
- setup_clear_cpu_cap(X86_FEATURE_XMM);
263
- }
264
-
265
- if (cmdline_find_option_bool(boot_command_line, "noxsave"))
266
- fpu__xstate_clear_all_cpu_caps();
267
-
268
- if (cmdline_find_option_bool(boot_command_line, "noxsaveopt"))
269
- setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
270
-
271
- if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
272
- setup_clear_cpu_cap(X86_FEATURE_XSAVES);
273
-
274
- arglen = cmdline_find_option(boot_command_line, "clearcpuid", arg, sizeof(arg));
275
- if (arglen <= 0)
276
- return;
277
-
278
- pr_info("Clearing CPUID bits:");
279
- do {
280
- res = get_option(&argptr, &bit);
281
- if (res == 0 || res == 3)
282
- break;
283
-
284
- /* If the argument was too long, the last bit may be cut off */
285
- if (res == 1 && arglen >= sizeof(arg))
286
- break;
287
-
288
- if (bit >= 0 && bit < NCAPINTS * 32) {
289
- pr_cont(" " X86_CAP_FMT, x86_cap_flag(bit));
290
- setup_clear_cpu_cap(bit);
291
- }
292
- } while (res == 2);
293
- pr_cont("\n");
294234 }
295235
296236 /*
297237 * Called on the boot CPU once per system bootup, to set up the initial
298238 * FPU state that is later cloned into all processes:
299239 */
300
-void __init fpu__init_system(struct cpuinfo_x86 *c)
240
+void __init fpu__init_system(void)
301241 {
302
- fpu__init_parse_early_param();
303
- fpu__init_system_early_generic(c);
242
+ fpu__init_system_early_generic();
304243
305244 /*
306245 * The FPU has to be operational for some of the