Skip to content

riscv: Introduce support for defining instructions

Andrew Jones kvm-riscv linux-riscv lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 10 repliesIn review
  2. v14 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- Cleaned up some whitespace issues pointed out by Anup, myself and checkpatch and dropped some {}
- Pushed the quoting of register tokens into the macros
- Picked up Anup's r-b's

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4riscv: Add X register names to gpr-numsarch/riscv/include/asm/gpr-num.h+8 -01 reply
2/4riscv: Introduce support for defining instructionsarch/riscv/Kconfig arch/riscv/include/asm/insn-def.h+89 -07 replies
3/4riscv: KVM: Apply insn-def to hfence encodingsarch/riscv/include/asm/insn-def.h arch/riscv/kvm/tlb.c+27 -1121 reply
4/4riscv: KVM: Apply insn-def to hlv encodingsarch/riscv/include/asm/insn-def.h arch/riscv/kvm/vcpu_exit.c+22 -241 reply

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchAnup Patel
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/4] riscv: Introduce support for defining instructions

When compiling with toolchains that haven't yet been taught about new instructions we need to encode them ourselves. This series creates a new file where support for instruction definitions can evolve. For starters the file is initiated with a macro for R-type encodings. The series then applies the R-type encoding macro to all instances of hard coded instruction definitions in KVM.

Not only should using instruction encoding macros improve readability and maintainability of code, but we should also gain potential for more optimized code after compilation as the compiler will have control over the input and output registers used, which may provide more opportunities for inlining.

I grepped for other places we may want to use these macros and the only place I found was ALT_CMO_OP(), but I didn't dare touch it :-) I do suggest we apply this to the Svinal support [1] as we won't want to frustrate the compiler's inlining efforts with hard coded register selection.

[1] https://lore.kernel.org/linux-riscv/20220812042921.14508-1-mchitale at ventanamicro.com/

v2:
- Cleaned up some whitespace issues pointed out by Anup, myself and checkpatch and dropped some {}
- Pushed the quoting of register tokens into the macros
- Picked up Anup's r-b's

Andrew Jones (4):
riscv: Add X register names to gpr-nums
riscv: Introduce support for defining instructions
riscv: KVM: Apply insn-def to hfence encodings
riscv: KVM: Apply insn-def to hlv encodings

 arch/riscv/Kconfig                |   3 +
 arch/riscv/include/asm/gpr-num.h  |   8 ++
 arch/riscv/include/asm/insn-def.h | 113 ++++++++++++++++++++++++++
 arch/riscv/kvm/tlb.c              | 129 ++++--------------------------
 arch/riscv/kvm/vcpu_exit.c        |  29 ++-----
 5 files changed, 146 insertions(+), 136 deletions(-)
 create mode 100644 arch/riscv/include/asm/insn-def.h
Signature · 1 line
2.37.2