62 "#DB: Debug Exception",
66 "#BR: BOUND Range Exceeded",
67 "#UD: Invalid Opcode (Undefined Opcode)",
68 "#NM: Device Not Available (No Math Coprocessor)",
70 "Coprocessor Segment Overrun (reserved)",
72 "#NP: Segment Not Present",
73 "#SS: Stack-Segment Fault",
74 "#GP: General Protection",
77 "#MF: x87 FPU Floating-Point Error (Math Fault)",
78 "#AC: Alignment Check",
80 "#XM: SIMD Floating-Point Exception",
81 "#VE: Virtualization Exception",
126 extern uintptr_t x86_uaccess_fixups[], x86_uaccess_fixups_end[];
133 for (
uintptr_t *f = x86_uaccess_fixups; f < x86_uaccess_fixups_end; f += 2) {
162 if ((
regs->
cs & 3) == 3) {
177 printk(
"kernel: page fault at %p%s\n", (
void *) addr,
178 addr <
USER_STACK ?
" (user memory, outside copyin/copyout)" :
"");
180 panic(
"page fault in the kernel");
191 panic(
"syscall without a current thread");
218 const char *msg =
int_msg[vec];
219 printk(
"Recieved interrupt %d [err=%d]: %s\n", vec, (
int)
regs->
err, msg);
225 panic(
"Kernel Exception");
227 printk(
"Unhandled interrupt %d\n", vec);
228 panic(
"Kernel Exception");
void arch_syscall(struct aarch64_regs *r)
static uintptr_t read_cr2(void)
void x86_return_to_user(struct x86_regs *r, int syscall)
Delivers the current process's pending signals on the way back to user mode: stops and default action...
static void x86_dump_registers(struct x86_regs *regs)
int arch_mm_page_fault(vaddr_t vaddr, int err)
Handles a page fault: turns the CPU's error code into the kernel's PF_* flags, and calls mm_page_faul...
void x86_fpu_trap(void)
Handles #NM, the current thread's first FPU or SSE instruction since it was switched in: it saves the...
void x86_idt_gate_user_set(uint32_t id, uintptr_t offset)
Sets an interrupt gate that user mode may raise with int too: the system call vector.
void x86_idt_gate_set(uint32_t id, uintptr_t offset)
Sets an interrupt gate that only the hardware (and the kernel) can raise: an exception or a device in...
static const char * int_msg[32]
void x86_isr_setup(void)
Sets the IDT's gates for the exceptions and the system call vector.
void __x86_isr(struct x86_regs *regs)
Handles an exception or a system call, which the stubs in cpu.S call.
static const int int_sig[32]
static void isr_dispatch(struct x86_regs *regs)
Handles an exception or a system call, by its vector.
void kernel_leave(int took)
Lets go of the kernel lock on leaving the kernel, if kernel_enter() took it.
int kernel_enter(void)
Takes the kernel lock on entering the kernel, unless this CPU holds it already (an exception inside t...
int printk(const char *fmt,...)
Writes a kernel message, to the message buffer and the consoles.
void sched_thread_killed(void)
Ends the current thread, which was killed while it ran on this CPU (thread->killed).
void signal_force(struct proc *proc, int signal)
Sends a signal that can't be blocked or ignored, such as the SIGSEGV of a fault: if the process block...
The registers an interrupt or exception saved, on the kernel stack, as cpu.S's stubs push them: the g...
A thread's x86 state: its kernel stack, and where it resumes.
static int uaccess_fixup(struct aarch64_regs *r)
Handles a fault in a copy from or to user memory (cpu/uaccess.S): the copy goes on at its fixup,...