Crates.io | user-mode-riscv |
lib.rs | user-mode-riscv |
version | 0.1.0 |
source | src |
created_at | 2021-07-09 23:43:08.881226 |
updated_at | 2021-07-09 23:43:08.881226 |
description | RISCV CPU emulation focusing on user mode instructions only |
homepage | https://github.com/dparnell/user-mode-riscv |
repository | https://github.com/dparnell/user-mode-riscv |
max_upload_size | |
id | 420942 |
size | 5,522,212 |
This is a thought experiment made manifest. What would happen if you had an emulated CPU that used the same address space as the host machine. What would it look like to use a RISCV CPU emulation to run scripting code?
Because I can!
But seriously, this means that the host environment can allocate structures and pass pointers to them into the emulation and no address translation is necessary.
A bad pointer dereference in the emulated environment will bring down the host. If there is any chance of running untrusted code then this is not the way to do things. On the other hand if you are certain that the code you are going to run will not be doing anything naughty then you should be just fine.
This is the idea I'm playing with.
It seems to work, and work remarkably well especially considering I have not gone to any effort to optimize the code.
This code is based in part on the code found here https://github.com/takahirox/riscv-rust