Go to file
Martin Atkins 7d8fe2ab11
riscv: Expose privilege level as pseudo-register PRIV (#1989)
Unlike some other architectures, RISC-V does not expose the current
privilege mode in any architecturally-defined register. That is intentional
to make it easier to implement virtualization in software, but a Unicorn
caller operates outside of the emulated hart and so it can and should be
able to observe and change the current privilege mode in order to properly
emulate certain behaviors of a real CPU.

The current privilege level is therefore now exposed as a new
pseudo-register using the name "priv", which matches the name of the
virtual register used by RISC-V's debug extension to allow the debugger
to read and change the privilege mode while the hart is halted. Unicorn's
use of it is conceptually similar to a debugger.

The bit encoding of this register is the same as specified in RISC-V Debug
Specification v1.0-rc3 Section 4.10.1. It's defined as a "virtual"
register exposing a subset of fields from the dcsr register, although here
it's implemented directly inside the Unicorn code because QEMU doesn't
currently have explicit support for the CSRs from the debug specification.
If it supports "dcsr" in a future release then this implementation could
change to wrap reading and writing that CSR and then projecting the "prv"
and "v" bitfields into the correct locations for the virtual register.
2024-11-11 21:09:45 +08:00
.github/workflows Feat: Option to manually specify the build type in the workflow (#2034) 2024-10-17 21:15:56 +08:00
bindings riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
cmake Zig binding 2023-08-04 11:24:00 -03:00
docs Update logging 2024-09-22 00:14:03 +08:00
glib_compat Fix memory leak of g_array_free 2024-10-13 13:39:57 +08:00
include riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
msvc Reformat code with format.sh 2023-06-16 15:23:41 -07:00
qemu riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
samples Format 2024-02-12 00:10:58 +08:00
tests riscv: Expose privilege level as pseudo-register PRIV (#1989) 2024-11-11 21:09:45 +08:00
.clang-format Add clang-format and format code to qemu code style 2021-10-29 12:44:49 +02:00
.gitignore Python binding setup refactoring + cibuildwheel workflow (#2026) 2024-10-17 19:35:42 +08:00
.gitmodules Change git url to https url to avoid git submodule clone error 2022-01-18 21:09:01 +01:00
AUTHORS.TXT import 2015-08-21 15:04:50 +08:00
build.zig Update zig bindings to 0.13.0 2024-08-08 10:15:50 +02:00
build.zig.zon Tag and release 2.1.1 2024-09-26 18:44:51 +08:00
Cargo.toml Tag and release 2.1.1 2024-09-26 18:44:51 +08:00
ChangeLog Tag and release 2.1.1 2024-09-26 18:44:51 +08:00
CMakeLists.txt Python binding setup refactoring + cibuildwheel workflow (#2026) 2024-10-17 19:35:42 +08:00
COPYING import 2015-08-21 15:04:50 +08:00
COPYING_GLIB glib_compat: add COPYING_GLIB 2016-12-27 10:15:08 +08:00
COPYING.LGPL2 LGPL2 for all header files under include/unicorn/ 2017-12-16 10:08:42 +08:00
CREDITS.TXT Update CREDITS.TXT 2023-07-11 11:51:44 +02:00
format.sh Format unicorn_arm and unicorn_aarch64 2021-11-01 10:17:58 +01:00
go.mod add rpath and go.mod 2021-11-07 20:24:50 +01:00
list.c Fix possible leak in hooks 2022-02-12 16:28:43 +01:00
README.md Update README to reflect dev branch 2024-09-21 23:02:38 +08:00
SECURITY.md Update SECURITY.md 2022-10-31 12:35:37 +08:00
symbols.sh Optimize memory handling (#1963) 2024-10-16 21:51:13 +08:00
TODO Update TODO 2021-10-06 12:52:52 +02:00
uc.c Several bugfixes (#2049) 2024-11-04 12:53:26 +08:00

Unicorn Engine

pypi downloads Fuzzing Status

Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework, based on QEMU.

Unicorn offers some unparalleled features:

  • Multi-architecture: ARM, ARM64 (ARMv8), M68K, MIPS, PowerPC, RISCV, SPARC, S390X, TriCore and X86 (16, 32, 64-bit)
  • Clean/simple/lightweight/intuitive architecture-neutral API
  • Implemented in pure C language, with bindings for Crystal, Clojure, Visual Basic, Perl, Rust, Ruby, Python, Java, .NET, Go, Delphi/Free Pascal, Haskell, Pharo, Lua and Zig.
  • Native support for Windows & *nix (with Mac OSX, Linux, Android, *BSD & Solaris confirmed)
  • High performance via Just-In-Time compilation
  • Support for fine-grained instrumentation at various levels
  • Thread-safety by design
  • Distributed under free software license GPLv2

Further information is available at http://www.unicorn-engine.org

License

This project is released under the GPL license.

Compilation & Docs

See docs/COMPILE.md file for how to compile and install Unicorn.

More documentation is available in docs/README.md.

Contact

Contact us via mailing list, email or twitter for any questions.

Contribute

If you want to contribute, please pick up something from our Github issues.

We also maintain a list of more challenged problems in milestones for our regular release.

Please send pull request to our dev branch.

CREDITS.TXT records important contributors of our project.