summaryrefslogtreecommitdiff
path: root/i386/i386
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2023-09-25 00:24:25 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-09-25 10:21:29 +0200
commitb3921098e2807d6225d277986bc8063b6a271e88 (patch)
tree93aa20fdb9f5ef3055069dd913afd0ad09d4ca23 /i386/i386
parentbe0abe4c2361f2c7db5a52b0900e298083fefe40 (diff)
percpu: active_stack with gs
Message-Id: <20230925002417.467022-1-damien@zamaudio.com>
Diffstat (limited to 'i386/i386')
-rw-r--r--i386/i386/cswitch.S12
-rw-r--r--i386/i386/i386asm.sym1
-rw-r--r--i386/i386/locore.S2
-rw-r--r--i386/i386/percpu.h2
4 files changed, 9 insertions, 8 deletions
diff --git a/i386/i386/cswitch.S b/i386/i386/cswitch.S
index 598e32cf..2dee309b 100644
--- a/i386/i386/cswitch.S
+++ b/i386/i386/cswitch.S
@@ -41,7 +41,7 @@ ENTRY(Load_context)
lea KERNEL_STACK_SIZE-IKS_SIZE-IEL_SIZE(%ecx),%edx
/* point to stack top */
CPU_NUMBER(%eax)
- movl %ecx,CX(EXT(active_stacks),%eax) /* store stack address */
+ movl %ecx,MY(ACTIVE_STACK) /* store stack address */
movl %edx,CX(EXT(kernel_stack),%eax) /* store stack top */
movl KSS_ESP(%ecx),%esp /* switch stacks */
@@ -58,8 +58,7 @@ ENTRY(Load_context)
*/
ENTRY(Switch_context)
- CPU_NUMBER(%edx)
- movl CX(EXT(active_stacks),%edx),%ecx /* get old kernel stack */
+ movl MY(ACTIVE_STACK),%ecx /* get old kernel stack */
movl %ebx,KSS_EBX(%ecx) /* save registers */
movl %ebp,KSS_EBP(%ecx)
@@ -79,8 +78,9 @@ ENTRY(Switch_context)
lea KERNEL_STACK_SIZE-IKS_SIZE-IEL_SIZE(%ecx),%ebx
/* point to stack top */
+ CPU_NUMBER(%edx)
movl %esi,MY(ACTIVE_THREAD) /* new thread is active */
- movl %ecx,CX(EXT(active_stacks),%edx) /* set current stack */
+ movl %ecx,MY(ACTIVE_STACK) /* set current stack */
movl %ebx,CX(EXT(kernel_stack),%edx) /* set stack top */
movl KSS_ESP(%ecx),%esp /* switch stacks */
@@ -110,8 +110,7 @@ ENTRY(Thread_continue)
* has no FPU state)
*/
ENTRY(switch_to_shutdown_context)
- CPU_NUMBER(%edx)
- movl CX(EXT(active_stacks),%edx),%ecx /* get old kernel stack */
+ movl MY(ACTIVE_STACK),%ecx /* get old kernel stack */
movl %ebx,KSS_EBX(%ecx) /* save registers */
movl %ebp,KSS_EBP(%ecx)
movl %edi,KSS_EDI(%ecx)
@@ -125,6 +124,7 @@ ENTRY(switch_to_shutdown_context)
movl 4(%esp),%ebx /* get routine to run next */
movl 8(%esp),%esi /* get its argument */
+ CPU_NUMBER(%edx)
movl CX(EXT(int_stack_base),%edx),%ecx /* point to its interrupt stack */
lea -4+INTSTACK_SIZE(%ecx),%esp /* switch to it (top) */
diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym
index e9a792c3..e1f5c6bb 100644
--- a/i386/i386/i386asm.sym
+++ b/i386/i386/i386asm.sym
@@ -55,6 +55,7 @@ offset ApicLocalUnit lu apic_id APIC_ID
offset percpu pc cpu_id PERCPU_CPU_ID
offset percpu pc active_thread PERCPU_ACTIVE_THREAD
+offset percpu pc active_stack PERCPU_ACTIVE_STACK
offset pcb pcb iss
diff --git a/i386/i386/locore.S b/i386/i386/locore.S
index 8fba7638..d3986793 100644
--- a/i386/i386/locore.S
+++ b/i386/i386/locore.S
@@ -555,7 +555,7 @@ trap_from_kernel:
cmpl CX(EXT(kernel_stack),%edx),%esp
/* already on kernel stack? */
ja 0f
- cmpl CX(EXT(active_stacks),%edx),%esp
+ cmpl MY(ACTIVE_STACK),%esp
ja 1f /* switch if not */
0:
movl CX(EXT(kernel_stack),%edx),%esp
diff --git a/i386/i386/percpu.h b/i386/i386/percpu.h
index ad4836ce..d73cfc8d 100644
--- a/i386/i386/percpu.h
+++ b/i386/i386/percpu.h
@@ -59,10 +59,10 @@ struct percpu {
int cpu_id;
struct processor processor;
thread_t active_thread;
+ vm_offset_t active_stack;
/*
struct machine_slot machine_slot;
struct mp_desc_table mp_desc_table;
- vm_offset_t active_stack;
vm_offset_t int_stack_top;
vm_offset_t int_stack_base;
ast_t need_ast;