Created
August 9, 2023 09:16
-
-
Save sirn/2ce3867869483dc7b65e3c03022cf40c to your computer and use it in GitHub Desktop.
Fix AMX Context Saves/Restores on Sapphire Rapids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/os/linux/kernel/linux/simd_x86.h b/include/os/linux/kernel/linux/simd_x86.h | |
index 660f0d42d..7e1f46e81 100644 | |
--- a/include/os/linux/kernel/linux/simd_x86.h | |
+++ b/include/os/linux/kernel/linux/simd_x86.h | |
@@ -290,7 +290,7 @@ kfpu_begin(void) | |
*/ | |
union fpregs_state *state = zfs_kfpu_fpregs[smp_processor_id()]; | |
if (static_cpu_has(X86_FEATURE_XSAVE)) { | |
- kfpu_save_xsave(&state->xsave, ~0); | |
+ kfpu_save_xsave(&state->xsave, ~(XFEATURE_MASK_XTILE)); | |
} else if (static_cpu_has(X86_FEATURE_FXSR)) { | |
kfpu_save_fxsr(&state->fxsave); | |
} else { | |
@@ -319,18 +319,18 @@ kfpu_begin(void) | |
union fpregs_state *state = zfs_kfpu_fpregs[smp_processor_id()]; | |
#if defined(HAVE_XSAVES) | |
if (static_cpu_has(X86_FEATURE_XSAVES)) { | |
- kfpu_do_xsave("xsaves", &state->xsave, ~0); | |
+ kfpu_do_xsave("xsaves", &state->xsave, ~(XFEATURE_MASK_XTILE)); | |
return; | |
} | |
#endif | |
#if defined(HAVE_XSAVEOPT) | |
if (static_cpu_has(X86_FEATURE_XSAVEOPT)) { | |
- kfpu_do_xsave("xsaveopt", &state->xsave, ~0); | |
+ kfpu_do_xsave("xsaveopt", &state->xsave, ~(XFEATURE_MASK_XTILE)); | |
return; | |
} | |
#endif | |
if (static_cpu_has(X86_FEATURE_XSAVE)) { | |
- kfpu_do_xsave("xsave", &state->xsave, ~0); | |
+ kfpu_do_xsave("xsave", &state->xsave, ~(XFEATURE_MASK_XTILE)); | |
} else if (static_cpu_has(X86_FEATURE_FXSR)) { | |
kfpu_save_fxsr(&state->fxsave); | |
} else { | |
@@ -396,7 +396,7 @@ kfpu_end(void) | |
union fpregs_state *state = zfs_kfpu_fpregs[smp_processor_id()]; | |
if (static_cpu_has(X86_FEATURE_XSAVE)) { | |
- kfpu_restore_xsave(&state->xsave, ~0); | |
+ kfpu_restore_xsave(&state->xsave, ~(XFEATURE_MASK_XTILE)); | |
} else if (static_cpu_has(X86_FEATURE_FXSR)) { | |
kfpu_restore_fxsr(&state->fxsave); | |
} else { | |
@@ -415,12 +415,12 @@ kfpu_end(void) | |
union fpregs_state *state = zfs_kfpu_fpregs[smp_processor_id()]; | |
#if defined(HAVE_XSAVES) | |
if (static_cpu_has(X86_FEATURE_XSAVES)) { | |
- kfpu_do_xrstor("xrstors", &state->xsave, ~0); | |
+ kfpu_do_xrstor("xrstors", &state->xsave, ~(XFEATURE_MASK_XTILE)); | |
goto out; | |
} | |
#endif | |
if (static_cpu_has(X86_FEATURE_XSAVE)) { | |
- kfpu_do_xrstor("xrstor", &state->xsave, ~0); | |
+ kfpu_do_xrstor("xrstor", &state->xsave, ~(XFEATURE_MASK_XTILE)); | |
} else if (static_cpu_has(X86_FEATURE_FXSR)) { | |
kfpu_restore_fxsr(&state->fxsave); | |
} else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment