mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-16 22:36:59 +00:00
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>
This commit is contained in:
parent
768355712d
commit
8b483849f4
9 changed files with 467 additions and 218 deletions
|
|
@ -340,7 +340,8 @@ int mmu_gva_to_gpa(pound::kvm::kvm_vcpu_t* vcpu, guest_memory_t* memory, uint64_
|
|||
}
|
||||
|
||||
const uint64_t level_entry_address = table_address + (level_index * page_table_entry_size);
|
||||
const uint64_t descriptor = guest_mem_readq(memory, level_entry_address);
|
||||
uint64_t descriptor = 0;
|
||||
guest_mem_readq(memory, level_entry_address, &descriptor);
|
||||
uint64_t offset_mask = (1ULL << offset_bits) - 1;
|
||||
uint64_t page_offset = gva & offset_mask;
|
||||
uint64_t page_address_mask = ~offset_mask;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue