mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +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
|
; because it's still using the user stack
|
||||||
mov cr2, rax
|
mov cr2, rax
|
||||||
; rax can be used just fine now
|
; 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
|
mov rax, [rax] ; kernel stack top
|
||||||
xchg rsp, rax ; switch stack pointers
|
xchg rsp, rax ; switch stack pointers
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ typedef struct cpu_t {
|
|||||||
void *schedulerstack;
|
void *schedulerstack;
|
||||||
isr_t *isrqueue;
|
isr_t *isrqueue;
|
||||||
dpc_t *dpcqueue;
|
dpc_t *dpcqueue;
|
||||||
|
struct cpu_t *self;
|
||||||
} cpu_t;
|
} cpu_t;
|
||||||
|
|
||||||
#define CPU_HALT() asm volatile("hlt")
|
#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() {
|
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) {
|
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();
|
void cpu_initstate();
|
||||||
|
|||||||
Reference in New Issue
Block a user