diff options
Diffstat (limited to 'Userland/DevTools/UserspaceEmulator/MmapRegion.cpp')
-rw-r--r-- | Userland/DevTools/UserspaceEmulator/MmapRegion.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp index c7f4b3f8ad..a7056e47f0 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp @@ -129,6 +129,40 @@ ValueWithShadow<u64> MmapRegion::read64(u32 offset) return { *reinterpret_cast<const u64*>(m_data + offset), *reinterpret_cast<const u64*>(m_shadow_data + offset) }; } +ValueWithShadow<u128> MmapRegion::read128(u32 offset) +{ + if (!is_readable()) { + reportln("128-bit read from unreadable MmapRegion @ {:p}", base() + offset); + emulator().dump_backtrace(); + TODO(); + } + + if (is_malloc_block()) { + if (auto* tracer = emulator().malloc_tracer()) + tracer->audit_read(*this, base() + offset, 16); + } + + VERIFY(offset + 15 < size()); + return { *reinterpret_cast<const u128*>(m_data + offset), *reinterpret_cast<const u128*>(m_shadow_data + offset) }; +} + +ValueWithShadow<u256> MmapRegion::read256(u32 offset) +{ + if (!is_readable()) { + reportln("256-bit read from unreadable MmapRegion @ {:p}", base() + offset); + emulator().dump_backtrace(); + TODO(); + } + + if (is_malloc_block()) { + if (auto* tracer = emulator().malloc_tracer()) + tracer->audit_read(*this, base() + offset, 32); + } + + VERIFY(offset + 31 < size()); + return { *reinterpret_cast<const u256*>(m_data + offset), *reinterpret_cast<const u256*>(m_shadow_data + offset) }; +} + void MmapRegion::write8(u32 offset, ValueWithShadow<u8> value) { if (!is_writable()) { @@ -203,6 +237,44 @@ void MmapRegion::write64(u32 offset, ValueWithShadow<u64> value) *reinterpret_cast<u64*>(m_shadow_data + offset) = value.shadow(); } +void MmapRegion::write128(u32 offset, ValueWithShadow<u128> value) +{ + if (!is_writable()) { + reportln("128-bit write from unwritable MmapRegion @ {:p}", base() + offset); + emulator().dump_backtrace(); + TODO(); + } + + if (is_malloc_block()) { + if (auto* tracer = emulator().malloc_tracer()) + tracer->audit_write(*this, base() + offset, 16); + } + + VERIFY(offset + 15 < size()); + VERIFY(m_data != m_shadow_data); + *reinterpret_cast<u128*>(m_data + offset) = value.value(); + *reinterpret_cast<u128*>(m_shadow_data + offset) = value.shadow(); +} + +void MmapRegion::write256(u32 offset, ValueWithShadow<u256> value) +{ + if (!is_writable()) { + reportln("256-bit write from unwritable MmapRegion @ {:p}", base() + offset); + emulator().dump_backtrace(); + TODO(); + } + + if (is_malloc_block()) { + if (auto* tracer = emulator().malloc_tracer()) + tracer->audit_write(*this, base() + offset, 32); + } + + VERIFY(offset + 31 < size()); + VERIFY(m_data != m_shadow_data); + *reinterpret_cast<u256*>(m_data + offset) = value.value(); + *reinterpret_cast<u256*>(m_shadow_data + offset) = value.shadow(); +} + NonnullOwnPtr<MmapRegion> MmapRegion::split_at(VirtualAddress offset) { VERIFY(!m_malloc); |