mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-28 05:06:08 +00:00
kern: fix bugs in MapAlias ipc mappings
This commit is contained in:
parent
a8d4b10b17
commit
e2e5a2ccc2
3 changed files with 11 additions and 9 deletions
|
@ -257,7 +257,9 @@ namespace ams::kern {
|
|||
/* If there's a previous, we should check for coalescing. */
|
||||
check_coalesce_prev = true;
|
||||
prev--;
|
||||
} else if (cur_info.GetSize() > remaining_size) {
|
||||
}
|
||||
|
||||
if (cur_info.GetSize() > remaining_size) {
|
||||
/* If we need to, create a new block after and insert it. */
|
||||
KMemoryBlock *new_block = allocator->Allocate();
|
||||
|
||||
|
|
|
@ -2144,8 +2144,8 @@ namespace ams::kern {
|
|||
}
|
||||
|
||||
/* Handle the last direct-mapped page. */
|
||||
if (cur_mapped_addr < mapping_src_end) {
|
||||
const size_t last_block_size = mapping_src_end - cur_mapped_addr;
|
||||
if (const KProcessAddress mapped_block_end = aligned_src_start + tot_block_size - cur_block_size; mapped_block_end < mapping_src_end) {
|
||||
const size_t last_block_size = mapping_src_end - mapped_block_end;
|
||||
|
||||
/* Map the last block. */
|
||||
R_TRY(this->Operate(updater.GetPageList(), cur_mapped_addr, last_block_size / PageSize, cur_block_addr, true, dst_map_properties, OperationType_Map, false));
|
||||
|
@ -2153,7 +2153,7 @@ namespace ams::kern {
|
|||
/* Update tracking extents. */
|
||||
cur_mapped_addr += last_block_size;
|
||||
cur_block_addr += last_block_size;
|
||||
if (aligned_src_start + tot_block_size < aligned_src_end && cur_block_size == last_block_size) {
|
||||
if (mapped_block_end + cur_block_size < aligned_src_end && cur_block_size == last_block_size) {
|
||||
traverse_valid = impl.ContinueTraversal(std::addressof(next_entry), std::addressof(context));
|
||||
MESOSPHERE_ASSERT(traverse_valid);
|
||||
|
||||
|
@ -2256,12 +2256,12 @@ namespace ams::kern {
|
|||
/* Get aligned extents. */
|
||||
const KProcessAddress aligned_start = util::AlignDown(GetInteger(address), PageSize);
|
||||
const KProcessAddress aligned_end = util::AlignUp(GetInteger(address) + size, PageSize);
|
||||
const size_t aligned_size = aligned_start - aligned_end;
|
||||
const size_t aligned_size = aligned_end - aligned_start;
|
||||
const size_t aligned_num_pages = aligned_size / PageSize;
|
||||
|
||||
/* Unmap the pages. */
|
||||
const KPageProperties unmap_properties = { KMemoryPermission_None, false, false, false };
|
||||
R_TRY(this->Operate(updater.GetPageList(), aligned_start, aligned_size / PageSize, Null<KPhysicalAddress>, false, unmap_properties, OperationType_Unmap, false));
|
||||
R_TRY(this->Operate(updater.GetPageList(), aligned_start, aligned_num_pages, Null<KPhysicalAddress>, false, unmap_properties, OperationType_Unmap, false));
|
||||
|
||||
/* Update memory blocks. */
|
||||
this->memory_block_manager.Update(std::addressof(allocator), aligned_start, aligned_num_pages, KMemoryState_None, KMemoryPermission_None, KMemoryAttribute_None);
|
||||
|
|
|
@ -413,17 +413,17 @@ namespace ams::kern {
|
|||
|
||||
/* Cleanup Send mappings. */
|
||||
for (size_t i = 0; i < request->GetSendCount(); ++i) {
|
||||
R_TRY(client_page_table->CleanupForIpcClient(request->GetSendServerAddress(i), request->GetSendSize(i), request->GetSendMemoryState(i)));
|
||||
R_TRY(client_page_table->CleanupForIpcClient(request->GetSendClientAddress(i), request->GetSendSize(i), request->GetSendMemoryState(i)));
|
||||
}
|
||||
|
||||
/* Cleanup Receive mappings. */
|
||||
for (size_t i = 0; i < request->GetReceiveCount(); ++i) {
|
||||
R_TRY(client_page_table->CleanupForIpcClient(request->GetReceiveServerAddress(i), request->GetReceiveSize(i), request->GetReceiveMemoryState(i)));
|
||||
R_TRY(client_page_table->CleanupForIpcClient(request->GetReceiveClientAddress(i), request->GetReceiveSize(i), request->GetReceiveMemoryState(i)));
|
||||
}
|
||||
|
||||
/* Cleanup Exchange mappings. */
|
||||
for (size_t i = 0; i < request->GetExchangeCount(); ++i) {
|
||||
R_TRY(client_page_table->CleanupForIpcClient(request->GetExchangeServerAddress(i), request->GetExchangeSize(i), request->GetExchangeMemoryState(i)));
|
||||
R_TRY(client_page_table->CleanupForIpcClient(request->GetExchangeClientAddress(i), request->GetExchangeSize(i), request->GetExchangeMemoryState(i)));
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
|
|
Loading…
Reference in a new issue