2. Customization¶
In this section, we will demonstrate how to customize the RISC-V ISA by designing a custom instruction extension called RegVault as an example, which is described in paper [1].
The RegVault instruction extension contains two sets of context-aware cryptographic instructions that provide cryptographically strong confidentiality and integrity protection for register-grained data. The mnemonics for these instructions are listed in the table below:
Set Name |
Mnemonic |
|---|---|
context-aware register encrypt |
|
context-aware register decrypt |
|
cre[x]k rd, rs[e:s], rtis the encryption instruction. It selects bytes within range[e:s](i.e., s-th to e-th bytes) from source registerrs, encrypts them with the tweak in registerrtand the key in key registerx, and puts the ciphertext in destination registerrd.crd[x]k rd[e:s], rs, rtis the decryption instruction. It decrypts the value inrswith given tweak inrtand keyx, and puts the plaintext inrd. Moreover, it checks whether the bytes other than[e:s]in plaintext remain zero. If not, the integrity check fails and an exception is raised.
RegVault is a great example of how to customize the RISC-V ISA. It stands out because it not only contains heteromorphic instruction formats, but also requires the support of new states. To implement the RegVault instruction extension, we need to customize the instruction set architecture (ISA) to support the new instructions, and customize the Control and Status Registers (CSRs) to save the keys.
Next, we will provide step-by-step instructions on the following topics: