Munmap can fail if the length argument is 0, and the address being freed
is not a multiple of the host's page size.
Signed-off-by: Ronald Caesar <github43132@proton.me>
Strengthens the decoder's foundation but does not yet implement the core
instruction lookup table logic or the public arm32_decode API. These
will be addressed in future patches.
Signed-off-by: Ronald Caesar <github43132@proton.me>
The term KVM is missleading because we are not using linux kernel
virtualization. PVM stands for "Pound Virtual Machine" which is more
accurate.
Signed-off-by: Ronald Caesar <github43132@proton.me>
The mmio will not be touchwd for a couple months while we focus on
executing arm instructions. Once we get to that point this design doc
will be rewritten.
Signed-off-by: Ronald Caesar <github43132@proton.me>
The changes affects multiple places in the repo and this one of the rare
instances where I cant be bothered writing a comprehensive commit. Look
at the diff for changes.
Signed-off-by: Ronald Caesar <github43132@proton.me>
The GUI will not be necessary for the foreseeable future. Focus will be
on implementing the virtual machine. And this commit speeds up the compile time
as well.
Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit introduces the core assertion subsystem as defined in
`DESIGN_DOC_ASSERT_FRAMEWORK.md`.
Signed-off-by: Ronald Caesar <github43132@proton.me>
Ronald Caesar (4):
arm64/mem: Refactor guest memory access and made it endian aware
build: Refactor CMake build system
common: Add design doc for log framework.
common: Implement logging framework
This new architecture decomposes the project into several distict static
libraries: common, host, kvm, and frontend.
By using static libraries, changes within one module will only require
that library to be re-linked, rather than recompiling and re-linking the
entire executable.
The third party library ImGui is now built as a static library target.
Signed-off-by: Ronald Caesar <github43132@proton.me>
Refactors the core guest memory access subsystem (guest.h) to be safer
and portable accross host systems with different endianness. The
previous implementation used direct pointer casting, which is not endian
safe.
1. All read and write functions have been converted from unsafe pointer
casts to memcpy(). This resolves alignment warning -Wcast-align.
2. The access functions no longer rely on asserts for error checking.
They now perform explicit boundary and alignment checking and returns
a guest_mem_access_result_t status code.
3. A new header (endian.h) provides cross platform byte swapping macros.
The memory access functions use these macros to ensure that the guest
always sees memory in the correct endian format, regardless of the
host's native byte order. The host endianness is now automatically
detected via CMake.
3. Asserts are now explicitly enabled in release builds to catch
critical errors.
Signed-off-by: Ronald Caesar <github43132@proton.me>
This is a major architectural overhaul of the KVM core.
The monolithic core directory has been restructured into a more logical
component based structure under src/:
* src/common: Truly genercic platform agnostic utilities.
* src/host: The host abstraction layer for the OS soecific code.
* src/frontend: User-interface and session management.
* src/kvm: The core CPU and virtual machine emulation logic.
* src/targets: Machine specific hardware definitions.
The core of the logical changes is a new framework for initializing and
running virtual machines.
* Machine Probing: A new machine factory (kvm_probe) and operations
table (kvm_ops_t) has been introduced. The core now interacts with
the emulated machine through this abstraction interface.
* Data Oriented MMIO disaptcher: This uses a data oriented structure
of arrays design and a binary search lookup to provide efficient
(O(log N)) dispatch for guest physical addresses.
Signed-off-by: Ronald Caesar <github43132@proton.me>
The core of the machine-type support is the new operations table,
kvm_ops_t. This acts as a standard C-style virtual table decoupling the
generic KVM core logic from target specific hardware emualtion. The
kvm_t VM instance now points to an ops table, which defines the
"personality" of the guest. A kvm_probe() factory function has been
added to initialize a kvm_t instance with the correct ops table for a
given machine type (eg, Switch 1).
The ops table's .mmio_read and .mmio_write function pointers are the
link between the armv8 CPU core and this new MMIO dispatcher. When a
physical memory access is determined to be MMIO, the VM will call the
appropriate function pointer, which in turn will use the MMIO dispatcher
to find and execute the correct device handler.
The initial implementation for the Switch 1 target
(targets/switch1/hardware/probe.cpp) is a stub. The bootstrapping
logic will be added in subsequent patches.
Signed-off-by: Ronald Caesar <github43132@proton.me>