mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-13 22:54:24 -04:00
kern: implement additional randomness in KPageHeap allocations
This commit is contained in:
parent
24739f245e
commit
401047f603
6 changed files with 150 additions and 18 deletions
|
@ -202,7 +202,7 @@ namespace ams::kern {
|
|||
Impl *chosen_manager = nullptr;
|
||||
KPhysicalAddress allocated_block = Null<KPhysicalAddress>;
|
||||
for (chosen_manager = this->GetFirstManager(pool, dir); chosen_manager != nullptr; chosen_manager = this->GetNextManager(chosen_manager, dir)) {
|
||||
allocated_block = chosen_manager->AllocateBlock(heap_index, true);
|
||||
allocated_block = chosen_manager->AllocateAligned(heap_index, num_pages, align_pages);
|
||||
if (allocated_block != Null<KPhysicalAddress>) {
|
||||
break;
|
||||
}
|
||||
|
@ -213,12 +213,6 @@ namespace ams::kern {
|
|||
return Null<KPhysicalAddress>;
|
||||
}
|
||||
|
||||
/* If we allocated more than we need, free some. */
|
||||
const size_t allocated_pages = KPageHeap::GetBlockNumPages(heap_index);
|
||||
if (allocated_pages > num_pages) {
|
||||
chosen_manager->Free(allocated_block + num_pages * PageSize, allocated_pages - num_pages);
|
||||
}
|
||||
|
||||
/* Maintain the optimized memory bitmap, if we should. */
|
||||
if (m_has_optimized_process[pool]) {
|
||||
chosen_manager->TrackUnoptimizedAllocation(allocated_block, num_pages);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue