Skip to content

Commit

Permalink
x86_64: remove unused ability to return a different interrupt context
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Jan 17, 2024
1 parent 4b2932a commit 7418447
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
31 changes: 10 additions & 21 deletions kernel/arch/x86_64/idt.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,14 @@ static void panic(const char * desc, struct regs * r, uintptr_t faulting_address
* @param r Interrupt register context
* @return Register context, which should be unmodified.
*/
static struct regs * _debug_int(struct regs * r) {
static void _debug_int(struct regs * r) {
/* Unset the debug flag */
r->rflags &= ~(1 << 8);

/* If the current process was debugging, trigger a SINGLESTEP event. */
if (this_core->current_process->flags & PROC_FLAG_TRACE_SIGNALS) {
ptrace_signal(SIGTRAP, PTRACE_EVENT_SINGLESTEP);
}

/* Return from interrupt */
return r;
}

/**
Expand Down Expand Up @@ -538,11 +535,10 @@ static void _page_fault(struct regs * r) {
* @param r Interrupt register context
* @return Register state after resume from task task switch.
*/
static struct regs * _local_timer(struct regs * r) {
static void _local_timer(struct regs * r) {
extern void arch_update_clock(void);
arch_update_clock();
switch_task(1);
return r;
}

/**
Expand Down Expand Up @@ -581,10 +577,10 @@ static void _handle_irq(struct regs * r, int irq) {
#define EXC(i,n) case i: _exception(r, n); break;
#define IRQ(i) case i: _handle_irq(r,i-32); break;

struct regs * isr_handler_inner(struct regs * r) {
void isr_handler_inner(struct regs * r) {
switch (r->int_no) {
EXC(0,"divide-by-zero");
case 1: return _debug_int(r);
case 1: _debug_int(r); return;
/* NMI doesn't reach here, we use it as a panic signal. */
EXC(3,"breakpoint"); /* TODO: This should map to a ptrace event */
EXC(4,"overflow");
Expand Down Expand Up @@ -630,8 +626,8 @@ struct regs * isr_handler_inner(struct regs * r) {
IRQ(47);

/* Local interrupts that make it here. */
case 123: return _local_timer(r);
case 127: syscall_handler(r); return r;
case 123: _local_timer(r); return;
case 127: syscall_handler(r); return;

/* Other interrupts that don't make it here:
* 124: TLB shootdown, we just reload CR3 in the handler.
Expand All @@ -648,35 +644,28 @@ struct regs * isr_handler_inner(struct regs * r) {
* to run that was awoken by the interrupt. */
switch_next();
}

return r;
}

struct regs * isr_handler(struct regs * r) {
void isr_handler(struct regs * r) {
int from_userspace = r->cs != 0x08;

if (from_userspace && this_core->current_process) {
this_core->current_process->time_switch = arch_perf_timer();
}

struct regs * out = isr_handler_inner(r);
isr_handler_inner(r);

if (from_userspace && this_core->current_process) {
process_check_signals(out);
process_check_signals(r);
update_process_times_on_exit();
}

return out;

}

struct regs * syscall_centry(struct regs * r) {
void syscall_centry(struct regs * r) {
this_core->current_process->time_switch = arch_perf_timer();

syscall_handler(r);

process_check_signals(r);
update_process_times_on_exit();

return r;
}
2 changes: 0 additions & 2 deletions kernel/arch/x86_64/irq.S
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ isr_common:
/* Call interrupt handler */
mov %rsp, %rdi
call isr_handler
mov %rax, %rsp

/* Restore all registers */
pop %r15
Expand Down Expand Up @@ -301,7 +300,6 @@ syscall_entry:

mov %rsp, %rdi
call syscall_centry
mov %rax, %rsp

pop %r15
pop %r14
Expand Down

0 comments on commit 7418447

Please sign in to comment.