mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
cpu: dont access cpu local storage using rdmsr
This commit is contained in:
@@ -130,7 +130,8 @@ arch_syscall_entry:
|
||||
; because it's still using the user stack
|
||||
mov cr2, rax
|
||||
; rax can be used just fine now
|
||||
mov rax, [gs:0x0] ; thread pointer
|
||||
mov rax, [gs:0x0] ; cpu pointer
|
||||
mov rax, [rax] ; thread pointer
|
||||
mov rax, [rax] ; kernel stack top
|
||||
xchg rsp, rax ; switch stack pointers
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ typedef struct cpu_t {
|
||||
void *schedulerstack;
|
||||
isr_t *isrqueue;
|
||||
dpc_t *dpcqueue;
|
||||
struct cpu_t *self;
|
||||
} cpu_t;
|
||||
|
||||
#define CPU_HALT() asm volatile("hlt")
|
||||
@@ -53,11 +54,14 @@ static inline uint16_t be_to_cpu_w(uint16_t w) {
|
||||
}
|
||||
|
||||
static inline cpu_t *_cpu() {
|
||||
return (cpu_t *)rdmsr(MSR_GSBASE);
|
||||
volatile cpu_t *cpu;
|
||||
asm volatile ("mov %%gs:0, %%rax" : "=a"(cpu));
|
||||
return cpu->self;
|
||||
}
|
||||
|
||||
static inline void cpu_set(cpu_t *ptr) {
|
||||
wrmsr(MSR_GSBASE, (uint64_t)ptr);
|
||||
ptr->self = ptr;
|
||||
wrmsr(MSR_GSBASE, (uint64_t)&ptr->self);
|
||||
}
|
||||
|
||||
void cpu_initstate();
|
||||
|
||||
Reference in New Issue
Block a user