From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796262117; b=uR6nPYthPilI84OErLXrKCbNEOcfOBwjILV0IFzqq3WbyhmIQfNpfgMcBiS9NRCPOodZ gF7a57N6z/iJRMzaJkPEoBaB50G4HLxpRIvCiNCBO9gvs18Vy5tJ7XVv5FbS8zzO6xy3i mWZDEgMVYMuAD3qHtEPADGDv0gWuD1YajE9FtSbBX0DzAD6q5qcu6NGQls6WwLJNqOOw0 xprygwMle+njJlh4uHDeBWA2HNoO1xdXN+TJ9MZVS/PZHB66BJUyyIKzThkw6dqf2Pw25 ccKS3F6HIWMeiD2O6gnzaz0xFRcQJujc28x3Ff6I+PQZuU+cFwvM80nD9NpEuil5VlQ== 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=yXer5FyvrziiRGKuJWgiSGrLYK2vtPOaYrmaZMHUsuqvOOKsfAPg0PK3ITdcpXL0+mH6 x6HzyA8tlVPHZIt/DY269nQxpSm/ucgXvgIQ8j70X2245QXZNh0b9VcFxIfxrI7UM9TgL X4xzAoZ3zdBmm6JPOPVAifRPdcRxvZBkuakvELtcPEqcSS9bReQ9CJ62G/cQbULbsBbS0 Yj61Ofy9FGesjkpp9R+OOMpOtAjy1tS2GeWIYLOFx5zFdUFMpAp4xYlrRaKmqi31HDDf+ j7mXe+7MOvZ6lIQ6ZsHBnZaD7B+l+b4AaEBa9haM/jJ49jiT15nnFWGaRTTUXp0TP0w== 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=91.218.175.173 Received: from mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 3831E606A333 for ; Thu, 3 Dec 2026 01:41:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3831E606A333 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: loongarch@lists.linux.dev 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: loongarch@lists.linux.dev 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: loongarch@lists.linux.dev 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