From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E448D3AB496 for ; Mon, 6 Jul 2026 17:29:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783358943; cv=none; b=mFc1Qkts07a7VGvfku8PTGUgTsCiHgrGIu9QmORyj+mCbyJ578SspcitNQbj1+cJRHt/9DtPutXTmR067SoAHJqJ6Nq2DvDXkl0f0hfZHDMQPx+D/5RB1bUxr30rCJ2eCrKcw7cKwuIo/iiu5bTfk7QOKkZYHeIjKz0xY9LHtww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783358943; c=relaxed/simple; bh=a6fvkYTDuu+14XJxPnVus2CzWTlAZzpebRF6dfNrIPY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=IlLIAM8Tqta1GOSU97hPJpjEHVX25hHX1MqfTNPMIJndtbVU+FyYSIKYfyvEZiM3CwTL58tcEJXZnbCKkvErkjO7stx3q83MhEdMnp/9DJSLTJTRNc0TKGehgpqweG0akQLB3ffUu+e8LevI27khM0MmCDD5HLNqeVFQf47muF4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DxJ9VYxL; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DxJ9VYxL" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2cacd69a9c0so27861255ad.1 for ; Mon, 06 Jul 2026 10:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783358941; x=1783963741; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Sc8UWUFIFca5T75Paxs4hgOTZtiZGU1HZksFlaVnRMg=; b=DxJ9VYxLeHYGAdrSxcSwAYV6p+mezUC9PjEa6L9YvzCr3/tk7mMyL0rC76shdGgAoa f/VE0bxRVkyhHId8l4n9Im+n8yVFdQ2Ax8Us6F8WKvPEPs6/4rU0vPFBJeLdyK41t0Lz /cfr5JXmC0goJhqsG2QYjXOYhjGW5u/iU0LO3ms4Fx3gLPOL+K8BE7B4FBhOHMYRxqcX ZQyo8HrixkflLXOoKzslSR3cEK8jI+sUJWa+VsPvFJrheZOBm3yQfDu4ObS5V6j1354N GuEAJDql81ht4LyWtdTgUJzOPUrRnsFuTgiTi275xzLII/LAQaBd+cYTL+i+XY9rKQHH UsWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783358941; x=1783963741; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Sc8UWUFIFca5T75Paxs4hgOTZtiZGU1HZksFlaVnRMg=; b=WcffhOXhW+Bd6Wyj6T4uluKmzjICJB+AGuxoCts085evKP9lwS0pKiJVs6gw3MFPx6 WbPCyVVOBG0J60rOTgicFedKkwfsOoNjMqf1qaIl224m+oNEGGzIEATacUJTW5ODKVYH 9pTBVDvTZiWXJs9d96gXm1D4ZRT53/leG1vN7rJdYI+oSYwtrFxIiqlcbTBphlKinK4c Vu4JpWPOtUDBzEdY+m+sIHbl1j/uFx1+fc0P41Sd8O4+yjYvyEjbdXGgzNq2WP/8R8vl E3+JzcIUY78TT9aBYkI3RftSbY5HiJoGtX+ppbnzh5aMHBxz58x5txJ7Ng1p9FCovN8W AxYQ== X-Forwarded-Encrypted: i=1; AHgh+RoH7obzzD76oL7Kesf4U+84ATdsylJqjnsBBhd/omd5O+Rw6xgVtpEuAr4dnHoWq9skBeYoUdlUqEUpfjc=@vger.kernel.org X-Gm-Message-State: AOJu0YwMSmIEi567osrLG1sTdkCYrKvr7V+li7fddnL1/1ZH72ChJ5BI A671vQ1y1uSZ+dTVcgmOpz86p4IJwJ6ArYKBzCMN8jIf6m2NpE/XSv7R X-Gm-Gg: AfdE7cmJO0CO6FcdJkS2XzBYbM9+4KpY1TGVqaDHRVxHTx6aYj1MHmW7lgfSFVk4a8b 6RjKo9N6Zn/tF0u+N8HCb74TbYlc0cEQ4q/SxDtcCfx/evGP61xtPL9h3IissRoht0ge24O2/mM AlX1qOvUDa069/DZS90uObtGMksz2rXzcOB5V+pUbWVPro0fqbCkwgWmf+UCZ7RKXPPWNgfi5Zi zIPEz3fBIKcEEyBQ0nzw+E0RiQtXzASRjcU7RFiEkLzxQrL+szbFIyIrMPXP2A+s+EW7z6lfQjb TskkNxV6RPL/JJN0jUpxLPiy/4qRg1rv3HmWjBTEL6ap0cKI2DHKgOx8rh5Lei5NVAj2JWClPM3 ioUZpwbGteqabQyZCmp1Y8XN0oQBhcfvucMc6w5tpEa8RjSUqNgthxK1FBXaEiQhXy8vHC3GZQ8 ogWMnbYW+A+isANmlNysextoJ5gALna6InKXQXehqSWTZMRi7JJadFUGhdlTI7PInY7lfDs0k0p /tCrsj99WzJ X-Received: by 2002:a17:902:ec85:b0:2c6:a012:6241 with SMTP id d9443c01a7336-2ccbe3f7d69mr17749295ad.6.1783358941128; Mon, 06 Jul 2026 10:29:01 -0700 (PDT) Received: from visitorckw-work01.c.googlers.com.com (32.237.80.34.bc.googleusercontent.com. [34.80.237.32]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cad6f25e54sm54667005ad.2.2026.07.06.10.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 10:29:00 -0700 (PDT) From: Kuan-Wei Chiu To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, luke.r.nels@gmail.com, xi.wang@gmail.com, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, pulehui@huawei.com Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, alex@ghiti.fr, jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com, marscheng@google.com, bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH bpf-next v3 0/3] riscv, bpf: Add support for signed operations and 32-bit atomics Date: Mon, 6 Jul 2026 17:28:43 +0000 Message-ID: <20260706172846.3876436-1-visitorckw@gmail.com> X-Mailer: git-send-email 2.55.0.rc2.803.g1fd1e6609c-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add support for missing signed operations and 32-bit atomics in the RV32 BPF JIT compiler. The current implementation lacks support for BPF_SDIV, BPF_SMOD, and BPF_MOVSX, ignoring the instruction offset field and treating them as unsigned or zero-extended. Introduce support for these operations by checking the offset field and emitting the corresponding instructions. Additionally, we leverage the mandatory A extension to natively support 32-bit BPF atomics (and, or, xor, xchg) by mapping them directly to amo*.w instructions. BPF_CMPXCHG continues to fall back to the interpreter. As a result, test_bpf.ko now runs with 0 failures, and the total number of successfully JIT'ed test cases increases from 843 to 902. --- Changes in v3: - Pass insn directly to emit_alu_r32(). - Remove the Fixes: tag and update title. - Consolidate size, mode, and off into insn for emit_store_r64(). Changes in v2: - Add missing Fixes tags. - Fix memory ordering by emitting aq=1, rl=1 Kuan-Wei Chiu (3): riscv, bpf: Add support for BPF_SDIV and BPF_SMOD in RV32 JIT riscv, bpf: Add support for BPF_MOVSX in RV32 JIT riscv, bpf: Add 32 bit atomic operations to RV32 JIT arch/riscv/net/bpf_jit_comp32.c | 111 +++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 16 deletions(-) -- 2.55.0.rc2.803.g1fd1e6609c-goog