forked from keystone-enclave/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RV32 support (keystone-enclave#213)
* Add RV32 Linux/Buildroot * Modify bootrom * Add RV32-related scripts (source32.sh, rv32-setup.sh) * Bump SDK to be able to compile with RV32 * Bump driver * Bump riscv-pk * Bump QEMU * Create document (Running-Keystone-on-RV32.rst) Co-authored-by: Dayeol Lee <dayeol@berkeley.edu>
- Loading branch information
1 parent
ba90c92
commit b6bcb71
Showing
14 changed files
with
149 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
05211edea5a47ebaf906ef4bed2c9609a93e8c6ad5e45f8c87678eabbfd424e7 1.0.tar.gz | ||
bdc9e3ec47ac461ecc7865609fda6b820439c36130e9da9275af010d9f4fe4bc 2.0.tar.gz | ||
e73fa1191ce97be2531401d4628384c321c45ca5e4c83756e8415f2cc31a0b18 rv32gc.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.. | ||
Running Keystone in RV32 | ||
-------------------------------------- | ||
|
||
Currently we support running Keystone using all three priviledges, which are Machine, Supervisor, and User mode (M/S/U). Currently, we are working on a Machine and User mode \ | ||
implementation on Keystone to better support embedded systems. | ||
|
||
Setup RV32 Environment | ||
############################# | ||
|
||
First, run the ``rv32-setup.sh`` script (located at the top-level directory) to install the RV32 toolchain (which uses the GC extensions). | ||
|
||
:: | ||
|
||
./rv32-setup.sh | ||
This script will unzip and install the RV32 toolchain and store it in ``./riscv32``. The script will also set the ``$RISCV`` environment variable to point to the ``riscv32`` \ | ||
directory. We strongly recommend adding the following to your ``.bashrc``. | ||
|
||
:: | ||
|
||
export RISCV=$(pwd)/riscv32 | ||
export PATH=$RISCV/bin:$PATH | ||
|
||
Build SDK in RV32 | ||
############################# | ||
|
||
We will now have to build the SDK in RV32. Go to your SDK directory and create a build directory. Remember to set your SDK path | ||
|
||
:: | ||
|
||
mkdir <build directory> | ||
cd <build directory> | ||
export KEYSTONE_SDK_DIR=<install_directory> | ||
cmake .. -DRISCV32=y | ||
make | ||
make install | ||
This will build the SDK in RV32. | ||
|
||
Build Keystone in RV32 | ||
############################# | ||
|
||
Similar to the SDK, we may now build the entire Keystone framework in RV32. First, create a build directory and specify the RV32 flag. | ||
|
||
:: | ||
|
||
mkdir <build directory> | ||
cd <build directory> | ||
cmake .. -DRISCV32=y | ||
make | ||
|
||
This will begin building Keystone in RV32. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule qemu
updated
4037 files
Submodule riscv-pk
updated
8 files
+1 −1 | sm/enclave.c | |
+68 −56 | sm/mprv.S | |
+41 −26 | sm/mprv.h | |
+1 −1 | sm/pmp.c | |
+3 −6 | sm/safe_math_util.h | |
+17 −8 | sm/tests/CMakeLists.txt | |
+ − | sm/tests/cmocka/libcmocka-static-32.a | |
+4 −4 | sm/tests/mock/mprv.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Starting RV32 Instllation..." | ||
|
||
if ( $(command -v riscv32-unknown-linux-gnu-gcc > /dev/null) && | ||
$(command -v riscv32-unknown-elf-gcc > /dev/null) ) | ||
then | ||
echo "RISCV32 tools are already installed" | ||
else | ||
echo "Downloading Prebuilt RISC-V 32 Toolchain... " | ||
|
||
export RISCV32=$(pwd)/riscv32 | ||
export PATH=$PATH:$RISCV32/bin | ||
wget https://keystone-enclave.eecs.berkeley.edu/files/rv32gc.tar.gz | ||
|
||
# Check tool integrity | ||
echo "Verifying prebuilt toolchain integrity..." | ||
sha256sum -c .prebuilt_tools_shasums --status --ignore-missing | ||
if [[ $? != 0 ]] | ||
then | ||
echo "Toolchain binary download incomplete or corrupted. You can build the toolchain locally or try again." | ||
exit 1 | ||
fi | ||
|
||
tar -xzvf rv32gc.tar.gz | ||
mv riscv32gc riscv32 | ||
rm rv32gc.tar.gz | ||
echo "Toolchain has been installed in $RISCV32" | ||
fi |
Submodule sdk
updated
13 files
+3 −1 | CMakeLists.txt | |
+6 −1 | examples/hello-native/CMakeLists.txt | |
+6 −1 | examples/hello/CMakeLists.txt | |
+15 −6 | examples/tests/CMakeLists.txt | |
+2 −2 | examples/tests/long-nop/func_base.s | |
+1 −1 | examples/tests/long-nop/func_long.s | |
+2 −1 | examples/tests/long-nop/generate_func.sh | |
+3 −1 | examples/tests/long-nop/long-nop.S | |
+9 −0 | examples/tests/long-nop/nop.h | |
+21 −0 | examples/tests/stack/stack.S | |
+0 −11 | examples/tests/stack/stack.s | |
+4 −4 | include/host/Params.hpp | |
+3 −0 | macros.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export RISCV=$(pwd)/riscv32 | ||
export PATH=$RISCV/bin:$PATH | ||
export KEYSTONE_SDK_DIR=$(pwd)/sdk/build |