Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1815535lqp; Sat, 23 Mar 2024 09:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8bRsf32QAlSN/dsvf2kD9LuwQ0sCT8rH54mEOWktBzC51IDghgllRzz+K2U5SaHYNakzBK1wQwwKizqy1BOPdiKSqiP6hblSxuiWQRQ== X-Google-Smtp-Source: AGHT+IHyNC/tfTkMuBBKmf2F1xCtbWKRXZwO3Ym4EKR9BOxM/L/5+ubvOeAXi9ww47qM5ZbXTKUz X-Received: by 2002:ac8:5c86:0:b0:431:39ab:299b with SMTP id r6-20020ac85c86000000b0043139ab299bmr3047683qta.0.1711212614895; Sat, 23 Mar 2024 09:50:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711212614; cv=pass; d=google.com; s=arc-20160816; b=nwUI49mI0IYT9/hdk4zKapZPpl76Bjc3w8vsJgNi0fqK2RhGXWbckx6fBQA2hROo2H 5W/H01fD1vxVG3hyTxhGO4f8rFvD0TWP8S5GqKfIgZRD9UCBYZc0jD5GpKXDNbZSH0zo /1k2pZjICEisZGHK2NSroamJ9P+vXbteN6294QiaXEtEZcBU7RFszFTWr1AVGFk+MmQq M+MYMCkuTm5Jii3WTVElvp4bX+DDZBH4n7oGSMaG/SB5OfHbPwnXM/anVwxrUGggixs1 KX574ThMKIE12Wy8Kj8GiZApw2eeRjY9i2XF6zsrtf1JGz0qgONPe80VTRGU3rrQD2b5 h7kQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=HnA+iaUYbG4Zl+BUkgQEG3RRYKiMKGopzjr/nHZbKKo=; fh=eXJtaVXWIxP1WjtvjZuAWUoE+WeG4F+yETAlU8V+9Eg=; b=tx/LSirthiTMm6fi0O4qS4iS59f+O+pxmXwzf6R0I6xLq/qVrjXJpCN6Dra2R3xZtz m0AQZ5MicLfmEQ/yHxOZmo9ufs50Wk8pa9RhWrOKKAE+y49YuqlAf9ByIKMGQ+q2Zwcj 4J4FHzo7rV1A6fQJ4jXSOMoa92BM/xWRudU+9F4loe4bQZtUTaspzNexWpqqFiHLmIbI Tn5yZV9Ui5pxcyXBqOeYNI8awdHELunOKzW8PnjpGKhE4sSzprSWd9AtD5ohJPeqh7Pg 1WoR/tCgBdtslU7NqS1tsukWlHrDt0SGPS3bf6MEDHYrpx80SYItbfk47LW4mI55oKl2 IN+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eDA2v0V3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112414-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z9-20020a05622a028900b004313780832asi1941789qtw.15.2024.03.23.09.50.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 09:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112414-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eDA2v0V3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112414-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 95D4B1C20DB2 for ; Sat, 23 Mar 2024 16:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F51D4DA0F; Sat, 23 Mar 2024 16:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eDA2v0V3" Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 E6CE41EB34; Sat, 23 Mar 2024 16:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711212605; cv=none; b=GI/0KMWYractxgM9bztGnRgoCsua57Uv5zPbWMTjREjOFQpfMbvYR2a0F8chdFeIBa0iHk+Q/RUCkoHo+WhAOFOwPYC6dr8Ghgzuvqag2x0nVnzORdyWxNCrXUarr5eBFV9elv/ftn0+TALHnKBj69npKj2bVjVy8rUHjh7Nbbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711212605; c=relaxed/simple; bh=FCa+zdri2byezl1CH5h7lx8PklCLKuJ3W0WVfBHXkvw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=RG1jfLbPLP4cTwO3b9x0GaMACdO/d/xQyw3zzXKQpBXOOHRHAQb8zeFCcpdXgwL1R8mW4qSkQSJPubAcsirmFj0nCuZtRDV2TkjRVPfwoGoPIvlETyDdoZ8tayyKOiFvIxZgr6MmqJH59ZG2Og6vAXRWHXqFEglA336A63Z+0vQ= 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=eDA2v0V3; arc=none smtp.client-ip=209.85.208.169 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 Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d49f7e5c2cso42290921fa.2; Sat, 23 Mar 2024 09:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711212602; x=1711817402; darn=vger.kernel.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=HnA+iaUYbG4Zl+BUkgQEG3RRYKiMKGopzjr/nHZbKKo=; b=eDA2v0V3uFLJXnhQg/C+s18QzPZf9FnMadAXqb1AY6riPaHyTph0t06+NDB4uJielv KrLVehHTA7FNeZO4bow/ag1dm1SCraCpRcr80DC+NbQ5Vr/IpVC+84AV6qskKiemW/f2 2ndlzhr6grhGfokXk+t8NItC+PeY/SpF0wT0XVow8YJYh+U4ebITo/WVJbkK5Tw8OuFb y9HJyYuC+GnjdfUfln4WgI/1T9zU7o5KAxzmpzzpy7tVD3RDP+gX8sw0ySvEoYcJZGoz kxf7K04H0NxO6anBqjxp6UEv9FEeUz5lz+JRTODptUOehsmOFmrYLSxIvBo8TtCMm2/e cYVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711212602; x=1711817402; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HnA+iaUYbG4Zl+BUkgQEG3RRYKiMKGopzjr/nHZbKKo=; b=KGVNgmOLHt1x5GWt2yZ1cUtKS0rSZHAfU0JtW5rox5phn1qF0cKIKb+AgWfU25PvQm FwbKUS4+1DR40BdDtFWmC7x52tPk+WEzsFQ1VoKxdHy34C3fL7jwpziEz/5eKaurvm4m T7tACe4KjydPh0rwnFiBO26Av9uXmdKA4daI8duhe802ckYAhXvMZZTevLLu1O4jEr9u Anjs/vh6Fu5WRLSZwVY298e9VcmXgt2TBKEgetr5iO1VW8uR2kQpSS0WvVhRCh7PUzsp KayZiseJyeZXwO9MKnYj9/wcH2aYzah2vTF6+ctiX7Pg5VF3QM1qTwdBlhnvMFFmXZ6T HilA== X-Forwarded-Encrypted: i=1; AJvYcCX44ZKe3RvPtalnrtL5s7KlgttjQtXPE30j8lNnIf89TK+5SDYkcZSxB2IA5tUetG2deKBfqRacIQcpERYNxJV68wiSg8e+RL3ChBIEiszGarkvaLK9/us+Lr+22dc8HNdB X-Gm-Message-State: AOJu0Yx3RKzCLhBYAFzfwOFigG8SzJA7sp9eFEJn2wWRd3E9uKFu6RBC +TovmdhNmTAZo16IkO3pxxzQYNLv9AU/cQMqC4tC+tzZ4ovPQeZqruK9XG9Rn231vw== X-Received: by 2002:a05:651c:1042:b0:2d4:764f:8256 with SMTP id x2-20020a05651c104200b002d4764f8256mr1716395ljm.53.1711212601733; Sat, 23 Mar 2024 09:50:01 -0700 (PDT) Received: from localhost (54-240-197-231.amazon.com. [54.240.197.231]) by smtp.gmail.com with ESMTPSA id fc19-20020a05600c525300b0041401eb021asm2949255wmb.24.2024.03.23.09.50.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Mar 2024 09:50:01 -0700 (PDT) From: Puranjay Mohan To: Pu Lehui Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , "Eduard Zingerman" , Song Liu , Yonghong Song , John Fastabend , "KP Singh" , Stanislav Fomichev , Hao Luo , Jiri Olsa , =?utf-8?B?QmrDtnJuIFQ=?= =?utf-8?B?w7ZwZWw=?= , Luke Nelson , Xi Wang , Paul Walmsley , Palmer Dabbelt , Albert Ou , bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next 2/2] bpf,riscv: Implement bpf_addr_space_cast instruction In-Reply-To: <3e07fb21-da08-4183-8bd4-064b519c7ddb@huawei.com> References: <20240323154652.54572-1-puranjay12@gmail.com> <20240323154652.54572-3-puranjay12@gmail.com> <3e07fb21-da08-4183-8bd4-064b519c7ddb@huawei.com> Date: Sat, 23 Mar 2024 16:49:54 +0000 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Pu Lehui writes: > On 2024/3/23 23:46, Puranjay Mohan wrote: >> LLVM generates bpf_addr_space_cast instruction while translating > [snip] >> >> /* Convert from ninsns to bytes. */ >> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c >> index f51b832eafb6..3c389e75cb96 100644 >> --- a/arch/riscv/net/bpf_jit_comp64.c >> +++ b/arch/riscv/net/bpf_jit_comp64.c >> @@ -1083,6 +1083,16 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx, >> /* dst = src */ >> case BPF_ALU | BPF_MOV | BPF_X: >> case BPF_ALU64 | BPF_MOV | BPF_X: >> + if (BPF_CLASS(insn->code) == BPF_ALU64 && insn->off == BPF_ADDR_SPACE_CAST && >> + insn->imm == 1U << 16) { >> + emit_mv(RV_REG_T1, rs, ctx); > + emit_zextw(RV_REG_T1, RV_REG_T1, ctx); > combine mv and zextw will be better Do you suggest doing: emit_zextw(RV_REG_T1, rs, ctx); Will do it in next version. >> + emit_imm(rd, (ctx->user_vm_start >> 32) << 32, ctx); >> + emit(rv_beq(RV_REG_T1, RV_REG_ZERO, 4), ctx); >> + emit_or(RV_REG_T1, rd, RV_REG_T1, ctx); >> + emit_mv(rd, RV_REG_T1, ctx); > ditto, but for or and mv How would we combine or and mv? also, we have a beq above and in one case both or and mv should happen, but in other case only mv should happen. Thanks, Puranjay