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

Add extra extensions to RISC-V #218

Closed
dramforever opened this issue Nov 1, 2022 · 6 comments
Closed

Add extra extensions to RISC-V #218

dramforever opened this issue Nov 1, 2022 · 6 comments

Comments

@dramforever
Copy link

(Moved from: #199 (comment))

Can we get some extra extensions like vector, bit-manipulation and scalar crypto enabled? It seems that for user-mode emulation setting QEMU_CPU to rv64,v=on etc would do the trick, though it does require a sort of recent version of QEMU, and I'm not sure what's the minimum required and what's the version on the runner. I've tested on QEMU 7.1.0/7.0.0 and GCC 11.3.0.

I roughly checked https://gitlab.com/qemu-project/qemu/-/blob/master/target/riscv/cpu.c and it seems that passing argument -march=rv64gcv_zba_zbb_zbc_zbs_zbkx_zk_zks to GCC and environment QEMU_CPU=rv64,v=on,zbkx=on,zk=on,zks=on to QEMU should enable everything that QEMU supports.

Though it seems that the crypto ones (Zbk* and Zk*) are not supported on 7.0.0 yet though, so -march=rv64gcv_zba_zbb_zbc_zbs and QEMU_CPU=rv64,v=on would be a great start (Zb* are enabled on QEMU by default). In addition, on QEMU 7.1.0, it complains with a warning unless you add vext_spec=v1.0 like rv64,v=on,vext_spec=v1.0, so that's something to keep in mind.

I've written a kumite that should work (at least compile fine (at least should fail with a different message)) if the changes above are implemented: https://www.codewars.com/kumite/635ac4a48f20014af2cf522e

@dramforever
Copy link
Author

What's the QEMU version on the runner host? The changelog says that QEMU supports the ratified vector extension starting from 7.0 only, so if we're going to go vectors we probably need to get at least 7.0 on the host: https://wiki.qemu.org/ChangeLog/7.0#RISC-V. 7.1 would be better because it will also add, as said, the crypto extensions: https://wiki.qemu.org/ChangeLog/7.1#RISC-V

@kazk
Copy link
Member

kazk commented Nov 1, 2022

The current version should be 6.x (6.23?). https://packages.ubuntu.com/focal/qemu-user-static
We should be able to upgrade to Ubuntu 22.04 and match GitHub's current ubuntu-latest to have 7.0.

@kazk
Copy link
Member

kazk commented Nov 1, 2022

Maybe we can use https://github.com/multiarch/qemu-user-static to get 7.1.

@kazk
Copy link
Member

kazk commented Nov 2, 2022

I'll install qemu-user-static 7.1 from .deb like codewars/riscv#9

@kazk
Copy link
Member

kazk commented Nov 8, 2022

Deployed

@kazk kazk closed this as completed Nov 8, 2022
@dramforever
Copy link
Author

Thanks! I've tried it on a few kata and it works great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants