mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 14:08:21 +00:00
cpu: change _cpu()->thread calls to current_thread() to fix smp race
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
void arch_syscall_entry();
|
||||
static void illisr(isr_t *self, context_t *ctx) {
|
||||
if (ARCH_CONTEXT_ISUSER(ctx)) {
|
||||
signal_signalthread(_cpu()->thread, SIGILL, true);
|
||||
signal_signalthread(current_thread(), SIGILL, true);
|
||||
} else {
|
||||
_panic("Invalid Opcode", ctx);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ static void illisr(isr_t *self, context_t *ctx) {
|
||||
|
||||
static void div0isr(isr_t *self, context_t *ctx) {
|
||||
if (ARCH_CONTEXT_ISUSER(ctx)) {
|
||||
signal_signalthread(_cpu()->thread, SIGFPE, true);
|
||||
signal_signalthread(current_thread(), SIGFPE, true);
|
||||
} else {
|
||||
_panic("Division by 0", ctx);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ static void div0isr(isr_t *self, context_t *ctx) {
|
||||
|
||||
static void simdisr(isr_t *self, context_t *ctx) {
|
||||
if (ARCH_CONTEXT_ISUSER(ctx)) {
|
||||
signal_signalthread(_cpu()->thread, SIGFPE, true);
|
||||
signal_signalthread(current_thread(), SIGFPE, true);
|
||||
} else {
|
||||
_panic("SIMD Exception", ctx);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ static void simdisr(isr_t *self, context_t *ctx) {
|
||||
|
||||
static void x87isr(isr_t *self, context_t *ctx) {
|
||||
if (ARCH_CONTEXT_ISUSER(ctx)) {
|
||||
signal_signalthread(_cpu()->thread, SIGFPE, true);
|
||||
signal_signalthread(current_thread(), SIGFPE, true);
|
||||
} else {
|
||||
_panic("x87 Floating-Point Exception", ctx);
|
||||
}
|
||||
|
||||
@@ -220,11 +220,11 @@ void arch_mmu_tlbipi(isr_t *isr, context_t *context) {
|
||||
|
||||
void arch_mmu_tlbshootdown(void *page) {
|
||||
// scheduler not up yet, or there are no other cpus, nothing to do
|
||||
if (_cpu()->thread == NULL || arch_smp_cpusawake == 1)
|
||||
if (current_thread() == NULL || arch_smp_cpusawake == 1)
|
||||
return;
|
||||
|
||||
if (page >= KERNELSPACE_START ||
|
||||
(_cpu()->thread->proc->runningthreadcount > 1 && page >= USERSPACE_START && page < USERSPACE_END)) {
|
||||
(current_thread()->proc->runningthreadcount > 1 && page >= USERSPACE_START && page < USERSPACE_END)) {
|
||||
// shoot down if page is in the kernel space or in a multithreaded userland application
|
||||
int oldipl = interrupt_raiseipl(IPL_DPC);
|
||||
spinlock_acquire(&shootdownlock);
|
||||
@@ -275,7 +275,7 @@ static volatile struct limine_kernel_address_request kaddrreq = {
|
||||
#define ERROR_FETCH 16
|
||||
|
||||
static void pfisr(isr_t *self, context_t *ctx) {
|
||||
thread_t *thread = _cpu()->thread;
|
||||
thread_t *thread = current_thread();
|
||||
interrupt_set(true);
|
||||
int vmmerror = 0;
|
||||
if (ctx->error & ERROR_PRESENT)
|
||||
@@ -301,7 +301,7 @@ static void pfisr(isr_t *self, context_t *ctx) {
|
||||
}
|
||||
|
||||
static void gpfisr(isr_t *self, context_t *ctx) {
|
||||
thread_t *thread = _cpu()->thread;
|
||||
thread_t *thread = current_thread();
|
||||
if (thread->usercopyctx) {
|
||||
memcpy(ctx, thread->usercopyctx, sizeof(context_t));
|
||||
thread->usercopyctx = NULL;
|
||||
|
||||
@@ -206,7 +206,7 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, ui
|
||||
char argbuff[768];
|
||||
char printbuff[1024];
|
||||
|
||||
thread_t *thread = _cpu()->thread;
|
||||
thread_t *thread = current_thread();
|
||||
proc_t *proc = thread->proc;
|
||||
snprintf(argbuff, 768, syscall < SYSCALL_COUNT ? args[syscall] : "N/A", a1, a2, a3, a4, a5, a6);
|
||||
snprintf(printbuff, 1024, "\e[92msyscall: pid %d tid %d: %s: %s (%lu cached pages, %lu free pages)\n\e[0m", proc->pid, thread->tid, syscall < SYSCALL_COUNT ? name[syscall] : "invalid syscall", argbuff, vmmcache_cachedpages, freepagecount);
|
||||
@@ -219,7 +219,7 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log_return(uint64_t
|
||||
#ifdef SYSCALL_LOGGING
|
||||
char printbuff[1024];
|
||||
|
||||
thread_t *thread = _cpu()->thread;
|
||||
thread_t *thread = current_thread();
|
||||
proc_t *proc = thread->proc;
|
||||
|
||||
snprintf(printbuff, 1024, "\e[94msyscall return: pid %d tid %d: %lu %s (%lu cached pages, %lu free pages)\n\e[0m", proc->pid, thread->tid, ret, strerror(errno), vmmcache_cachedpages, freepagecount);
|
||||
|
||||
Reference in New Issue
Block a user