Commit graph

223 commits

Author SHA1 Message Date
Ronald Caesar
6bdfd6fcea
Big Commit
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>
2025-09-27 09:16:49 -04:00
Ronald Caesar
4dd8506346 Update 3rd_Party/SDL3 to a96677bdf6b4acb84af4ec294e5f60a4e8cbbe03: Since the build system is being refactered, all submodules will be updated to their latest release 2025-09-21 23:10:05 -04:00
Ronald Caesar
d0f9fd8686 Update 3rd_Party/imgui to bf75bfec48fc00f532af8926130b70c0e26eb099: Since the build system is being refactered, all submodules will be updated to their latest release 2025-09-21 22:50:55 -04:00
Ronald Caesar
4d363ea3b2 Remove fmt library
This library wasnt used anywhere in the source code.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 18:37:06 -04:00
Ronald Caesar
8713dd751a docs: Add githib vuln scanning design doc
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 18:36:28 -04:00
Ronald Caesar
3058e9992f docs: Add License complience design docs
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 18:23:39 -04:00
Ronald Caesar
1138d8c9d3 docs: Add 3rd Party libs design doc.
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 18:22:44 -04:00
Ronald Caesar
5850a13f18 Move design docs to one folder
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 15:11:36 -04:00
Ronald Caesar
fddd5b6694 kvm: Add MMIO design doc
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 14:39:57 -04:00
Ronald Caesar
0af6018a3f frontend: Disable GUI
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>
2025-09-21 13:03:52 -04:00
Ronald Caesar
5b0aaf5fc4 Merge branch 'arm64'
Ronald Caesar (7):
      common: Implement logging framework
      common: add assert framework dedign doc
      common: Implement assertion framework
      Add Pound log and assert macros in every system, and fixed all linux compiler warnings
      common: Remove unused files
      build: remove commented code
      Remove outdated contributing suggestions
2025-09-21 12:38:35 -04:00
Ronald Caesar
994cf52ae7 Remove outdated contributing suggestions
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 12:31:43 -04:00
Ronald Caesar
f94022057a build: remove commented code
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 12:29:02 -04:00
Ronald Caesar
3f8ce127ea common: Remove unused files
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 12:24:48 -04:00
Ronald Caesar
61f1340dee Add Pound log and assert macros in every system, and fixed all linux
compiler warnings

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 12:18:46 -04:00
Ronald Caesar
df86db1aa4 common: Implement assertion framework
This commit introduces the core assertion subsystem as defined in
`DESIGN_DOC_ASSERT_FRAMEWORK.md`.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-21 09:42:05 -04:00
Ronald Caesar
ba82ab5e9b common: add assert framework dedign doc
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-20 20:52:46 -04:00
Ronald Caesar
5b0e750c01 common: Implement logging framework
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-20 20:42:12 -04:00
Ronald Caesar
e8ce7a4921
Merge branch 'arm64'
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
2025-09-20 07:50:18 -04:00
Ronald Caesar
d0857d83f0 common: Implement logging framework
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-20 04:59:09 -04:00
Ronald Caesar
2e45679675 common: Add design doc for log framework.
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-09-14 20:36:03 -04:00
Ronald Caesar
a3ed44003b build: Refactor CMake build system
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>
2025-09-14 18:40:30 -04:00
Ronald Caesar
8b483849f4 arm64/mem: Refactor guest memory access and made it endian aware
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>
2025-09-13 23:14:26 -04:00
Ronald Caesar
768355712d
Merge branch 'arm64'
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>
2025-09-11 16:44:25 -04:00
OwnedByWuigi
f4b68e9467
Update README.md 2025-09-01 11:04:44 +01:00
Ronald Caesar
c6706dd8a0 kvm: Add framework for machine types and MMIO dispatch
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>
2025-08-24 21:45:32 -04:00
Ronald Caesar
dea94dc259 Fix unknown type definition
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 17:41:32 -04:00
Ronald Caesar
05c4f7025f Major project restructuring
Remove unecessary files and made the tree much more cleaner.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 17:23:33 -04:00
Ronald Caesar
2a72632075 Update Readme
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 14:26:04 -04:00
Ronald Caesar
5fa10cd9c2 Merge branch 'arm64'
Ronald Caesar (3):
      arm64/mem: Add MMU layer for GVA->GPA translation
      arm64: include missing definitions
      arm64/mem: Add initial software page table walker
2025-08-23 02:36:38 -04:00
Ronald Caesar
13b2e741b9 arm64/mem: Add initial software page table walker
Introduce a software-based page table walker for the arm64 MMU
emulation. This is foundational component for handling GVA-GPA
translations when a request missses the (future) software TLB.

