|
|
@ -2379,8 +2379,7 @@ Result KPageTable::MapPageGroup(KProcessAddress* out_addr, const KPageGroup& pg,
|
|
|
|
KScopedPageTableUpdater updater(this);
|
|
|
|
KScopedPageTableUpdater updater(this);
|
|
|
|
|
|
|
|
|
|
|
|
// Perform mapping operation.
|
|
|
|
// Perform mapping operation.
|
|
|
|
const KPageProperties properties = {perm, state == KMemoryState::Io, false,
|
|
|
|
const KPageProperties properties = {perm, false, false, DisableMergeAttribute::DisableHead};
|
|
|
|
DisableMergeAttribute::DisableHead};
|
|
|
|
|
|
|
|
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
|
|
|
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
|
|
|
|
|
|
|
|
|
|
|
// Update the blocks.
|
|
|
|
// Update the blocks.
|
|
|
@ -2422,8 +2421,7 @@ Result KPageTable::MapPageGroup(KProcessAddress addr, const KPageGroup& pg, KMem
|
|
|
|
KScopedPageTableUpdater updater(this);
|
|
|
|
KScopedPageTableUpdater updater(this);
|
|
|
|
|
|
|
|
|
|
|
|
// Perform mapping operation.
|
|
|
|
// Perform mapping operation.
|
|
|
|
const KPageProperties properties = {perm, state == KMemoryState::Io, false,
|
|
|
|
const KPageProperties properties = {perm, false, false, DisableMergeAttribute::DisableHead};
|
|
|
|
DisableMergeAttribute::DisableHead};
|
|
|
|
|
|
|
|
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
|
|
|
R_TRY(this->MapPageGroupImpl(updater.GetPageList(), addr, pg, properties, false));
|
|
|
|
|
|
|
|
|
|
|
|
// Update the blocks.
|
|
|
|
// Update the blocks.
|
|
|
@ -2863,7 +2861,8 @@ Result KPageTable::LockForMapDeviceAddressSpace(bool* out_is_io, KProcessAddress
|
|
|
|
&KMemoryBlock::ShareToDevice, KMemoryPermission::None);
|
|
|
|
&KMemoryBlock::ShareToDevice, KMemoryPermission::None);
|
|
|
|
|
|
|
|
|
|
|
|
// Set whether the locked memory was io.
|
|
|
|
// Set whether the locked memory was io.
|
|
|
|
*out_is_io = old_state == KMemoryState::Io;
|
|
|
|
*out_is_io =
|
|
|
|
|
|
|
|
static_cast<Svc::MemoryState>(old_state & KMemoryState::Mask) == Svc::MemoryState::Io;
|
|
|
|
|
|
|
|
|
|
|
|
R_SUCCEED();
|
|
|
|
R_SUCCEED();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3106,79 +3105,79 @@ void KPageTable::FinalizeUpdate(PageLinkedList* page_list) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KProcessAddress KPageTable::GetRegionAddress(KMemoryState state) const {
|
|
|
|
KProcessAddress KPageTable::GetRegionAddress(Svc::MemoryState state) const {
|
|
|
|
switch (state) {
|
|
|
|
switch (state) {
|
|
|
|
case KMemoryState::Free:
|
|
|
|
case Svc::MemoryState::Free:
|
|
|
|
case KMemoryState::Kernel:
|
|
|
|
case Svc::MemoryState::Kernel:
|
|
|
|
return m_address_space_start;
|
|
|
|
return m_address_space_start;
|
|
|
|
case KMemoryState::Normal:
|
|
|
|
case Svc::MemoryState::Normal:
|
|
|
|
return m_heap_region_start;
|
|
|
|
return m_heap_region_start;
|
|
|
|
case KMemoryState::Ipc:
|
|
|
|
case Svc::MemoryState::Ipc:
|
|
|
|
case KMemoryState::NonSecureIpc:
|
|
|
|
case Svc::MemoryState::NonSecureIpc:
|
|
|
|
case KMemoryState::NonDeviceIpc:
|
|
|
|
case Svc::MemoryState::NonDeviceIpc:
|
|
|
|
return m_alias_region_start;
|
|
|
|
return m_alias_region_start;
|
|
|
|
case KMemoryState::Stack:
|
|
|
|
case Svc::MemoryState::Stack:
|
|
|
|
return m_stack_region_start;
|
|
|
|
return m_stack_region_start;
|
|
|
|
case KMemoryState::Static:
|
|
|
|
case Svc::MemoryState::Static:
|
|
|
|
case KMemoryState::ThreadLocal:
|
|
|
|
case Svc::MemoryState::ThreadLocal:
|
|
|
|
return m_kernel_map_region_start;
|
|
|
|
return m_kernel_map_region_start;
|
|
|
|
case KMemoryState::Io:
|
|
|
|
case Svc::MemoryState::Io:
|
|
|
|
case KMemoryState::Shared:
|
|
|
|
case Svc::MemoryState::Shared:
|
|
|
|
case KMemoryState::AliasCode:
|
|
|
|
case Svc::MemoryState::AliasCode:
|
|
|
|
case KMemoryState::AliasCodeData:
|
|
|
|
case Svc::MemoryState::AliasCodeData:
|
|
|
|
case KMemoryState::Transfered:
|
|
|
|
case Svc::MemoryState::Transfered:
|
|
|
|
case KMemoryState::SharedTransfered:
|
|
|
|
case Svc::MemoryState::SharedTransfered:
|
|
|
|
case KMemoryState::SharedCode:
|
|
|
|
case Svc::MemoryState::SharedCode:
|
|
|
|
case KMemoryState::GeneratedCode:
|
|
|
|
case Svc::MemoryState::GeneratedCode:
|
|
|
|
case KMemoryState::CodeOut:
|
|
|
|
case Svc::MemoryState::CodeOut:
|
|
|
|
case KMemoryState::Coverage:
|
|
|
|
case Svc::MemoryState::Coverage:
|
|
|
|
case KMemoryState::Insecure:
|
|
|
|
case Svc::MemoryState::Insecure:
|
|
|
|
return m_alias_code_region_start;
|
|
|
|
return m_alias_code_region_start;
|
|
|
|
case KMemoryState::Code:
|
|
|
|
case Svc::MemoryState::Code:
|
|
|
|
case KMemoryState::CodeData:
|
|
|
|
case Svc::MemoryState::CodeData:
|
|
|
|
return m_code_region_start;
|
|
|
|
return m_code_region_start;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t KPageTable::GetRegionSize(KMemoryState state) const {
|
|
|
|
size_t KPageTable::GetRegionSize(Svc::MemoryState state) const {
|
|
|
|
switch (state) {
|
|
|
|
switch (state) {
|
|
|
|
case KMemoryState::Free:
|
|
|
|
case Svc::MemoryState::Free:
|
|
|
|
case KMemoryState::Kernel:
|
|
|
|
case Svc::MemoryState::Kernel:
|
|
|
|
return m_address_space_end - m_address_space_start;
|
|
|
|
return m_address_space_end - m_address_space_start;
|
|
|
|
case KMemoryState::Normal:
|
|
|
|
case Svc::MemoryState::Normal:
|
|
|
|
return m_heap_region_end - m_heap_region_start;
|
|
|
|
return m_heap_region_end - m_heap_region_start;
|
|
|
|
case KMemoryState::Ipc:
|
|
|
|
case Svc::MemoryState::Ipc:
|
|
|
|
case KMemoryState::NonSecureIpc:
|
|
|
|
case Svc::MemoryState::NonSecureIpc:
|
|
|
|
case KMemoryState::NonDeviceIpc:
|
|
|
|
case Svc::MemoryState::NonDeviceIpc:
|
|
|
|
return m_alias_region_end - m_alias_region_start;
|
|
|
|
return m_alias_region_end - m_alias_region_start;
|
|
|
|
case KMemoryState::Stack:
|
|
|
|
case Svc::MemoryState::Stack:
|
|
|
|
return m_stack_region_end - m_stack_region_start;
|
|
|
|
return m_stack_region_end - m_stack_region_start;
|
|
|
|
case KMemoryState::Static:
|
|
|
|
case Svc::MemoryState::Static:
|
|
|
|
case KMemoryState::ThreadLocal:
|
|
|
|
case Svc::MemoryState::ThreadLocal:
|
|
|
|
return m_kernel_map_region_end - m_kernel_map_region_start;
|
|
|
|
return m_kernel_map_region_end - m_kernel_map_region_start;
|
|
|
|
case KMemoryState::Io:
|
|
|
|
case Svc::MemoryState::Io:
|
|
|
|
case KMemoryState::Shared:
|
|
|
|
case Svc::MemoryState::Shared:
|
|
|
|
case KMemoryState::AliasCode:
|
|
|
|
case Svc::MemoryState::AliasCode:
|
|
|
|
case KMemoryState::AliasCodeData:
|
|
|
|
case Svc::MemoryState::AliasCodeData:
|
|
|
|
case KMemoryState::Transfered:
|
|
|
|
case Svc::MemoryState::Transfered:
|
|
|
|
case KMemoryState::SharedTransfered:
|
|
|
|
case Svc::MemoryState::SharedTransfered:
|
|
|
|
case KMemoryState::SharedCode:
|
|
|
|
case Svc::MemoryState::SharedCode:
|
|
|
|
case KMemoryState::GeneratedCode:
|
|
|
|
case Svc::MemoryState::GeneratedCode:
|
|
|
|
case KMemoryState::CodeOut:
|
|
|
|
case Svc::MemoryState::CodeOut:
|
|
|
|
case KMemoryState::Coverage:
|
|
|
|
case Svc::MemoryState::Coverage:
|
|
|
|
case KMemoryState::Insecure:
|
|
|
|
case Svc::MemoryState::Insecure:
|
|
|
|
return m_alias_code_region_end - m_alias_code_region_start;
|
|
|
|
return m_alias_code_region_end - m_alias_code_region_start;
|
|
|
|
case KMemoryState::Code:
|
|
|
|
case Svc::MemoryState::Code:
|
|
|
|
case KMemoryState::CodeData:
|
|
|
|
case Svc::MemoryState::CodeData:
|
|
|
|
return m_code_region_end - m_code_region_start;
|
|
|
|
return m_code_region_end - m_code_region_start;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KPageTable::CanContain(KProcessAddress addr, size_t size, KMemoryState state) const {
|
|
|
|
bool KPageTable::CanContain(KProcessAddress addr, size_t size, Svc::MemoryState state) const {
|
|
|
|
const KProcessAddress end = addr + size;
|
|
|
|
const KProcessAddress end = addr + size;
|
|
|
|
const KProcessAddress last = end - 1;
|
|
|
|
const KProcessAddress last = end - 1;
|
|
|
|
|
|
|
|
|
|
|
@ -3192,32 +3191,32 @@ bool KPageTable::CanContain(KProcessAddress addr, size_t size, KMemoryState stat
|
|
|
|
const bool is_in_alias = !(end <= m_alias_region_start || m_alias_region_end <= addr ||
|
|
|
|
const bool is_in_alias = !(end <= m_alias_region_start || m_alias_region_end <= addr ||
|
|
|
|
m_alias_region_start == m_alias_region_end);
|
|
|
|
m_alias_region_start == m_alias_region_end);
|
|
|
|
switch (state) {
|
|
|
|
switch (state) {
|
|
|
|
case KMemoryState::Free:
|
|
|
|
case Svc::MemoryState::Free:
|
|
|
|
case KMemoryState::Kernel:
|
|
|
|
case Svc::MemoryState::Kernel:
|
|
|
|
return is_in_region;
|
|
|
|
return is_in_region;
|
|
|
|
case KMemoryState::Io:
|
|
|
|
case Svc::MemoryState::Io:
|
|
|
|
case KMemoryState::Static:
|
|
|
|
case Svc::MemoryState::Static:
|
|
|
|
case KMemoryState::Code:
|
|
|
|
case Svc::MemoryState::Code:
|
|
|
|
case KMemoryState::CodeData:
|
|
|
|
case Svc::MemoryState::CodeData:
|
|
|
|
case KMemoryState::Shared:
|
|
|
|
case Svc::MemoryState::Shared:
|
|
|
|
case KMemoryState::AliasCode:
|
|
|
|
case Svc::MemoryState::AliasCode:
|
|
|
|
case KMemoryState::AliasCodeData:
|
|
|
|
case Svc::MemoryState::AliasCodeData:
|
|
|
|
case KMemoryState::Stack:
|
|
|
|
case Svc::MemoryState::Stack:
|
|
|
|
case KMemoryState::ThreadLocal:
|
|
|
|
case Svc::MemoryState::ThreadLocal:
|
|
|
|
case KMemoryState::Transfered:
|
|
|
|
case Svc::MemoryState::Transfered:
|
|
|
|
case KMemoryState::SharedTransfered:
|
|
|
|
case Svc::MemoryState::SharedTransfered:
|
|
|
|
case KMemoryState::SharedCode:
|
|
|
|
case Svc::MemoryState::SharedCode:
|
|
|
|
case KMemoryState::GeneratedCode:
|
|
|
|
case Svc::MemoryState::GeneratedCode:
|
|
|
|
case KMemoryState::CodeOut:
|
|
|
|
case Svc::MemoryState::CodeOut:
|
|
|
|
case KMemoryState::Coverage:
|
|
|
|
case Svc::MemoryState::Coverage:
|
|
|
|
case KMemoryState::Insecure:
|
|
|
|
case Svc::MemoryState::Insecure:
|
|
|
|
return is_in_region && !is_in_heap && !is_in_alias;
|
|
|
|
return is_in_region && !is_in_heap && !is_in_alias;
|
|
|
|
case KMemoryState::Normal:
|
|
|
|
case Svc::MemoryState::Normal:
|
|
|
|
ASSERT(is_in_heap);
|
|
|
|
ASSERT(is_in_heap);
|
|
|
|
return is_in_region && !is_in_alias;
|
|
|
|
return is_in_region && !is_in_alias;
|
|
|
|
case KMemoryState::Ipc:
|
|
|
|
case Svc::MemoryState::Ipc:
|
|
|
|
case KMemoryState::NonSecureIpc:
|
|
|
|
case Svc::MemoryState::NonSecureIpc:
|
|
|
|
case KMemoryState::NonDeviceIpc:
|
|
|
|
case Svc::MemoryState::NonDeviceIpc:
|
|
|
|
ASSERT(is_in_alias);
|
|
|
|
ASSERT(is_in_alias);
|
|
|
|
return is_in_region && !is_in_heap;
|
|
|
|
return is_in_region && !is_in_heap;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|