Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3023436rdb; Tue, 12 Sep 2023 22:18:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmB+ubcNXsoNkVrXvU6igUAMg10PGTSCMKdUZeiozxyPKm3/W2Tcvh6izB00+tOG0CwSaj X-Received: by 2002:a05:6a00:1343:b0:68e:36b1:3d85 with SMTP id k3-20020a056a00134300b0068e36b13d85mr2100685pfu.33.1694582293724; Tue, 12 Sep 2023 22:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694582293; cv=none; d=google.com; s=arc-20160816; b=DhViB22CO/priZ4zEpSQWw5hyt8qZyBsma04LUfiS/6uWo3zc3DKFvUg1NWB2SsaJO jxgptGz9hegGtPAhhEsyhqIFyvYpZ/26BoZgFoCDpxYfo6xjCRjVVqswDDzSBZ28wmaS 3fOS70YaSJQ0gaYvL0zJ+XbNTGoGusIcCBqzOwfTqRhWrKY9ldH4E+MaqvTxZNXPs+4y RbCV8gGJVPOe8YJtI2NONs/nk2dwp1jpfCowZXFw0IK3Grw4EDMqsktzdhPN45MNE2p0 /PFJJkliqLXInrTusHURPD6cR7ujTBebJvTGPqYeOX446KuPw8uRvAhVGlExRyYDbL4G RmoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qhUNqTKNJ5t40WxcJkQJJc6NwQozn+LNI3JL0/ULous=; fh=hMBEqt/pVmrAPCFGyVmCH7huCf/AuQCDaKKyFO1Q7X0=; b=lrCvL641F2pT26ibakOfMrqpt19HcNRF24D72eHI8wL4zkhb6+1sjgzchMEI09KCG6 DAkn3m+L0w44zseFwf3Jbu6PoJGuJOZyT405iDZepWaDaoPt8wykAI1K4Lj1ad3RVpon 4asMMl0pNjqp/JGZ/AOeq1XiUXzuoJVYBCJzWP+1Z1WDx3d9vP4+uC21yV9SO5Hklxop /VcOycrozoIS+SlyRsc4e6hZZYL5Uk41K6D+0aAw+flbezrBr850o1gQ/hnKIaJkZYIz ll9t6BEIAXXvsjqF+p/67cETJfwwLSR02p8ZCqZTfmqMwuF96PlcwxV2yphuW/BwHmNA B9kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=dsh8CodR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id cm26-20020a056a00339a00b006901504b6a3si448913pfb.153.2023.09.12.22.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 22:18:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=dsh8CodR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 233E883EE9E8; Tue, 12 Sep 2023 15:47:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237842AbjILWrP (ORCPT + 99 others); Tue, 12 Sep 2023 18:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237825AbjILWrG (ORCPT ); Tue, 12 Sep 2023 18:47:06 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1153210F4; Tue, 12 Sep 2023 15:47:02 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31c65820134so5762419f8f.1; Tue, 12 Sep 2023 15:47:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694558820; x=1695163620; 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=qhUNqTKNJ5t40WxcJkQJJc6NwQozn+LNI3JL0/ULous=; b=dsh8CodRO/rjPAwHsY5JMfDmx8BK07PZ4jrSu27Py0Tef5Mr+XoxzwVHp7iuX7a51c Dvikoo4hYXxMHrL8vcxwFNL8zxnaLK6MTHe/4xOQqWoHVBm4WgDyJhCBNXN730LSYUgk SF2JWi3oU99EMGbDqsVqFrDp8liz8DHqJV3hPMhNuN0V87V749ae1wgCGtkDHlBT/JHP fbRNxYZrDe2FcS9TZvws1003xu03L32J2uo/Q0k+OZtsDkCenl7mEk8qnYqcqaYg/gSM WJNk0DaBfxkneFNf6zZmFyrhqimnuQX7IElCVRKWBCaNvaV5/gXp3KBD1+i7G86O5htO 1ERg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694558820; x=1695163620; 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=qhUNqTKNJ5t40WxcJkQJJc6NwQozn+LNI3JL0/ULous=; b=sWI9ps6tej+A/643AqH/qPTq7bSRsWooXjxvOwPmFleT1zV/3KDsLPwUQQQ93Xtons Uwea9uDI5mYZBdmm2xNNKUlTdQgssv44a35Lb+2yyIfEuSf0RFWiJG5TUraqjXfS7X8q bbmhCisDBa4RiR31Ub41DgwEyzpY70T6YxORUzFEULhd4B9UFSVduF372VIUqwEQGu3I NJKngj2bwhmFH7VLVkCVHHsmcml9zcfnkDkz5LZGbinpbMLtNUV70xQbezaNCRWpTXo5 la9/i1yB6McKi+CemJZvQd38uANxuEwsVicUBPwgIQav0+8eQtsYOwkyIQtlFllFkxiU Fqsg== X-Gm-Message-State: AOJu0YyS1ChUxTAQZCE9oQNPsTcPdAF9R7btvAuGG9ezuKf1hhLrx4uZ hCw+QijRnbYnW0OegWemGQw= X-Received: by 2002:a5d:628c:0:b0:319:7a9f:c63 with SMTP id k12-20020a5d628c000000b003197a9f0c63mr718103wru.50.1694558820430; Tue, 12 Sep 2023 15:47:00 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 15:47:00 -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 4/6] bpf, powerpc32: Always zero extend for LDX Date: Tue, 12 Sep 2023 22:46:52 +0000 Message-Id: <20230912224654.6556-5-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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 15:47:16 -0700 (PDT) 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/powerpc/net/bpf_jit_comp32.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c index 7f91ea064c08..0a952a2cfaac 100644 --- a/arch/powerpc/net/bpf_jit_comp32.c +++ b/arch/powerpc/net/bpf_jit_comp32.c @@ -936,14 +936,13 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context * PPC_BCC_SHORT(COND_GT, (ctx->idx + 4) * 4); EMIT(PPC_RAW_LI(dst_reg, 0)); /* - * For BPF_DW case, "li reg_h,0" would be needed when - * !fp->aux->verifier_zext. Emit NOP otherwise. + * For BPF_DW case, "li reg_h,0" would be needed emit NOP otherwise. * * Note that "li reg_h,0" is emitted for BPF_B/H/W case, * if necessary. So, jump there insted of emitting an * additional "li reg_h,0" instruction. */ - if (size == BPF_DW && !fp->aux->verifier_zext) + if (size == BPF_DW) EMIT(PPC_RAW_LI(dst_reg_h, 0)); else EMIT(PPC_RAW_NOP()); @@ -974,7 +973,7 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context * break; } - if (size != BPF_DW && !fp->aux->verifier_zext) + if (size != BPF_DW) EMIT(PPC_RAW_LI(dst_reg_h, 0)); if (BPF_MODE(code) == BPF_PROBE_MEM) { @@ -982,20 +981,12 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context * int jmp_off = 4; /* - * In case of BPF_DW, two lwz instructions are emitted, one - * for higher 32-bit and another for lower 32-bit. So, set - * ex->insn to the first of the two and jump over both - * instructions in fixup. - * - * Similarly, with !verifier_zext, two instructions are - * emitted for BPF_B/H/W case. So, set ex->insn to the - * instruction that could fault and skip over both - * instructions. + * Two instructions are emitted for LDX. + * So, set ex->insn to the instruction that could fault and skip + * over both instructions. */ - if (size == BPF_DW || !fp->aux->verifier_zext) { - insn_idx -= 1; - jmp_off += 4; - } + insn_idx -= 1; + jmp_off += 4; ret = bpf_add_extable_entry(fp, image, pass, ctx, insn_idx, jmp_off, dst_reg); -- 2.39.2