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 BEEB6276028; Mon, 9 Feb 2026 14:36:59 +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=1770647819; cv=none; b=gHzCkT9MkqdKTHaPFvuWce4f2Y7ZeHvbWtNGmE+f3BufFD1oPO/DijvxhmeygSP9X5fb7rM36/pNs1IMcxVrj27bqmDTzQ0g9kRvpzUFWoY8xIARrL6zaHGHe3FCrM+Gl02xMiD+PPDZpaaXsIPgpdvp4aB71hZUyQhnjpDfl2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770647819; c=relaxed/simple; bh=+FabBQdsbv5V4VwS1d0R9YrmMp1WynC0W0kvEN1KqpQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gCVdejJdbEqLZVAJvcX6lzT+spHDRTEnD2NMDNYkO4hED7hCTDYRo41s6lG885aDtSkWjy8YD0kRFbaYCGyHFZgAkkTd1wgOPrYwi0DvDFlPc8084Lxmitj7yM69LRn6KGxui1HPfx8lRePYxEMU/alqePcnVv3hSmkUjDzIgV0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mFSp/xRI; 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="mFSp/xRI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06AF1C116C6; Mon, 9 Feb 2026 14:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770647819; bh=+FabBQdsbv5V4VwS1d0R9YrmMp1WynC0W0kvEN1KqpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mFSp/xRIGyMUhyLnwtWir19i2F9/Hr0Gx1yCMasemje058kMNcW/rJltl4KkcqucV imAU3L3zRQKNoWpJUrzL1vwjH0TRUCvQUygsrdGsKdXHNync18nVy5KL6+Hf8pPYm9 3TMSd+TQAWTJjqVx7TVtk6XQNUF8jIsyjpnw1hfU= 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.12 038/113] LoongArch: Enable exception fixup for specific ADE subcode Date: Mon, 9 Feb 2026 15:23:07 +0100 Message-ID: <20260209142311.578092645@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142310.204833231@linuxfoundation.org> References: <20260209142310.204833231@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.12-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 d827ed3178b02..40c162fb645a3 100644 --- a/arch/loongarch/kernel/traps.c +++ b/arch/loongarch/kernel/traps.c @@ -534,10 +534,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