cpu: change _cpu()->thread calls to current_thread() to fix smp race

This commit is contained in:
Matheus
2024-09-15 17:47:26 -03:00
parent d1c0f2a5fd
commit e058d62261
65 changed files with 196 additions and 190 deletions
+7 -1
View File
@@ -56,12 +56,18 @@ static inline uint16_t be_to_cpu_w(uint16_t w) {
cpu_t *_bsp(void);
static inline cpu_t *_cpu() {
static inline cpu_t *_cpu(void) {
cpu_t *cpu;
asm volatile ("mov %%gs:8, %%rax" : "=a"(cpu) : : "memory");
return cpu;
}
static inline thread_t *current_thread(void) {
thread_t *thread;
asm volatile ("mov %%gs:0, %%rax" : "=a"(thread) : : "memory");
return thread;
}
static inline void cpu_set(cpu_t *ptr) {
ptr->self = ptr;
wrmsr(MSR_GSBASE, (uint64_t)ptr);