Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv: Add support for riscv64ilp32 (X32 ABI) #2

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

inspireMeNow
Copy link

The riscv64ilp32 target, also known as the X32 ABI, allows 64-bit RISC-V processors to run 32-bit user space programs. This provides better performance than the pure 32-bit environment, while maintaining binary compatibility with existing 32-bit programs.

This commit adds support for the riscv64ilp32 target to QEMU. With this change, QEMU can now simulate and execute 32-bit user space programs on 64-bit RISC-V processors following the X32 ABI specification.

Major changes:

  • Add new configs for riscv64ilp32 target in configs/devices and configs/targets
  • Modify configure script to recognize riscv64ilp32 target
  • Update hw/riscv/boot.c to handle kernel load address for riscv64ilp32
  • Extend include/elf.h to include EF_RISCV_X32 flag for riscv64ilp32
  • Modify linux-user/elfload.c to handle riscv64ilp32 ELF files
  • Add RISCV64ILP32 config option in target/riscv/Kconfig
  • Update CPU parameter definitions in target/riscv/cpu-param.h for riscv64ilp32
  • Extend CPU object initialization in target/riscv/cpu.c for riscv64ilp32
  • Handle riscv64ilp32 target in various files under target/riscv/

Testing:

This change has been tested by running the QEMU riscv64ilp32-softmmu and riscv64ilp32-linux-user targets with the following commands:

$ ./qemu-system-riscv64ilp32 -cpu rv64 -M virt -m 256M -nographic
-bios fw_dynamic.bin_m64lp64 -kernel ./Image
-drive file=./rootfs.ext2,format=raw,id=hd0
-device virtio-blk-device,drive=hd0
-append "root=/dev/vda rw console=ttyS0 earlycon=sbi"

$ ./qemu-riscv64ilp32 /path/to/riscv64ilp32-binary

All tests passed successfully.

The riscv64ilp32 target, also known as the X32 ABI, allows 64-bit RISC-V
processors to run 32-bit user space programs. This provides better performance
than the pure 32-bit environment, while maintaining binary compatibility
with existing 32-bit programs.

This commit adds support for the riscv64ilp32 target to QEMU. With this
change, QEMU can now simulate and execute 32-bit user space programs on
64-bit RISC-V processors following the X32 ABI specification.

Major changes:

- Add new configs for riscv64ilp32 target in configs/devices and configs/targets
- Modify configure script to recognize riscv64ilp32 target
- Update hw/riscv/boot.c to handle kernel load address for riscv64ilp32
- Extend include/elf.h to include EF_RISCV_X32 flag for riscv64ilp32
- Modify linux-user/elfload.c to handle riscv64ilp32 ELF files
- Add RISCV64ILP32 config option in target/riscv/Kconfig
- Update CPU parameter definitions in target/riscv/cpu-param.h for riscv64ilp32
- Extend CPU object initialization in target/riscv/cpu.c for riscv64ilp32
- Handle riscv64ilp32 target in various files under target/riscv/

Testing:

This change has been tested by running the QEMU riscv64ilp32-softmmu and
riscv64ilp32-linux-user targets with the following commands:

$ ./qemu-system-riscv64ilp32 -cpu rv64 -M virt -m 256M -nographic \
  -bios fw_dynamic.bin_m64lp64 -kernel ./Image \
  -drive file=./rootfs.ext2,format=raw,id=hd0 \
  -device virtio-blk-device,drive=hd0 \
  -append "root=/dev/vda rw console=ttyS0 earlycon=sbi"

$ ./qemu-riscv64ilp32 /path/to/riscv64ilp32-binary

All tests passed successfully.

Signed-off-by: Kaiyao Duan <[email protected]>
Copy link

Thank you for your interest in the QEMU project.

This repository is a read-only mirror of the project's repostories hosted
on https://gitlab.com/qemu-project/qemu.git.
The project does not process merge requests filed on GitHub.

QEMU welcomes contributions of code (either fixing bugs or adding new
functionality). However, we get a lot of patches, and so we have some
guidelines about contributing on the project website:
https://www.qemu.org/contribute/

@github-actions github-actions bot closed this Apr 29, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2024
@pz9115 pz9115 reopened this Apr 29, 2024
@pz9115 pz9115 merged commit f946be9 into ruyisdk:rv64ilp32-dev Apr 29, 2024
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants