From 7308b8d294145e4a401b8fe5ad03b11d18cc13aa Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sat, 17 Nov 2018 14:31:00 -0500 Subject: [PATCH] Memory: remove IsValidVirtualAddress with current process --- src/core/gdbstub/gdbstub.cpp | 6 ++++-- src/core/hle/kernel/svc.cpp | 6 +++--- src/core/memory.cpp | 4 ---- src/core/memory.h | 1 - 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 1296b71b4c..dcc45ebcf5 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -830,7 +830,8 @@ static void ReadMemory() { SendReply("E01"); } - if (!Memory::IsValidVirtualAddress(addr)) { + if (!Memory::IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(), + addr)) { return SendReply("E00"); } @@ -852,7 +853,8 @@ static void WriteMemory() { auto len_pos = std::find(start_offset, command_buffer + command_length, ':'); u32 len = HexToInt(start_offset, static_cast(len_pos - start_offset)); - if (!Memory::IsValidVirtualAddress(addr)) { + if (!Memory::IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(), + addr)) { return SendReply("E00"); } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index a896f770f5..5dd82075d5 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -346,7 +346,7 @@ ResultCode SVC::UnmapMemoryBlock(Handle handle, u32 addr) { /// Connect to an OS service given the port name, returns the handle to the port to out ResultCode SVC::ConnectToPort(Handle* out_handle, VAddr port_name_address) { - if (!Memory::IsValidVirtualAddress(port_name_address)) + if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), port_name_address)) return ERR_NOT_FOUND; static constexpr std::size_t PortNameMaxLength = 11; @@ -451,7 +451,7 @@ ResultCode SVC::WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle bool wait_all, s64 nano_seconds) { Thread* thread = kernel.GetThreadManager().GetCurrentThread(); - if (!Memory::IsValidVirtualAddress(handles_address)) + if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address)) return ERR_INVALID_POINTER; // NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If @@ -622,7 +622,7 @@ static ResultCode ReceiveIPCRequest(SharedPtr server_session, /// In a single operation, sends a IPC reply and waits for a new request. ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_count, Handle reply_target) { - if (!Memory::IsValidVirtualAddress(handles_address)) + if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address)) return ERR_INVALID_POINTER; // Check if 'handle_count' is invalid diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 185d9cce2a..ed64ee381d 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -212,10 +212,6 @@ bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { return false; } -bool IsValidVirtualAddress(const VAddr vaddr) { - return IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(), vaddr); -} - bool IsValidPhysicalAddress(const PAddr paddr) { return GetPhysicalPointer(paddr) != nullptr; } diff --git a/src/core/memory.h b/src/core/memory.h index aaa44aaa15..15efa6781a 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -183,7 +183,6 @@ PageTable* GetCurrentPageTable(); /// Determines if the given VAddr is valid for the specified process. bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr); -bool IsValidVirtualAddress(VAddr vaddr); bool IsValidPhysicalAddress(PAddr paddr);