[PATCH v5 21/28] x86/fpu/amx: Initialize child's AMX state

From: Chang S. Bae
Date: Sun May 23 2021 - 15:39:57 EST


Assure that a forked child starts AMX registers in the INIT-state.

Signed-off-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
Reviewed-by: Len Brown <len.brown@xxxxxxxxx>
Cc: x86@xxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
Changes from v4:
* Added as a new patch. This was missing on previous versions.
---
arch/x86/kernel/fpu/core.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 016c3adebec3..cccfeafe81e5 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -285,6 +285,10 @@ int fpu__copy(struct task_struct *dst, struct task_struct *src)

fpregs_unlock();

+ /* AMX state is volatile, children do not inherit it. */
+ if (xfeatures_mask_all & XFEATURE_MASK_XTILE)
+ dst_fpu->state->xsave.header.xfeatures &= ~(XFEATURE_MASK_XTILE);
+
set_tsk_thread_flag(dst, TIF_NEED_FPU_LOAD);

trace_x86_fpu_copy_src(src_fpu);
--
2.17.1