Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1812306lqp; Sat, 23 Mar 2024 09:41:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaaWeR/iBveWG9Ca5wTgc+VOBPJLIKprSIKmmKxkRn0Zg7j+aW/p+B5gRLNd8kKiH1HtoesgmObpu8YjHxwmy8biUDSgFERauAPAANAQ== X-Google-Smtp-Source: AGHT+IHpgDsnmCDB1+m+O6y4ezzLe3LG5yQhbqFDB+MnKbi6NErUKjXu2JVABPNS2viPSyWeq7hy X-Received: by 2002:a50:9ec2:0:b0:56b:afe0:3070 with SMTP id a60-20020a509ec2000000b0056bafe03070mr1854588edf.19.1711212080599; Sat, 23 Mar 2024 09:41:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711212080; cv=pass; d=google.com; s=arc-20160816; b=Ip1vT7Qwvw9uvmVhLGsapuVh64Z59DwZj6nweFpaeli7bpJMiIwhNaWOK/B91r/qSa XxvFEtc+Uisnqbe1o/aoq/K74NyzNL4Egs/sR4zaVELmNQ0p1bjX9kem4WiQhX2iKoE1 r08HPEug2d9L6oSOMtejgexrAdbvvuA5jwnQv2oNWvNrCYoLlH9OqEHomY4xrALvyed7 f0ASiT10igtsqOYaVzocXRPlV2QcufnaI8y9KvXhqWu9xqepiICTfG238vvsADCmADok nQvzD7gDJ3InNeJlwRo4qO/h536ZcNB8rViibPBm5ewk8CWftsaIrRqGT8fT1j3gn3hN B51A== 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=/aWSy+jKRNanj3DGVMWaciMMoyWLVa5QkGIdAtUWrcQ=; fh=YQpeMXqjscUXUUhoUK3pDTjy8pXFkFHbm37DrX0kOyI=; b=S4WtH4NCR0CX4ndccLz589SPANIgNFXioD9ZYOn00Q9CGXO36pqyf2yRXA3545Lpvu 07nhM8c+NnJQYOSaheseIZF3jS31SL6q3TXKykz4PBzrKg+slFqF5esSKhJyLtASXaUl /CW7UEZgViQglBxkC3EO4BjjElqdSVrt+UongouZ8lEHUGt6j36WaJRZq+0OkXALRSH3 jjB1G6eQ0rMcTQnc4PL7pzf9DK6J8Hnk5TIT9IUsM00s29utwyXYhgSM7qjj7lczR2AN dzwQJgimNXGN0d+DY8C5e6fU00drZvd6rfL35OKOviELLW6oSEZsuD/1LjxZYiNSoUAR nDxg==; 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-112410-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112410-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v20-20020a509554000000b00568c3dbfdbdsi951492eda.585.2024.03.23.09.41.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 09:41:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112410-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-112410-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112410-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 55EF81F219CE for ; Sat, 23 Mar 2024 16:41:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6E1E47A7C; Sat, 23 Mar 2024 16:41:12 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 1187014AA3; Sat, 23 Mar 2024 16:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711212072; cv=none; b=t3l24/4WtxLKnLUtduJweuEYemEv1hoP57aweNO0tM5TKK6YyjycCtzgfpi+iqIUZJOuYBNaoenmlg8j3kNg0BxoaguEJPZWouH3bVnarnZNiM/TR4KxYCQV7cIdSWdMlXNV8OgkO5UYwC98MK6NM45Nagp9gC98mDAfbc4yfJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711212072; c=relaxed/simple; bh=atvZrKiUAUvZM2NuYgS1vjg/ulbuXOUdayurW+vjXAY=; h=Message-ID:Date:MIME-Version:Subject:To:References:CC:From: In-Reply-To:Content-Type; b=U2N3fcye+CUPoudMd6BDvt5waqw6XlQ/gdMVW07PuqQELOnaulkzB7TYnkWRKT7a6itcWwOi/DN8vkV8nG235SdGbrz69lW3t3OitAh9Cnwe+EQdwnN4fzrFzdZtNrxIq11M4T4fBstgzEHI8xB1PqCPZeFtonkjtpRU0EbiATI= 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.191 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 szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V24dB1K99z1h2m2; Sun, 24 Mar 2024 00:38:22 +0800 (CST) Received: from kwepemd100009.china.huawei.com (unknown [7.221.188.135]) by mail.maildlp.com (Postfix) with ESMTPS id 3C7521A0172; Sun, 24 Mar 2024 00:40:58 +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:40:57 +0800 Message-ID: Date: Sun, 24 Mar 2024 00:40:56 +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 1/2] bpf,riscv: Implement PROBE_MEM32 pseudo instructions Content-Language: en-US To: Puranjay Mohan References: <20240323154652.54572-1-puranjay12@gmail.com> <20240323154652.54572-2-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-2-puranjay12@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd100009.china.huawei.com (7.221.188.135) On 2024/3/23 23:46, Puranjay Mohan wrote: > Add support for [LDX | STX | ST], PROBE_MEM32, [B | H | W | DW] [snip] > > #define BPF_FIXUP_OFFSET_MASK GENMASK(26, 0) > #define BPF_FIXUP_REG_MASK GENMASK(31, 27) > +#define DONT_CLEAR 16 /* RV_REG_A6 unused in BPF */ This is a bit misleading. RV_REG_A6 is actually used in riscv64. Maybe "RV_REG_A6 unused in pt_regmap" or change to other register will be better. > > bool ex_handler_bpf(const struct exception_table_entry *ex, [snip] > > stack_adjust = round_up(stack_adjust, 16); > stack_adjust += bpf_stack_adjust; > @@ -1794,6 +1974,10 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog) > emit_sd(RV_REG_SP, store_offset, RV_REG_S6, ctx); > store_offset -= 8; > } > + if (ctx->arena_vm_start) { > + emit_sd(RV_REG_SP, store_offset, RV_REG_S11, ctx); > + store_offset -= 8; > + } I think it's fine to use s7 and keep the original dynamic stack code style. > > emit_addi(RV_REG_FP, RV_REG_SP, stack_adjust, ctx); > > @@ -1807,6 +1991,9 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog) > emit_mv(RV_REG_TCC_SAVED, RV_REG_TCC, ctx); > > ctx->stack_size = stack_adjust; > + > + if (ctx->arena_vm_start) > + emit_imm(RV_REG_S11, ctx->arena_vm_start, ctx); > } > > void bpf_jit_build_epilogue(struct rv_jit_context *ctx) > diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c > index 6b3acac30c06..9b6696b1290a 100644 > --- a/arch/riscv/net/bpf_jit_core.c > +++ b/arch/riscv/net/bpf_jit_core.c > @@ -50,6 +50,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) > int pass = 0, prev_ninsns = 0, i; > struct rv_jit_data *jit_data; > struct rv_jit_context *ctx; > + u64 arena_vm_start; unused variable