|
147 | 147 | #error "Toolchain needs to support the XSAVE assembler instruction"
|
148 | 148 | #endif
|
149 | 149 |
|
| 150 | +#ifndef XFEATURE_MASK_XTILE |
| 151 | +/* |
| 152 | + * For kernels where this doesn't exist yet, we still don't want to break |
| 153 | + * by save/restoring this broken nonsense. |
| 154 | + * See issue #14989 or Intel errata SPR4 for why |
| 155 | + */ |
| 156 | +#define XFEATURE_MASK_XTILE 0x60000 |
| 157 | +#endif |
| 158 | + |
150 | 159 | #include <linux/mm.h>
|
151 | 160 | #include <linux/slab.h>
|
152 | 161 |
|
@@ -315,18 +324,18 @@ kfpu_begin(void)
|
315 | 324 | uint8_t *state = zfs_kfpu_fpregs[smp_processor_id()];
|
316 | 325 | #if defined(HAVE_XSAVES)
|
317 | 326 | if (static_cpu_has(X86_FEATURE_XSAVES)) {
|
318 |
| - kfpu_do_xsave("xsaves", state, ~0); |
| 327 | + kfpu_do_xsave("xsaves", state, ~XFEATURE_MASK_XTILE); |
319 | 328 | return;
|
320 | 329 | }
|
321 | 330 | #endif
|
322 | 331 | #if defined(HAVE_XSAVEOPT)
|
323 | 332 | if (static_cpu_has(X86_FEATURE_XSAVEOPT)) {
|
324 |
| - kfpu_do_xsave("xsaveopt", state, ~0); |
| 333 | + kfpu_do_xsave("xsaveopt", state, ~XFEATURE_MASK_XTILE); |
325 | 334 | return;
|
326 | 335 | }
|
327 | 336 | #endif
|
328 | 337 | if (static_cpu_has(X86_FEATURE_XSAVE)) {
|
329 |
| - kfpu_do_xsave("xsave", state, ~0); |
| 338 | + kfpu_do_xsave("xsave", state, ~XFEATURE_MASK_XTILE); |
330 | 339 | } else if (static_cpu_has(X86_FEATURE_FXSR)) {
|
331 | 340 | kfpu_save_fxsr(state);
|
332 | 341 | } else {
|
@@ -376,12 +385,12 @@ kfpu_end(void)
|
376 | 385 | uint8_t *state = zfs_kfpu_fpregs[smp_processor_id()];
|
377 | 386 | #if defined(HAVE_XSAVES)
|
378 | 387 | if (static_cpu_has(X86_FEATURE_XSAVES)) {
|
379 |
| - kfpu_do_xrstor("xrstors", state, ~0); |
| 388 | + kfpu_do_xrstor("xrstors", state, ~XFEATURE_MASK_XTILE); |
380 | 389 | goto out;
|
381 | 390 | }
|
382 | 391 | #endif
|
383 | 392 | if (static_cpu_has(X86_FEATURE_XSAVE)) {
|
384 |
| - kfpu_do_xrstor("xrstor", state, ~0); |
| 393 | + kfpu_do_xrstor("xrstor", state, ~XFEATURE_MASK_XTILE); |
385 | 394 | } else if (static_cpu_has(X86_FEATURE_FXSR)) {
|
386 | 395 | kfpu_restore_fxsr(state);
|
387 | 396 | } else {
|
|
0 commit comments