Skip to content

Add RISC-V TCG backend support

Alistair Francis qemu-devel qemu-riscv 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest23 patches 3 repliesIn review

Changes in v1 from the cover letter

- Fix long jump with slowpath load/stores

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23elf.h: Add the RISCV ELF magic numbersinclude/elf.h+55 -00 replies
2/23linux-user: Add host dependency for RISC-V 32-bitMAINTAINERS linux-user/host/riscv32/hostdep.h+12 -00 replies
3/23linux-user: Add host dependency for RISC-V 64-bitMAINTAINERS linux-user/host/riscv64/hostdep.h+12 -00 replies
4/23exec: Add RISC-V GCC poison macroinclude/exec/poison.h+1 -00 replies
5/23riscv: Add the tcg-target header fileMAINTAINERS tcg/riscv/tcg-target.h+176 -01 reply
6/23riscv: Add the tcg target registerstcg/riscv/tcg-target.inc.c+118 -00 replies
7/23riscv: tcg-target: Add support for the constraintstcg/riscv/tcg-target.inc.c+168 -00 replies
8/23riscv: tcg-target: Add the immediate encoderstcg/riscv/tcg-target.inc.c+90 -00 replies
9/23riscv: tcg-target: Add the instruction emitterstcg/riscv/tcg-target.inc.c+48 -00 replies
10/23riscv: tcg-target: Add the relocation functionstcg/riscv/tcg-target.inc.c+75 -00 replies
11/23riscv: tcg-target: Add the mov and movi instructiontcg/riscv/tcg-target.inc.c+85 -00 replies
12/23riscv: tcg-target: Add the extract instructionstcg/riscv/tcg-target.inc.c+34 -00 replies
13/23riscv: tcg-target: Add the out load and store instructionstcg/riscv/tcg-target.inc.c+65 -00 replies
14/23riscv: tcg-target: Add the add2 and sub2 instructionstcg/riscv/tcg-target.inc.c+55 -00 replies
15/23riscv: tcg-target: Add branch and jump instructionstcg/riscv/tcg-target.inc.c+142 -00 replies
16/23riscv: tcg-target: Add slowpath load and store instructionstcg/riscv/tcg-target.inc.c+256 -00 replies
17/23riscv: tcg-target: Add direct load and store instructionstcg/riscv/tcg-target.inc.c+158 -00 replies
18/23riscv: tcg-target: Add the out op decodertcg/riscv/tcg-target.inc.c+493 -00 replies
19/23riscv: tcg-target: Add the prologue generation and register the JITtcg/riscv/tcg-target.inc.c+111 -00 replies
20/23riscv: tcg-target: Add the target init codetcg/riscv/tcg-target.inc.c+31 -00 replies
21/23tcg: Add RISC-V cpu signal handleraccel/tcg/user-exec.c+75 -00 replies
22/23dias: Add RISC-V supportdisas.c+8 -20 replies
23/23configure: Add support for building RISC-V hostconfigure+10 -20 replies

Reviews trailers per patch

18 of 23 patches have a Reviewed-by or Acked-by.

PatchRichard Henderson
1/23R-b
2/23R-b
3/23R-b
4/23R-b
5/23R-b
6/23R-b
7/23R-b
8/23R-b
9/23R-b
10/23
11/23
12/23R-b
13/23R-b
14/23R-b
15/23
16/23
17/23R-b
18/23R-b
19/23R-b
20/23R-b
21/23
22/23R-b
23/23R-b

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

Read the v1 thread

Cover letter [Qemu-devel] [PATCH v1 00/23] Add RISC-V TCG backend support

This patch set adds RISC-V backend support to QEMU. This is based on Michael Clark's original work with extra work on top.
This has been somewhat tested and can run other architecture softmmu code. It seems that any complex OS will eventually hang, but we can run the BIOS and OS startup code for a number of different operating systems.
I haven't tested linux user support at all yet. I think Michael had that working reliably though and hopefully my changes haven't broken it. There are still some todos in the code (there are missing instructions and byte swapping) but these should assert instead of generating invalid code.
As this is all new work (so can't cause regressions) I'm starting the patch series process with what we have so far. That way others can help contribute and test. If anyone has strong feelings for missing functionality let me know and we can work on adding that before this is merged. This branch can be found here:
https://github.com/alistair23/qemu/tree/mainline/alistair/tcg-backend-upstream.next
v1:
- Fix long jump with slowpath load/stores
RFC v3:
- Update the MAINTAINERS file
- Enusre that RISC-V 32-bit works
- More changes based on Richard's feedback and contributions
RFC v2:
- A large number of changes based on Richard's feedback

Alistair Francis (23):
elf.h: Add the RISCV ELF magic numbers
linux-user: Add host dependency for RISC-V 32-bit
linux-user: Add host dependency for RISC-V 64-bit
exec: Add RISC-V GCC poison macro
riscv: Add the tcg-target header file
riscv: Add the tcg target registers
riscv: tcg-target: Add support for the constraints
riscv: tcg-target: Add the immediate encoders
riscv: tcg-target: Add the instruction emitters
riscv: tcg-target: Add the relocation functions
riscv: tcg-target: Add the mov and movi instruction
riscv: tcg-target: Add the extract instructions
riscv: tcg-target: Add the out load and store instructions
riscv: tcg-target: Add the add2 and sub2 instructions
riscv: tcg-target: Add branch and jump instructions
riscv: tcg-target: Add slowpath load and store instructions
riscv: tcg-target: Add direct load and store instructions
riscv: tcg-target: Add the out op decoder
riscv: tcg-target: Add the prologue generation and register the JIT
riscv: tcg-target: Add the target init code
tcg: Add RISC-V cpu signal handler
dias: Add RISC-V support
configure: Add support for building RISC-V host

 MAINTAINERS                       |    3 +
 accel/tcg/user-exec.c             |   75 ++
 configure                         |   12 +-
 disas.c                           |   10 +-
 include/elf.h                     |   55 +
 include/exec/poison.h             |    1 +
 linux-user/host/riscv32/hostdep.h |   11 +
 linux-user/host/riscv64/hostdep.h |   11 +
 tcg/riscv/tcg-target.h            |  175 +++
 tcg/riscv/tcg-target.inc.c        | 1929 +++++++++++++++++++++++++++++
 10 files changed, 2278 insertions(+), 4 deletions(-)
 create mode 100644 linux-user/host/riscv32/hostdep.h
 create mode 100644 linux-user/host/riscv64/hostdep.h
 create mode 100644 tcg/riscv/tcg-target.h
 create mode 100644 tcg/riscv/tcg-target.inc.c
Signature · 1 line
2.19.1