From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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 AF2FC45519E for ; Wed, 29 Jul 2026 16:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785342591; cv=none; b=iCzSyGKQRiZkwWUB88i0f//cpD2Y1K5/ofUGKZ+atWUOM68ALSUH52kICLhOfFqJkHm1a2IpXPPFVTy6C9NjSdpXnFEENK+eOxRnrxIwM2RU8GfZo/KW2VJ0kgqwGF0f2/ZYD2DlW3RmqupYjl7ENqEOr1mGk4Fn5UnL00pWlEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785342591; c=relaxed/simple; bh=R3lUFwXzA6Utc8Qmizb9zVXH9qJGnpDmVVKh5fC1sUc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=OLGmnghiGX2b26pcCts2/wr/yRUvKMn6MvP9JaeZZgoUflGH6hL57uCxEXXRX/SYM3V0jt4mCBIp0/P0bMBPmcqerkv3PIvyvjb2Ph8HEsYi4z7I6DRiK63FtSUCXwgxgFpsuawuo7wb1JiHKwvRPJYPhC6MwjNtoiufa4ZGF8Q= 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=ZtgYFZ2e; arc=none smtp.client-ip=209.85.222.170 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="ZtgYFZ2e" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-930fad20240so64313585a.0 for ; Wed, 29 Jul 2026 09:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785342585; x=1785947385; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YaMgBKE4IT7GHc8dKZ/bu4hutKGY9j/cGc76tkbN8yg=; b=ZtgYFZ2eWkhuGGMDXhroyuZQI8hwTLcYaa8NSDzBk/kmSztyCwiu717evu5D7+0BH5 WT5zfhitoDa8VfsNrqEF0E8zuE9oNVkx2wQGOZ3rob8i51GIrbxBxXUiNAWIUFaFSZp1 ozjNYHCL8wYdr23vxXnzodUkgHWXs4TDYga8YQdxQVXx5kWWW01KJqmP7koxHODzlmw9 26uWTsCMg4lhoIEz4INiu/HFFNb82WQDtz0HhJD+/b5OsRQaBLbFiyKJ3n/UUps1Knzl B5G9nCJtS8kb0j2jLO1Rg83B9pcT69DSeAomPb031V3oOhzEHwS0ejS+4kEpsxnD4LPB PhTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785342585; x=1785947385; h=content-transfer-encoding:content-type: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=YaMgBKE4IT7GHc8dKZ/bu4hutKGY9j/cGc76tkbN8yg=; b=NBhBBApBe2JGcZ8NkRAe2QmdE9CK9TQV53xccXTGg5xFme1kNZ3l41kIlNfJpGewiI jUjNiZuJf/5/LzlC/pHRsjEfoh1i+3BAsxSZHsaLhmI2aty7ONI10KKjhtzeWuAaEwQe 76VAbAd25DWEuNAKNeyy8vYU/P2y0EjXBfmSBJtHMHCUSHeEIN4tqN94Of3JMasIEVZa BnFswDhOdg7Q6k0eqqPb0TRU+sYhdVoAYfw4FW6pImnKoPOxz18V1Pxuaho5JrGhaerF nmJpLg0csyg07cTscq24pYRve+zuKYlgopFPPH7YE29oFJlxSso3GCmPxJnMG8vawq7H GODw== X-Forwarded-Encrypted: i=1; AHgh+RpZtDfvWKYAGWi1F4abKMfB2cFYw26LlfiGb3O8P2QQPATsmpMiQpOlSZsJH792rnTgjlZDxOud9IV4000=@vger.kernel.org X-Gm-Message-State: AOJu0Yx134DPdZWlKOTt1FEirSlvqbDfsB9/p2QRbaTsQ0+ApM1xc5qx rxhxLY20dbhDOtZYwQeEYcd58eT27rdIkVkmn7jmyyucmcG/Ikd2pxEa X-Gm-Gg: AR+sD138eXCr4I0NivOPfRlqZgEXWfIMLvgIUXLAV6N4wQxz6flGXV1vp1ct1w/lrD9 jQh9Lqb/omn8kkuve3a5VwgLUiIJhzzeGdTbEbdVtbYux/YoB6Xw22KRpq/xWdTNurdLSfTYtFL 1F4O8U9LJPZf/13b34tYI5j++CrMkXKYnY55k1zl6dErF7J+mlUvECF+chxI7NZmeIg9Yyy7ZrR 7NR0sKq8iL0urMpNwjFJKTj3CkReaeYWs22rhb3I9MlAp6gAgzSn0tDOvWUYSbYU+UOOlQNcvH/ +Jdg182kr3GEFwQ/3rriy/yHa7+K2P+2eP/FA/W8p9UdzDsWmiRS7dtdKoCGVDSXz52Xc8Mgbm/ 4iooz/TSXWzkZQMstF/vPjhhPA1hhcB8SMxRUaMJ1wZSgXfMfw3elzvSJ+vtYgiNYaLwgSh0Dq5 tZjNk6Tcb40ygP+FdAdrMfHmI8OQSFO4sZM6P0acnuZK/qw+Myn7Q4bB5DDbJiHkwZ4V6MnVdwH rDG5w== X-Received: by 2002:a05:620a:284a:b0:92e:bd6f:b166 with SMTP id af79cd13be357-9330266c55emr706970885a.63.1785342585335; Wed, 29 Jul 2026 09:29:45 -0700 (PDT) Received: from localhost.localdomain ([187.15.144.227]) by smtp.gmail.com with ESMTPSA id af79cd13be357-933e7318180sm201745885a.28.2026.07.29.09.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 09:29:44 -0700 (PDT) From: Nicholas Dudar To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, tsbogend@alpha.franken.de, johan.almbladh@anyfinetworks.com, paulburton@kernel.org Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev, philmd@oss.qualcomm.com, visitorckw@gmail.com, bpf@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 0/2] bpf, mips: Add signed div/mod support Date: Wed, 29 Jul 2026 12:29:29 -0400 Message-Id: <20260729162931.2369353-1-main.kalliope@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MIPS JITs select division and modulo implementations from the BPF class and opcode, but do not inspect insn->off. BPF_SDIV and BPF_SMOD therefore use unsigned instructions, or unsigned C helpers for ALU64 on 32-bit MIPS. Patch 1 factors division and modulo emission into helpers. Patch 2 uses insn->off to select the signed instructions and helpers. Tested with test_bpf under QEMU on MIPS32r2, MIPS64r2, MIPS32r6, and MIPS64r6, with CONFIG_BPF_JIT_ALWAYS_ON=y. Patch 1 produced the base failure set on each target. With both patches, all 16 SDIV/SMOD cases passed. Fourteen failed on the base; two already passed. No test changed from PASS to FAIL. v2: - split out the div/mod helpers as Philippe suggested - use an unsigned quotient intermediate in the signed remainder helper - rebase onto bpf-next at fdec474c65fd - test the base, patch 1, and the full series on four MIPS targets v1: https://lore.kernel.org/bpf/20260716211055.2569433-1-main.kalliope@gmail.com/ Nicholas Dudar (2): bpf, mips: Factor out div/mod emission helpers bpf, mips: Add support for BPF_SDIV and BPF_SMOD arch/mips/include/asm/uasm.h | 6 +++ arch/mips/mm/uasm-mips.c | 10 +++++ arch/mips/mm/uasm.c | 20 ++++++--- arch/mips/net/bpf_jit_comp.c | 53 +++++++++++++++++------- arch/mips/net/bpf_jit_comp.h | 5 ++- arch/mips/net/bpf_jit_comp32.c | 30 +++++++++----- arch/mips/net/bpf_jit_comp64.c | 74 +++++++++++++++++++++++----------- 7 files changed, 143 insertions(+), 55 deletions(-) base-commit: fdec474c65fd35d5a6e1497ed50a9f98c07192f0 -- 2.34.1