1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-26 22:02:15 +00:00

kern: clear new pages in init page allocator, not init page table

This commit is contained in:
Michael Scire 2023-10-11 03:27:45 -07:00 committed by SciresM
parent c72ba35684
commit cfd2d5b012

View file

@ -87,9 +87,8 @@ namespace ams::kern::arch::arm64::init {
template<IsInitialPageAllocator PageAllocator> template<IsInitialPageAllocator PageAllocator>
static ALWAYS_INLINE KPhysicalAddress AllocateNewPageTable(PageAllocator &allocator, u64 phys_to_virt_offset) { static ALWAYS_INLINE KPhysicalAddress AllocateNewPageTable(PageAllocator &allocator, u64 phys_to_virt_offset) {
auto address = allocator.Allocate(PageSize); MESOSPHERE_UNUSED(phys_to_virt_offset);
ClearNewPageTable(address, phys_to_virt_offset); return allocator.Allocate(PageSize);
return address;
} }
static ALWAYS_INLINE void ClearNewPageTable(KPhysicalAddress address, u64 phys_to_virt_offset) { static ALWAYS_INLINE void ClearNewPageTable(KPhysicalAddress address, u64 phys_to_virt_offset) {
@ -883,6 +882,12 @@ namespace ams::kern::arch::arm64::init {
const size_t ind_max = ((aligned_end - aligned_start) / align) - 1; const size_t ind_max = ((aligned_end - aligned_start) / align) - 1;
while (true) { while (true) {
if (const uintptr_t random_address = aligned_start + (KSystemControl::Init::GenerateRandomRange(0, ind_max) * align); this->TryAllocate(random_address, size)) { if (const uintptr_t random_address = aligned_start + (KSystemControl::Init::GenerateRandomRange(0, ind_max) * align); this->TryAllocate(random_address, size)) {
/* Clear the allocated pages. */
volatile u64 *ptr = reinterpret_cast<volatile u64 *>(random_address);
for (size_t i = 0; i < size / sizeof(u64); ++i) {
ptr[i] = 0;
}
return random_address; return random_address;
} }
} }