mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
kern: Add special-case for InvalidateProcessDataCache on current process
This commit is contained in:
parent
2a4d68f916
commit
3737151a2f
4 changed files with 27 additions and 1 deletions
|
@ -150,6 +150,10 @@ namespace ams::kern::arch::arm64 {
|
||||||
R_RETURN(m_page_table.InvalidateProcessDataCache(address, size));
|
R_RETURN(m_page_table.InvalidateProcessDataCache(address, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result InvalidateCurrentProcessDataCache(KProcessAddress address, size_t size) {
|
||||||
|
R_RETURN(m_page_table.InvalidateCurrentProcessDataCache(address, size));
|
||||||
|
}
|
||||||
|
|
||||||
Result ReadDebugMemory(void *buffer, KProcessAddress address, size_t size) {
|
Result ReadDebugMemory(void *buffer, KProcessAddress address, size_t size) {
|
||||||
R_RETURN(m_page_table.ReadDebugMemory(buffer, address, size));
|
R_RETURN(m_page_table.ReadDebugMemory(buffer, address, size));
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,6 +412,7 @@ namespace ams::kern {
|
||||||
Result MakeAndOpenPageGroup(KPageGroup *out, KProcessAddress address, size_t num_pages, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr);
|
Result MakeAndOpenPageGroup(KPageGroup *out, KProcessAddress address, size_t num_pages, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr);
|
||||||
|
|
||||||
Result InvalidateProcessDataCache(KProcessAddress address, size_t size);
|
Result InvalidateProcessDataCache(KProcessAddress address, size_t size);
|
||||||
|
Result InvalidateCurrentProcessDataCache(KProcessAddress address, size_t size);
|
||||||
|
|
||||||
Result ReadDebugMemory(void *buffer, KProcessAddress address, size_t size);
|
Result ReadDebugMemory(void *buffer, KProcessAddress address, size_t size);
|
||||||
Result ReadDebugIoMemory(void *buffer, KProcessAddress address, size_t size, KMemoryState state);
|
Result ReadDebugIoMemory(void *buffer, KProcessAddress address, size_t size, KMemoryState state);
|
||||||
|
|
|
@ -2508,6 +2508,23 @@ namespace ams::kern {
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result KPageTableBase::InvalidateCurrentProcessDataCache(KProcessAddress address, size_t size) {
|
||||||
|
/* Check pre-condition: this is being called on the current process. */
|
||||||
|
MESOSPHERE_ASSERT(this == std::addressof(GetCurrentProcess().GetPageTable().GetBasePageTable()));
|
||||||
|
|
||||||
|
/* Check that the region is in range. */
|
||||||
|
R_UNLESS(this->Contains(address, size), svc::ResultInvalidCurrentMemory());
|
||||||
|
|
||||||
|
/* Lock the table. */
|
||||||
|
KScopedLightLock lk(m_general_lock);
|
||||||
|
|
||||||
|
/* Check the memory state. */
|
||||||
|
R_TRY(this->CheckMemoryStateContiguous(address, size, KMemoryState_FlagReferenceCounted, KMemoryState_FlagReferenceCounted, KMemoryPermission_UserReadWrite, KMemoryPermission_UserReadWrite, KMemoryAttribute_Uncached, KMemoryAttribute_None));
|
||||||
|
|
||||||
|
/* Invalidate the data cache. */
|
||||||
|
R_RETURN(cpu::InvalidateDataCache(GetVoidPointer(address), size));
|
||||||
|
}
|
||||||
|
|
||||||
Result KPageTableBase::ReadDebugMemory(void *buffer, KProcessAddress address, size_t size) {
|
Result KPageTableBase::ReadDebugMemory(void *buffer, KProcessAddress address, size_t size) {
|
||||||
/* Lightly validate the region is in range. */
|
/* Lightly validate the region is in range. */
|
||||||
R_UNLESS(this->Contains(address, size), svc::ResultInvalidCurrentMemory());
|
R_UNLESS(this->Contains(address, size), svc::ResultInvalidCurrentMemory());
|
||||||
|
|
|
@ -102,7 +102,11 @@ namespace ams::kern::svc {
|
||||||
R_UNLESS(process.IsNotNull(), svc::ResultInvalidHandle());
|
R_UNLESS(process.IsNotNull(), svc::ResultInvalidHandle());
|
||||||
|
|
||||||
/* Invalidate the cache. */
|
/* Invalidate the cache. */
|
||||||
|
if (process.GetPointerUnsafe() == GetCurrentProcessPointer()) {
|
||||||
|
R_TRY(process->GetPageTable().InvalidateCurrentProcessDataCache(address, size));
|
||||||
|
} else {
|
||||||
R_TRY(process->GetPageTable().InvalidateProcessDataCache(address, size));
|
R_TRY(process->GetPageTable().InvalidateProcessDataCache(address, size));
|
||||||
|
}
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue