diff options
| author | Chenghao Duan <duanchenghao@kylinos.cn> | 2025-12-31 15:19:20 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-02-11 13:37:22 +0100 |
| commit | b9d9a221bd14ed4b01d113701976fa376762c544 (patch) | |
| tree | 2e9f4efa2837527845f96b7644e3bc4e3ec1e207 | |
| parent | 046303283d02c9732a778ccdeea433a899c78cbd (diff) | |
| download | linux-b9d9a221bd14ed4b01d113701976fa376762c544.tar.gz linux-b9d9a221bd14ed4b01d113701976fa376762c544.tar.bz2 linux-b9d9a221bd14ed4b01d113701976fa376762c544.zip | |
LoongArch: Enable exception fixup for specific ADE subcode
[ Upstream commit 9bdc1ab5e4ce6f066119018d8f69631a46f9c5a0 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | arch/loongarch/kernel/traps.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c index 12c726482d15..cad1e08ca3fb 100644 --- a/arch/loongarch/kernel/traps.c +++ b/arch/loongarch/kernel/traps.c @@ -361,10 +361,15 @@ out: asmlinkage void noinstr do_ade(struct pt_regs *regs) { irqentry_state_t state = irqentry_enter(regs); + unsigned int esubcode = FIELD_GET(CSR_ESTAT_ESUBCODE, regs->csr_estat); + + if ((esubcode == EXSUBCODE_ADEM) && fixup_exception(regs)) + goto out; die_if_kernel("Kernel ade access", regs); force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)regs->csr_badvaddr); +out: irqentry_exit(regs, state); } |
