Thread (49 messages) 49 messages, 6 authors, 2019-11-01

Re: [PATCH v7 04/27] x86/fpu/xstate: Introduce XSAVES system states

From: Andy Lutomirski <luto@amacapital.net>
Date: 2019-06-06 22:04:47
Also in: linux-arch, linux-doc, linux-mm, lkml


On Jun 6, 2019, at 2:18 PM, Dave Hansen [off-list ref] wrote:
quoted
+/*
+ * Helpers for changing XSAVES system states.
+ */
+static inline void modify_fpu_regs_begin(void)
+{
+    fpregs_lock();
+    if (test_thread_flag(TIF_NEED_FPU_LOAD))
+        __fpregs_load_activate();
+}
+
+static inline void modify_fpu_regs_end(void)
+{
+    fpregs_unlock();
+}
These are massively under-commented and under-changelogged.  This looks
like it's intended to ensure that we have supervisor FPU state for this
task loaded before we go and run the MSRs that might be modifying it.

But, that seems broken.  If we have supervisor state, we can't always
defer the load until return to userspace, so we'll never?? have
TIF_NEED_FPU_LOAD.  That would certainly be true for cet_kernel_state.
Ugh. I was sort of imagining that we would treat supervisor state completely separately from user state.  But can you maybe give examples of exactly what you mean?
It seems like we actually need three classes of XSAVE states:
1. User state
This is FPU, XMM, etc, right?
2. Supervisor state that affects user mode
User CET?

3. Supervisor state that affects kernel mode
Like supervisor CET?  If we start doing supervisor shadow stack, the context switches will be real fun.  We may need to handle this in asm.

Where does PKRU fit in?  Maybe we can treat it as #3?

—Andy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help