From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.90 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796262117; b=Bg0973s0jrz7jNlhv6xuVNCrfEoVmdEoOwt8/rnbZ5OR3sY0i0pY1CwXVQFuOJX9/67L kjlZU6xoFHSR3dNcbRPQAY4nq9+5aOmZ/NV/pTj1h7a/nPCNT8/yYOzAZgjEG2P+nPO7q TW1moyGBxEpEz+pQJiGvTZ+IZrbB6AtMFBj6cRcDKYFL5lyn5OB8rKBXYCS170t/AD7Md ahoCxIvb9WmeD0+JpDNfFNFYJr+vtivSAuKWYj8p2s+Lvkn8+avQArhTeJvWxYNPoo+up N5PeC3JVWvh4pljNQv5Qnt2ypaYOQ8daGJx7W/lUbI03ofIgQOdGjsG9HVdsMWf+8lA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796262117; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=MRpw0TlJdr6fubQmJVDereROd9uF/mjbjZayf406qLE=; b=T1e6ew0dB/CDbZDpkIC6YYQpfYT55CXHkynqBId5gbGWZSjNxi+66CnOXPicrowsIL2J T8Ey0FyNKUDkYaBiPPFYWBs2v96mzhYWrBxYXKNY2tApr/sKbY56KmMSpKbwNSIWM4Tdv sUTcMlqpYzYK1iuLXWqM4NIXuaAjWShUWe+eoROefYt5u1PAU0lmeAiolLYpLMEmMdevf iVlAZKFY9e6mILNHQVL3+VbGBhCuYnfPbnESDAaqxc6ua55pPGeaQpcQFFMxjNZb3fajU 0d5GD461ib4VDSnnr7bY/wiX5B2EMki5jtRWi+RDBgkKo4M+XJs07ti1HSnOrg+Ndxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=U7A0QFm0; arc=none smtp.remote-ip=95.215.58.90 Received: from mta1.migadu.com (out-90.mta1.migadu.com [95.215.58.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACF21606A32D for ; Thu, 3 Dec 2026 01:41:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ACF21606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=U7A0QFm0 X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=cVWuZQNVIBnD+LRak2dljK+D7PSJonynZ3N86Tmb+gc=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796262114; v=1; x=1796866914; b=U7A0QFm0SSr6Z17otSKUbIFGIGWrVYF7nyWGuDMtpOnmYZQrk0XMzTtPMKJywdtOVUSbRfxA JUmyO40Cuw1e5SyKKqmqCXxthdH0N6swRLCSNZf0n2nhIxrkbiUvRNnskGlRL1qTrGBVZOueQCp SqJ/32d+TNjtXSCXEq5GtXxU= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 3245349a441b6b35; Thu, 03 Dec 2026 01:41:54 +0000 X-Mizu-Trace-ID: 3245349a441b6b35 X-Migadu-Flow: FLOW_OUT From: George Guo To: chenhuacai@kernel.org, yangtiezhu@loongson.cn Cc: sashiko-reviews@lists.linux.dev, hengqi.chen@gmail.com, loongarch@lists.linux.dev, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 6/6] LoongArch: BPF: Add support for arena atomics Date: Wed, 2 Dec 2026 17:41:39 -0800 Message-ID: <20261203014139.7077-1-dongtai.guo@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On 2026/12/1 10:11, sashiko-bot@kernel.org wrote: > Can an unaligned BPF_PROBE_ATOMIC read-modify-write access trigger a kernel > Oops in do_ale() instead of recovering through ex_handler_bpf()? > > check_ptr_alignment() returns 0 unconditionally for PTR_TO_ARENA, so the > verifier allows unaligned arena addresses to reach the atomic instructions > emitted by emit_atomic_rmw(). On LoongArch, AM* atomic instructions require > natural alignment and raise EXCCODE_ALE when unaligned. > > However, neither do_ale() nor emulate_load_store_insn() consults > fixup_exception(regs) on kernel alignment faults: Yes, this is a real issue. I reproduced it with an atomic one byte off an aligned arena address, the kernel panics at the first amadd_db.w: Kernel ale access[#1]: ... ERA: ffff8000020136f4 bpf_prog_53d40cccca5faaf3_unaligned+0x10c/0x284 ESTAT: 00090000 [ALE] (IS= ECode=9 EsubCode=0) BADV: ffff80008d600001 ... Kernel panic - not syncing: Fatal exception The exception table entry added by this patch is fine, the problem is that the trap code never looks it up for ALE. This is fixed by Tiezhu's patch "LoongArch: Call fixup_exception() for unaligned accesses", which calls fixup_exception() on the failure paths of do_ale() and emulate_load_store_insn(): https://lore.kernel.org/loongarch/20261203012908.27076-1-yangtiezhu@loongson.cn/ With that patch, a new arena_atomics/unaligned subtest (32-bit fetch add and fetch or, 64-bit xchg and cmpxchg, all one byte off) passed on Loongson-3C6000, with both CONFIG_ARCH_STRICT_ALIGN=y and CONFIG_ARCH_STRICT_ALIGN=n: $ sudo ./test_progs -a arena_atomics/unaligned #3/10 arena_atomics/unaligned:OK #3 arena_atomics:OK Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED The test is archived in the v1 thread of that patch: https://lore.kernel.org/loongarch/20261202134056.40836-1-dongtai.guo@linux.dev/ I will send it formally after the LoongArch BPF JIT support is merged. Thanks, George