[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250307164123.1613414-8-chao.gao@intel.com>
Date: Sat, 8 Mar 2025 00:41:20 +0800
From: Chao Gao <chao.gao@...el.com>
To: chao.gao@...el.com,
tglx@...utronix.de,
dave.hansen@...el.com,
x86@...nel.org,
seanjc@...gle.com,
pbonzini@...hat.com,
linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: peterz@...radead.org,
rick.p.edgecombe@...el.com,
weijiang.yang@...el.com,
john.allen@....com,
bp@...en8.de,
Maxim Levitsky <mlevitsk@...hat.com>
Subject: [PATCH v3 07/10] x86/fpu/xstate: Initialize guest fpstate with fpu_guest_config
From: Yang Weijiang <weijiang.yang@...el.com>
Use fpu_guest_cfg to initialize the guest fpstate and the guest FPU pseduo
container.
The user_* fields remain unchanged for compatibility with KVM uAPIs.
Inline the logic of __fpstate_reset() to directly utilize fpu_guest_cfg.
Note fpu_guest_cfg and fpu_kernel_cfg remain the same for now. So there
is no functional change.
Signed-off-by: Yang Weijiang <weijiang.yang@...el.com>
Signed-off-by: Chao Gao <chao.gao@...el.com>
Reviewed-by: Maxim Levitsky <mlevitsk@...hat.com>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@...el.com>
---
arch/x86/kernel/fpu/core.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index d7ae684adbad..9cb800918b6d 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -194,8 +194,6 @@ void fpu_reset_from_exception_fixup(void)
}
#if IS_ENABLED(CONFIG_KVM)
-static void __fpstate_reset(struct fpstate *fpstate, u64 xfd);
-
static void fpu_lock_guest_permissions(struct fpu_guest *gfpu)
{
struct fpu_state_perm *fpuperm;
@@ -219,19 +217,22 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu)
struct fpstate *fpstate;
unsigned int size;
- size = fpu_kernel_cfg.default_size + ALIGN(offsetof(struct fpstate, regs), 64);
+ size = fpu_guest_cfg.default_size + ALIGN(offsetof(struct fpstate, regs), 64);
+
fpstate = vzalloc(size);
if (!fpstate)
return false;
- /* Leave xfd to 0 (the reset value defined by spec) */
- __fpstate_reset(fpstate, 0);
+ fpstate->size = fpu_guest_cfg.default_size;
+ fpstate->xfeatures = fpu_guest_cfg.default_features;
+ fpstate->user_size = fpu_user_cfg.default_size;
+ fpstate->user_xfeatures = fpu_user_cfg.default_features;
fpstate_init_user(fpstate);
fpstate->is_valloc = true;
fpstate->is_guest = true;
gfpu->fpstate = fpstate;
- gfpu->xfeatures = fpu_kernel_cfg.default_features;
+ gfpu->xfeatures = fpu_guest_cfg.default_features;
/*
* KVM sets the FP+SSE bits in the XSAVE header when copying FPU state
--
2.46.1
Powered by blists - more mailing lists