-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
RISC-V disassembly, part 4/4: LibDisassembly: Actually disassemble RISC-V #21540
base: master
Are you sure you want to change the base?
RISC-V disassembly, part 4/4: LibDisassembly: Actually disassemble RISC-V #21540
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look at the F/D/C/A extensions, as I don't know much about them.
I only have some comments regarding the naming of things.
But very nice to see risc-v disassembly support in serenity!
697671f
to
dd1cd0f
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! |
This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions! |
This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions! |
c2023a0
to
6725b3f
Compare
eb11cbb
to
4737f32
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! |
This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions! |
4737f32
to
62e3196
Compare
62e3196
to
a6e18f5
Compare
a6e18f5
to
781b7c7
Compare
Note that CSR pretty-printing is not yet implemented, since we aim to establish shared CSR utilities in AK in the near future.
781b7c7
to
515ed86
Compare
Again, no point in splitting these two since the orthagonal instruction set makes supporting both in common abstractions convenient.
This does not include all instructions for S- and M-mode from the priviledged spec, but these are the common ones that we will definitely need (and use ourselves)
This was prettier to add in one go instead of many small sections :^)
This does *not* support RV32C or RV128C, since those use the same instructions for different purposes. We decode compressed instructions into the same internal representation as their full counterparts, since all compressed instructions have such an exact counterpart by design.
There are two tests here, one for full RV64G coverage and one with the asinh implementation from our libc. There's no dedicated C tests (though C is tested plenty in asinh) since I've already spent over two days writing these tests.
515ed86
to
9a20742
Compare
This is part 4, the final part of a long chain of PRs and commits that add RISC-V disassembly support. Today: exactly this. RISC-V disassembly support. It's quite a lot of code, I've tried to split it up by extension and also separate out the initial support commits so it's hopefully easier to review. There's full tests for everything added here, so the functionality is verified correct.
A small look at what some of our libc looks like with disasm, grabbing a random function:
Depends on #21539.
LibDisassembly: Add RISC-V register definitions
The next series of commits will add full RV64GC decoding, but since this
is a lot of code, it is split up into semi-logical chunks which each
contain plenty of dead code initially.
This first commit adds the RISC-V register definitions and enums
necessary for RV64GC; that is, no vector registers.
LibDisassembly: Add decoding for all RISC-V instruction formats
These structs just handle decoding the raw bit format, including details
like sign extending, but not interpreting these bits or translating them
to higher level constructs.
LibDisassembly: Add string fmting for RISC-V registers and rounding mode
LibDisassembly: Add RISC-V instruction abstractions
These will be used later on by concrete instruction implementations.
LibDisassembly: Add RISC-V 64 base ISA instruction decoding
Actually, this is RV64IMZifencei and RV32IMZifencei:
arithmetic instructions that are represented in a common class with
other I instructions.
file.
LibDisassembly: Add RISC-V Zicsr extension decoding
Note that CSR pretty-printing is not yet implemented, since we aim to
establish shared CSR utilities in AK in the near future.
LibDisassembly: Add RISC-V FD extension decoding
Again, no point in splitting these two since the orthagonal instruction
set makes supporting both in common abstractions convenient.
LibDisassembly: Add RISC-V A extension decoding
LibDisassembly: Add common priviledged instructions
This does not include all instructions for S- and M-mode from the
priviledged spec, but these are the common ones that we will definitely
need (and use ourselves)
LibDisassembly: Use RISC-V decoding functions for 32-bit instructions
This was prettier to add in one go instead of many small sections :^)
LibDisassembly: Add RV64C extension decoding
This does not support RV32C or RV128C, since those use the same
instructions for different purposes. We decode compressed instructions
into the same internal representation as their full counterparts, since
all compressed instructions have such an exact counterpart by design.
LibDisassembly: Support disassembling a RISC-V instruction stream
This small commit finally plugs the RISC-V decoding capabilities into
Disassembler, allowing RISC-V to be disassembled correctly.
Tests: Add RISC-V disassembly tests
There are two tests here, one for full RV64G coverage and one with the
asinh implementation from our libc. There's no dedicated C tests (though
C is tested plenty in asinh) since I've already spent over two days
writing these tests.