From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00C4EC3F2DA for ; Tue, 3 Mar 2020 07:50:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF4C0215A4 for ; Tue, 3 Mar 2020 07:50:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C/AVVaOw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727699AbgCCHul (ORCPT ); Tue, 3 Mar 2020 02:50:41 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:35598 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbgCCHuk (ORCPT ); Tue, 3 Mar 2020 02:50:40 -0500 Received: by mail-qk1-f195.google.com with SMTP id 145so2518325qkl.2; Mon, 02 Mar 2020 23:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=BhbULqBIdorw/yrEs1cpQIXkzYiAMwapHjsDli7SNmE=; b=C/AVVaOwRUMOQcM2QkfZkYxtY1XRUW6kdvKrulJevxuG6/m6BCkwSOmh1vkwJEattR K2cO/soZ0G4mS1yCz5uEbc8M6tRfZ8hDc/4UgnsLxewUBVG7PW1mtlJmH4yuqpWG2HFL 0BOR7EE0z6q/Rn2e6tG3jiuBmPno7lfidiNSVBrakQFDxRCFkjk+vUYldkXeS6Wq7El7 YtONSsi4xMbYIPuq9dTkIRO+aqy/6IJrFYDlKGUOzk2CK7AbniZJYRILqKFV5chwLdJC /UhsBX5zUY7GtsKdUX3dfz+Frx7mfxgW4Y5BCoUzACYteQqmkg+82P8OkYuBUbuCv/N5 g2jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=BhbULqBIdorw/yrEs1cpQIXkzYiAMwapHjsDli7SNmE=; b=UlKeKfjl8/Hv0Q88eFqU9cN/p63zyRK1yl7npoPcRYJI0/vJOVsQd4MLAsK4Y5DquV A/DV4A1ZMknEa9+nbjvMfdxw7GfiOFbwNrPO2rlKmHLtkesnVbYzpb5Ckck7qTqx4FLF gulI2VCc5dU6nMeabfzOFu5NbU0inv38gdX7ORF6sIarh/D8nDFVZEC3Dd60MH3ggaKc 2W9vA5RdxCUzrIZX5A7pheOouhRy6dH0rRY7dmfkcaMQsNZ1aJs9Od//aU+D8NGhOisc 8IjhHBmuMmXU1DsYECLEwXi3nRjX1ipzYdNzE6hgPtriSWE8iZtjHi6Z/sS7/i+hOzWy zqsA== X-Gm-Message-State: ANhLgQ3HrFGIS/A7cVgQOuonp6PjKAIOWF9v5OXJVcZdMyrJP9zetjfk qUdbSPooiv3RbH8XH+CrTg6VJnSlp9yERI6pM8c= X-Google-Smtp-Source: ADFU+vvnqa4SHi+3vaAmK9vIruVCzKAjusAJShsWdCzHBDnIgJIuzP96vxeO5VLCbYsVUfv798aIL4vqMNwbrS/cGx4= X-Received: by 2002:a37:8046:: with SMTP id b67mr2937683qkd.218.1583221839180; Mon, 02 Mar 2020 23:50:39 -0800 (PST) MIME-Version: 1.0 References: <20200303005035.13814-1-luke.r.nels@gmail.com> <20200303005035.13814-2-luke.r.nels@gmail.com> In-Reply-To: <20200303005035.13814-2-luke.r.nels@gmail.com> From: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Date: Tue, 3 Mar 2020 08:50:28 +0100 Message-ID: Subject: Re: [PATCH bpf-next v4 1/4] riscv, bpf: move common riscv JIT code to header To: Luke Nelson Cc: bpf , Luke Nelson , Jonathan Corbet , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , "David S. Miller" , Jakub Kicinski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Xi Wang , Mauro Carvalho Chehab , Stephen Hemminger , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron , Andy Shevchenko , linux-doc@vger.kernel.org, LKML , Netdev , linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, 3 Mar 2020 at 01:50, Luke Nelson wrote= : > > This patch factors out code that can be used by both the RV64 and RV32 > JITs to a common header. > > Rename rv_sb_insn/rv_uj_insn to rv_b_insn/rv_j_insn to match the RISC-V > specification. > Thanks for clearing this up! > Co-developed-by: Xi Wang > Signed-off-by: Xi Wang > Signed-off-by: Luke Nelson > --- > We could put more code into a shared .c file in the future (e.g., > build_body). It seems to make sense right now to first factor > common data structures and helper functions into a header. Yes, I agree. > --- > arch/riscv/net/bpf_jit.h | 504 ++++++++++++++++++++++++++++++++++ > arch/riscv/net/bpf_jit_comp.c | 443 +----------------------------- > 2 files changed, 505 insertions(+), 442 deletions(-) > create mode 100644 arch/riscv/net/bpf_jit.h > > diff --git a/arch/riscv/net/bpf_jit.h b/arch/riscv/net/bpf_jit.h > new file mode 100644 > index 000000000000..6f45f95bc4d0 > --- /dev/null > +++ b/arch/riscv/net/bpf_jit.h > @@ -0,0 +1,504 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Common functionality for RV32 and RV64 BPF JIT compilers > + * > + * Copyright (c) 2019 Bj=C3=B6rn T=C3=B6pel > + * Copyright (c) 2020 Luke Nelson > + * Copyright (c) 2020 Xi Wang I'm no lawyer, so this is more of a question; You've pulled out code into a header, and renamed two functions. Does that warrant copyright line additions? Should my line be removed? > + */ > + > +#ifndef _BPF_JIT_H > +#define _BPF_JIT_H > + > +#include > +#include > +#include [...] > + > +static inline u32 rv_amoadd_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) > +{ > + return rv_amo_insn(0, aq, rl, rs2, rs1, 2, rd, 0x2f); > +} > + > +#if __riscv_xlen =3D=3D 64 Please remove this. If the inlined functions are not used, they're not part of the binary. This adds complexity to the code, and without it we can catch build errors early on! > + > +/* RV64-only instructions. */ > + [...] > +{ > + return rv_amo_insn(0, aq, rl, rs2, rs1, 3, rd, 0x2f); > +} > + > +#endif /* __riscv_xlen =3D=3D 64 */ ...and this. Thanks! Bj=C3=B6rn