From patchwork Tue Oct 5 08:26:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 12535829 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC01DC433FE for ; Tue, 5 Oct 2021 08:31:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAF57613D5 for ; Tue, 5 Oct 2021 08:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233441AbhJEIcu (ORCPT ); Tue, 5 Oct 2021 04:32:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233366AbhJEIcs (ORCPT ); Tue, 5 Oct 2021 04:32:48 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824FBC061745; Tue, 5 Oct 2021 01:30:58 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id oa6-20020a17090b1bc600b0019ffc4b9c51so1364821pjb.2; Tue, 05 Oct 2021 01:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DAGNoLYAM13FCAsShiHivQ1p6RlYfr33Xe38II2bD8U=; b=cBDmZU424tuQmQIoC3gjJYq5sHDqh+yCBNy2EH1IMKIbT5rkl9vk+5RTjfb8AQ7MFI dC2ULIApzwL8Wk1GHv9W9SXUogddOGtt1oFvKrVuQQg8ucZcztM1fJYzdfzRsSG6r/GE QDaMLodiHKPyOMm+iFfzxrjhs4A/dHn34XWXbRUPfql3ACKK7JG3LIQFA6ADa1s5/R65 bB8d3hTaqQ/cAc6apMOpbiycNiA9pYskY+XC96U9eKL+lnoNRvT9Mioelkkf640EoQhz l+hn8d0lgu3KoJ5yGaUHs/6nEOJ5DDlNsbR757s6pUqSMZhE1Y+g+TvO/xZltr79xca5 5dng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DAGNoLYAM13FCAsShiHivQ1p6RlYfr33Xe38II2bD8U=; b=GpqIbrh+2hAm9jxdl6tykLu1nMyWh+lPCCJkGRvP3or/IHsJqcnQEXD0UbiJjNnd5Y gl1MsLaE4jMH4PXKZ2Oa64imLu7LPBwzJyulXNboi+ufoSTlfWZzIS4TjdY4Kk2ZGfWe NV1NxAGzr+CbSo3Pg39eX9XWCXohIPyMyOknZtl4XfMo4TYPBpFE5dn63vXtfw8+BL9q 1LGkhKDNPPNYBF6F+UWnTOwXVJyRmJFHQcx1qfhjJhf49zgrrqyxdZEvgYhAeeg/vXKb lA8DCPfB4VZV8Kuclbp13+XxfGelhvZknpzG0imlTCYQAtgzzvus77To7xxMx87Y2Wzl kB+Q== X-Gm-Message-State: AOAM531Pq8u8J25zMhhml3QSpfWLDjNzwUrO4qztSwzWVTh74moz/xXq tR/2vuuQ6M/v0pxLDzu/Icn//Eo9xT/bRw== X-Google-Smtp-Source: ABdhPJz/t0tF4B5I4040OsOvyCt2OxNMZtEY5lMth30IA55yWXN5QOuG8MDZSgY1PeOduk0kdTtOiQ== X-Received: by 2002:a17:90b:3901:: with SMTP id ob1mr2329767pjb.12.1633422658158; Tue, 05 Oct 2021 01:30:58 -0700 (PDT) Received: from localhost.localdomain ([2001:470:e92d:10:78ba:4bcc:a59a:2284]) by smtp.gmail.com with ESMTPSA id a15sm4941257pfg.53.2021.10.05.01.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 01:30:57 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Thomas Bogendoerfer , Paul Burton Cc: Tony Ambardar , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-mips@vger.kernel.org, Johan Almbladh , Tiezhu Yang , Hassan Naveed , David Daney , Luke Nelson , Serge Semin , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Subject: [RFC PATCH bpf-next v2 07/16] MIPS: eBPF: fix MOD64 insn on R6 ISA Date: Tue, 5 Oct 2021 01:26:51 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC The BPF_ALU64 | BPF_MOD implementation is broken on MIPS64R6 due to use of a 32-bit "modu" insn, as shown by the test_verifier failures: 455/p MOD64 overflow, check 1 FAIL retval 0 != 1 (run 1/1) 456/p MOD64 overflow, check 2 FAIL retval 0 != 1 (run 1/1) Resolve by using the 64-bit "dmodu" instead. Fixes: 6c2c8a188868 ("MIPS: eBPF: Provide eBPF support for MIPS64R6") Signed-off-by: Tony Ambardar --- arch/mips/net/ebpf_jit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c index b8dc6cebefab..00dc20bc0def 100644 --- a/arch/mips/net/ebpf_jit.c +++ b/arch/mips/net/ebpf_jit.c @@ -800,7 +800,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, if (bpf_op == BPF_DIV) emit_instr(ctx, ddivu_r6, dst, dst, MIPS_R_AT); else - emit_instr(ctx, modu, dst, dst, MIPS_R_AT); + emit_instr(ctx, dmodu, dst, dst, MIPS_R_AT); break; } emit_instr(ctx, ddivu, dst, MIPS_R_AT); @@ -882,7 +882,7 @@ static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, emit_instr(ctx, ddivu_r6, dst, dst, src); else - emit_instr(ctx, modu, dst, dst, src); + emit_instr(ctx, dmodu, dst, dst, src); break; } emit_instr(ctx, ddivu, dst, src);