From patchwork Tue Sep 12 22:46:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puranjay Mohan X-Patchwork-Id: 13382267 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27134EE49B7 for ; Tue, 12 Sep 2023 22:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237815AbjILWrE (ORCPT ); Tue, 12 Sep 2023 18:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237813AbjILWrD (ORCPT ); Tue, 12 Sep 2023 18:47:03 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43F4510EF; Tue, 12 Sep 2023 15:46:59 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-403012f27e1so42464965e9.1; Tue, 12 Sep 2023 15:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694558817; x=1695163617; 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=Vapbmpx4kHHnDeZPSymjWm+kxhmkjrMGYPDoYN863/0=; b=KvwGakzvA8fZIvgUYktGJpztbNfYPIIkemd9w75oQY9amw3HurQ4ojrzlyKVkgytH6 wN/I9Xls1IogYeV2Gzmjyy99uBC8gycwmzmzd5ZUey1pAjmvM6r1mlQ7VHTDY/O7t1Go 9RAh6BYAZR041009d3mspkjKXt3FI68FWzdkIDjJLNImRXILAjYtvMFrLOJ2bw9TY8w8 8FloAVbQy8+Zho+4DOQv2YsNCTPo1bFW5k24DD9K87EhyEf5XWyU6k5sCBhGpuwfyD8F +UkyJAJF9RXoXHhXwng3HuX2AoGbnSzbEFC766Mziexjn5Rr6ECjAoDhqppBGqBu3b6/ MScQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694558817; x=1695163617; 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=Vapbmpx4kHHnDeZPSymjWm+kxhmkjrMGYPDoYN863/0=; b=E6kZPQleAdzqVX4UPLHtNBIrdAcvC2oxwqRHbRNMfbVTR+Htj5oAcU4tWUqedMgJTq fas0tpW/sqsgeX+0hdkXxjp5wWS68/F/7AJGGptVJw1AuSbs9uokyyZIAHbi85bJP4AH +1ijKm9e88Pvj8FGf+JZQCGRtYk6UyRwiaYcjGk6WCCW2sZ2SReTGDnywCcAU4P0JZMO EP2AJWxMTCLwer6D7wLZjZZq0VeudTqEUefjjdy45jPN+EmAIbtzUNbKj2UTEenQnkQ7 dBKuq6J7Ou+2BRrNqFNCEzDbpDgvhSCjqWx2IBl3AGpPkO6U4amkpLiw1GINV/Y3D7Z1 PIpA== X-Gm-Message-State: AOJu0YzLTFNo7a+K71gCqcV+/9gg2vAKt2mE7n38VyXvE20kaCdSSg7K q05wIgUNA34BCEvrYvQLh9E= X-Google-Smtp-Source: AGHT+IGYaSde42//e2zWhzE0pBMJ3eH7x1xRhsn/tGbjooCPwkOeTE3BOytCJBgEeqN+vRwsYu0ZSg== X-Received: by 2002:adf:f302:0:b0:317:ddd3:1aed with SMTP id i2-20020adff302000000b00317ddd31aedmr616529wro.68.1694558817139; Tue, 12 Sep 2023 15:46:57 -0700 (PDT) Received: from ip-172-31-30-46.eu-west-1.compute.internal (ec2-34-242-166-189.eu-west-1.compute.amazonaws.com. [34.242.166.189]) by smtp.gmail.com with ESMTPSA id e15-20020a5d594f000000b00317df42e91dsm13921794wri.4.2023.09.12.15.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 15:46:56 -0700 (PDT) From: Puranjay Mohan To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shubham Bansal , Russell King , "James E.J. Bottomley" , Helge Deller , "Naveen N. Rao" , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Luke Nelson , Xi Wang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Wang YanQing , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, netdev@vger.kernel.org Cc: puranjay12@gmail.com Subject: [PATCH bpf-next 1/6] bpf, riscv32: Always zero extend for LDX with B/W/H Date: Tue, 12 Sep 2023 22:46:49 +0000 Message-Id: <20230912224654.6556-2-puranjay12@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230912224654.6556-1-puranjay12@gmail.com> References: <20230912224654.6556-1-puranjay12@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org The JITs should not depend on the verifier for zero extending the upper 32 bits of the destination register when loading a byte, half-word, or word. A following patch will make the verifier stop patching zext instructions after LDX. Signed-off-by: Puranjay Mohan --- arch/riscv/net/bpf_jit_comp32.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/riscv/net/bpf_jit_comp32.c b/arch/riscv/net/bpf_jit_comp32.c index 529a83b85c1c..8f8255519ba1 100644 --- a/arch/riscv/net/bpf_jit_comp32.c +++ b/arch/riscv/net/bpf_jit_comp32.c @@ -847,18 +847,15 @@ static int emit_load_r64(const s8 *dst, const s8 *src, s16 off, switch (size) { case BPF_B: emit(rv_lbu(lo(rd), 0, RV_REG_T0), ctx); - if (!ctx->prog->aux->verifier_zext) - emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); + emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); break; case BPF_H: emit(rv_lhu(lo(rd), 0, RV_REG_T0), ctx); - if (!ctx->prog->aux->verifier_zext) - emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); + emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); break; case BPF_W: emit(rv_lw(lo(rd), 0, RV_REG_T0), ctx); - if (!ctx->prog->aux->verifier_zext) - emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); + emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); break; case BPF_DW: emit(rv_lw(lo(rd), 0, RV_REG_T0), ctx);