Skip to content

Commit 9bdc1ab

Browse files
Chenghao Duanchenhuacai
authored andcommitted
LoongArch: Enable exception fixup for specific ADE subcode
This patch allows the LoongArch BPF JIT to handle recoverable memory access errors generated by BPF_PROBE_MEM* instructions. When a BPF program performs memory access operations, the instructions it executes may trigger ADEM exceptions. The kernel’s built-in BPF exception table mechanism (EX_TYPE_BPF) will generate corresponding exception fixup entries in the JIT compilation phase; however, the architecture-specific trap handling function needs to proactively call the common fixup routine to achieve exception recovery. do_ade(): fix EX_TYPE_BPF memory access exceptions for BPF programs, ensure safe execution. Relevant test cases: illegal address access tests in module_attach and subprogs_extable of selftests/bpf. Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 4cd641a commit 9bdc1ab

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

arch/loongarch/kernel/traps.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,15 @@ asmlinkage void noinstr do_fpe(struct pt_regs *regs, unsigned long fcsr)
535535
asmlinkage void noinstr do_ade(struct pt_regs *regs)
536536
{
537537
irqentry_state_t state = irqentry_enter(regs);
538+
unsigned int esubcode = FIELD_GET(CSR_ESTAT_ESUBCODE, regs->csr_estat);
539+
540+
if ((esubcode == EXSUBCODE_ADEM) && fixup_exception(regs))
541+
goto out;
538542

539543
die_if_kernel("Kernel ade access", regs);
540544
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)regs->csr_badvaddr);
541545

546+
out:
542547
irqentry_exit(regs, state);
543548
}
544549

0 commit comments

Comments
 (0)