Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/trap.c
Show First 20 Lines • Show All 346 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
td->td_frame = oframe; | td->td_frame = oframe; | ||||
} | } | ||||
void | void | ||||
do_el0_sync(struct thread *td, struct trapframe *frame) | do_el0_sync(struct thread *td, struct trapframe *frame) | ||||
{ | { | ||||
pcpu_bp_harden bp_harden; | |||||
uint32_t exception; | uint32_t exception; | ||||
uint64_t esr, far; | uint64_t esr, far; | ||||
/* 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))); | ||||
esr = frame->tf_esr; | esr = frame->tf_esr; | ||||
exception = ESR_ELx_EXCEPTION(esr); | exception = ESR_ELx_EXCEPTION(esr); | ||||
switch (exception) { | switch (exception) { | ||||
case EXCP_UNKNOWN: | |||||
case EXCP_INSN_ABORT_L: | case EXCP_INSN_ABORT_L: | ||||
far = READ_SPECIALREG(far_el1); | |||||
/* | |||||
* Userspace may be trying to train the branch predictor to | |||||
* attack the kernel. If we are on a CPU affected by this | |||||
* call the handler to clear the branch predictor state. | |||||
*/ | |||||
if (far > VM_MAXUSER_ADDRESS) { | |||||
bp_harden = PCPU_GET(bp_harden); | |||||
if (bp_harden != NULL) | |||||
bp_harden(); | |||||
} | |||||
break; | |||||
case EXCP_UNKNOWN: | |||||
case EXCP_DATA_ABORT_L: | case EXCP_DATA_ABORT_L: | ||||
case EXCP_DATA_ABORT: | case EXCP_DATA_ABORT: | ||||
far = READ_SPECIALREG(far_el1); | far = READ_SPECIALREG(far_el1); | ||||
break; | |||||
} | } | ||||
intr_enable(); | intr_enable(); | ||||
CTR4(KTR_TRAP, | CTR4(KTR_TRAP, | ||||
"do_el0_sync: curthread: %p, esr %lx, elr: %lx, frame: %p", td, esr, | "do_el0_sync: curthread: %p, esr %lx, elr: %lx, frame: %p", td, esr, | ||||
frame->tf_elr, frame); | frame->tf_elr, frame); | ||||
switch(exception) { | switch(exception) { | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |