Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1813263lqp; Sat, 23 Mar 2024 09:43:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWR93b7+gCegEGEbXVaRlYl93Ps8C0o2qgoL6XZ4A9VS//uwz9gQzfaizu4OiDejkOSgqWSAmUBAKxYOgrf8AJwH19PVAJT3krD/W97GQ== X-Google-Smtp-Source: AGHT+IFJURcN1k1YpM10deqPiKoSNIvLU6DTf+Qznx8EAWLspVR2ludavu/qwU27l8ZJcO8qtmh9 X-Received: by 2002:a17:902:e806:b0:1e0:abeb:8fb4 with SMTP id u6-20020a170902e80600b001e0abeb8fb4mr1373778plg.41.1711212238432; Sat, 23 Mar 2024 09:43:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711212238; cv=pass; d=google.com; s=arc-20160816; b=KQUpaoSw57OZr0h/7WL+JjU3buJdt9v0oquh62ZNXJJV+YuMdNvlKV39Y6Tb9G+AoT 5JmOc1mR1neOq7nEmA7hd1C+GZJSkscRJTTJJH2e/FB2uKlGkg4LU8ZtuzYuEnRXfbNs x5GZTtzoDEb0pd9JUOdUMXqLaAesUmqGwzpgTNbsBmMqWuB1Gpt6mV6TID6dKS3cMBEU jWC17d16pZa2pz9jcjpKqoZUDS+cYdy6lDYm3uIW+MQGmdZHxuBzmBj0oXLuypgjd11K siS8HA/joyzgsvqiR0rsRJVbyA5HJY3wOrnBiQ5FoMHSxbzSgZGAcGrdrc1ESp9e2nqS Z54g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:cc:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=3BJaKf3jF6i/zF2C09Z5vKL3hxrBZaFuwlSzuCo6Z6g=; fh=YQpeMXqjscUXUUhoUK3pDTjy8pXFkFHbm37DrX0kOyI=; b=dwEzua7dWVWfQK4qRtvW5BmojKzWxfEqXyNbo7aYSmZtPbooctBX0WOweyPw31cqIp +NR8RefIC19VB8k1kWoRglvxnfba10Khe9ievbxixKgkc6AjRRwM+wVLUUAcy25Q2frM 9J66YEG5AQ8EB8+xc7ULmDJyRz2vw9S81ZwCzyRg8LMb5srADGghl8QkytNkqB/oFMBT ygrwypdQpHrT1aTnbI2Ci/bpw9qhBQJEjxiEK7DIU6Fd0gLam55T7L0wna8KctmPI5/3 EQYagVPwAVS+NK/LkesaZ+xuci9MuiJlWQSyKcU25TBq6+RUHzCFaYhUVEHs2uPmAh6K 3nQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-112411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q17-20020a17090311d100b001df00895ab8si1864024plh.123.2024.03.23.09.43.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 09:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-112411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1A5532825B7 for ; Sat, 23 Mar 2024 16:43:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F3F2481DD; Sat, 23 Mar 2024 16:43:50 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 5A5557483; Sat, 23 Mar 2024 16:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711212229; cv=none; b=nD7WKWfeW8CoWzKu/EaOqW0V0TXjaPR7vgtN6Q9kEuPriuZF/eFALrk/RLgPU//9MhBjXWwN2U3lkvEZJ1CC7niiU6PcJKO/gFlz3/15oiuZuTGQM/mg3UDcAyIvbY5EmS9xh4Ho8Y72ZqMkkw4LHAZA//DDBem4fIES0atdeRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711212229; c=relaxed/simple; bh=ILndtPVVRX8gDHNgqvEeObtv64F5TztKoHFIV9p/3oA=; h=Message-ID:Date:MIME-Version:Subject:To:References:CC:From: In-Reply-To:Content-Type; b=tc1iXGOrOIKzqS+1/5kkoolt6fgUWUqIwJzDSui4BLo1888VQvZhlaotQN1KKtQFX78kKw5jl0KokRaokIEiHdjGMOLJlY3ZMYqWyHFWh0DeU2o5yvYMbt7sVd/5XLg/Q+xfi6sQsEJfmX+sZdPH+rlHeHX5vAij4ThYa1AxL2k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V24hG5Fmtz2BhGd; Sun, 24 Mar 2024 00:41:02 +0800 (CST) Received: from kwepemd100009.china.huawei.com (unknown [7.221.188.135]) by mail.maildlp.com (Postfix) with ESMTPS id F3E161A0172; Sun, 24 Mar 2024 00:43:38 +0800 (CST) Received: from [10.67.109.184] (10.67.109.184) by kwepemd100009.china.huawei.com (7.221.188.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Sun, 24 Mar 2024 00:43:38 +0800 Message-ID: <3e07fb21-da08-4183-8bd4-064b519c7ddb@huawei.com> Date: Sun, 24 Mar 2024 00:43:37 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH bpf-next 2/2] bpf,riscv: Implement bpf_addr_space_cast instruction Content-Language: en-US To: Puranjay Mohan References: <20240323154652.54572-1-puranjay12@gmail.com> <20240323154652.54572-3-puranjay12@gmail.com> CC: Puranjay Mohan , 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?QmrDtnJuIFTDtnBlbA==?= , Luke Nelson , Xi Wang , Paul Walmsley , Palmer Dabbelt , Albert Ou , , , From: Pu Lehui In-Reply-To: <20240323154652.54572-3-puranjay12@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemd100009.china.huawei.com (7.221.188.135) 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 > + 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