2023-06-21 13:13:23

by Chang S. Bae

[permalink] [raw]
Subject: [PATCH v1 2/4] x86/fpu/xstate: Simplify xstate_calculate_size()

This size calculation code uses xfeatures_get_offset() only for the
compacted format. But, it is capable of handling both formats. Use it
for simpler and more concise code.

Signed-off-by: Chang S. Bae <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/x86/kernel/fpu/xstate.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 2f03acc47f62..d488621b280e 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -563,14 +563,11 @@ static bool __init check_xstate_against_struct(int nr)
static unsigned int xstate_calculate_size(u64 xfeatures, bool compacted)
{
unsigned int topmost = fls64(xfeatures) - 1;
- unsigned int offset = xstate_offsets[topmost];

if (topmost <= XFEATURE_SSE)
return sizeof(struct xregs_state);

- if (compacted)
- offset = xfeature_get_offset(xfeatures, topmost);
- return offset + xstate_sizes[topmost];
+ return xfeature_get_offset(xfeatures, topmost) + xstate_sizes[topmost];
}

/*
--
2.34.1