[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210825155413.19673-22-chang.seok.bae@intel.com>
Date: Wed, 25 Aug 2021 08:54:06 -0700
From: "Chang S. Bae" <chang.seok.bae@...el.com>
To: bp@...e.de, luto@...nel.org, tglx@...utronix.de, mingo@...nel.org,
x86@...nel.org
Cc: len.brown@...el.com, lenb@...nel.org, dave.hansen@...el.com,
thiago.macieira@...el.com, jing2.liu@...el.com,
ravi.v.shankar@...el.com, linux-kernel@...r.kernel.org,
chang.seok.bae@...el.com
Subject: [PATCH v10 21/28] x86/fpu/amx: Initialize child's AMX state
Assure that a forked child starts AMX registers in the INIT-state.
Signed-off-by: Chang S. Bae <chang.seok.bae@...el.com>
Reviewed-by: Len Brown <len.brown@...el.com>
Cc: x86@...nel.org
Cc: linux-kernel@...r.kernel.org
---
Changes from v5:
* Introduced a new define. (Andy Lutomirski)
Changes from v4:
* Added as a new patch. This was missing on previous versions.
---
arch/x86/include/asm/fpu/xstate.h | 3 +++
arch/x86/kernel/fpu/core.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h
index 0156ed3d2bc9..ce65c4871d70 100644
--- a/arch/x86/include/asm/fpu/xstate.h
+++ b/arch/x86/include/asm/fpu/xstate.h
@@ -80,6 +80,9 @@
XFEATURE_MASK_INDEPENDENT | \
XFEATURE_MASK_SUPERVISOR_UNSUPPORTED)
+/* Volatile states that a child does not inherit. */
+#define XFEATURE_MASK_CLEARED_ON_CLONE XFEATURE_MASK_XTILE
+
#ifdef CONFIG_X86_64
#define REX_PREFIX "0x48, "
#else
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 74941a490200..02681cce1d4e 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -300,6 +300,9 @@ int fpu_clone(struct task_struct *dst)
save_fpregs_to_fpstate(dst_fpu);
fpregs_unlock();
+ if (xfeatures_mask_all & XFEATURE_MASK_CLEARED_ON_CLONE)
+ dst_fpu->state->xsave.header.xfeatures &= ~XFEATURE_MASK_CLEARED_ON_CLONE;
+
set_tsk_thread_flag(dst, TIF_NEED_FPU_LOAD);
trace_x86_fpu_copy_src(src_fpu);
--
2.17.1
Powered by blists - more mailing lists