[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 1/2] x86_64: Fix updating fsgs base on context switch
From: |
Sergey Bugaev |
Subject: |
[RFC PATCH 1/2] x86_64: Fix updating fsgs base on context switch |
Date: |
Thu, 11 May 2023 16:58:43 +0300 |
Commit 31dd30a94a682955c3c9e2f42252b4a07687067a "add setting gs/fsbase"
added the code to set fs and gs bases on context_switch. However, this
was only being done when switching context via the explicit
switch_context() method, but not in other cases where the context is
switched, such as with call_continuation().
Instead, put setting fsgs base into switch_ktss(), where it will be
called in all cases.
---
i386/i386/pcb.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c
index 8a9e3bf4..a5efb9a8 100644
--- a/i386/i386/pcb.c
+++ b/i386/i386/pcb.c
@@ -223,6 +223,11 @@ void switch_ktss(pcb_t pcb)
pcb->ims.user_gdt, sizeof pcb->ims.user_gdt);
#endif /* MACH_PV_DESCRIPTORS */
+#if defined(__x86_64__) && !defined(USER32)
+ wrmsr(MSR_REG_FSBASE, pcb->iss.fsbase);
+ wrmsr(MSR_REG_GSBASE, pcb->iss.gsbase);
+#endif
+
db_load_context(pcb);
/*
@@ -373,10 +378,6 @@ thread_t switch_context(
* Load the rest of the user state for the new thread
*/
switch_ktss(new->pcb);
-#if defined(__x86_64__) && !defined(USER32)
- wrmsr(MSR_REG_FSBASE, new->pcb->iss.fsbase);
- wrmsr(MSR_REG_GSBASE, new->pcb->iss.gsbase);
-#endif
return Switch_context(old, continuation, new);
}
--
2.40.1
- [RFC PATCH 1/2] x86_64: Fix updating fsgs base on context switch,
Sergey Bugaev <=