mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-24 23:57:57 -05:00
kernel: reduce page table region checking
This commit is contained in:
@ -63,36 +63,13 @@ Result MapUnmapMemorySanityChecks(const KPageTable& manager, u64 dst_addr, u64 s
|
||||
R_THROW(ResultInvalidCurrentMemory);
|
||||
}
|
||||
|
||||
if (!manager.IsInsideAddressSpace(src_addr, size)) {
|
||||
if (!manager.Contains(src_addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Source is not within the address space, addr=0x{:016X}, size=0x{:016X}",
|
||||
src_addr, size);
|
||||
R_THROW(ResultInvalidCurrentMemory);
|
||||
}
|
||||
|
||||
if (manager.IsOutsideStackRegion(dst_addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Destination is not within the stack region, addr=0x{:016X}, size=0x{:016X}",
|
||||
dst_addr, size);
|
||||
R_THROW(ResultInvalidMemoryRegion);
|
||||
}
|
||||
|
||||
if (manager.IsInsideHeapRegion(dst_addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Destination does not fit within the heap region, addr=0x{:016X}, "
|
||||
"size=0x{:016X}",
|
||||
dst_addr, size);
|
||||
R_THROW(ResultInvalidMemoryRegion);
|
||||
}
|
||||
|
||||
if (manager.IsInsideAliasRegion(dst_addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Destination does not fit within the map region, addr=0x{:016X}, "
|
||||
"size=0x{:016X}",
|
||||
dst_addr, size);
|
||||
R_THROW(ResultInvalidMemoryRegion);
|
||||
}
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,14 @@ Result MapPhysicalMemory(Core::System& system, u64 addr, u64 size) {
|
||||
R_THROW(ResultInvalidState);
|
||||
}
|
||||
|
||||
if (!page_table.IsInsideAddressSpace(addr, size)) {
|
||||
if (!page_table.Contains(addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Address is not within the address space, addr=0x{:016X}, size=0x{:016X}", addr,
|
||||
size);
|
||||
R_THROW(ResultInvalidMemoryRegion);
|
||||
}
|
||||
|
||||
if (page_table.IsOutsideAliasRegion(addr, size)) {
|
||||
if (!page_table.IsInAliasRegion(addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Address is not within the alias region, addr=0x{:016X}, size=0x{:016X}", addr,
|
||||
size);
|
||||
@ -100,14 +100,14 @@ Result UnmapPhysicalMemory(Core::System& system, u64 addr, u64 size) {
|
||||
R_THROW(ResultInvalidState);
|
||||
}
|
||||
|
||||
if (!page_table.IsInsideAddressSpace(addr, size)) {
|
||||
if (!page_table.Contains(addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Address is not within the address space, addr=0x{:016X}, size=0x{:016X}", addr,
|
||||
size);
|
||||
R_THROW(ResultInvalidMemoryRegion);
|
||||
}
|
||||
|
||||
if (page_table.IsOutsideAliasRegion(addr, size)) {
|
||||
if (!page_table.IsInAliasRegion(addr, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Address is not within the alias region, addr=0x{:016X}, size=0x{:016X}", addr,
|
||||
size);
|
||||
|
@ -66,8 +66,8 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, u64 out_proc
|
||||
auto& kernel = system.Kernel();
|
||||
const auto total_copy_size = out_process_ids_size * sizeof(u64);
|
||||
|
||||
if (out_process_ids_size > 0 && !GetCurrentProcess(kernel).GetPageTable().IsInsideAddressSpace(
|
||||
out_process_ids, total_copy_size)) {
|
||||
if (out_process_ids_size > 0 &&
|
||||
!GetCurrentProcess(kernel).GetPageTable().Contains(out_process_ids, total_copy_size)) {
|
||||
LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}",
|
||||
out_process_ids, out_process_ids + total_copy_size);
|
||||
R_THROW(ResultInvalidCurrentMemory);
|
||||
|
@ -179,7 +179,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst
|
||||
}
|
||||
|
||||
auto& page_table = process->GetPageTable();
|
||||
if (!page_table.IsInsideAddressSpace(src_address, size)) {
|
||||
if (!page_table.Contains(src_address, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Source address range is not within the address space (src_address=0x{:016X}, "
|
||||
"size=0x{:016X}).",
|
||||
@ -187,14 +187,6 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst
|
||||
R_THROW(ResultInvalidCurrentMemory);
|
||||
}
|
||||
|
||||
if (!page_table.IsInsideASLRRegion(dst_address, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Destination address range is not within the ASLR region (dst_address=0x{:016X}, "
|
||||
"size=0x{:016X}).",
|
||||
dst_address, size);
|
||||
R_THROW(ResultInvalidMemoryRegion);
|
||||
}
|
||||
|
||||
R_RETURN(page_table.MapCodeMemory(dst_address, src_address, size));
|
||||
}
|
||||
|
||||
@ -247,7 +239,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d
|
||||
}
|
||||
|
||||
auto& page_table = process->GetPageTable();
|
||||
if (!page_table.IsInsideAddressSpace(src_address, size)) {
|
||||
if (!page_table.Contains(src_address, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Source address range is not within the address space (src_address=0x{:016X}, "
|
||||
"size=0x{:016X}).",
|
||||
@ -255,14 +247,6 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d
|
||||
R_THROW(ResultInvalidCurrentMemory);
|
||||
}
|
||||
|
||||
if (!page_table.IsInsideASLRRegion(dst_address, size)) {
|
||||
LOG_ERROR(Kernel_SVC,
|
||||
"Destination address range is not within the ASLR region (dst_address=0x{:016X}, "
|
||||
"size=0x{:016X}).",
|
||||
dst_address, size);
|
||||
R_THROW(ResultInvalidMemoryRegion);
|
||||
}
|
||||
|
||||
R_RETURN(page_table.UnmapCodeMemory(dst_address, src_address, size,
|
||||
KPageTable::ICacheInvalidationStrategy::InvalidateAll));
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, u64 out_thread_
|
||||
const auto total_copy_size = out_thread_ids_size * sizeof(u64);
|
||||
|
||||
if (out_thread_ids_size > 0 &&
|
||||
!current_process->GetPageTable().IsInsideAddressSpace(out_thread_ids, total_copy_size)) {
|
||||
!current_process->GetPageTable().Contains(out_thread_ids, total_copy_size)) {
|
||||
LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}",
|
||||
out_thread_ids, out_thread_ids + total_copy_size);
|
||||
R_THROW(ResultInvalidCurrentMemory);
|
||||
|
Reference in New Issue
Block a user