20.0.0: Difference between revisions

Add kernel diff
Line 324: Line 324:


The anti-downgrade fuses were [[Fuses#Anti-downgrade|updated]].
The anti-downgrade fuses were [[Fuses#Anti-downgrade|updated]].
==== Kernel ====
* No/minimal compiler update
* Inverted boolean(s) in system control/targetsystem logic
** All KTargetSystem fields have inverted meaning
** KTargetSystem "is present" bool is now inverted
** MersenneTwister "is initialized" bool is now inverted
* KPageTable::ChangeProperties now does a data synchronization barrier after calling the set-attrs lambda
* KPageTableImpl::MergePages now takes an argument for a callback to call after updating page table PTE entries.
** All callers on NX are KPageTable::NoteUpdated
** This causes TLB entries to be flushed/etc every time an entry is written instead of once at the end.
** The callback is passed the disable-merge software-reserved bits from the entry, but this appears unused on NX.
*** This is probably for something in the Switch2 kernel/ifdef'd out.
* KAddressSpaceInfo::GetBegin now takes a size as a third argument; this is unused on NX.
* KAddressSpaceInfo::GetSize now performs more complicated logic based on the input type.
** If address space not CreateProcessFlag_AddressSpace32BitWithoutAlias then the size is returned directly.
** Otherwise:
*** If the type is Heap, it returns the requested size + the alias size.
*** If the type is Alias, it returns 0.
** KProcess::InitializeByParam now sets m_max_process_memory to KAddressSpaceInfo::GetSize(..., Type_Heap) instead of getting the page table's heap size.
** KPageTableBase::InitializeForProcess has simpler calculation of region extents for 32BitWithoutAlias now.
* KPageTableBase::MapPageGroup_ now checks if the input permission has the execute bit set, and invalidates instruction cache if so.
** This fixes a correctness bug; this was used to map pages as ReadExecute by JIT svcs, so stale instruction cache could result before.
** KPageTableBase::UnmapPageGroup also now invalidates instruction cache after unmapping, if the memory had the execute bit set.
* KSecureSystemResource now has better checking for the case where resource limit is nullptr.
** This is impossible on NX.
** This includes checks in GetUsed/TotalUserPhysicalMemorySize
** KSecureSystemResource::Destroy now checks before calling ReleaseLimit
* KPageTableBase::SetProcessMemoryPermission changes:
** Function now uses PageTableOperation_ChangePermsAndRefresh instead of _ChangePermsAndRefreshAndFlushDataCache when the execute permission is set.
** Data cache store + instruction cache invalidate is now done before operating instead of after
** instruction cache invalidate is done after memory block manager is updated.
* El0SynchronousExceptionHandler now always does tlbi vae1 instead of doing that or tlbi aside1 depending on status bits.
* El1SynchronousExceptionHandler now always does tlbi vaae1 instead of doing that or tlbi vmalle1 depending on status bits.
** NOTE: The checks Nintendo did previously have been bugged for many years and did not work.
** These checks were fixed to actually work now.
* UserspaceAccess changes:
** UserspaceAccess functions are now all called through helper functions, which directly call UserspaceAccess::*
*** This is probably "UserspaceAccessChecked", and likely for parity with the supervisor mode access function they added in 19.0.0.
** UserspaceAccess functions which previously had no callers have been deleted.
*** This includes UserspaceAccess::ClearUserMemory*.
* HandleException changes:
** After checking for thread termination, fixup is done on esr_el1/ec values.
*** If esr_ec is 0x20 or 0x24 (DataAbortEl0/InstructionAbortEl0):
**** If esr_el1 & 0x43F == 0x410 then pc is treated as 0
**** Otherwise, if pc is a kernel address, then esr_el1 has the ISFC bits set to hardcoded-value 4.
** This is also done in ReturnFromException
* Kernel::InitializeResourceManagers now initializes the managers in a different order.
* KPageTableBase::FindFreeArea now uses a helper to compute the start and end of the guarded region to generate an address within.
** The same logic is used (without helper, possibly inlined) in KMemoryBlockManager::FindFreeArea.


==See Also==
==See Also==