Skip to content

Commit 2308ee5

Browse files
ChangSeokBaesuryasaimadhu
authored andcommitted
x86/fpu/amx: Enable the AMX feature in 64-bit mode
Add the AMX state components in XFEATURE_MASK_USER_SUPPORTED and the TILE_DATA component to the dynamic states and update the permission check table accordingly. This is only effective on 64 bit kernels as for 32bit kernels XFEATURE_MASK_TILE is defined as 0. TILE_DATA is caller-saved state and the only dynamic state. Add build time sanity check to ensure the assumption that every dynamic feature is caller- saved. Make AMX state depend on XFD as it is dynamic feature. Signed-off-by: Chang S. Bae <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent db3e732 commit 2308ee5

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

arch/x86/include/asm/fpu/xstate.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
XFEATURE_MASK_Hi16_ZMM | \
3636
XFEATURE_MASK_PKRU | \
3737
XFEATURE_MASK_BNDREGS | \
38-
XFEATURE_MASK_BNDCSR)
38+
XFEATURE_MASK_BNDCSR | \
39+
XFEATURE_MASK_XTILE)
3940

4041
/*
4142
* Features which are restored when returning to user space.
@@ -46,7 +47,7 @@
4647
(XFEATURE_MASK_USER_SUPPORTED & ~XFEATURE_MASK_PKRU)
4748

4849
/* Features which are dynamically enabled for a process on request */
49-
#define XFEATURE_MASK_USER_DYNAMIC 0ULL
50+
#define XFEATURE_MASK_USER_DYNAMIC XFEATURE_MASK_XTILE_DATA
5051

5152
/* All currently supported supervisor features */
5253
#define XFEATURE_MASK_SUPERVISOR_SUPPORTED (XFEATURE_MASK_PASID)

arch/x86/kernel/cpu/cpuid-deps.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static const struct cpuid_dep cpuid_deps[] = {
7676
{ X86_FEATURE_SGX1, X86_FEATURE_SGX },
7777
{ X86_FEATURE_SGX2, X86_FEATURE_SGX1 },
7878
{ X86_FEATURE_XFD, X86_FEATURE_XSAVES },
79+
{ X86_FEATURE_AMX_TILE, X86_FEATURE_XFD },
7980
{}
8081
};
8182

arch/x86/kernel/fpu/core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags)
494494
return 0;
495495
}
496496

497+
/*
498+
* If a new feature is added, ensure all dynamic features are
499+
* caller-saved from here!
500+
*/
501+
BUILD_BUG_ON(XFEATURE_MASK_USER_DYNAMIC != XFEATURE_MASK_XTILE_DATA);
502+
497503
/*
498504
* Save the default portion of the current FPU state into the
499505
* clone. Assume all dynamic features to be defined as caller-

arch/x86/kernel/fpu/xstate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ static __init void os_xrstor_booting(struct xregs_state *xstate)
404404
XFEATURE_MASK_PKRU | \
405405
XFEATURE_MASK_BNDREGS | \
406406
XFEATURE_MASK_BNDCSR | \
407-
XFEATURE_MASK_PASID)
407+
XFEATURE_MASK_PASID | \
408+
XFEATURE_MASK_XTILE)
408409

409410
/*
410411
* setup the xstate image representing the init state
@@ -1636,7 +1637,7 @@ static int __xstate_request_perm(u64 permitted, u64 requested)
16361637
* Permissions array to map facilities with more than one component
16371638
*/
16381639
static const u64 xstate_prctl_req[XFEATURE_MAX] = {
1639-
/* [XFEATURE_XTILE_DATA] = XFEATURE_MASK_XTILE, */
1640+
[XFEATURE_XTILE_DATA] = XFEATURE_MASK_XTILE_DATA,
16401641
};
16411642

16421643
static int xstate_request_perm(unsigned long idx)

0 commit comments

Comments
 (0)