| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * x86 FPU boot time init code: |
|---|
| 3 | 4 | */ |
|---|
| 4 | 5 | #include <asm/fpu/internal.h> |
|---|
| 5 | 6 | #include <asm/tlbflush.h> |
|---|
| 6 | 7 | #include <asm/setup.h> |
|---|
| 7 | | -#include <asm/cmdline.h> |
|---|
| 8 | 8 | |
|---|
| 9 | 9 | #include <linux/sched.h> |
|---|
| 10 | 10 | #include <linux/sched/task.h> |
|---|
| .. | .. |
|---|
| 203 | 203 | */ |
|---|
| 204 | 204 | |
|---|
| 205 | 205 | 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); |
|---|
| 212 | 206 | fpu_kernel_xstate_size = sizeof(struct swregs_state); |
|---|
| 213 | 207 | } else { |
|---|
| 214 | 208 | if (boot_cpu_has(X86_FEATURE_FXSR)) |
|---|
| .. | .. |
|---|
| 229 | 223 | */ |
|---|
| 230 | 224 | u64 __init fpu__get_supported_xfeatures_mask(void) |
|---|
| 231 | 225 | { |
|---|
| 232 | | - return XCNTXT_MASK; |
|---|
| 226 | + return XFEATURE_MASK_USER_SUPPORTED | |
|---|
| 227 | + XFEATURE_MASK_SUPERVISOR_SUPPORTED; |
|---|
| 233 | 228 | } |
|---|
| 234 | 229 | |
|---|
| 235 | 230 | /* Legacy code to initialize eager fpu mode. */ |
|---|
| .. | .. |
|---|
| 239 | 234 | |
|---|
| 240 | 235 | WARN_ON_FPU(!on_boot_cpu); |
|---|
| 241 | 236 | 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"); |
|---|
| 294 | 237 | } |
|---|
| 295 | 238 | |
|---|
| 296 | 239 | /* |
|---|
| .. | .. |
|---|
| 299 | 242 | */ |
|---|
| 300 | 243 | void __init fpu__init_system(struct cpuinfo_x86 *c) |
|---|
| 301 | 244 | { |
|---|
| 302 | | - fpu__init_parse_early_param(); |
|---|
| 303 | 245 | fpu__init_system_early_generic(c); |
|---|
| 304 | 246 | |
|---|
| 305 | 247 | /* |
|---|