Jump to navigation Jump to search
8,499 bytes added ,  03:43, 27 August 2020
** Future invocations of StorageExpMod will ignore the user-provided modulus, and use the imported one.
* UnwrapTitleKey now returns new result 7 ("NotImported") when attempting to unwrap a titlekey before importing the exponent and modulus.
<check back for more diffs later>
* The firmware revision magic was changed from 0x18C to 0x1AD.
<check back for more diffs later>
* Kernel crt0 was heavily refactored.
** Core 0 init vs Core 1/2/3 init are now separate functions.
** The initial arguments are now stored inside the Core Local regions before those regions are initialized.
*** This saves a little memory by allowing for reusing that space.
** The initial arguments now store an entrypoint invocation function pointer in addition to the entrypoint.
** Core 1/2/3 now panic if cpuactlr/cpuectlr hold a value different than the one in init argument. Previously, they they did if (real value != expected value) { real value = expected value }.
* The reserved memory size for slab heap aslr gaps was reduced by 64 KB from 2 MB to 0x1F0000.
* Physical ASLR for certain backing regions (Kernel .text/.rodata/.rwdata/.bss + the Slab Heap region) was implemented.
** Physical randomization of the kernel image is done by KernelLdr.
** Randomization of the slab heap region is done by kernel during init.
** To accommodate this, the virtual/physical memory trees no longer track pair blocks for the kernel/slab heap regions (as they no longer correlate directly).
* The global rng is now std::mt19937_64 instead of std::mt19937
* KPageHeap bitmaps now store a small TinyMT rng.
** This is used to allocate random pages from the bitmap instead of first-available. Thus, KPageHeap allocation order is now random/non-deterministic.
* KSpinLock was changed. Previously it used two u16s, each aligned to cache line. Now it packs the u16s into a single non-cache-line aligned u32.
** The new spin lock is identical to the implementation in the ARM Reference Manual.
** KScheduler's spin lock still uses the old cache-line aligned u16s.
** Speculatively, we can consider the following motivation for the change:
*** The old spin lock cannot atomically update both tickets with a single write. Thus, it is required to do two loops (one to update the current ticket, one to check if the obtained ticket is the active and the lock is taken).
*** The new spin lock can atomically update both tickets with a single write. Thus, in the case where the lock is not held by another core when it is acquired, the new spin lock only has to do one atomic loop.
*** From this we can observe that the new spin lock is likely more performant under low contention (where it is expected that the lock is not held), however its downsides are potential false sharing (due to not owning the cache line). It is also probably better when at the start of a cache line and the locked data exists entirely within that cache line.
*** Most kernel locks are expected to be relatively uncontended (and there aren't really cases where two locks are in the same cache line so false sharing isn't such a problem), and thus the switch to the new ARM reference manual style lock should lead to an overall performance upgrade.
*** However, the scheduler lock is heavily contended (all cores will be locking it and unlocking it pretty much all the time). Thus, it makes more sense for it to continue using the old two-cache-line style lock, which performs better under high contention.
* KProcess now has an additional data member storing the kernel virtual address of the process local region.
** This is now used instead of the process virtual address for the tls region when writing context during exception handling.
** This probably fixes a bug if an exception is being handled for a non-current process and the relevant codepath is taken(?)
* Page table entry handling code was changed. Bit 56 is now used as an is valid/present flag. Previously checks that checked entries with bitmask 0x3 now check 0x100000000000002.
* KPageTableBase now has an additional data member storing how much unsafe memory is currently mapped. (This value is incremented/decremented on calls to svcMapPhysicalMemoryUnsafe/svcUnmapPhysicalMemoryUnsafe).
* KPageTableBase::LockForIpc* now takes a KPhysicalAddress * argument. Mapping code will try to write the physical address of the locked virtual address to this out pointer, KernelPanic() is called if physical address translation fails.
* KServerSession::SendReply now takes an additional argument for the physical address of the user message buffer. NULL is passed when doing ReplyAndReceive without a user buffer.
** When this argument is not null, the message buffer is accessed by doing linear phys-to-virt translation on this physaddress, otherwise the message buffer is accessed by doing linear phys-to-virt translation on the TLS physical address.
** Previously, the process virtual address for the user buffer was accessed directly.
* Pages allocated from the dynamic page slab heap are no longer memset to zero after being allocated.
** Instead, they are memset to zero when the heap is first initialized, and when being freed.
** This fixes the issue that pages were sometimes memset to zero unnecessarily, because they were already zero'd by some previous operation.
** Newly allocated pages being all-zero is now a kernel invariant.
* A new KMemoryPermission bit (0x40) was added. When this bit is set, the page is completely unmapped (for both user and kernel). This is done when e.g. memory is mirrored via MapMemory, when memory is locked for IPC usage, etc.
* KPageTable::ChangePermissions was changed substantially to accommodate this.
** Previously, it separated pages, iterated over mappings changing permissions as required (and invalidating + flushing cache if bool arg is true), then merged pages.
** Now, the function has a lambda which iterates over all mappings, changing permissions as required and performing additional operations depending on a bitflag parameter.
** First, the function separates pages.
** Then if the input bool is false, this lambda is called with entry template = input entry template, bitflag parameter = 0. This changes all mappings to the new permissions. Pages are then merged, and the function returns.
** Otherwise if the input bool is true, the lambda is called with entry template = input entry template & ~1 and bitflag parameter = 2. This changes all mappings to be invalid (as low bit of pte is zero). Bitflag & 2 causes entries to be merged during traversal.
** Next, the scheduling lock is locked and immediately unlocked. This forces a reschedule.
** Next, the lambda is called with entry template = input entry template, bitflag parameter = 1. This changes all mappings to new permissions, and flushes data cache on all new mappings.
** Finally, mappings are merged, and the function returns.
* SvcQueryIoMapping's ABI was changed.
** Previously signature was Result QueryIoMapping(uintptr_t *out_address, PhysicalAddress physical_address, size_t size).
** New signature is Result QueryIoMapping(uintptr_t *out_address, size_t *out_size, PhysicalAddress physical_address, size_t size);
** For normal IO, out_size is just written with the input size parameter.
** For special debug regions (mapped using 8.0.0+ memory region descriptor, queried by passing 1/2/3 as phys_addr parameter), out_size is written with the real size of the queried region.
* SvcQueryPhysicalAddress was stubbed, and now always returns ResultInvalidCurrentMemoryState.
* KCurrentContext now stores a dereferencable pointer to the current thread's TLS.
** This is used to check the user disable count (for thread pinning) in the SvcHandler instead of loading tls from tpidrro_el0.
====FIRM Sysmodules====
* Sysmodules jit and pgl were added.
* All titles were updated, except for: ppc (was already stubbed), Chinese and Korean dictionaries, Dictionary, LocalNews, Eula, ControllerIcon, and flog.
* The following sysmodules had IPC changes: [[Filesystem_services|fs]], [[Loader_services|Loader]], [[NCM_services|ncm]], [[Settings_services|settings]], [[Bus_services|Bus]], [[Bluetooth_Driver_services|bluetooth]], [[BCAT_services|bcat]], [[Friend_services|friends]], [[PTM_services|ptm]], [[Sockets_services|bsdsockets]], [[HID_services|hid]], [[Audio_services|audio]], [[WLAN_services|wlan]], [[NV_services|nvservices]], [[PCV_services|pcv]], [[Account_services|account]], [[NS_Services|ns]], [[PSC_services|psc]], [[Applet_Manager_services|am]], [[NIM_services|nim]], [[Backlight_services|lbl]], [[BTM_services|btm]], [[Display_services|vi]], [[Parental_Control_services|pctl]], [[NPNS_services|npns]], [[Error_Upload_services|eupld]], [[Glue_services|glue]], [[ETicket_services|es]], [[Shared_Database_services|sdb]], [[OLSC_services|olsc]], [[NGCT_services|ngct]].
NPDM changes:
* [[PTM_services|ptm]] now hosts lbl. lbl is now stubbed, there's no content besides the Meta and the ContentMetaType is now SystemData.
* [[Sockets_services|bsdsocket]] no longer has access to bgtc:t. It now has access to psc:l and time:al.
* The pcie.withoutHb sysmodule was renamed to pcie.
* The mapped IO range for wlan and pcie was updated.
* [[NS_Services|ns]] now has access to arp:w and pgl. Access to ldr:shel, ncm:v, and pm:shell were removed. Bitmask 0x0000001000000000 is now set in the FS permissions.* [[SSL_services|ssl]] now has access to lm, but the sysmodule doesn't actually use it.
* [[Error_Upload_services|eupld]] now has access to srepo:u.
* [[Glue_services|glue]] no longer has access to bpc, and access to time:al was added.
** Prior to this sysupdate, no retail system-titles used time:al.
* [[GRC_services|grc]] now has access to time:su.
* [[creport]] no longer has access to ns:dev, and access to pgl was added.
* [[Shared_Database_services|sdb]] no longer has access to prepo:s, and access to srepo:u was added.
* [[OLSC_services|olsc]] now hosts a new [[Services_API|service]], and access to arp:r was added. [[SVC]]s svcMapTransferMemory and svcUnmapTransferMemory are now accessible.
* All web-applets now have access to [[SVC]]s svcMapPhysicalMemoryUnsafe/svcUnmapPhysicalMemoryUnsafe, but these aren't used in the main-codebin for any of these applets.
* [[MyPage_Applet|LibraryAppletMyPage]] now has access to npns:s.
** "/listWebYouTubePlayerCommon.txt" was added, containing the same youtube whitelist originally from LibraryAppletWeb.
* TimeZoneBinary was updated with new timezone info.
* The font in FontNintendoExtension : "/nintendo_ext2_003.bfttf" was updated.
* The config in FirmwareDebugSettings, PlatformConfigIcosa, PlatformConfigCopper, PlatformConfigHoag, and PlatformConfigIcosaMariko were updated.
* [[HID_services#Firmware_update|ControllerFirmware]] was updated with new firmware. See that page for the new files, and also regarding hid-sysmodule RomFs. The following files were updated:

Navigation menu