From patchwork Thu Oct 26 18:43:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438116 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83E5F881F for ; Fri, 27 Oct 2023 06:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eJj3fLkY" Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82BD81AC for ; Thu, 26 Oct 2023 23:01:10 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-27d0a173e61so1443714a91.0 for ; Thu, 26 Oct 2023 23:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386470; x=1698991270; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XOAetODyKAZtmGq4juMfnsuGXFtx5PudQ3Ii+cytJu4=; b=eJj3fLkY8d1stknlMy8/hkmqd11u/bovm9XNtqxF1AMjDRB7SwBTbRXRhE9QdMvmWP GGUeQnNk7AGO3kgPpVo6fpHaStm32ZlMrQEhtrZ6pWPSrqWVX3G/M57ZWVH4hw1kp//1 yzALvPgkxHPt72k0pcUwnBJ9sxghWDhxD0SmSQ0lyQlZ1oNiTb3OQGs7T+y8vDTM9aXC O+gU7n+V75px/c41OnomMbn2tKys8LG52aUS6dlKNd4cZcaO38J01NdTXBRq5Eqz49Qm NE/A+hxW03KhwbBCfgNMJz/2e1Cu6cLHqXoQ8RGS0CjD9tS5hbvE4M21XsZgobWKwMJU xcdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386470; x=1698991270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XOAetODyKAZtmGq4juMfnsuGXFtx5PudQ3Ii+cytJu4=; b=KZYfIYkuiOF+63R6zGXCovpQApZzaVIZP7F4HgkHb7317/VMoQ3dnN4gBtHl9KDgQF pimmkfEb3aDgwR9IufRkvb6eQ7SrnGS1wDNut5fDRp+C7iJBu62V7WS+pBKeSIWAMJrv mD6ebhUflUOxYtgd4yUPFxS6M3xGpZXkP3aSA+IR/vfTLohvsrb6Sgel52Wo/XZU26Dq Cd1T8gvekf7Zmv27/9mxGEyNr6BtZ5h2fqKrky/VTRP7/qmaU860KbH1Mk+CXldIJaN1 zpDboa7t5KQso0IBQBUuM/F3j+qViLNAtlb7PeZfysMqHH6xk78by2zsez5aIfYq9YSc waQQ== X-Gm-Message-State: AOJu0YzSQMn0XBz/JxASjqR7+1VYcd46wAiuwcdcAHHbwfqjX8I/J8Zp lvPycrbEwVkowd3a8RiC8Fc= X-Google-Smtp-Source: AGHT+IFKkk/FmkDvRFb2t82GndS2qIQ4DB43yNCvuipJTQpVhZ7laCMccD98YMenu6lbOguM6Rr73Q== X-Received: by 2002:a17:90a:2d83:b0:27d:2abc:f9c1 with SMTP id p3-20020a17090a2d8300b0027d2abcf9c1mr1598389pjd.20.1698386469984; Thu, 26 Oct 2023 23:01:09 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:09 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 1/8] LoongArch: Add more instruction opcodes and emit_* helpers Date: Thu, 26 Oct 2023 18:43:30 +0000 Message-Id: <20231026184337.563801-2-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net This patch adds more instruction opcodes and their corresponding emit_* helpers which will be used in later patches. Signed-off-by: Hengqi Chen --- arch/loongarch/include/asm/inst.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/loongarch/include/asm/inst.h b/arch/loongarch/include/asm/inst.h index 71e1ed4165c8..5350ae9ee380 100644 --- a/arch/loongarch/include/asm/inst.h +++ b/arch/loongarch/include/asm/inst.h @@ -65,6 +65,8 @@ enum reg2_op { revbd_op = 0x0f, revh2w_op = 0x10, revhd_op = 0x11, + extwh_op = 0x16, + extwb_op = 0x17, }; enum reg2i5_op { @@ -556,6 +558,8 @@ static inline void emit_##NAME(union loongarch_instruction *insn, \ DEF_EMIT_REG2_FORMAT(revb2h, revb2h_op) DEF_EMIT_REG2_FORMAT(revb2w, revb2w_op) DEF_EMIT_REG2_FORMAT(revbd, revbd_op) +DEF_EMIT_REG2_FORMAT(extwh, extwh_op) +DEF_EMIT_REG2_FORMAT(extwb, extwb_op) #define DEF_EMIT_REG2I5_FORMAT(NAME, OP) \ static inline void emit_##NAME(union loongarch_instruction *insn, \ @@ -607,6 +611,9 @@ DEF_EMIT_REG2I12_FORMAT(lu52id, lu52id_op) DEF_EMIT_REG2I12_FORMAT(andi, andi_op) DEF_EMIT_REG2I12_FORMAT(ori, ori_op) DEF_EMIT_REG2I12_FORMAT(xori, xori_op) +DEF_EMIT_REG2I12_FORMAT(ldb, ldb_op) +DEF_EMIT_REG2I12_FORMAT(ldh, ldh_op) +DEF_EMIT_REG2I12_FORMAT(ldw, ldw_op) DEF_EMIT_REG2I12_FORMAT(ldbu, ldbu_op) DEF_EMIT_REG2I12_FORMAT(ldhu, ldhu_op) DEF_EMIT_REG2I12_FORMAT(ldwu, ldwu_op) @@ -685,9 +692,12 @@ static inline void emit_##NAME(union loongarch_instruction *insn, \ insn->reg3_format.rk = rk; \ } +DEF_EMIT_REG3_FORMAT(addw, addw_op) DEF_EMIT_REG3_FORMAT(addd, addd_op) DEF_EMIT_REG3_FORMAT(subd, subd_op) DEF_EMIT_REG3_FORMAT(muld, muld_op) +DEF_EMIT_REG3_FORMAT(divd, divd_op) +DEF_EMIT_REG3_FORMAT(modd, modd_op) DEF_EMIT_REG3_FORMAT(divdu, divdu_op) DEF_EMIT_REG3_FORMAT(moddu, moddu_op) DEF_EMIT_REG3_FORMAT(and, and_op) @@ -699,6 +709,9 @@ DEF_EMIT_REG3_FORMAT(srlw, srlw_op) DEF_EMIT_REG3_FORMAT(srld, srld_op) DEF_EMIT_REG3_FORMAT(sraw, sraw_op) DEF_EMIT_REG3_FORMAT(srad, srad_op) +DEF_EMIT_REG3_FORMAT(ldxb, ldxb_op) +DEF_EMIT_REG3_FORMAT(ldxh, ldxh_op) +DEF_EMIT_REG3_FORMAT(ldxw, ldxw_op) DEF_EMIT_REG3_FORMAT(ldxbu, ldxbu_op) DEF_EMIT_REG3_FORMAT(ldxhu, ldxhu_op) DEF_EMIT_REG3_FORMAT(ldxwu, ldxwu_op) From patchwork Thu Oct 26 18:43:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438117 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84AC87495 for ; Fri, 27 Oct 2023 06:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mj0WuIWX" Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CFB31A7 for ; Thu, 26 Oct 2023 23:01:14 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5a9bf4fbd3fso1443042a12.1 for ; Thu, 26 Oct 2023 23:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386473; x=1698991273; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dhv57qGO2ds9mbz1kzxH2y7YI2Zg20QWv6WH4DiyAo4=; b=mj0WuIWXz4air3W1ndK/ksNO7jEM5unuXaBdifKgWHjEJ+4H4iIbLy2plbYhzRS2xs wMT8XLcGsN56VL+BvtxKhgfMbe+KzVc6425yIEUqAv42vnzbJgEMtYewY1PtZmgga84W oVl3DHMWLhO0REIHb6rPEASIAIsWI3X7FN0hZpDEW7D0w9TdMn5ICJzoEuYRo7lNvREu Gzuyd85xILRMaNA+Aqt2BnoaQwWAuTpwzRPv3DLm4l8wpYddnQgBd5RTOhNZOmLmbxEv Xmb8js5KhndLsSiUKswXsjuTYVeZUP2M2TWVy3K/vh2pE5XUw/jykvUfQ2m9QUDOWzKL x33g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386473; x=1698991273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dhv57qGO2ds9mbz1kzxH2y7YI2Zg20QWv6WH4DiyAo4=; b=AagkgL+nXa3E86jGy5BtIp3TndzsW01v3IkiHHpntlQhZU0h3BjcVnAni4yXDRYDR/ 6sRxIAorGCuQdpVmWJtPWCYFK5ZB9syxoJqiHw1GsL/KjD6qLojvdHwhxxYq4ZFenf1J HcEaTwMaOoTviUE1kovoOfLIsvUPVrEtZ6pfi6iPFuWMyFCxjjH6vuUeWixqqxIOgGWA jyzAQTe6jG6nvc48Hj0LqRX5HkzERV67rxGQPy/pHLxZSsvqJ1bHXCzSc2fNjFIQL2Au 9vdvIumi1pDnFjkE7ZOT/hTQPXz1Wv6XTB7+jVuKo5EuBjZ4Lke/RA07VNAVtVNX6CQV KWGw== X-Gm-Message-State: AOJu0YxtfSP2gIMG3la9tJ0pkNR77PgdECkg3M0V9sVAsr57YtQPdZMD jfMJ0y3Dz6HS0v3OOqyBfZA= X-Google-Smtp-Source: AGHT+IE2jl0HioVsQXNEfZxRACFosanEuhKFHfIooEHzU9KdPnTtunsaur1cC+gCgV8FkLRBioC3ig== X-Received: by 2002:a17:90a:1996:b0:27d:2054:9641 with SMTP id 22-20020a17090a199600b0027d20549641mr1710760pji.36.1698386473513; Thu, 26 Oct 2023 23:01:13 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:13 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 2/8] LoongArch: BPF: Support sign-extension load instructions Date: Thu, 26 Oct 2023 18:43:31 +0000 Message-Id: <20231026184337.563801-3-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add support for sign-extension load instructions. Signed-off-by: Hengqi Chen --- arch/loongarch/net/bpf_jit.c | 49 ++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index db9342b2d0e6..0c2bbca527ef 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -411,7 +411,11 @@ static int add_exception_handler(const struct bpf_insn *insn, off_t offset; struct exception_table_entry *ex; - if (!ctx->image || !ctx->prog->aux->extable || BPF_MODE(insn->code) != BPF_PROBE_MEM) + if (!ctx->image || !ctx->prog->aux->extable) + return 0; + + if (BPF_MODE(insn->code) != BPF_PROBE_MEM && + BPF_MODE(insn->code) != BPF_PROBE_MEMSX) return 0; if (WARN_ON_ONCE(ctx->num_exentries >= ctx->prog->aux->num_exentries)) @@ -450,7 +454,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext { u8 tm = -1; u64 func_addr; - bool func_addr_fixed; + bool func_addr_fixed, sign_extend; int i = insn - ctx->prog->insnsi; int ret, jmp_offset; const u8 code = insn->code; @@ -879,31 +883,56 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext case BPF_LDX | BPF_PROBE_MEM | BPF_W: case BPF_LDX | BPF_PROBE_MEM | BPF_H: case BPF_LDX | BPF_PROBE_MEM | BPF_B: + /* dst_reg = (s64)*(signed size *)(src_reg + off) */ + case BPF_LDX | BPF_MEMSX | BPF_B: + case BPF_LDX | BPF_MEMSX | BPF_H: + case BPF_LDX | BPF_MEMSX | BPF_W: + case BPF_LDX | BPF_PROBE_MEMSX | BPF_B: + case BPF_LDX | BPF_PROBE_MEMSX | BPF_H: + case BPF_LDX | BPF_PROBE_MEMSX | BPF_W: + sign_extend = BPF_MODE(insn->code) == BPF_MEMSX || + BPF_MODE(insn->code) == BPF_PROBE_MEMSX; switch (BPF_SIZE(code)) { case BPF_B: if (is_signed_imm12(off)) { - emit_insn(ctx, ldbu, dst, src, off); + if (sign_extend) + emit_insn(ctx, ldb, dst, src, off); + else + emit_insn(ctx, ldbu, dst, src, off); } else { move_imm(ctx, t1, off, is32); - emit_insn(ctx, ldxbu, dst, src, t1); + if (sign_extend) + emit_insn(ctx, ldxb, dst, src, t1); + else + emit_insn(ctx, ldxbu, dst, src, t1); } break; case BPF_H: if (is_signed_imm12(off)) { - emit_insn(ctx, ldhu, dst, src, off); + if (sign_extend) + emit_insn(ctx, ldh, dst, src, off); + else + emit_insn(ctx, ldhu, dst, src, off); } else { move_imm(ctx, t1, off, is32); - emit_insn(ctx, ldxhu, dst, src, t1); + if (sign_extend) + emit_insn(ctx, ldxh, dst, src, t1); + else + emit_insn(ctx, ldxhu, dst, src, t1); } break; case BPF_W: if (is_signed_imm12(off)) { - emit_insn(ctx, ldwu, dst, src, off); - } else if (is_signed_imm14(off)) { - emit_insn(ctx, ldptrw, dst, src, off); + if (sign_extend) + emit_insn(ctx, ldw, dst, src, off); + else + emit_insn(ctx, ldwu, dst, src, off); } else { move_imm(ctx, t1, off, is32); - emit_insn(ctx, ldxwu, dst, src, t1); + if (sign_extend) + emit_insn(ctx, ldxw, dst, src, t1); + else + emit_insn(ctx, ldxwu, dst, src, t1); } break; case BPF_DW: From patchwork Thu Oct 26 18:43:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438118 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B99688BEB for ; Fri, 27 Oct 2023 06:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d62LNUpt" Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F961B4 for ; Thu, 26 Oct 2023 23:01:17 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5b93ddb10b8so356333a12.0 for ; Thu, 26 Oct 2023 23:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386477; x=1698991277; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ju1+333w2vHRlYpxQccqOWvW/oF44n6WKsFZFqcRgwI=; b=d62LNUptod+As6hYJnQ71t2ae29MYpkTS/35LvzuAUQsUCSQ9EMbj32fgrbnwdKxHx l32+fNWKzpAQmCnsVRW3VVMo5+K33Fk/FgNO+/zvXE2CDck+KlX9VzdUJeK4osxrLTW6 1gNRqaatDekj4mPShHUcW9PsVcWpo64mIU+zZn5iZdNDljL29sb81lcSOfBIuADsqy6o 3uspBTfHopLEsjISFSUNZ2HkS5kLu2QqEPAaZFOWsl6x5kgIs032pOrI9w6JM2Ihb8zw or/gPrYSMMGfTNFJY9HJuNC/JIoDO688+hF+VGJOcZ6lwqIyPTH6roYEmEmWgxb+kiQC SxTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386477; x=1698991277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ju1+333w2vHRlYpxQccqOWvW/oF44n6WKsFZFqcRgwI=; b=P//f/6a6T/vjuJ2JBJvAr8Sj2Cf+T1CVkR5r7zBqdNqxJH2dxzIRET3uHQ7yx0jWZy YHQscuBJ/HDwMQNtLN3ce9b2PY6X8tWECrahaokHBvxJx5ac17tbKRZSLePeFLoWbYuF YV+iPFCV7Q7kEU00Xszvr668ddB1qY6mTEr1O9zYbDZ6zp5NK5ejIGR6uVrvs2m1a0oc M8iuLy/c2b63x+3dUWES/+WY0fkwc9MhjWtdHySZ9nHhHJ7uBq76JPlyL6PsM55YNzPg 1cRpOZ3ymSTbu4zGShMvf4fPTc/Mu9zbWG8OER505jSb6RVxR+IJALvIsSWflInRlRJ+ 0/zA== X-Gm-Message-State: AOJu0YzftQ/LHtO+V/sRg2Zffi6Zj4IzgOQqq72ay8BEJL1RWuQL58DW 0I9ZUVdiCqP3tpIFAtUkEOU= X-Google-Smtp-Source: AGHT+IEi6zWufaoGL7LwP/y41ik7Gw7wqoxmlOg6OH5y2xkeUU5UrPt5OnGZ+hsmY71N8RdwgRsZQw== X-Received: by 2002:a17:90a:be0e:b0:27d:2ce9:d6d5 with SMTP id a14-20020a17090abe0e00b0027d2ce9d6d5mr2390073pjs.12.1698386476634; Thu, 26 Oct 2023 23:01:16 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:16 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 3/8] LoongArch: BPF: Support sign-extension mov instructions Date: Thu, 26 Oct 2023 18:43:32 +0000 Message-Id: <20231026184337.563801-4-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add support for sign-extension mov instructions. Signed-off-by: Hengqi Chen --- arch/loongarch/net/bpf_jit.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index 0c2bbca527ef..ac9edf02675c 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -472,8 +472,23 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext /* dst = src */ case BPF_ALU | BPF_MOV | BPF_X: case BPF_ALU64 | BPF_MOV | BPF_X: - move_reg(ctx, dst, src); - emit_zext_32(ctx, dst, is32); + switch (off) { + case 0: + move_reg(ctx, dst, src); + emit_zext_32(ctx, dst, is32); + break; + case 8: + move_reg(ctx, t1, src); + emit_insn(ctx, extwb, dst, t1); + break; + case 16: + move_reg(ctx, t1, src); + emit_insn(ctx, extwh, dst, t1); + break; + case 32: + emit_insn(ctx, addw, dst, src, LOONGARCH_GPR_ZERO); + break; + } break; /* dst = imm */ From patchwork Thu Oct 26 18:43:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438119 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3663E881F for ; Fri, 27 Oct 2023 06:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nN62+KP6" Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43F9A1B2 for ; Thu, 26 Oct 2023 23:01:20 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-27d45f5658fso1482894a91.3 for ; Thu, 26 Oct 2023 23:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386479; x=1698991279; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4zelpIOoWAgGbxFR3NcYgOUoojFa9hIieRbhvyFBjF8=; b=nN62+KP6yHpv3e74JnCzeL9/MsBs7ZFrsv9Yu5FQfXSnMtwXXZOHPb5qkY/xYuR7g1 2UPvHBPKwS1KHMOI31rfcu2JuI+Fj3NPxeD4J+Z+BpPQgv3ASZ1bmAiI9sHucBb6PtEU m/6JKLnn0AVQbn3w4Nx7OK4IvTqViftHKUwDtUOHlvwb5YI2RF1u8i7mnk+TPQ4z0lrx Yiq2zgnHy4osYfa2HZttwFkJxXelbaOb2W1SZPo1gA5fUdXrg7qK1oxhMGVNQ0U9Whwu ShrhQ3EWdUQx8OVYPEJl/aNiERD2WunTM32o7bD2MirdapSUXRu9M32xM8SG+szwiQb7 kf1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386479; x=1698991279; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4zelpIOoWAgGbxFR3NcYgOUoojFa9hIieRbhvyFBjF8=; b=U6qawUeG/9TTEACGFcD1K2wbcHPgFaRycKrW75qK/wzOfVfXB90OCygMyxgl5hrmer t2xxnI4fN0zz6aXyyxNQuctdrGEjp1sFB6P4PecNsyIncNYLBFVFxHJSjARv1mnwOli2 v7eRhBkaQEi4MlaQWZuzdmjeCpXGByoUY5iwBtQ+Ne4LQ4YqGulUtHlB/thmw60C2aMA jUadnDfhbikltgzrzhFUps5iUvwnEtXtr0itCQOF+h1WHfQZ3U/tGCcV6p4eZ/0tJ4ll k+e/wD6M8t5hJl8c94Scs5EhQoozzZOkZ+jJ1Q3igJMIvsf05mrazQgrXRtqlsHtFLPD zvOw== X-Gm-Message-State: AOJu0Yx0XPy7sEn0en+sfDA14KNSgi7gpcKwlWBOCNiU2cY3/VMLGEhF WGD+VrVxPT5KGVhFci8X5uE= X-Google-Smtp-Source: AGHT+IGbB6lqmvFnNAP3CD23VIw7yN0hIQByt8lNkGolnRtThjkjKWvfJvwwOVugZSO/BXqfROSkmw== X-Received: by 2002:a17:90a:1a50:b0:27d:3ed2:86a5 with SMTP id 16-20020a17090a1a5000b0027d3ed286a5mr1572448pjl.33.1698386479701; Thu, 26 Oct 2023 23:01:19 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:19 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 4/8] LoongArch: BPF: Support unconditional bswap instructions Date: Thu, 26 Oct 2023 18:43:33 +0000 Message-Id: <20231026184337.563801-5-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add support for unconditional bswap instruction. Since LoongArch is always little-endian, just treat unconditional bswap the same as big-endian conversion. Signed-off-by: Hengqi Chen --- arch/loongarch/net/bpf_jit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index ac9edf02675c..a8be6d4b058c 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -731,6 +731,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext break; case BPF_ALU | BPF_END | BPF_FROM_BE: + case BPF_ALU64 | BPF_END | BPF_FROM_LE: switch (imm) { case 16: emit_insn(ctx, revb2h, dst, dst); From patchwork Thu Oct 26 18:43:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438121 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F74D7493 for ; Fri, 27 Oct 2023 06:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iZp9mzzB" Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77F4F1BB for ; Thu, 26 Oct 2023 23:01:23 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6b89ab5ddb7so1696111b3a.0 for ; Thu, 26 Oct 2023 23:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386483; x=1698991283; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCu11tyAMn6bcFBf0dU4cUbsZOD9OVnoAoPidBrK0dw=; b=iZp9mzzBOubo8YgjeH8lHOyrznCgKAZ0yPDA6DjNEh2FjuItTeCLIKbvRF8t2WRcre GlNFAUtoXGNekRSlqVyf9BSlztlHgSGZRp1X9jEgXIyYfWzQBtgreRLr1glbYxrRKDjw 37aDyY9WAC049JwvO1zOo6lkmAu0O1u2oV4Lk1rs9GwxnFx69GorA1C2oquXulJ4+HO1 TtohmeDFoKDYLTlBS8KakMx8Z5U4EeeSIJ3DXi+WsLvQUiqdPDkpQfyaCAyWui94J/Zw glD+1yBfMAVlbG12XPpk4TvVJWhgLGRnBYyUmZOq3xYfCghsCP/MZTBWlmXfSxGuPdgB AB5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386483; x=1698991283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCu11tyAMn6bcFBf0dU4cUbsZOD9OVnoAoPidBrK0dw=; b=uzbnpq0X2N3KUWhlGaw2DtY8gXGIGlHot4JgH/bM4AC4k1Cd2p87HgUyPs3BhaLmKA harcOb+eDlLdBS7fHqfESdP7G5tp2dY/vxJ6v2fAW/vmKE5qxjXuOX8sLYRijcAo4tyw 9wgzGDAM0kucNfvVmKl5wL32riZHd8wUGjB4xWjs8+apyvY2NmqWE1dKnB2su1y1oIpj wP3WpzXYrEsYeegTHREIOUSHbRcJXgGkmsROs22/X7/Ax2FgH7sr2BFEQkLfvpv7GdLG /F/wbkXWSYjvsYM9t8qJr6oo0SQcZr5VnLX1TBqBJXStT0qo1VyJTQypxzUKWVm8FK6u 9X7A== X-Gm-Message-State: AOJu0Yy0x/Nn6AEBwu7iKPtfYmJyep+6EHixSxCjbfkEZsyHX1OPhCXU BRMMRWe2LpRdNpAipa/B2Dw= X-Google-Smtp-Source: AGHT+IGuUIL1PqYppXFOJIf0V5ue/O92A5XTGr2JcoGCzUOopOcu/Wji5+fvUJ6YofnaZyw3jB9wpA== X-Received: by 2002:a05:6a21:198:b0:140:3aa:e2ce with SMTP id le24-20020a056a21019800b0014003aae2cemr2636338pzb.42.1698386482807; Thu, 26 Oct 2023 23:01:22 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:22 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 5/8] LoongArch: BPF: Support 32-bit offset jmp instructions Date: Thu, 26 Oct 2023 18:43:34 +0000 Message-Id: <20231026184337.563801-6-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add support for 32-bit offset jmp instruction. Currently, we use b instruction which supports range within ±128MB for such jumps. This should be large enough for BPF progs. Signed-off-by: Hengqi Chen --- arch/loongarch/net/bpf_jit.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index a8be6d4b058c..050fcf233a34 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -848,7 +848,11 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext /* PC += off */ case BPF_JMP | BPF_JA: - jmp_offset = bpf2la_offset(i, off, ctx); + case BPF_JMP32 | BPF_JA: + if (BPF_CLASS(code) == BPF_JMP) + jmp_offset = bpf2la_offset(i, off, ctx); + else + jmp_offset = bpf2la_offset(i, imm, ctx); if (emit_uncond_jmp(ctx, jmp_offset) < 0) goto toofar; break; From patchwork Thu Oct 26 18:43:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438122 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51BB8881F for ; Fri, 27 Oct 2023 06:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cR4C6EpX" Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AFEE1B8 for ; Thu, 26 Oct 2023 23:01:26 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5ab2cb900fcso1371065a12.0 for ; Thu, 26 Oct 2023 23:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386486; x=1698991286; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UXv9dn4i8m4RUIoprh3jAeTLejyEjZe30vXJvAEpPQI=; b=cR4C6EpXr4IThnhKsLx3wrUu1ZDu7BgPoMZRP8xGtNjZAfhSaah354P20hYZD35WUu JySEG6Igo4ha8A+U0umg5X9SaUjMAbbWAounA6uvEc3bpSxtzyHk/MzW5fSkNir29dK5 jY80FrX91XzwMGQtP5sWuBNp/NObRvA6TD2NpfFtvjKzxhs+b8P3XGJjUeq4mVt623vz M+tqRUtX8MI8AOi/EBpJh3D9PB67Zfq/cN15Iaq6woKMHaZMd/QvLdse9TldlO9I2NIZ g4A8K4+T4Y07XXSnFmvbUgll5GamtOuLdGOTAgahLk0NEibz+ZlvDnEKv3R4UDECDYrC FziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386486; x=1698991286; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UXv9dn4i8m4RUIoprh3jAeTLejyEjZe30vXJvAEpPQI=; b=qfeMBmrQ3WO3mmYTo68zeWVx8Dqiuwty7/10VsKE6KvepX7wB+TGFKKDBY1xWrU+cM ydJrgi8/76f95e+m4zAWne2ic8g2cN+zP1q13GypmEAjThXocIN8LjUu8Thcy42uDBJl juTrQGJ6Po/Kl1Fo08tvJo06LyK1SfXUyba8T8oyvf4ofD8WwTiqxg0U/nfndxLurtKt WY66IvvzGrRqHLcc7sS1O6CZ7IotHNbouhpdGVioxgn5Lcn+x7ZmvTc13G4P9Izo5aau r3NLQwFQMvGY+L/KjyOqe0GyDt4nRIr6A7k+5c8Jz0B31u49YjQMHFp/2o9ErfwZR24z hPRg== X-Gm-Message-State: AOJu0Yy7jgkFUN5LC/QivgqDLbHtOTSwgc3sC12Q3OsV6x2nVT/XGW0W L0a0hRWyxw6Z2KIef3pLDm8= X-Google-Smtp-Source: AGHT+IFiVPAOA9+35Jg4JjLI0IlKVNR+C1+6tE2tw5V9YMxPmaqIL13TxeO8q1y4Gjwqe7cV/wMzxQ== X-Received: by 2002:a17:90a:ad91:b0:27d:b9d:bd6f with SMTP id s17-20020a17090aad9100b0027d0b9dbd6fmr1567936pjq.45.1698386485857; Thu, 26 Oct 2023 23:01:25 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:25 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 6/8] LoongArch: BPF: Support signed div instructions Date: Thu, 26 Oct 2023 18:43:35 +0000 Message-Id: <20231026184337.563801-7-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add support for signed div instructions. Signed-off-by: Hengqi Chen --- arch/loongarch/net/bpf_jit.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index 050fcf233a34..7c0d129b82a4 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -553,20 +553,36 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext /* dst = dst / src */ case BPF_ALU | BPF_DIV | BPF_X: case BPF_ALU64 | BPF_DIV | BPF_X: - emit_zext_32(ctx, dst, is32); - move_reg(ctx, t1, src); - emit_zext_32(ctx, t1, is32); - emit_insn(ctx, divdu, dst, dst, t1); - emit_zext_32(ctx, dst, is32); + if (!off) { + emit_zext_32(ctx, dst, is32); + move_reg(ctx, t1, src); + emit_zext_32(ctx, t1, is32); + emit_insn(ctx, divdu, dst, dst, t1); + emit_zext_32(ctx, dst, is32); + } else { + emit_sext_32(ctx, dst, is32); + move_reg(ctx, t1, src); + emit_sext_32(ctx, t1, is32); + emit_insn(ctx, divd, dst, dst, t1); + emit_sext_32(ctx, dst, is32); + } break; /* dst = dst / imm */ case BPF_ALU | BPF_DIV | BPF_K: case BPF_ALU64 | BPF_DIV | BPF_K: - move_imm(ctx, t1, imm, is32); - emit_zext_32(ctx, dst, is32); - emit_insn(ctx, divdu, dst, dst, t1); - emit_zext_32(ctx, dst, is32); + if (!off) { + move_imm(ctx, t1, imm, is32); + emit_zext_32(ctx, dst, is32); + emit_insn(ctx, divdu, dst, dst, t1); + emit_zext_32(ctx, dst, is32); + } else { + move_imm(ctx, t1, imm, false); + emit_sext_32(ctx, t1, is32); + emit_sext_32(ctx, dst, is32); + emit_insn(ctx, divd, dst, dst, t1); + emit_sext_32(ctx, dst, is32); + } break; /* dst = dst % src */ From patchwork Thu Oct 26 18:43:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438123 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 442278F44 for ; Fri, 27 Oct 2023 06:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f/W99DOy" Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720161B5 for ; Thu, 26 Oct 2023 23:01:29 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2800229592aso1001300a91.2 for ; Thu, 26 Oct 2023 23:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386489; x=1698991289; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kWzFDBlrCucXbuh5gH/vQd/Yt8pKHvjRpmiR9c5r4z8=; b=f/W99DOyNgtlyEq6BO1L9KN0ld/qBLMrAqzW5BK8Q5qizkdJrQt3UqoApdNoPOobxW 1M14A4+IjIZPq6euInnoOmvTI28/xFMpCFlhxnz7n2j84n9G1q26DYkMbQOlQKjCI2uT fBHU34NJf9m1bM0BvrHM1yk4jgurAJtmExNe4psw7m99fZYvmJ5URf7pWvc2x1ECkMzM Xm1OWL26MhCscTBAaW1kIJFJrn0FUCvvdv/Z65wJ51sleet6q80cwm7syWp/RKevLq1f ZQoF+OShfad/fzrdiJty9zyqlXzmeIz0LN/Mk5uXKVmjUkoK8FX8n+Oajblq74DEx+nN 0Tug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386489; x=1698991289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kWzFDBlrCucXbuh5gH/vQd/Yt8pKHvjRpmiR9c5r4z8=; b=nAItZ7LIfbKNIz70ptDC2qBFnUCEq9PWnsHIhIO92vv/QUb5kJzA+TBVhVg/cbS8Km CIRiIxTRer1p8FEyAUIcjnXc9kvfDoq+2LpAEQRojC4O3xy5zPtsDI4Gt1jomudLgd3q EZ4uD6MMvlF3+jUSWCGD7Izp0WDa5v1EsxkM4vBIhxooXruVhVP93wWQZ1/IvmZR7LXx B8IVw1HNi+atzjkcnp78PxCu2tL7wWawvvv3XsMlBTSYuhlD7/nKCco4WAAjNT7hwuSd wmAD6B9wbcvxQLYnXbLS/UQayOOBVniu74PSttaDYjhgWiByVx7iWleqg0NMBQBphDk1 qQcg== X-Gm-Message-State: AOJu0YwMt98rdj6+LG3WGCa5PW/Fcv/x8x54XyxcaeQi+Q3WCyEvRj5r CQERoNtK7cQdstY0PYnx5ww= X-Google-Smtp-Source: AGHT+IEgaSgxsA8ckgC4SVIe+CC8eYEBsm/X0UUFfamFblf24Hb9Jb0oZED6z29P/GkbWh4L7jz1Mw== X-Received: by 2002:a17:90a:6f03:b0:27d:6b5:9e07 with SMTP id d3-20020a17090a6f0300b0027d06b59e07mr1649997pjk.1.1698386488891; Thu, 26 Oct 2023 23:01:28 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:28 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 7/8] LoongArch: BPF: Support signed mod instructions Date: Thu, 26 Oct 2023 18:43:36 +0000 Message-Id: <20231026184337.563801-8-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add support for signed mod instructions. Signed-off-by: Hengqi Chen --- arch/loongarch/net/bpf_jit.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index 7c0d129b82a4..169ff8b3915e 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -588,20 +588,36 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext /* dst = dst % src */ case BPF_ALU | BPF_MOD | BPF_X: case BPF_ALU64 | BPF_MOD | BPF_X: - emit_zext_32(ctx, dst, is32); - move_reg(ctx, t1, src); - emit_zext_32(ctx, t1, is32); - emit_insn(ctx, moddu, dst, dst, t1); - emit_zext_32(ctx, dst, is32); + if (!off) { + emit_zext_32(ctx, dst, is32); + move_reg(ctx, t1, src); + emit_zext_32(ctx, t1, is32); + emit_insn(ctx, moddu, dst, dst, t1); + emit_zext_32(ctx, dst, is32); + } else { + emit_sext_32(ctx, dst, is32); + move_reg(ctx, t1, src); + emit_sext_32(ctx, t1, is32); + emit_insn(ctx, modd, dst, dst, t1); + emit_sext_32(ctx, dst, is32); + } break; /* dst = dst % imm */ case BPF_ALU | BPF_MOD | BPF_K: case BPF_ALU64 | BPF_MOD | BPF_K: - move_imm(ctx, t1, imm, is32); - emit_zext_32(ctx, dst, is32); - emit_insn(ctx, moddu, dst, dst, t1); - emit_zext_32(ctx, dst, is32); + if (!off) { + move_imm(ctx, t1, imm, is32); + emit_zext_32(ctx, dst, is32); + emit_insn(ctx, moddu, dst, dst, t1); + emit_zext_32(ctx, dst, is32); + } else { + move_imm(ctx, t1, imm, false); + emit_sext_32(ctx, t1, is32); + emit_sext_32(ctx, dst, is32); + emit_insn(ctx, modd, dst, dst, t1); + emit_sext_32(ctx, dst, is32); + } break; /* dst = -dst */ From patchwork Thu Oct 26 18:43:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hengqi Chen X-Patchwork-Id: 13438124 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D70CB8F51 for ; Fri, 27 Oct 2023 06:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WFRZZqDP" Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 807B61B8 for ; Thu, 26 Oct 2023 23:01:32 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2800dfa0dd6so204852a91.1 for ; Thu, 26 Oct 2023 23:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698386492; x=1698991292; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/48rHxcr2kfCnpdZusbnXUGyablf+8gA/Vo2wvFNoEk=; b=WFRZZqDPydS+Vk/n1r5a5QFhzI2LDfWh7r8WYlY6AYExzMvXNZQ3xMGmSv2iiAQEak VFiTvoFJUC5MYwNQv07xgj5000wVKUX20x0zeYUTD9KFcFK8eJnnSuQMopU2szyp/QNX Slg4SR5s+L5CX2JjPkR4mAjLvmH71y2T05FKmRbzp6SBJuR5Ed3l3t+Xcn5iBgqNoTsx 78UPEYiFcKwE7TTI0QByI0X7+0V7WFrNPpazIH7sdn0JARUj8Qswq7QLHJKHs7DRS6+N SWDH4razG/lvmu3wcJRcPMPy3+44FvKgKchaXWM6jHjxKCvR85ykPT5DDbFYbirgwAK7 dG3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698386492; x=1698991292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/48rHxcr2kfCnpdZusbnXUGyablf+8gA/Vo2wvFNoEk=; b=pzWzqOBHdt+duqHxNoFeNUF+kywbEb99D8oFUDTWPPGTlNo+nJCrV21z4VKqUUarlF gIhJ1xDlgHqPn45cIsGy094VYstn5nnLDy5CGfLRvpD5Jb3RSMQ3OuvnR1OqP2qyAIYc vKLpTOffMN4xipmXEHC985/X48uVb/GlU8Gvp4WNgypjzMxSksLaTcmpZopKhzE679MF FY/VtuZK64Fp0fuqN0fJC/jCLhipCmSJYoeCPcW30tvnFSELIPMywU9tlUGFcBdz22wS 21dbjrfdqykbbnmEG1nADOmzU6UAzQcwjlJKEAz6N6rxhOMCLA0Bnvjl+93Q7JqQ0TK+ oNvw== X-Gm-Message-State: AOJu0YxDWSKmY075WA8IpNqfdRCi5UrqNDvkn3ETOXQhtQiAW3LzDnB4 7e0qwAtZzX31jr4UoFzie0I= X-Google-Smtp-Source: AGHT+IE0zAhS7gyXastTzXcZoMnulUI70kaiASHm0CrGGxTmnAXcjDNM4lkrJhxX+lVBNAhCBC3k0g== X-Received: by 2002:a17:90b:e89:b0:27d:5562:7e13 with SMTP id fv9-20020a17090b0e8900b0027d55627e13mr1415304pjb.39.1698386491863; Thu, 26 Oct 2023 23:01:31 -0700 (PDT) Received: from ubuntu.. ([43.132.98.47]) by smtp.googlemail.com with ESMTPSA id z2-20020a17090a1fc200b00277337818afsm1113667pjz.0.2023.10.26.23.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:01:31 -0700 (PDT) From: Hengqi Chen To: loongarch@lists.linux.dev, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, yangtiezhu@loongson.cn, hengqi.chen@gmail.com Subject: [PATCH bpf-next 8/8] selftests/bpf: Enable cpu v4 tests for LoongArch Date: Thu, 26 Oct 2023 18:43:37 +0000 Message-Id: <20231026184337.563801-9-hengqi.chen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026184337.563801-1-hengqi.chen@gmail.com> References: <20231026184337.563801-1-hengqi.chen@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Enable cpu v4 tests for LoongArch. Currently, we don't have BPF trampoline in LoongArch JIT, so the fentry test `test_ptr_struct_arg` still failed, will followup. Test result attached below: # ./test_progs -t verifier_sdiv,verifier_movsx,verifier_ldsx,verifier_gotol,verifier_bswap #316/1 verifier_bswap/BSWAP, 16:OK #316/2 verifier_bswap/BSWAP, 16 @unpriv:OK #316/3 verifier_bswap/BSWAP, 32:OK #316/4 verifier_bswap/BSWAP, 32 @unpriv:OK #316/5 verifier_bswap/BSWAP, 64:OK #316/6 verifier_bswap/BSWAP, 64 @unpriv:OK #316 verifier_bswap:OK #330/1 verifier_gotol/gotol, small_imm:OK #330/2 verifier_gotol/gotol, small_imm @unpriv:OK #330 verifier_gotol:OK #338/1 verifier_ldsx/LDSX, S8:OK #338/2 verifier_ldsx/LDSX, S8 @unpriv:OK #338/3 verifier_ldsx/LDSX, S16:OK #338/4 verifier_ldsx/LDSX, S16 @unpriv:OK #338/5 verifier_ldsx/LDSX, S32:OK #338/6 verifier_ldsx/LDSX, S32 @unpriv:OK #338/7 verifier_ldsx/LDSX, S8 range checking, privileged:OK #338/8 verifier_ldsx/LDSX, S16 range checking:OK #338/9 verifier_ldsx/LDSX, S16 range checking @unpriv:OK #338/10 verifier_ldsx/LDSX, S32 range checking:OK #338/11 verifier_ldsx/LDSX, S32 range checking @unpriv:OK #338 verifier_ldsx:OK #349/1 verifier_movsx/MOV32SX, S8:OK #349/2 verifier_movsx/MOV32SX, S8 @unpriv:OK #349/3 verifier_movsx/MOV32SX, S16:OK #349/4 verifier_movsx/MOV32SX, S16 @unpriv:OK #349/5 verifier_movsx/MOV64SX, S8:OK #349/6 verifier_movsx/MOV64SX, S8 @unpriv:OK #349/7 verifier_movsx/MOV64SX, S16:OK #349/8 verifier_movsx/MOV64SX, S16 @unpriv:OK #349/9 verifier_movsx/MOV64SX, S32:OK #349/10 verifier_movsx/MOV64SX, S32 @unpriv:OK #349/11 verifier_movsx/MOV32SX, S8, range_check:OK #349/12 verifier_movsx/MOV32SX, S8, range_check @unpriv:OK #349/13 verifier_movsx/MOV32SX, S16, range_check:OK #349/14 verifier_movsx/MOV32SX, S16, range_check @unpriv:OK #349/15 verifier_movsx/MOV32SX, S16, range_check 2:OK #349/16 verifier_movsx/MOV32SX, S16, range_check 2 @unpriv:OK #349/17 verifier_movsx/MOV64SX, S8, range_check:OK #349/18 verifier_movsx/MOV64SX, S8, range_check @unpriv:OK #349/19 verifier_movsx/MOV64SX, S16, range_check:OK #349/20 verifier_movsx/MOV64SX, S16, range_check @unpriv:OK #349/21 verifier_movsx/MOV64SX, S32, range_check:OK #349/22 verifier_movsx/MOV64SX, S32, range_check @unpriv:OK #349/23 verifier_movsx/MOV64SX, S16, R10 Sign Extension:OK #349/24 verifier_movsx/MOV64SX, S16, R10 Sign Extension @unpriv:OK #349 verifier_movsx:OK #361/1 verifier_sdiv/SDIV32, non-zero imm divisor, check 1:OK #361/2 verifier_sdiv/SDIV32, non-zero imm divisor, check 1 @unpriv:OK #361/3 verifier_sdiv/SDIV32, non-zero imm divisor, check 2:OK #361/4 verifier_sdiv/SDIV32, non-zero imm divisor, check 2 @unpriv:OK #361/5 verifier_sdiv/SDIV32, non-zero imm divisor, check 3:OK #361/6 verifier_sdiv/SDIV32, non-zero imm divisor, check 3 @unpriv:OK #361/7 verifier_sdiv/SDIV32, non-zero imm divisor, check 4:OK #361/8 verifier_sdiv/SDIV32, non-zero imm divisor, check 4 @unpriv:OK #361/9 verifier_sdiv/SDIV32, non-zero imm divisor, check 5:OK #361/10 verifier_sdiv/SDIV32, non-zero imm divisor, check 5 @unpriv:OK #361/11 verifier_sdiv/SDIV32, non-zero imm divisor, check 6:OK #361/12 verifier_sdiv/SDIV32, non-zero imm divisor, check 6 @unpriv:OK #361/13 verifier_sdiv/SDIV32, non-zero imm divisor, check 7:OK #361/14 verifier_sdiv/SDIV32, non-zero imm divisor, check 7 @unpriv:OK #361/15 verifier_sdiv/SDIV32, non-zero imm divisor, check 8:OK #361/16 verifier_sdiv/SDIV32, non-zero imm divisor, check 8 @unpriv:OK #361/17 verifier_sdiv/SDIV32, non-zero reg divisor, check 1:OK #361/18 verifier_sdiv/SDIV32, non-zero reg divisor, check 1 @unpriv:OK #361/19 verifier_sdiv/SDIV32, non-zero reg divisor, check 2:OK #361/20 verifier_sdiv/SDIV32, non-zero reg divisor, check 2 @unpriv:OK #361/21 verifier_sdiv/SDIV32, non-zero reg divisor, check 3:OK #361/22 verifier_sdiv/SDIV32, non-zero reg divisor, check 3 @unpriv:OK #361/23 verifier_sdiv/SDIV32, non-zero reg divisor, check 4:OK #361/24 verifier_sdiv/SDIV32, non-zero reg divisor, check 4 @unpriv:OK #361/25 verifier_sdiv/SDIV32, non-zero reg divisor, check 5:OK #361/26 verifier_sdiv/SDIV32, non-zero reg divisor, check 5 @unpriv:OK #361/27 verifier_sdiv/SDIV32, non-zero reg divisor, check 6:OK #361/28 verifier_sdiv/SDIV32, non-zero reg divisor, check 6 @unpriv:OK #361/29 verifier_sdiv/SDIV32, non-zero reg divisor, check 7:OK #361/30 verifier_sdiv/SDIV32, non-zero reg divisor, check 7 @unpriv:OK #361/31 verifier_sdiv/SDIV32, non-zero reg divisor, check 8:OK #361/32 verifier_sdiv/SDIV32, non-zero reg divisor, check 8 @unpriv:OK #361/33 verifier_sdiv/SDIV64, non-zero imm divisor, check 1:OK #361/34 verifier_sdiv/SDIV64, non-zero imm divisor, check 1 @unpriv:OK #361/35 verifier_sdiv/SDIV64, non-zero imm divisor, check 2:OK #361/36 verifier_sdiv/SDIV64, non-zero imm divisor, check 2 @unpriv:OK #361/37 verifier_sdiv/SDIV64, non-zero imm divisor, check 3:OK #361/38 verifier_sdiv/SDIV64, non-zero imm divisor, check 3 @unpriv:OK #361/39 verifier_sdiv/SDIV64, non-zero imm divisor, check 4:OK #361/40 verifier_sdiv/SDIV64, non-zero imm divisor, check 4 @unpriv:OK #361/41 verifier_sdiv/SDIV64, non-zero imm divisor, check 5:OK #361/42 verifier_sdiv/SDIV64, non-zero imm divisor, check 5 @unpriv:OK #361/43 verifier_sdiv/SDIV64, non-zero imm divisor, check 6:OK #361/44 verifier_sdiv/SDIV64, non-zero imm divisor, check 6 @unpriv:OK #361/45 verifier_sdiv/SDIV64, non-zero reg divisor, check 1:OK #361/46 verifier_sdiv/SDIV64, non-zero reg divisor, check 1 @unpriv:OK #361/47 verifier_sdiv/SDIV64, non-zero reg divisor, check 2:OK #361/48 verifier_sdiv/SDIV64, non-zero reg divisor, check 2 @unpriv:OK #361/49 verifier_sdiv/SDIV64, non-zero reg divisor, check 3:OK #361/50 verifier_sdiv/SDIV64, non-zero reg divisor, check 3 @unpriv:OK #361/51 verifier_sdiv/SDIV64, non-zero reg divisor, check 4:OK #361/52 verifier_sdiv/SDIV64, non-zero reg divisor, check 4 @unpriv:OK #361/53 verifier_sdiv/SDIV64, non-zero reg divisor, check 5:OK #361/54 verifier_sdiv/SDIV64, non-zero reg divisor, check 5 @unpriv:OK #361/55 verifier_sdiv/SDIV64, non-zero reg divisor, check 6:OK #361/56 verifier_sdiv/SDIV64, non-zero reg divisor, check 6 @unpriv:OK #361/57 verifier_sdiv/SMOD32, non-zero imm divisor, check 1:OK #361/58 verifier_sdiv/SMOD32, non-zero imm divisor, check 1 @unpriv:OK #361/59 verifier_sdiv/SMOD32, non-zero imm divisor, check 2:OK #361/60 verifier_sdiv/SMOD32, non-zero imm divisor, check 2 @unpriv:OK #361/61 verifier_sdiv/SMOD32, non-zero imm divisor, check 3:OK #361/62 verifier_sdiv/SMOD32, non-zero imm divisor, check 3 @unpriv:OK #361/63 verifier_sdiv/SMOD32, non-zero imm divisor, check 4:OK #361/64 verifier_sdiv/SMOD32, non-zero imm divisor, check 4 @unpriv:OK #361/65 verifier_sdiv/SMOD32, non-zero imm divisor, check 5:OK #361/66 verifier_sdiv/SMOD32, non-zero imm divisor, check 5 @unpriv:OK #361/67 verifier_sdiv/SMOD32, non-zero imm divisor, check 6:OK #361/68 verifier_sdiv/SMOD32, non-zero imm divisor, check 6 @unpriv:OK #361/69 verifier_sdiv/SMOD32, non-zero reg divisor, check 1:OK #361/70 verifier_sdiv/SMOD32, non-zero reg divisor, check 1 @unpriv:OK #361/71 verifier_sdiv/SMOD32, non-zero reg divisor, check 2:OK #361/72 verifier_sdiv/SMOD32, non-zero reg divisor, check 2 @unpriv:OK #361/73 verifier_sdiv/SMOD32, non-zero reg divisor, check 3:OK #361/74 verifier_sdiv/SMOD32, non-zero reg divisor, check 3 @unpriv:OK #361/75 verifier_sdiv/SMOD32, non-zero reg divisor, check 4:OK #361/76 verifier_sdiv/SMOD32, non-zero reg divisor, check 4 @unpriv:OK #361/77 verifier_sdiv/SMOD32, non-zero reg divisor, check 5:OK #361/78 verifier_sdiv/SMOD32, non-zero reg divisor, check 5 @unpriv:OK #361/79 verifier_sdiv/SMOD32, non-zero reg divisor, check 6:OK #361/80 verifier_sdiv/SMOD32, non-zero reg divisor, check 6 @unpriv:OK #361/81 verifier_sdiv/SMOD64, non-zero imm divisor, check 1:OK #361/82 verifier_sdiv/SMOD64, non-zero imm divisor, check 1 @unpriv:OK #361/83 verifier_sdiv/SMOD64, non-zero imm divisor, check 2:OK #361/84 verifier_sdiv/SMOD64, non-zero imm divisor, check 2 @unpriv:OK #361/85 verifier_sdiv/SMOD64, non-zero imm divisor, check 3:OK #361/86 verifier_sdiv/SMOD64, non-zero imm divisor, check 3 @unpriv:OK #361/87 verifier_sdiv/SMOD64, non-zero imm divisor, check 4:OK #361/88 verifier_sdiv/SMOD64, non-zero imm divisor, check 4 @unpriv:OK #361/89 verifier_sdiv/SMOD64, non-zero imm divisor, check 5:OK #361/90 verifier_sdiv/SMOD64, non-zero imm divisor, check 5 @unpriv:OK #361/91 verifier_sdiv/SMOD64, non-zero imm divisor, check 6:OK #361/92 verifier_sdiv/SMOD64, non-zero imm divisor, check 6 @unpriv:OK #361/93 verifier_sdiv/SMOD64, non-zero imm divisor, check 7:OK #361/94 verifier_sdiv/SMOD64, non-zero imm divisor, check 7 @unpriv:OK #361/95 verifier_sdiv/SMOD64, non-zero imm divisor, check 8:OK #361/96 verifier_sdiv/SMOD64, non-zero imm divisor, check 8 @unpriv:OK #361/97 verifier_sdiv/SMOD64, non-zero reg divisor, check 1:OK #361/98 verifier_sdiv/SMOD64, non-zero reg divisor, check 1 @unpriv:OK #361/99 verifier_sdiv/SMOD64, non-zero reg divisor, check 2:OK #361/100 verifier_sdiv/SMOD64, non-zero reg divisor, check 2 @unpriv:OK #361/101 verifier_sdiv/SMOD64, non-zero reg divisor, check 3:OK #361/102 verifier_sdiv/SMOD64, non-zero reg divisor, check 3 @unpriv:OK #361/103 verifier_sdiv/SMOD64, non-zero reg divisor, check 4:OK #361/104 verifier_sdiv/SMOD64, non-zero reg divisor, check 4 @unpriv:OK #361/105 verifier_sdiv/SMOD64, non-zero reg divisor, check 5:OK #361/106 verifier_sdiv/SMOD64, non-zero reg divisor, check 5 @unpriv:OK #361/107 verifier_sdiv/SMOD64, non-zero reg divisor, check 6:OK #361/108 verifier_sdiv/SMOD64, non-zero reg divisor, check 6 @unpriv:OK #361/109 verifier_sdiv/SMOD64, non-zero reg divisor, check 7:OK #361/110 verifier_sdiv/SMOD64, non-zero reg divisor, check 7 @unpriv:OK #361/111 verifier_sdiv/SMOD64, non-zero reg divisor, check 8:OK #361/112 verifier_sdiv/SMOD64, non-zero reg divisor, check 8 @unpriv:OK #361/113 verifier_sdiv/SDIV32, zero divisor:OK #361/114 verifier_sdiv/SDIV32, zero divisor @unpriv:OK #361/115 verifier_sdiv/SDIV64, zero divisor:OK #361/116 verifier_sdiv/SDIV64, zero divisor @unpriv:OK #361/117 verifier_sdiv/SMOD32, zero divisor:OK #361/118 verifier_sdiv/SMOD32, zero divisor @unpriv:OK #361/119 verifier_sdiv/SMOD64, zero divisor:OK #361/120 verifier_sdiv/SMOD64, zero divisor @unpriv:OK #361 verifier_sdiv:OK Summary: 5/163 PASSED, 0 SKIPPED, 0 FAILED # ./test_progs -t ldsx_insn test_map_val_and_probed_memory:PASS:test_ldsx_insn__open 0 nsec test_map_val_and_probed_memory:PASS:test_ldsx_insn__load 0 nsec libbpf: prog 'test_ptr_struct_arg': failed to attach: ERROR: strerror_r(-524)=22 libbpf: prog 'test_ptr_struct_arg': failed to auto-attach: -524 test_map_val_and_probed_memory:FAIL:test_ldsx_insn__attach unexpected error: -524 (errno 524) #116/1 ldsx_insn/map_val and probed_memory:FAIL #116/2 ldsx_insn/ctx_member_sign_ext:OK #116/3 ldsx_insn/ctx_member_narrow_sign_ext:OK #116 ldsx_insn:FAIL All error logs: test_map_val_and_probed_memory:PASS:test_ldsx_insn__open 0 nsec test_map_val_and_probed_memory:PASS:test_ldsx_insn__load 0 nsec libbpf: prog 'test_ptr_struct_arg': failed to attach: ERROR: strerror_r(-524)=22 libbpf: prog 'test_ptr_struct_arg': failed to auto-attach: -524 test_map_val_and_probed_memory:FAIL:test_ldsx_insn__attach unexpected error: -524 (errno 524) #116/1 ldsx_insn/map_val and probed_memory:FAIL #116 ldsx_insn:FAIL Summary: 0/2 PASSED, 0 SKIPPED, 1 FAILED Signed-off-by: Hengqi Chen --- tools/testing/selftests/bpf/progs/test_ldsx_insn.c | 3 ++- tools/testing/selftests/bpf/progs/verifier_bswap.c | 3 ++- tools/testing/selftests/bpf/progs/verifier_gotol.c | 3 ++- tools/testing/selftests/bpf/progs/verifier_ldsx.c | 3 ++- tools/testing/selftests/bpf/progs/verifier_movsx.c | 3 ++- tools/testing/selftests/bpf/progs/verifier_sdiv.c | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/test_ldsx_insn.c b/tools/testing/selftests/bpf/progs/test_ldsx_insn.c index 3ddcb3777912..2a2a942737d7 100644 --- a/tools/testing/selftests/bpf/progs/test_ldsx_insn.c +++ b/tools/testing/selftests/bpf/progs/test_ldsx_insn.c @@ -7,7 +7,8 @@ #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \ - defined(__TARGET_ARCH_s390)) && __clang_major__ >= 18 + defined(__TARGET_ARCH_s390) || defined(__TARGET_ARCH_loongarch)) && \ + __clang_major__ >= 18 const volatile int skip = 0; #else const volatile int skip = 1; diff --git a/tools/testing/selftests/bpf/progs/verifier_bswap.c b/tools/testing/selftests/bpf/progs/verifier_bswap.c index 107525fb4a6a..e61755656e8d 100644 --- a/tools/testing/selftests/bpf/progs/verifier_bswap.c +++ b/tools/testing/selftests/bpf/progs/verifier_bswap.c @@ -6,7 +6,8 @@ #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \ - defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \ + defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) || \ + defined(__TARGET_ARCH_loongarch)) && \ __clang_major__ >= 18 SEC("socket") diff --git a/tools/testing/selftests/bpf/progs/verifier_gotol.c b/tools/testing/selftests/bpf/progs/verifier_gotol.c index 9f202eda952f..d1edbcff9a18 100644 --- a/tools/testing/selftests/bpf/progs/verifier_gotol.c +++ b/tools/testing/selftests/bpf/progs/verifier_gotol.c @@ -6,7 +6,8 @@ #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \ - defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \ + defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) || \ + defined(__TARGET_ARCH_loongarch)) && \ __clang_major__ >= 18 SEC("socket") diff --git a/tools/testing/selftests/bpf/progs/verifier_ldsx.c b/tools/testing/selftests/bpf/progs/verifier_ldsx.c index 375525329637..d4427d8e1217 100644 --- a/tools/testing/selftests/bpf/progs/verifier_ldsx.c +++ b/tools/testing/selftests/bpf/progs/verifier_ldsx.c @@ -6,7 +6,8 @@ #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \ - defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \ + defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) || \ + defined(__TARGET_ARCH_loongarch)) && \ __clang_major__ >= 18 SEC("socket") diff --git a/tools/testing/selftests/bpf/progs/verifier_movsx.c b/tools/testing/selftests/bpf/progs/verifier_movsx.c index b2a04d1179d0..cbb9d6714f53 100644 --- a/tools/testing/selftests/bpf/progs/verifier_movsx.c +++ b/tools/testing/selftests/bpf/progs/verifier_movsx.c @@ -6,7 +6,8 @@ #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \ - defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \ + defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) || \ + defined(__TARGET_ARCH_loongarch)) && \ __clang_major__ >= 18 SEC("socket") diff --git a/tools/testing/selftests/bpf/progs/verifier_sdiv.c b/tools/testing/selftests/bpf/progs/verifier_sdiv.c index 8fc5174808b2..2a2271cf0294 100644 --- a/tools/testing/selftests/bpf/progs/verifier_sdiv.c +++ b/tools/testing/selftests/bpf/progs/verifier_sdiv.c @@ -6,7 +6,8 @@ #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \ - defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \ + defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) || \ + defined(__TARGET_ARCH_loongarch)) && \ __clang_major__ >= 18 SEC("socket")