Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp811994rdb; Sun, 20 Aug 2023 04:10:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsgzcsWB9ckuV2GHn1RcCc11ymeMi5gaKuE8w/Wz7aGPlWyH4P8VUQJY3++XRNTOREzZtp X-Received: by 2002:a17:902:f814:b0:1bf:650b:14fc with SMTP id ix20-20020a170902f81400b001bf650b14fcmr3100131plb.58.1692529840972; Sun, 20 Aug 2023 04:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692529840; cv=none; d=google.com; s=arc-20160816; b=Jb/XaUPl8g2kwwZQMEGNnQlIP8e9sET+Er/BGW7b2ZQ2staDF2SiKlqP8OxXH61XkW LJBrOgfOqV947PMKTpkK4U54xc1vOgR3En3VM30Kbd97BC05LuwnG+TMjNFqvJmY5xGL TlhmXif89p+jys+ynsjkZbjpm9/FrSwceWzHBdVYImKrl8YjrbLRbBp/pVVTa1jMLH8g VMLiRTUYOhs0tptK2RIhJNzpudtM6IGsWg3FhUaXL8njKWduJRlU6ZwNMHR0kUOGxM25 TsvgTs/XBfxWGkVevoW1lgWYhEIg8PLTLbBBmivpeYLSZiAm1Mf7Mdn8a0w7o6ZircPr 05Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=n6zcSzpJqJ0VluuSboFsoL227pWupWbEH5Uz9sUxXS8=; fh=ier2belMs0l5WiyGiKALPD9lsn9rFM/NL3t7aBKRCaM=; b=QG9eBvZ7epkVGGA/mmOLAlN32EUpbfxK1ALCR4Te2kCQe05Sm4bw7OsavLzVXKDGHZ 58E+Ir1MoC3GzzU6bxloi3ANoa7Y+4/Hc5WpKW0+B6n8+Can0XNsxFNisC9kWtwmiaNM z9zcUEQ9ORbLbyQt1/5P5xFhxdUxHzGTeTJKE7XSn+VYOsQ1SObKzCpum48qj3GRPVdk TsUOZ7ybSSNv3rS1uH8ZUgXZ2AK3XbsgP3EeoLIBWLtZ3fEBXUDJl3NqQNvefVqT7Bnn loHcL3bGz3c+9bgqlS4rCTlIkOzkVPfjCa3G+33sTifJOnZeYZI5k/XSJj3aqbOHEvD3 lYvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=iRlWhDih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e15-20020a17090301cf00b001bf1973eafcsi5556148plh.571.2023.08.20.04.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Aug 2023 04:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=iRlWhDih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43BE12FB5BF; Sat, 19 Aug 2023 11:55:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347937AbjHQD6b (ORCPT + 99 others); Wed, 16 Aug 2023 23:58:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347927AbjHQD6B (ORCPT ); Wed, 16 Aug 2023 23:58:01 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD86C270C for ; Wed, 16 Aug 2023 20:57:59 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe4b45a336so66495155e9.1 for ; Wed, 16 Aug 2023 20:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; t=1692244678; x=1692849478; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=n6zcSzpJqJ0VluuSboFsoL227pWupWbEH5Uz9sUxXS8=; b=iRlWhDihY+i26ll38K6xAbDNtaTXOuLoVg+U++anaW8++WA1Nc8aLPFmLaFol3/DzO vCk8ILimnRqbPwG3L9C6UPATHJCcVyzJMW1olzMNT4uP8Ia0Xzzd7pzvpl9M9Jikbt4J wZREMgFBQACUU0HsJiKSqdVWByf3yAW+PtqlmCvigtgevZ6H9MT1+7qEnIAXigvkihBj uXfG2d6MHrrne26law8lGRUn3SgA6zcmL9i9DiNsbxR70HQIIy6WhHCmxx/zxayqen2d wYlKEok34Ge1IhiDocb3D6KB4+VWfUG7Di6IuDVZpfD7bxUgbmtrUR3rebpcrKyKKp4/ UsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692244678; x=1692849478; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n6zcSzpJqJ0VluuSboFsoL227pWupWbEH5Uz9sUxXS8=; b=Gm9/TIz9Yvv3TSoJ5yZM5N4PtDXPIQInAbvL8TSzUzaPQTptPntxjk3ivqAcqPbUwh m5J6VflUxxNPq67/vu4qhZ7yQh+e1YtmT7OuGUJtBWa7+D4O6kbox2e5Fy3xQ5kjPmE7 qHVepQoH6mYg7Un34qhKCE5fE1xnuRoF8z4J4Tf4gvUb1IBLTKB7uZdZVxxwzxs7eZlH +7yirUnuLvGTOc/o8vghx539Ygx0khUgsJ6pqAZgMUY9kgoVaFXyMXnlDzirZfh4ldmF sAini2OMhqWUMm7J8n9Zn8wBCiSTdgKr034tSQIOc/MiV75S0j7yMScXbG8ammlCiDL6 /vtg== X-Gm-Message-State: AOJu0Yw7+ocY9FBperD/gw0l3WJptyzF6bGfwqaTTBJmNQ6vcqnw/MtI kQtrYKNN7COtjLSZdkq2bBVOgg== X-Received: by 2002:a1c:e913:0:b0:3fa:98c3:7dbd with SMTP id q19-20020a1ce913000000b003fa98c37dbdmr2924986wmc.41.1692244677964; Wed, 16 Aug 2023 20:57:57 -0700 (PDT) Received: from smtpclient.apple ([131.111.5.246]) by smtp.gmail.com with ESMTPSA id l6-20020adff486000000b003143867d2ebsm23309801wro.63.2023.08.16.20.57.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2023 20:57:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Subject: Re: [PATCH 00/10] RISC-V: Refactor instructions From: Jessica Clarke In-Reply-To: Date: Thu, 17 Aug 2023 04:57:46 +0100 Cc: Andrew Jones , linux-riscv , LKML , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, bpf@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , Anup Patel , Atish Patra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Luke Nelson , Xi Wang , Nam Cao Content-Transfer-Encoding: quoted-printable Message-Id: <12FAB5A9-5723-4A5B-8729-75D8A38921B9@jrtc27.com> References: <20230803-master-refactor-instructions-v4-v1-0-2128e61fa4ff@rivosinc.com> <20230804-2c57bddd6e87fdebc20ff9d5@orel> To: Charlie Jenkins X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17 Aug 2023, at 01:31, Charlie Jenkins wrote: >=20 > On Fri, Aug 04, 2023 at 10:24:33AM -0700, Charlie Jenkins wrote: >> On Fri, Aug 04, 2023 at 12:28:28PM +0300, Andrew Jones wrote: >>> On Thu, Aug 03, 2023 at 07:10:25PM -0700, Charlie Jenkins wrote: >>>> There are numerous systems in the kernel that rely on directly >>>> modifying, creating, and reading instructions. Many of these = systems >>>> have rewritten code to do this. This patch will delegate all = instruction >>>> handling into insn.h and reg.h. All of the compressed instructions, = RVI, >>>> Zicsr, M, A instructions are included, as well as a subset of the = F,D,Q >>>> extensions. >>>>=20 >>>> --- >>>> This is modifying code that = https://lore.kernel.org/lkml/20230731183925.152145-1-namcaov@gmail.com/ >>>> is also touching. >>>>=20 >>>> --- >>>> Testing: >>>>=20 >>>> There are a lot of subsystems touched and I have not tested every >>>> individual instruction. I did a lot of copy-pasting from the RISC-V = spec >>>> so opcodes and such should be correct >>>=20 >>> How about we create macros which generate each of the functions an >>> instruction needs, e.g. riscv_insn_is_*(), etc. based on the output = of >>> [1]. I know basically nothing about that project, but it looks like = it >>> creates most the defines this series is creating from what we [hope] = to >>> be an authoritative source. I also assume that if we don't like the >>> current output format, then we could probably post patches to the = project >>> to get the format we want. For example, we could maybe propose an = "lc" >>> format for "Linux C". >> That's a great idea, I didn't realize that existed! > I have discovered that the riscv-opcodes repository is not in a state > that makes it helpful. If it were workable, it would make it easy to > include a "Linux C" format. I have had a pull request open on the repo > for two weeks now and the person who maintains the repo has not > interacted. Huh? Andrew has replied to you twice on your PR, and was the last one to comment. That=E2=80=99s hardly =E2=80=9Chas not interacted=E2=80=9D. > At minimum, in order for it to be useful it would need an ability to > describe the bit order of immediates in an instruction and include = script > arguments to select which instructions should be included. There is a > "C" format, but it is actually just a Spike format. So extend it? Or do something with QEMU=E2=80=99s equivalent that = expresses it. Jess > Nonetheless, it > seems like it is prohibitive to use it. >>>=20 >>> I'd also recommend only importing the generated defines and = generating >>> the functions that will actually have immediate consumers or are = part of >>> a set of defines that have immediate consumers. Each consumer of new >>> instructions will be responsible for generating and importing the = defines >>> and adding the respective macro invocations to generate the = functions. >>> This series can also take that approach, i.e. convert one set of >>> instructions at a time, each in a separate patch. >> Since I was hand-writing everything and copying it wasn't too much >> effort to just copy all of the instructions from a group. However, = from >> a testing standpoint it makes sense to exclude instructions not yet = in >> use. >>>=20 >>> [1] https://github.com/riscv/riscv-opcodes >>>=20 >>> Thanks, >>> drew >>>=20 >>>=20 >>>> , but the construction of every >>>> instruction is not fully tested. >>>>=20 >>>> vector: Compiled and booted >>>>=20 >>>> jump_label: Ensured static keys function as expected. >>>>=20 >>>> kgdb: Attempted to run the provided tests but they failed even = without >>>> my changes >>>>=20 >>>> module: Loaded and unloaded modules >>>>=20 >>>> patch.c: Ensured kernel booted >>>>=20 >>>> kprobes: Used a kprobing module to probe jalr, auipc, and branch >>>> instructions >>>>=20 >>>> nommu misaligned addresses: Kernel boots >>>>=20 >>>> kvm: Ran KVM selftests >>>>=20 >>>> bpf: Kernel boots. Most of the instructions are exclusively used by = BPF >>>> but I am unsure of the best way of testing BPF. >>>>=20 >>>> Signed-off-by: Charlie Jenkins >>>>=20 >>>> --- >>>> Charlie Jenkins (10): >>>> RISC-V: Expand instruction definitions >>>> RISC-V: vector: Refactor instructions >>>> RISC-V: Refactor jump label instructions >>>> RISC-V: KGDB: Refactor instructions >>>> RISC-V: module: Refactor instructions >>>> RISC-V: Refactor patch instructions >>>> RISC-V: nommu: Refactor instructions >>>> RISC-V: kvm: Refactor instructions >>>> RISC-V: bpf: Refactor instructions >>>> RISC-V: Refactor bug and traps instructions >>>>=20 >>>> arch/riscv/include/asm/bug.h | 18 +- >>>> arch/riscv/include/asm/insn.h | 2744 = +++++++++++++++++++++++++++--- >>>> arch/riscv/include/asm/reg.h | 88 + >>>> arch/riscv/kernel/jump_label.c | 13 +- >>>> arch/riscv/kernel/kgdb.c | 13 +- >>>> arch/riscv/kernel/module.c | 80 +- >>>> arch/riscv/kernel/patch.c | 3 +- >>>> arch/riscv/kernel/probes/kprobes.c | 13 +- >>>> arch/riscv/kernel/probes/simulate-insn.c | 100 +- >>>> arch/riscv/kernel/probes/uprobes.c | 5 +- >>>> arch/riscv/kernel/traps.c | 9 +- >>>> arch/riscv/kernel/traps_misaligned.c | 218 +-- >>>> arch/riscv/kernel/vector.c | 5 +- >>>> arch/riscv/kvm/vcpu_insn.c | 281 +-- >>>> arch/riscv/net/bpf_jit.h | 707 +------- >>>> 15 files changed, 2825 insertions(+), 1472 deletions(-) >>>> --- >>>> base-commit: 5d0c230f1de8c7515b6567d9afba1f196fb4e2f4 >>>> change-id: 20230801-master-refactor-instructions-v4-433aa040da03 >>>> --=20 >>>> - Charlie >>>>=20 >>>>=20 >>>> --=20 >>>> kvm-riscv mailing list >>>> kvm-riscv@lists.infradead.org >>>> http://lists.infradead.org/mailman/listinfo/kvm-riscv >=20 > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv