From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 580E435CB6B; Mon, 9 Feb 2026 14:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770647303; cv=none; b=PzX0lWqoC4oM7h4YTAxwAUhKDAASIfpEDJ3c9JWiTmUmR4bE2WPv9qfB1SVHDyCQieYtKW+bKSsSDPTf900fSHQTA4/KHmE6tyMzOyhB/2mj55jxjY+4Ggy4kHBzbw3RK+syakSTgLON0PoqcfOjiIaYvFYhvEzPF19cpxNilzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770647303; c=relaxed/simple; bh=ZgDGoU+pecc5Wu7d06sSyzZx5oxmllz7B7ujO0A1Hy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eKYPE/mkerUrURUwJfR9p64MN3QLLhDW64H7D+mURyojwnNEno5bEbmmagS3tTk8vqGjE8cUghiISLXxL9/cjpHbaZOgQxa5F0SrE3EZv70cFQzWJwSTTZ2cYNBzHtkbtlf5ZlBF98hRrP7iqQDhgWdQvl02iz/4zVsVLwvyD9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=B+VCyuVp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="B+VCyuVp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCE03C116C6; Mon, 9 Feb 2026 14:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770647303; bh=ZgDGoU+pecc5Wu7d06sSyzZx5oxmllz7B7ujO0A1Hy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B+VCyuVpzpprvDL0tNVtb2/0V3H3A1dsA4NL25zatrr81vTIno6heA31+n6eNi1xG Qmfs0dXSE8+3YgofSslSLKrdN0nPPiEwV91oB0MtqHnxgVSm+QDWx9fcEQY9ZP1Qn1 ZjgdOPTk7EVrlhxrrVQW3rQ9wIJrO8Nprq/P5GIM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chenghao Duan , Huacai Chen , Sasha Levin Subject: [PATCH 6.18 060/175] LoongArch: Enable exception fixup for specific ADE subcode Date: Mon, 9 Feb 2026 15:22:13 +0100 Message-ID: <20260209142322.621867220@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142320.474120190@linuxfoundation.org> References: <20260209142320.474120190@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chenghao Duan [ 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 Signed-off-by: Huacai Chen Signed-off-by: Sasha Levin --- arch/loongarch/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c index da5926fead4af..8e51ce004572c 100644 --- a/arch/loongarch/kernel/traps.c +++ b/arch/loongarch/kernel/traps.c @@ -535,10 +535,15 @@ asmlinkage void noinstr do_fpe(struct pt_regs *regs, unsigned long fcsr) 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); } -- 2.51.0