From: Charlie Jenkins <charlie@rivosinc.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
bpf@vger.kernel.org, "Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Peter Zijlstra" <peterz@infradead.org>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Jason Baron" <jbaron@akamai.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Anup Patel" <anup@brainfault.org>,
"Atish Patra" <atishp@atishpatra.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@google.com>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Björn Töpel" <bjorn@kernel.org>,
"Luke Nelson" <luke.r.nels@gmail.com>,
"Xi Wang" <xi.wang@gmail.com>, "Nam Cao" <namcaov@gmail.com>
Subject: Re: [PATCH 00/10] RISC-V: Refactor instructions
Date: Fri, 4 Aug 2023 10:24:33 -0700 [thread overview]
Message-ID: <ZM00UYDzEAz/JT3n@ghost> (raw)
In-Reply-To: <20230804-2c57bddd6e87fdebc20ff9d5@orel>
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.
> >
> > ---
> > This is modifying code that https://lore.kernel.org/lkml/20230731183925.152145-1-namcaov@gmail.com/
> > is also touching.
> >
> > ---
> > Testing:
> >
> > 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
>
> 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'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.
>
> [1] https://github.com/riscv/riscv-opcodes
>
> Thanks,
> drew
>
>
> > , but the construction of every
> > instruction is not fully tested.
> >
> > vector: Compiled and booted
> >
> > jump_label: Ensured static keys function as expected.
> >
> > kgdb: Attempted to run the provided tests but they failed even without
> > my changes
> >
> > module: Loaded and unloaded modules
> >
> > patch.c: Ensured kernel booted
> >
> > kprobes: Used a kprobing module to probe jalr, auipc, and branch
> > instructions
> >
> > nommu misaligned addresses: Kernel boots
> >
> > kvm: Ran KVM selftests
> >
> > bpf: Kernel boots. Most of the instructions are exclusively used by BPF
> > but I am unsure of the best way of testing BPF.
> >
> > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> >
> > ---
> > 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
> >
> > 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
> > --
> > - Charlie
> >
> >
> > --
> > kvm-riscv mailing list
> > kvm-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kvm-riscv
next prev parent reply other threads:[~2023-08-04 17:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 2:10 [PATCH 00/10] RISC-V: Refactor instructions Charlie Jenkins
2023-08-04 2:10 ` [PATCH 02/10] RISC-V: vector: " Charlie Jenkins
2023-08-04 2:10 ` [PATCH 03/10] RISC-V: Refactor jump label instructions Charlie Jenkins
2023-08-04 2:10 ` [PATCH 04/10] RISC-V: KGDB: Refactor instructions Charlie Jenkins
2023-08-04 2:10 ` [PATCH 05/10] RISC-V: module: " Charlie Jenkins
2023-08-04 2:10 ` [PATCH 06/10] RISC-V: Refactor patch instructions Charlie Jenkins
2023-08-04 2:10 ` [PATCH 07/10] RISC-V: nommu: Refactor instructions Charlie Jenkins
2023-08-04 2:10 ` [PATCH 08/10] RISC-V: kvm: " Charlie Jenkins
2023-08-04 2:10 ` [PATCH 09/10] RISC-V: bpf: " Charlie Jenkins
2023-08-04 2:10 ` [PATCH 10/10] RISC-V: Refactor bug and traps instructions Charlie Jenkins
2023-08-04 5:16 ` kernel test robot
[not found] ` <20230803-master-refactor-instructions-v4-v1-1-2128e61fa4ff@rivosinc.com>
2023-08-04 7:59 ` [PATCH 01/10] RISC-V: Expand instruction definitions Conor Dooley
2023-08-04 17:26 ` Charlie Jenkins
2023-08-04 9:28 ` [PATCH 00/10] RISC-V: Refactor instructions Andrew Jones
2023-08-04 17:24 ` Charlie Jenkins [this message]
2023-08-17 0:31 ` Charlie Jenkins
2023-08-17 3:57 ` Jessica Clarke
2023-08-17 4:05 ` Jessica Clarke
2023-08-17 16:43 ` Charlie Jenkins
2023-08-17 17:52 ` Palmer Dabbelt
2023-08-18 7:30 ` Andrew Jones
2023-09-06 18:51 ` Charlie Jenkins
2023-09-07 8:51 ` Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZM00UYDzEAz/JT3n@ghost \
--to=charlie@rivosinc.com \
--cc=ajones@ventanamicro.com \
--cc=andrii@kernel.org \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=ast@kernel.org \
--cc=atishp@atishpatra.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=jbaron@akamai.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luke.r.nels@gmail.com \
--cc=martin.lau@linux.dev \
--cc=namcaov@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=xi.wang@gmail.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox