pound-emu_pound/core/arm64/mmu.cpp
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

16 lines
344 B
C++

#include "mmu.h"
namespace pound::arm64::memory
{
int mmu_gva_to_gpa(pound::arm64::vcpu_state_t* vcpu, uint64_t gva, uint64_t* out_gpa)
{
const uint8_t SCTLR_EL1_M_BIT = (1 << 0);
if (0 == (vcpu->sctlr_el1 & SCTLR_EL1_M_BIT))
{
*out_gpa = gva;
return 0;
}
return -1;
}
} // namespace pound::arm64::memory