[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250307164123.1613414-11-chao.gao@intel.com>
Date: Sat, 8 Mar 2025 00:41:23 +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
Subject: [PATCH v3 10/10] x86/fpu/xstate: Warn if CET supervisor state is detected in normal fpstate
From: Yang Weijiang <weijiang.yang@...el.com>
CET supervisor state bit is __ONLY__ enabled for guest fpstate, i.e.,
never for normal kernel fpstate. The bit is set when guest FPU config
is initialized.
For normal fpstate, the bit should have been removed when initializes
kernel FPU config settings, WARN_ONCE() if kernel detects normal fpstate
xfeatures contains CET supervisor state bit before xsaves operation.
Signed-off-by: Yang Weijiang <weijiang.yang@...el.com>
Signed-off-by: Chao Gao <chao.gao@...el.com>
---
arch/x86/kernel/fpu/xstate.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h
index aa16f1a1bbcf..3df135a7d8bd 100644
--- a/arch/x86/kernel/fpu/xstate.h
+++ b/arch/x86/kernel/fpu/xstate.h
@@ -209,6 +209,8 @@ static inline void os_xsave(struct fpstate *fpstate)
WARN_ON_FPU(!alternatives_patched);
xfd_validate_state(fpstate, mask, false);
+ WARN_ON_FPU(!fpstate->is_guest && (mask & XFEATURE_MASK_CET_KERNEL));
+
XSTATE_XSAVE(&fpstate->regs.xsave, lmask, hmask, err);
/* We should never fault when copying to a kernel buffer: */
--
2.46.1
Powered by blists - more mailing lists