From: Yang Weijiang <weijiang.yang@xxxxxxxxx> The guest fpstate size is calculated based on fpu_user_cfg, while fpstate->xfeatures is set to fpu_kernel_cfg.default_features in fpu_alloc_guest_fpstate(). In other words, the guest fpstate doesn't allocate memory for all supervisor states, even though they are enabled. Correct the calculation of the guest fpstate size. Note that this issue does not cause any functional problems because the guest fpstate is allocated using vmalloc(), which aligns the size to a full page, providing enough space for all existing supervisor components. On Emerald Rapids CPUs, the guest fpstate after this correction is ~2880 bytes. Link: https://lore.kernel.org/kvm/20230914063325.85503-3-weijiang.yang@xxxxxxxxx/ Fixes: 69f6ed1d14c6 ("x86/fpu: Provide infrastructure for KVM FPU cleanup") Signed-off-by: Yang Weijiang <weijiang.yang@xxxxxxxxx> Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx> --- arch/x86/kernel/fpu/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 6166a928d3f5..adc34914634e 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -218,7 +218,7 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu) struct fpstate *fpstate; unsigned int size; - size = fpu_user_cfg.default_size + ALIGN(offsetof(struct fpstate, regs), 64); + size = fpu_kernel_cfg.default_size + ALIGN(offsetof(struct fpstate, regs), 64); fpstate = vzalloc(size); if (!fpstate) return false; -- 2.46.1