From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 AF41A3BED18 for ; Wed, 29 Apr 2026 12:35:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777466130; cv=none; b=sITPYM3KW+7KMUJSDU6R0Dtf+oilFPdXH1WTq0K12XR8Ex0z3+SdCTgMl6xVfkZcq5e/86uMbE911TEoHTgYzrGtsAVO4B7RE86T+g6/2dCGAfB4YE021+H+CkHGPXjJbWiW/hXnzthZGLDgn7z9EHu0kC6M1Z/MIhPEFr8HQL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777466130; c=relaxed/simple; bh=13+JLLoZ1Hg0KlvJTzgFeoD3QrJ58AaLVxqe7Odzv4w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=p/06ufshxSAxzxFjUTnCZiZIR0LRsaxGXVkcb4ttzzwfUoMMPNvdCnmAhwwLEZyM0eiEeNn6f42YdTLOt0dBwgQbfpPZ+jK6IKzmdDTxnWMo4I8hiC4vhPGuzkpUt7kZBJ9TYfLXFaR5LQbxtD939LhDP7q9M4jOgbR2Pv++WVg= 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=mQLFwWhI; arc=none smtp.client-ip=209.85.216.49 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="mQLFwWhI" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-35e576110adso591902a91.0 for ; Wed, 29 Apr 2026 05:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777466129; x=1778070929; 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; bh=JgQqfgYWSA68LM6eambu1VWNYKMusGRf22zT6tQJHig=; b=mQLFwWhIMTifSFV2/+ImVdTRdw5/BlDkZ86Eoy7R7uKd7oEAHwmGyIcIqPtJcjd5Tr eHygO6wcFCEb27LN0vbXlJ16PHINcdU7YNYmUFE8BzOLi9ZwOsxu6XcqqESxrkTxH5Ua hfQasBvRkpJKm9r6iWFcX84A35diR/OAihA6UabGg94f0+ITqq6EGvyIpKiic+BdST3x XSOju40n7J0PR/x11Isx6wKGOXIVunrx/8Yl3+253kfXFdM2Ik1ygXhpf93FCPGxK5lM sxV/QgwCGrRZ3YMKaZ4Ul3imWcNy6eXkZqEyMWx9Br2aSoy8mwYoIF5Qg12+3wTPNq04 BQfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777466129; x=1778070929; 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; bh=JgQqfgYWSA68LM6eambu1VWNYKMusGRf22zT6tQJHig=; b=KJpcVkifrKBcSJVhIYAgntm7xj/+ABBX5Zjm+fpD16KZx2YNVe3rSTHXRcRFAIQa0X JAjRCfo6I80gCdN9sa3gycNfubsoi0xZkOgcL2J9S4No2SlcY7Ynbzlocv7pTb6AkL6s 23IZFUqiyhgeRiPnX26aIeLj+hcdcx/cps3K/liIfKv7sPuI9brTOd3yNlkulzYYAWUb 9JtqG5sKuQ1e/TF/RojC2pTC41+V7In65tnx5xt/RJWasJVCdwKmmwjZ6m/Khle9zV29 b5iE02siQvyA/KLLEvXlCPGcZULrUNWRHO7ruqnYm80NxIVdhHXQiVH/muuWLyfRr8Tt Zksw== X-Forwarded-Encrypted: i=1; AFNElJ9PbNrFh2l9o/YJczNqPXQpwjo222a1h4FP2Hfk5npZarLabfxj44N2CKOERpHDtsjEhn8hr0LPaw3O6Qw=@vger.kernel.org X-Gm-Message-State: AOJu0YzZ32qFBqHQdIDicT62vAyxEtCGS7S8jZ9dyOG2CMihA4aQ7VIe Z80tudsTXAPMwSGUDvg4wmpHctv05In76uNotaqOIZnDVoipgVa+VpRK X-Gm-Gg: AeBDietki7KXdX1wOSim3G6NQHvI1U9mDupvTKRmeJf9vEWvphEM2Opi5iJ5YKufsfA b5hLo6CDlm1MF5u1/0ykJvvmaHM6Z6ZpzbBIyIYd1dHc0rPAYJbPr1lGku1qL9H3lScrwxvxfXE QwqomImZCtlDXVY8FdS6H9UmNsymDuyk2klqMBNKGGFl3TDJhczVjXvbev9XcQLxMNCKhGMpLV9 tbE9VPjnFUC2mHfL49X52G/WdLFLKisL09hRQR8NzmhbuxDzV1QB/JtBh2bEd3mQtjAK4cjnxzr bGG6EOwuPGriE020UkkbBWUH9sfLONGPlVXhBzlRf5riccjp5uwmEAXhVDboIi9lvaTMAPsQf9o /P8Tt6g1xiiNbcy3kmv/Wx8jWjqBoSusAnHnUh62Rf8KTpsGAfaSUv1ClDu64LcNFQGejsfftwb MAMOnMCvl6pBR4ha8nZDWWdNVvG/5zFJQnezOosmHpsNNN9sGf07lKLFJDl6g+CoImkFs/RjLDg 3dhDcx+LHnRcdg3Q8HMVIaoE0VC/YrY3n1vgsSuZH8D X-Received: by 2002:a17:90b:2711:b0:35f:bc9f:e1b6 with SMTP id 98e67ed59e1d1-364a247db58mr2292751a91.1.1777466128927; Wed, 29 Apr 2026 05:35:28 -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 98e67ed59e1d1-364a419c9a6sm2261855a91.7.2026.04.29.05.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 05:35:28 -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 Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, 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 0/3] riscv, bpf: Fix signed operations and add 32 bit atomics Date: Wed, 29 Apr 2026 12:35:10 +0000 Message-ID: <20260429123513.3477780-1-visitorckw@gmail.com> X-Mailer: git-send-email 2.54.0.545.g6539524ca2-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 Fix miscompiled signed operations and expands 32 bit atomic support in the RV32 BPF JIT. The current implementation ignores the instruction offset field used by the bpf instruction set to specify BPF_SDIV/BPF_SMOD and BPF_MOVSX. This causes these operations to be treated as unsigned or zero-extended, leading to test_bpf failures. Fix this by checking the offset and emitting the correct 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. Kuan-Wei Chiu (3): riscv, bpf: Fix support for BPF_SDIV and BPF_SMOD in RV32 JIT riscv, bpf: Fix support for BPF_MOVSX in RV32 JIT riscv, bpf: Add 32 bit atomic operations to RV32 JIT arch/riscv/net/bpf_jit_comp32.c | 98 +++++++++++++++++++++++++++------ 1 file changed, 82 insertions(+), 16 deletions(-) -- 2.54.0.545.g6539524ca2-goog