Browse Source

[fastmem] fallback to callbacks on unaligned pages

pull/4181/head
Exverge 6 days ago
parent
commit
8193323731
No known key found for this signature in database GPG Key ID: DAD399BCC5FB77E4
  1. 3
      src/core/hle/kernel/k_thread_local_page.cpp
  2. 26
      src/core/memory.cpp

3
src/core/hle/kernel/k_thread_local_page.cpp

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

26
src/core/memory.cpp

@ -77,11 +77,13 @@ struct Memory::Impl {
Common::PageType::Memory);
if (current_page_table->fastmem_arena) {
ASSERT_MSG(GetInteger(base) % Common::HostPageSize == GetInteger(target) % Common::HostPageSize,
"base {:#x} and target {:#x} aren't aligned in relation to host page size {}",
GetInteger(base), GetInteger(target), Common::HostPageSize);
bool is_fastmem = GetInteger(base) % Common::HostPageSize != GetInteger(target) % Common::HostPageSize;
if (!is_fastmem) {
LOG_WARNING(HW_Memory, "base {:#x} and target {:#x} aren't aligned in relation to host page size {}",
GetInteger(base), GetInteger(target), Common::HostPageSize);
}
auto align = [&](bool b, u64 v) {
constexpr auto align = [&](bool b, u64 v) {
return b ? Common::AlignUp(v, Common::HostPageSize) : Common::AlignDown(v, Common::HostPageSize);
};
@ -89,11 +91,16 @@ struct Memory::Impl {
auto aligned_target = align(out.first, GetInteger(target) - DramMemoryMap::Base);
auto aligned_end = align(!out.second, GetInteger(base) + size);
host_buffer->Map(
aligned_base,
aligned_target,
aligned_end - aligned_base,
perms, separate_heap);
if (is_fastmem) {
host_buffer->Map(
aligned_base,
aligned_target,
aligned_end - aligned_base,
perms, separate_heap);
} else {
// Default to signal handlers/fastmem impl
host_buffer->Unmap(aligned_base, aligned_end - aligned_base, separate_heap);
}
}
}
@ -648,7 +655,6 @@ struct Memory::Impl {
return host_ptr;
}
case Common::PageType::Unmapped: [[unlikely]] {
__builtin_debugtrap();
on_unmapped();
return nullptr;
}

Loading…
Cancel
Save