Skip to content

Commit 1937e18

Browse files
Stanislav SpassovIngo Molnar
authored andcommitted
x86/fpu: Fix guest FPU state buffer allocation size
Ongoing work on an optimization to batch-preallocate vCPU state buffers for KVM revealed a mismatch between the allocation sizes used in fpu_alloc_guest_fpstate() and fpstate_realloc(). While the former allocates a buffer sized to fit the default set of XSAVE features in UABI form (as per fpu_user_cfg), the latter uses its ksize argument derived (for the requested set of features) in the same way as the sizes found in fpu_kernel_cfg, i.e. using the compacted in-kernel representation. The correct size to use for guest FPU state should indeed be the kernel one as seen in fpstate_realloc(). The original issue likely went unnoticed through a combination of UABI size typically being larger than or equal to kernel size, and/or both amounting to the same number of allocated 4K pages. Fixes: 69f6ed1 ("x86/fpu: Provide infrastructure for KVM FPU cleanup") Signed-off-by: Stanislav Spassov <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ccb7735 commit 1937e18

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/fpu/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu)
220220
struct fpstate *fpstate;
221221
unsigned int size;
222222

223-
size = fpu_user_cfg.default_size + ALIGN(offsetof(struct fpstate, regs), 64);
223+
size = fpu_kernel_cfg.default_size + ALIGN(offsetof(struct fpstate, regs), 64);
224224
fpstate = vzalloc(size);
225225
if (!fpstate)
226226
return false;

0 commit comments

Comments
 (0)