diff options
author | Ben Marshall <ben.marshall@bristol.ac.uk> | 2021-02-18 13:27:35 +0000 |
---|---|---|
committer | Ben Marshall <ben.marshall@bristol.ac.uk> | 2021-02-18 13:27:35 +0000 |
commit | da7748e6d88c75559e8f3c09067a502fe950136e (patch) | |
tree | a0d7a9151682bdc4f26431c79624fef6c8957fbc /disasm | |
parent | 5730d12167e0a0834d14b6332a4dd31d673bf73b (diff) | |
download | riscv-isa-sim-da7748e6d88c75559e8f3c09067a502fe950136e.zip riscv-isa-sim-da7748e6d88c75559e8f3c09067a502fe950136e.tar.gz riscv-isa-sim-da7748e6d88c75559e8f3c09067a502fe950136e.tar.bz2 |
scalar-crypto: Fix decoding of RV64 AES instructions.
Historically, one could uniquely decode any RISC-V instruction based on
the instruciton to decode, plus a MATCH and MASK pair.
The scalar crypto extension adds instructions for accelerating the AES
algorithm which work very differently on RV32 and RV64. However, they
overlap in terms of opcodes. The instructions are always mutually
exclusive, and so it makes sense to overlap them this way to save
encoding space.
This exposed a problem, where previously Spike assumed the decoder
function was something like:
> decode(instr_word, MATCH, MASK)
Now it needed to be
> decode(instr_word, MATCH, MASK, current_xlen)
To get around this in the initial implementation, the instructions which
shared opcodes were implemented in the same *.h file - e.g. aesds.h
contained an implementation of aes32dsi, and aes64ds. We detected
xlen in the file, and executed the appropriate instruction logic.
This worked fine for our limited set of benchmarks.
After more extensive testing, we found that Spike has an optimisation
which changes the order in which it tries to decode instructions based
on past instructions.
Running more extensive tests exposed the fact that the decoding logic
could still not unambiguously decode the instructions. Hence, more
substantial changes were needed to tell spike that an instruction is
RV32 or RV64 only.
These changes have been implemented as part of
- riscv/encoding.h
- disasm/disasm.cc
- riscv/processor.cc/h
Basically, every instr_desc_t has an extra field which marks which
base architecture the instruction can be exectuted on. This bitfield
can be altered for particular instructions.
The changes to riscv/insns/* simply split out the previously combined
instructions into a separate header files.
On branch scalar-crypto-fix
Changes to be committed:
modified: disasm/disasm.cc
modified: riscv/encoding.h
new file: riscv/insns/aes32dsi.h
new file: riscv/insns/aes32dsmi.h
new file: riscv/insns/aes32esi.h
new file: riscv/insns/aes32esmi.h
new file: riscv/insns/aes64ds.h
new file: riscv/insns/aes64dsm.h
new file: riscv/insns/aes64es.h
new file: riscv/insns/aes64esm.h
deleted: riscv/insns/aesds.h
deleted: riscv/insns/aesdsm.h
deleted: riscv/insns/aeses.h
deleted: riscv/insns/aesesm.h
modified: riscv/processor.cc
modified: riscv/processor.h
modified: riscv/riscv.mk.in
Diffstat (limited to 'disasm')
-rw-r--r-- | disasm/disasm.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/disasm/disasm.cc b/disasm/disasm.cc index e2d6277..691ec28 100644 --- a/disasm/disasm.cc +++ b/disasm/disasm.cc @@ -411,7 +411,11 @@ disassembler_t::disassembler_t(int xlen) #define DECLARE_INSN(code, match, mask) \ const uint32_t match_##code = match; \ const uint32_t mask_##code = mask; + #define DECLARE_RV32_ONLY(code) {} + #define DECLARE_RV64_ONLY(code) {} #include "encoding.h" + #undef DECLARE_RV64_INSN + #undef DECLARE_RV32_INSN #undef DECLARE_INSN // explicit per-instruction disassembly @@ -1332,7 +1336,11 @@ disassembler_t::disassembler_t(int xlen) // provide a default disassembly for all instructions as a fallback #define DECLARE_INSN(code, match, mask) \ add_insn(new disasm_insn_t(#code " (args unknown)", match, mask, {})); + #define DECLARE_RV32_ONLY(code) {} + #define DECLARE_RV64_ONLY(code) {} #include "encoding.h" + #undef DECLARE_RV64_INSN + #undef DECLARE_RV32_INSN #undef DECLARE_INSN } |