diff options
author | Damien Zammit <damien@zamaudio.com> | 2023-01-31 09:36:38 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-01-31 20:59:09 +0100 |
commit | 422ab47d25576587600d093297512d8b6cbec890 (patch) | |
tree | 52508ee186e2cdcd0812976b6ae74b521afb0e14 | |
parent | 8c87a640763c20238b6f28ba6bcbc54914d11664 (diff) | |
download | gnumach-422ab47d25576587600d093297512d8b6cbec890.tar.gz gnumach-422ab47d25576587600d093297512d8b6cbec890.tar.bz2 gnumach-422ab47d25576587600d093297512d8b6cbec890.zip |
locore: Fix int stack check
TODO: Return kernel_id via lookup table, not apic_id
Message-Id: <20230131093428.756906-5-damien@zamaudio.com>
-rw-r--r-- | i386/i386/cpu_number.h | 7 | ||||
-rw-r--r-- | i386/i386/i386asm.sym | 3 | ||||
-rw-r--r-- | i386/i386/locore.S | 15 |
3 files changed, 19 insertions, 6 deletions
diff --git a/i386/i386/cpu_number.h b/i386/i386/cpu_number.h index 9aef6370..a6dd47d6 100644 --- a/i386/i386/cpu_number.h +++ b/i386/i386/cpu_number.h @@ -35,6 +35,13 @@ /* More-specific code must define cpu_number() and CPU_NUMBER. */ #ifdef __i386__ #define CX(addr, reg) addr(,reg,4) + +#define CPU_NUMBER(reg) \ + movl %cs:lapic, reg ;\ + movl %cs:APIC_ID(reg), reg ;\ + shrl $24, reg ;\ + + #endif #ifdef __x86_64__ #define CX(addr, reg) addr(,reg,8) diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym index 85658b30..8317db6c 100644 --- a/i386/i386/i386asm.sym +++ b/i386/i386/i386asm.sym @@ -45,10 +45,13 @@ #include <i386/gdt.h> #include <i386/ldt.h> #include <i386/mp_desc.h> +#include <i386/apic.h> #include <i386/xen.h> expr CALL_SINGLE_FUNCTION_BASE +offset ApicLocalUnit lu apic_id APIC_ID + offset thread th pcb offset thread th task offset thread th recover diff --git a/i386/i386/locore.S b/i386/i386/locore.S index ff78e80d..5ac238f7 100644 --- a/i386/i386/locore.S +++ b/i386/i386/locore.S @@ -541,13 +541,15 @@ _kret_iret: trap_from_kernel: #if MACH_KDB || MACH_TTD movl %esp,%ebx /* save current stack */ - movl %esp,%edx /* on an interrupt stack? */ - and $(~(KERNEL_STACK_SIZE-1)),%edx - cmpl EXT(int_stack_base),%edx + + CPU_NUMBER(%ecx) + and $(~(INTSTACK_SIZE-1)),%edx + cmpl CX(EXT(int_stack_base),%ecx),%edx je 1f /* OK if so */ - CPU_NUMBER(%edx) /* get CPU number */ + movl %ecx,%edx + cmpl CX(EXT(kernel_stack),%edx),%esp /* already on kernel stack? */ ja 0f @@ -668,9 +670,10 @@ ENTRY(all_intrs) pushl %edx cld /* clear direction flag */ + CPU_NUMBER(%ecx) movl %esp,%edx /* on an interrupt stack? */ - and $(~(KERNEL_STACK_SIZE-1)),%edx - cmpl %ss:EXT(int_stack_base),%edx + and $(~(INTSTACK_SIZE-1)),%edx + cmpl %ss:CX(EXT(int_stack_base),%ecx),%edx je int_from_intstack /* if not: */ pushl %ds /* save segment registers */ |