Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/trap.c
Show All 26 Lines | |||||
#include "opt_ddb.h" | #include "opt_ddb.h" | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/asan.h> | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/ptrace.h> | #include <sys/ptrace.h> | ||||
#include <sys/syscall.h> | #include <sys/syscall.h> | ||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
▲ Show 20 Lines • Show All 393 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
do_el1h_sync(struct thread *td, struct trapframe *frame) | do_el1h_sync(struct thread *td, struct trapframe *frame) | ||||
{ | { | ||||
uint32_t exception; | uint32_t exception; | ||||
uint64_t esr, far; | uint64_t esr, far; | ||||
int dfsc; | int dfsc; | ||||
kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); | |||||
/* Read the esr register to get the exception details */ | /* Read the esr register to get the exception details */ | ||||
esr = frame->tf_esr; | esr = frame->tf_esr; | ||||
exception = ESR_ELx_EXCEPTION(esr); | exception = ESR_ELx_EXCEPTION(esr); | ||||
#ifdef KDTRACE_HOOKS | #ifdef KDTRACE_HOOKS | ||||
if (dtrace_trap_func != NULL && (*dtrace_trap_func)(frame, exception)) | if (dtrace_trap_func != NULL && (*dtrace_trap_func)(frame, exception)) | ||||
return; | return; | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | do_el0_sync(struct thread *td, struct trapframe *frame) | ||||
uint64_t esr, far; | uint64_t esr, far; | ||||
int dfsc; | int dfsc; | ||||
/* Check we have a sane environment when entering from userland */ | /* Check we have a sane environment when entering from userland */ | ||||
KASSERT((uintptr_t)get_pcpu() >= VM_MIN_KERNEL_ADDRESS, | KASSERT((uintptr_t)get_pcpu() >= VM_MIN_KERNEL_ADDRESS, | ||||
("Invalid pcpu address from userland: %p (tpidr %lx)", | ("Invalid pcpu address from userland: %p (tpidr %lx)", | ||||
get_pcpu(), READ_SPECIALREG(tpidr_el1))); | get_pcpu(), READ_SPECIALREG(tpidr_el1))); | ||||
kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); | |||||
esr = frame->tf_esr; | esr = frame->tf_esr; | ||||
exception = ESR_ELx_EXCEPTION(esr); | exception = ESR_ELx_EXCEPTION(esr); | ||||
switch (exception) { | switch (exception) { | ||||
case EXCP_INSN_ABORT_L: | case EXCP_INSN_ABORT_L: | ||||
far = READ_SPECIALREG(far_el1); | far = READ_SPECIALREG(far_el1); | ||||
/* | /* | ||||
* Userspace may be trying to train the branch predictor to | * Userspace may be trying to train the branch predictor to | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* TODO: We will need to handle these later when we support ARMv8.2 RAS. | * TODO: We will need to handle these later when we support ARMv8.2 RAS. | ||||
*/ | */ | ||||
void | void | ||||
do_serror(struct trapframe *frame) | do_serror(struct trapframe *frame) | ||||
{ | { | ||||
uint64_t esr, far; | uint64_t esr, far; | ||||
kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); | |||||
far = READ_SPECIALREG(far_el1); | far = READ_SPECIALREG(far_el1); | ||||
esr = frame->tf_esr; | esr = frame->tf_esr; | ||||
print_registers(frame); | print_registers(frame); | ||||
print_gp_register("far", far); | print_gp_register("far", far); | ||||
printf(" esr: %.8lx\n", esr); | printf(" esr: %.8lx\n", esr); | ||||
panic("Unhandled System Error"); | panic("Unhandled System Error"); | ||||
} | } | ||||
void | void | ||||
unhandled_exception(struct trapframe *frame) | unhandled_exception(struct trapframe *frame) | ||||
{ | { | ||||
uint64_t esr, far; | uint64_t esr, far; | ||||
kasan_mark(frame, sizeof(*frame), sizeof(*frame), 0); | |||||
far = READ_SPECIALREG(far_el1); | far = READ_SPECIALREG(far_el1); | ||||
esr = frame->tf_esr; | esr = frame->tf_esr; | ||||
print_registers(frame); | print_registers(frame); | ||||
print_gp_register("far", far); | print_gp_register("far", far); | ||||
printf(" esr: %.8lx\n", esr); | printf(" esr: %.8lx\n", esr); | ||||
panic("Unhandled exception"); | panic("Unhandled exception"); | ||||
} | } |