mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Memory: IsValidVirtualAddress can be global
This commit is contained in:
		
							parent
							
								
									42edab01d9
								
							
						
					
					
						commit
						c6b3186475
					
				
					 6 changed files with 27 additions and 27 deletions
				
			
		|  | @ -832,8 +832,8 @@ static void ReadMemory() { | |||
|         SendReply("E01"); | ||||
|     } | ||||
| 
 | ||||
|     if (!Core::System::GetInstance().Memory().IsValidVirtualAddress( | ||||
|             *Core::System::GetInstance().Kernel().GetCurrentProcess(), addr)) { | ||||
|     if (!Memory::IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(), | ||||
|                                        addr)) { | ||||
|         return SendReply("E00"); | ||||
|     } | ||||
| 
 | ||||
|  | @ -856,8 +856,8 @@ static void WriteMemory() { | |||
|     auto len_pos = std::find(start_offset, command_buffer + command_length, ':'); | ||||
|     u32 len = HexToInt(start_offset, static_cast<u32>(len_pos - start_offset)); | ||||
| 
 | ||||
|     if (!Core::System::GetInstance().Memory().IsValidVirtualAddress( | ||||
|             *Core::System::GetInstance().Kernel().GetCurrentProcess(), addr)) { | ||||
|     if (!Memory::IsValidVirtualAddress(*Core::System::GetInstance().Kernel().GetCurrentProcess(), | ||||
|                                        addr)) { | ||||
|         return SendReply("E00"); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -347,7 +347,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(*kernel.GetCurrentProcess(), port_name_address)) | ||||
|     if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), port_name_address)) | ||||
|         return ERR_NOT_FOUND; | ||||
| 
 | ||||
|     static constexpr std::size_t PortNameMaxLength = 11; | ||||
|  | @ -452,7 +452,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(*kernel.GetCurrentProcess(), 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
 | ||||
|  | @ -623,7 +623,7 @@ static ResultCode ReceiveIPCRequest(SharedPtr<ServerSession> 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(*kernel.GetCurrentProcess(), handles_address)) | ||||
|     if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address)) | ||||
|         return ERR_INVALID_POINTER; | ||||
| 
 | ||||
|     // Check if 'handle_count' is invalid
 | ||||
|  |  | |||
|  | @ -303,7 +303,7 @@ ResultVal<SharedPtr<Thread>> KernelSystem::CreateThread(std::string name, VAddr | |||
| 
 | ||||
|     // TODO(yuriks): Other checks, returning 0xD9001BEA
 | ||||
| 
 | ||||
|     if (!memory.IsValidVirtualAddress(owner_process, entry_point)) { | ||||
|     if (!Memory::IsValidVirtualAddress(owner_process, entry_point)) { | ||||
|         LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point); | ||||
|         // TODO: Verify error
 | ||||
|         return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ void MemorySystem::SetCurrentPageTable(PageTable* page_table) { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| PageTable* MemorySystem::GetCurrentPageTable() { | ||||
| PageTable* MemorySystem::GetCurrentPageTable() const { | ||||
|     return current_page_table; | ||||
| } | ||||
| 
 | ||||
|  | @ -173,7 +173,7 @@ void MemorySystem::Write(const VAddr vaddr, const T data) { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| bool MemorySystem::IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { | ||||
| bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { | ||||
|     auto& page_table = process.vm_manager.page_table; | ||||
| 
 | ||||
|     const u8* page_pointer = page_table.pointers[vaddr >> PAGE_BITS]; | ||||
|  |  | |||
|  | @ -212,7 +212,7 @@ class MemorySystem { | |||
| public: | ||||
|     /// Currently active page table
 | ||||
|     void SetCurrentPageTable(PageTable* page_table); | ||||
|     PageTable* GetCurrentPageTable(); | ||||
|     PageTable* GetCurrentPageTable() const; | ||||
| 
 | ||||
|     u8 Read8(VAddr addr); | ||||
|     u16 Read16(VAddr addr); | ||||
|  | @ -236,9 +236,6 @@ public: | |||
| 
 | ||||
|     std::string ReadCString(VAddr vaddr, std::size_t max_length); | ||||
| 
 | ||||
|     /// Determines if the given VAddr is valid for the specified process.
 | ||||
|     bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Gets a pointer to the memory region beginning at the specified physical address. | ||||
|      */ | ||||
|  | @ -279,4 +276,7 @@ private: | |||
|     PageTable* current_page_table = nullptr; | ||||
| }; | ||||
| 
 | ||||
| /// Determines if the given VAddr is valid for the specified process.
 | ||||
| bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr); | ||||
| 
 | ||||
| } // namespace Memory
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue