11.0.0: Difference between revisions

Kernel: there's a whole lot of different stuff.
Line 69: Line 69:


====Kernel====
====Kernel====
<check back for diffs later>
* Kernel is now built with -Os instead of -O3
** Many functions are no longer inlined.
* crt0 deprivileging code now sets hypervisor EL2 registers.
* Logic for flushing entire data cache and invalidating entire TLB during init is now a function called by JumpFromEL2ToEL1 and DisableMmuICacheAndDCache instead of being duplicated.
* Initialize0 has had several things re-ordered/shuffled:
** InsertDevicePhysicalMemoryBlocks is now called immediately after the KernelCode region is inserted.
** "Needed device virtual space" is now calculated as 3 * (0x18000 + { sum of KernelAutoMap physical device regions } + GetUnknownDebugDeviceRegionSize()
** KernelMisc region size is now util::AlignUp(std::max(needed_device_virtual_space, 32_MB), 2_MB).
** Code for mapping the unknown debug address as UnknownDebug is no longer present.
** Slab region is now memset to zero after the linear region is mapped instead of before.
** Ranges are now more uniform; value in [range address / 2_MB, last_address / 2_MB] is generated and multipled by 2 MB instead of aligning down result.
* KMemoryRegion now has a "last_address" member replacing its "size" member.
** GetSize() now calculated as (last_address - address + 1)
* KMemoryRegionTree::Insert now takes in last address instead of size.
** Several callsites now verify that last_address != 0xFFFF...
* "Virtual" cores now supported, KThread now stores core ID/affinity for both virtual and physical.
* New SVC 0x37 "GetResourceLimitPeakValue"
** Returns the highest value that a resource limit's current has ever achieved.
** KResourceLimit now stores an array of peak values to enable this
* Two new kernel objects, KAlpha and KBeta (placeholder names, true object names are unknown and cannot be guessed without observing purpose).
** KAlpha has size 0x50, KBeta has size 0x88
** KObjectAllocators for KAlpha/KBeta receive counts 1, 6.
** KProcess has a list of KBeta, intrusive list node is at KBeta + 0x68.
* Four new SVCs, ID 0x39, 0x3A, 0x46, 0x47
** These are likely for interacting with KAlpha and KBeta, but on NX they are (presumably) if-def'd to be "return svc::ResultNotImplemented()"
* KThread had all of its members reordered and its unused members deleted
* Most KThread waits now use KThreadWaiterListIntrusiveNode instead of KThreadQueue
* KConditionVariable no longer uses global threads for the call to .nfind()
* KCoreLocalRegion deleted, replaced with pointer-to-current-thread
** TPIDR_EL1 != X18 now, and TPIDR_EL1 now always points to the exception thread stack.
* KSynchronization was deleted, replaced with namespaced or static-on-ksynchronization-object functions
* KSynchronizationObject now contains a pointer to thread queue, instead of an inline list
* KInterruptEvent no longer has an InterruptEventTask member
* KInterruptEventTask::Reset no longer calls KInterruptManager::ClearInterrupt, instead it calls a new function which returns a result
* KInterruptEventTask now has a KLightLock member
* KHardwareTimer is now an interrupt task again
* KHardwareTimer now has a new member "maximum_time", set to std::numeric_limits<s64>::value().
** Tasks will only be added to the task list if their time is <= maximum_time, this is in addition to the >= 1 checks previously.
* KIntrusiveRedBlackTreeNode now has common member functions instead of templated, size is now packed to 0x1C instead of 0x20.
** All Insert/Remove/etc operations are common regardless of the type the node is intrusive in.
* KDebugLogImpl::Initialize() now assumes uart has been configured for logging by the secure monitor, and does not perform tegra uart init sequence
* vsprintf, KDebugString::PutString are now fully inlined inside KVPrintf.
* KObjectContainer::Insert now returns void instead of Result
** Code which previously did R_TRY() now just calls.
* KPageHeapBitmapRng now has TinyMt as a data member, instead of directly implementing KPageHeap.
** This affects how constructor is invoked.
* KMemoryBlock/KMemoryInfo now has extra members tracking u8 non_contig_bitflags, u16 ipc_non_contig_lock_count, u16 device_non_contig_lock_count
* KMemoryBlockManager Update now takes non-contig flags to determine where to coalesce (all coalescing must now happen forwards instead of either direction)
* KMemoryBlockManagerUpdateAllocator no longer has a result member, instead it has ->Initialize() which takes in a number of blocks to allocate
* KMemoryManager::Allocate, KMemoryManager::AllocatePageGroup, KMemoryManager::AllocatePageGroupForProcess, now call KPageGroup::Open on the returned page group.
** All callsites for these functions no longer call open after allocating.
* KMemoryManager::Open is now KMemoryManager::OpenAdditionalReference, now checks that refcount is >= 1 instead of >= 0
* KPageTableBase now has an additional data member "disable_device_address_space_merge"
** KProcessPageTable::Initialize now takes in (process flags & 0x1000) as a bool argument to set this.
* Page table Query operations now return a number of blocks required to support the above when relevant
* KPageTable now uses 4 sw-reserved bits instead of 1
** Former bit 0x01.... ("Is Mapped") is now bit 0x40..... (PTE bit 58)
** PTE bit 55 "contiguous not allowed" was reworked for significantly more fine-grained control
*** PTE bit 55 is now "start of block non-contiguous", coalescing cannot occur if the first block in a coalesce has this block set.
*** PTE bit 56 is now "not-end-of-block non-contiguous", coalescing cannot occur if a block other than the last in a coalesce has this bit set
*** PTE bit 57 is now "end of block non-contiguous", coalescing cannot occur if the last block in a coalesce has this bit set
*** The old non-contiguous semantics are equivalent to 56 + 57 together.
** These bits are now returned by KPageTableImpl::Traverse
** Upper byte of KPageProperties is now bitflags to control management of these bits.
** Bit 0x1 = "Set/Clear PTE Bit55"
** Bit 0x2 = "Set PTE Bit56"
** Bit 0x4 = "Clear PTE Bit56"
** Bit 0x8 = "Set PTE Bit57"
** Bit 0x10 = "Clear PTE Bit57"
** Bit 0x20 = Force-Clear 56+57 + attempt to merge
* KMemoryBlockManager/KPageTable now prevent coalescing of blocks which are reprotected --- (for transfer memory, ipc, ...)
* They also do not coalesce adjacent GPU mappings that were mapped separately.
* They removed the 0x80 "AnyLocked" bit from KMemoryAttribute
* KMemoryBlock/KMemoryInfo now have additional u16 "device_non_coalesce_right_count".
** Like device_non_coalesce_left_count from previous 11.x, this now prevents merging with block to the right if set.
* KMemoryBlock::Add now takes in the memory block to the right instead of the size of the block to the right.
** This facilitates combining flags for the newly coalesced blocks.
* KPageTableBase::SetProcessMemoryPermission no longer sets non-coalesce bit 24.
* KDeviceAddressSpace::Map/KDeviceAddressSpace::Unmap now call new KPageTableBase function to update non-coalesce state according to partial map state.
* KDevicePageTable::UnmapImpl now invalidates TlbGroup in the failure case of adding to the page group.
* KPageTableBase::MakeAndOpenContiguousPageGroup is now KPageTableBase::MakePageGroupForDeviceAddressSpace, and now prevents coalescing until call completion.
** non_coalesce_mask 0x10 is used for this.
* KPageTableBase::UnmapCodeMemory no longer requires the whole range have the same state.
** It now invalidates instruction cache if any pages are code.
* KPageTable::UnknownVirtualFunction10 now takes in more arguments: _QWORD (address probably), _QWORD (size probably), two bools, _QWORD (address2 probably), _QWORD (size2 probably), void * (probably KAlpha * or KBeta *)
** Returns whether a comparison between address_probably and address_2_probably holds depending on flags at pointer + 0x10.
* KMemoryState_Io now goes to the alias code region in GetRegionAddress/Size (weird, seems like incorrect behavior)
** Also very weird: KPageTableBase::MapIo maps IO into the kernel map region, but KPageTableBase::QueryMapping panics if it is not in the alias code region.
** This "probably" causes kernel panic if mapping IO into process with 32-bit-no-alias address space type?


====FIRM Sysmodules====
====FIRM Sysmodules====