Skip to content

Commit

Permalink
x86_64: fix for context switch in segment registers
Browse files Browse the repository at this point in the history
jewelcodes committed Jan 17, 2025
1 parent 4a931ee commit 8528ab4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/platform/x86_64/sched/context.c
Original file line number Diff line number Diff line change
@@ -95,7 +95,13 @@ void *platformCreateContext(void *ptr, int level, uintptr_t entry, uintptr_t arg
void platformSwitchContext(Thread *t) {
KernelCPUInfo *kinfo = getKernelCPUInfo();
ThreadContext *ctx = (ThreadContext *)t->context;
ctx->regs.rflags |= 0x202; // interrupts can never be switched off outside of the kernel
//

if((ctx->regs.cs & 0x03) || (ctx->regs.ss & 0x03)) {
ctx->regs.cs = (GDT_USER_CODE << 3) | 3;
ctx->regs.ss = (GDT_USER_DATA << 3) | 3;
ctx->regs.rflags |= 0x202;
}

// modify the TSS with the current thread's I/O permissions if necessary
Thread *old = kinfo->thread;

0 comments on commit 8528ab4

Please sign in to comment.