For now, it handles only Page descriptors and does not yet support Block
descriptors or permission checks. These will be added in subsequent
patches.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 02:28:28 -04:00
Ronald Caesar
b54b3d97cd arm64: include missing definitions
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 02:28:28 -04:00
Ronald Caesar
43bcf7e9a7 arm64/mem: Add MMU layer for GVA->GPA translation
A new function, mmu_gva_to_gpa(), will be the sole entry point for
resolving guest virtual addresses. This initial implementation models
the processor's state on reset. The function inspects the M bit from the
emulated SCTLR_EL1 register. If the bit is clear, address mapping (GVA =
GPA) is performed. This is an architecturally-mandated behavior required
for the Arm guest to execute its initiall boot code before enabling
virtual memory.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 02:28:28 -04:00
Ronald Caesar
a62aa833c0 Fix cmake errors
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 02:21:51 -04:00
Ronald Caesar
3cd11ab4ab Removed unused files and directories
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-23 02:01:14 -04:00
Ronald Caesar
1986c7bd5c Add another line break
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-22 16:09:37 -04:00
Ronald Caesar
b7047e7ae6 Add line breaks in note section
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-22 16:07:46 -04:00
Ronald Caesar
4bf9b0b819 Update note section in Readme.md
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-22 16:02:03 -04:00
Ronald Caesar
bad5c48022 arm64: Remove unwanted header file
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 23:09:21 -04:00
Ronald Caesar
ce08d9c1d4 Merge branch 'arm64' 2025-08-16 23:03:48 -04:00
Ronald Caesar
4eda010531 Add more casserts
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 23:01:18 -04:00
Ronald Caesar
cc2fb074e3 Switch to casserts
Pound's asserts were broken from the very beginning and I've just
realized this. Fixing it is not my problem.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 22:47:47 -04:00
Ronald Caesar
6f5b6b8742 Switch build mode to Debug
I was wondering why my asserts wasn't working.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 21:46:10 -04:00
Ronald Caesar
9224377fd9
arm64: Remove incomplete file 2025-08-16 18:54:02 -04:00
Ronald Caesar
97f2dcce45 Merge remote-tracking branch 'origin/aarch64'
Introduce the foundational support for emulating the AArch64 execution
state. This is the first major step towards running a guest operating
system.

    1. vCPU State: A structure that models the architectural state of an
       Arm64 vCPU. This includes the general-purpose registers, FP/SIMD
       vector registers, and the essential EL1 system registers
       (ELR_EL1, SPSR_EL1, ESR_EL1, FAR_EL1, VBAR_EL1) which are mandatory
       for handling exceptions.

    2. Guest Memory Model: A dedicated guest memory subsystem has been
       created to manage the emulated physical address space.

    3. Synchronous Exception Entry: This adds the core logic for taking
       synchronous exceptions. The new take_synchronous_exception() function
       emulates the hardware process of saving guest state, populating
       syndrome registers, and preparing the vCPU to enter an exception
       handler in EL1.

==========
GloriousTacoo (1):
      aarch64/cpu: added system registers to vcpu_state_t (#67)

Ronald Caesar (9):
      aarch64: Add core state structure for vCPU emulation
      aarch64: Correct vCPU register state and add FP/SIMD support
      aarch64/mem: Add fast GPA-to-HVA translation helper
      aarch64/mem: Fixed pointer arithmatic warning
      aarch64/mem: Introduce a dedicated guest memory access layer
      memory: Move arena allocator into pound::memory namespace
      aarch64/kernel: Add synchronous exception entry logic
      arm64: Renames the aarch64 directory to arm64
      arm64: Rename memory.h to guest.h

Sinan Karakaya (1):
      feat(aarch64): added system registers to vcpu_state_t

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 18:49:14 -04:00
Ronald Caesar
b11f04912d arm64: Rename memory.h to guest.h
The term "memory" is really ambiguous in the context of an emulator,
especially since the MMU is being developed. It can refer to host memory, or
guest memory, or both.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 18:17:59 -04:00
Ronald Caesar
58587bf754 arm64: Renames the aarch64 directory to arm64
The term "aarch64" is the formal name for Armv8-A architecture. However,
I found that the establish convention across the wider open source
ecosystem is to use the short name "arm64".

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 17:37:12 -04:00
Ronald Caesar
65f589e853 aarch64/kernel: Add synchronous exception entry logic
To handle faults such as data aborts, alignment faults, or supervisor
calls, the CPU must transition from the guest's context into a
privileged exception handler. This patch emulates the hardware sequence
for this entry process.

1. The vcpu_state_t struct includes the essential EL1 system registers
   required for exception handling (ELR_EL1, SPSR_EL1, ESR_EL1, FAR_EL1,
   and VBAR_EL1).

2. A new function, take_synchronous_exception(), is introduced. It
   models the requirements for entering an exception targeting EL1:
      - Saves the return address (PC) into ELR_EL1.
      - Saves the current proccess state (PSTATE) into SPSR_EL1.
      - Contructs the Exception Syndrome Register (ESR_EL1) from the
        provided Exception Class and ISS.
      - Saves the faulting address to FAR_EL1 for data aborts.
      - Updates the live PSTATE to a safe state for the handler.

This implementation is intentially partial. The final step of updating the
PC to jump to a handler in the guest's vector table (using VBAR_EL1) is
stubbed out. The vector table will contain assembly instructions so a
functional instruction decoder is required to fully complete the
exception handler.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 13:11:40 -04:00
Ronald Caesar
556ace64e8 memory: Move arena allocator into pound::memory namespace
The existing memory arena impelmentation is moved into the pound::memory
namespace to align with the pound::aarch64 namespace.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-16 12:58:51 -04:00
GloriousTacoo
3d8a69dd8e
aarch64/cpu: added system registers to vcpu_state_t (#67)
Sinan Karakaya says:

==============
 Adds the system registers for aarch64. They includes the one defined in Yuzu, but also include other from the armv8 specs that seems like they should be necessary for emulation.

Most of them might be subject to being removed in the future, if they turn out to not be required for emulation.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-14 20:42:41 -04:00