Skip to content

Commit 446e693

Browse files
cyrillosKAGA-KOKO
authored andcommitted
x86/fpu: Use XFEATURE_FP/SSE enum values instead of hardcoded numbers
When setting up sizes and offsets for legacy header entries the code uses hardcoded 0/1 instead of the corresponding enum values XFEATURE_FP and XFEATURE_SSE. Replace the hardcoded numbers which enhances readability of the code and also makes this code the first user of those enum values.. Signed-off-by: Cyrill Gorcunov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent c085505 commit 446e693

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

arch/x86/kernel/fpu/xstate.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,13 @@ static void __init setup_xstate_features(void)
254254
* in the fixed offsets in the xsave area in either compacted form
255255
* or standard form.
256256
*/
257-
xstate_offsets[0] = 0;
258-
xstate_sizes[0] = offsetof(struct fxregs_state, xmm_space);
259-
xstate_offsets[1] = xstate_sizes[0];
260-
xstate_sizes[1] = FIELD_SIZEOF(struct fxregs_state, xmm_space);
257+
xstate_offsets[XFEATURE_FP] = 0;
258+
xstate_sizes[XFEATURE_FP] = offsetof(struct fxregs_state,
259+
xmm_space);
260+
261+
xstate_offsets[XFEATURE_SSE] = xstate_sizes[XFEATURE_FP];
262+
xstate_sizes[XFEATURE_SSE] = FIELD_SIZEOF(struct fxregs_state,
263+
xmm_space);
261264

262265
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
263266
if (!xfeature_enabled(i))
@@ -350,8 +353,9 @@ static void __init setup_xstate_comp(void)
350353
* in the fixed offsets in the xsave area in either compacted form
351354
* or standard form.
352355
*/
353-
xstate_comp_offsets[0] = 0;
354-
xstate_comp_offsets[1] = offsetof(struct fxregs_state, xmm_space);
356+
xstate_comp_offsets[XFEATURE_FP] = 0;
357+
xstate_comp_offsets[XFEATURE_SSE] = offsetof(struct fxregs_state,
358+
xmm_space);
355359

356360
if (!boot_cpu_has(X86_FEATURE_XSAVES)) {
357361
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {

0 commit comments

Comments
 (0)