mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-27 17:34:15 +01:00
Merge yuzu-emu#12759
This commit is contained in:
parent
3e5078f409
commit
2a00de23e8
@ -69,9 +69,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename AddressType>
|
template <typename AddressType>
|
||||||
void InvalidateInstructionCache(KernelCore& kernel, AddressType addr, u64 size) {
|
void InvalidateInstructionCache(KernelCore& kernel, KPageTableBase* table, AddressType addr,
|
||||||
|
u64 size) {
|
||||||
// TODO: lock the process list
|
// TODO: lock the process list
|
||||||
for (auto& process : kernel.GetProcessList()) {
|
for (auto& process : kernel.GetProcessList()) {
|
||||||
|
if (std::addressof(process->GetPageTable().GetBasePageTable()) != table) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
|
for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
|
||||||
auto* interface = process->GetArmInterface(i);
|
auto* interface = process->GetArmInterface(i);
|
||||||
if (interface) {
|
if (interface) {
|
||||||
@ -1302,7 +1307,7 @@ Result KPageTableBase::UnmapCodeMemory(KProcessAddress dst_address, KProcessAddr
|
|||||||
bool reprotected_pages = false;
|
bool reprotected_pages = false;
|
||||||
SCOPE_EXIT({
|
SCOPE_EXIT({
|
||||||
if (reprotected_pages && any_code_pages) {
|
if (reprotected_pages && any_code_pages) {
|
||||||
InvalidateInstructionCache(m_kernel, dst_address, size);
|
InvalidateInstructionCache(m_kernel, this, dst_address, size);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2036,7 +2041,7 @@ Result KPageTableBase::SetProcessMemoryPermission(KProcessAddress addr, size_t s
|
|||||||
for (const auto& block : pg) {
|
for (const auto& block : pg) {
|
||||||
StoreDataCache(GetHeapVirtualPointer(m_kernel, block.GetAddress()), block.GetSize());
|
StoreDataCache(GetHeapVirtualPointer(m_kernel, block.GetAddress()), block.GetSize());
|
||||||
}
|
}
|
||||||
InvalidateInstructionCache(m_kernel, addr, size);
|
InvalidateInstructionCache(m_kernel, this, addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
@ -3277,7 +3282,7 @@ Result KPageTableBase::WriteDebugMemory(KProcessAddress dst_address, KProcessAdd
|
|||||||
R_TRY(PerformCopy());
|
R_TRY(PerformCopy());
|
||||||
|
|
||||||
// Invalidate the instruction cache, as this svc allows modifying executable pages.
|
// Invalidate the instruction cache, as this svc allows modifying executable pages.
|
||||||
InvalidateInstructionCache(m_kernel, dst_address, size);
|
InvalidateInstructionCache(m_kernel, this, dst_address, size);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,7 @@ SessionId Container::OpenSession(Kernel::KProcess* process) {
|
|||||||
|
|
||||||
void Container::CloseSession(SessionId session_id) {
|
void Container::CloseSession(SessionId session_id) {
|
||||||
std::scoped_lock lk(impl->session_guard);
|
std::scoped_lock lk(impl->session_guard);
|
||||||
|
impl->file.UnmapAllHandles(session_id);
|
||||||
auto& session = impl->sessions[session_id.id];
|
auto& session = impl->sessions[session_id.id];
|
||||||
auto& smmu = impl->host1x.MemoryManager();
|
auto& smmu = impl->host1x.MemoryManager();
|
||||||
if (session.has_preallocated_area) {
|
if (session.has_preallocated_area) {
|
||||||
|
@ -326,4 +326,17 @@ std::optional<NvMap::FreeInfo> NvMap::FreeHandle(Handle::Id handle, bool interna
|
|||||||
return freeInfo;
|
return freeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NvMap::UnmapAllHandles(NvCore::SessionId session_id) {
|
||||||
|
auto handles_copy = [&] {
|
||||||
|
std::scoped_lock lk{handles_lock};
|
||||||
|
return handles;
|
||||||
|
}();
|
||||||
|
|
||||||
|
for (auto& [id, handle] : handles_copy) {
|
||||||
|
if (handle->session_id.id == session_id.id) {
|
||||||
|
FreeHandle(id, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Service::Nvidia::NvCore
|
} // namespace Service::Nvidia::NvCore
|
||||||
|
@ -152,6 +152,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::optional<FreeInfo> FreeHandle(Handle::Id handle, bool internal_session);
|
std::optional<FreeInfo> FreeHandle(Handle::Id handle, bool internal_session);
|
||||||
|
|
||||||
|
void UnmapAllHandles(NvCore::SessionId session_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<std::shared_ptr<Handle>> unmap_queue{};
|
std::list<std::shared_ptr<Handle>> unmap_queue{};
|
||||||
std::mutex unmap_queue_lock{}; //!< Protects access to `unmap_queue`
|
std::mutex unmap_queue_lock{}; //!< Protects access to `unmap_queue`
|
||||||
|
Loading…
Reference in New Issue
Block a user