summaryrefslogtreecommitdiff
path: root/Kernel/VM
AgeCommit message (Collapse)Author
2021-07-11Kernel: Make VMObject::class_name() return a StringViewAndreas Kling
2021-07-11Kernel: Rename various *VMObject::create*() => try_create()Andreas Kling
try_*() implies that it can fail (and they all return RefPtr with nullptr signalling failure.)
2021-07-11Kernel: Make SharedInodeVMObject allocation OOM-safeAndreas Kling
2021-07-11Kernel: Store VMObject physical pages in a FixedArrayAndreas Kling
Let's enforce the invariant that VMObjects don't shrink or grow by storing the pages in a FixedArray.
2021-07-11Kernel: Make VMObject vend physical page range as a spanAndreas Kling
Stop exposing the internal data structure used for storing the physical pages and return a Span<RefPtr<PhysicalPage>> instead.
2021-07-11Kernel: Remove unused MemoryManager::find_region_from_vaddr()Andreas Kling
2021-07-11Kernel: Remove unused MemoryManager::m_physical_page_entries_freeAndreas Kling
2021-07-11Kernel: Remove pointless ref-counting from PhysicalRegionAndreas Kling
These are not multiple-owner objects and have no use for ref-counting. Make them simple value types instead (not eternal heap-allocated.)
2021-07-11Kernel: Use Forward.h headers moreAndreas Kling
2021-07-09Kernel: Support multiport for VirtIOConsolex-yl
This involves refactoring VirtIOConsole into VirtIOConsole and VirtIOConsolePort. VirtIOConsole is the VirtIODevice, it owns multiple VirtIOConsolePorts as well as two control queues. Each VirtIOConsolePort is a CharacterDevice.
2021-07-09Kernel: Add support for reading from VirtIOConsolex-yl
This allows two-way communication with the host through a VirtIOConsole. This is necessary for features like clipboard sharing.
2021-07-08Kernel: Return an already destructed PhysicalPage to the allocatorsTom
By making sure the PhysicalPage instance is fully destructed the allocators will have a chance to reclaim the PhysicalPageEntry for free-list purposes. Just pass them the physical address of the page that was freed, which is enough to lookup the PhysicalPageEntry later.
2021-07-08Kernel: Move PhysicalPage classes out of the heap into an arrayTom
By moving the PhysicalPage classes out of the kernel heap into a static array, one for each physical page, we can avoid the added overhead and easily find them by indexing into an array. This also wraps the PhysicalPage into a PhysicalPageEntry, which allows us to re-use each slot with information where to find the next free page.
2021-07-08Kernel: Use PAE to allow accessing all physical memory beyond 4GBTom
We already use PAE for the NX bit, but this changes the PhysicalAddress structure to be able to hold 64 bit physical addresses. This allows us to use all the available physical memory.
2021-07-02Kernel/TypedMapping: Round up length with offset_in_pageLiav A
Fixes #6948.
2021-06-28Kernel: Fix GDT and segment selectors to make userland work on x86_64Gunnar Beutner
Userland faulted on the very first instruction before because the PML4T/PDPT/etc. weren't marked as user-accessible. For some reason x86 doesn't care about that. Also, we need to provide an appropriate userspace stack segment selector to iretq.
2021-06-28Kernel: Fix page round wrap detection for 64-bitHendiadyoin1
We were assuming 32-bit pointers, which will not always be the case Also fixed an incorrect comment about wrapping
2021-06-28Kernel: Make and use KERNEL_BASEHendiadyoin1
This is to make the 0xc0000000 less a magic number, and will make it easier in the future to move the Kernel around
2021-06-28Kernel: Fix type for PageDirectory::s_cr3_mapGunnar Beutner
2021-06-27Kernel: Rename Thread::tss to Thread::regs and add x86_64 supportGunnar Beutner
We're using software context switches so calling this struct tss is somewhat misleading.
2021-06-26Kernel: Add PML4T support for the PageDirectory classGunnar Beutner
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-06-24Kernel: Add stubs for missing x86_64 functionalityGunnar Beutner
This adds just enough stubs to make the kernel compile on x86_64. Obviously it won't do anything useful - in fact it won't even attempt to boot because Multiboot doesn't support ELF64 binaries - but it gets those compiler errors out of the way so more progress can be made getting all the missing functionality in place.
2021-06-24Kernel: Move special sections into Sections.hHendiadyoin1
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24Kernel: Pull apart CPU.hHendiadyoin1
This does not add any functional changes
2021-06-17Kernel: Fix incorrect argument nameGunnar Beutner
2021-06-16Kernel: Remove various other uses of ssize_tGunnar Beutner
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
2021-06-02Kernel: Avoid allocations in the VMObject constructorGunnar Beutner
This avoids allocations in the VMObject constructor. The number of inline elements was determined empirically and covers most common cases including LibC malloc.
2021-06-02Kernel: Fix use-after-free in sys$mremapGunnar Beutner
Now that Region::name() has been changed to return a StringView we can't rely on keeping a copy of the region's name past the region's destruction just by holding a copy of the StringView.
2021-05-29Everywhere: Sort out superfluous QuickSort.h importsBen Wiederhake
They were sorta unneeded. :^)
2021-05-29Kernel: Move sys$munmap functionality into a helper methodGunnar Beutner
2021-05-29Kernel: Make Region creation API OOM safeBrian Gianforcaro
- Make Region::create_kernel_only OOM safe. - Make Region::create_user_accessible mostly OOM safe, there are still some tendrils to untangle before it and be completely fixed.
2021-05-29Kernel: Make Space::create API OOM safeBrian Gianforcaro
2021-05-29Kernel: Make ContiguousVMObject factory API OOM safeBrian Gianforcaro
2021-05-29Kernel: Make AnonymousVMObject::clone() API OOM safeBrian Gianforcaro
Propagate allocation failure of m_shared_committed_cow_pages, and uncommit previously committed COW pages on failure. This method needs a closer look in terms of error handling, as we will eventually need to rollback all changes on allocation failure. Alternatively we could allocate the anonymous object much earlier and only initialize it once the other steps have succeeded.
2021-05-29Kernel: Make PrivateInodeVMObject factory APIs OOM safeBrian Gianforcaro
2021-05-28Kernel: Use KString for Region namesAndreas Kling
Replace the AK::String used for Region::m_name with a KString. This seems beneficial across the board, but as a specific data point, it reduces time spent in sys$set_mmap_name() by ~50% on test-js. :^)
2021-05-26Kernel: Switch VMObject to IntrusiveList from InlineLinkedListBrian Gianforcaro
2021-05-26Kernel: Switch Region to IntrusiveList from InlineLinkedListBrian Gianforcaro
2021-05-25Kernel: Release the paging lock while reading from the diskTom
Because reading from the disk may preempt, we need to release the paging lock.
2021-05-20Kernel: Do not allocate AnonymousVMObject's under spin lockBrian Gianforcaro
Spinlocks guard short regions, with hopefully no other locks being taken in the process. Violating constraints usually had detrimental effects on platform stability as well as performance and scalability. Allocating memory takes it own locks, and can in some cases even allocate new regions, and thus violates these tenants. Move the AnonymousVMObject creation outside of the spinlock as creation does not modify any shared state.
2021-05-19Kernel: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-16Kernel: Expand the kernel memory slot from 16 MiB to 32 MiBLiav A
Like in 8cd5477e54a19d5476e9a31d0677e58c9a4ce12d, we need to expand the kernel slot again to be able to boot again.
2021-05-16AK+Kernel+LibELF: Remove the need for `IteratorDecision::Continue`Nicholas Baron
By constraining two implementations, the compiler will select the best fitting one. All this will require is duplicating the implementation and simplifying for the `void` case. This constraining also informs both the caller and compiler by passing the callback parameter types as part of the constraint (e.g.: `IterationFunction<int>`). Some `for_each` functions in LibELF only take functions which return `void`. This is a minimal correctness check, as it removes one way for a function to incompletely do something. There seems to be a possible idiom where inside a lambda, a `return;` is the same as `continue;` in a for-loop.
2021-05-15Kernel: Make AnonymousVMObject physical page APIs OOM safeBrian Gianforcaro
AnonymousVMObject::create_with_physical_page(s) can't be NonnullRefPtr as it allocates internally. Fixing the API then surfaced an issue in ScatterGatherList, where the code was attempting to create an AnonymousVMObject in the constructor which will not be observable during OOM. Fix all of these issues and start propagating errors at the callers of the AnonymousVMObject and ScatterGatherList APis.
2021-05-15Kernel: Make AnonymousVMObject::clone/create APIs OOM safeBrian Gianforcaro
2021-05-13Kernel: Move VirtIO code away from using a scatter gather listSahan Fernando
Currently, when passing buffers into VirtIOQueues, we use scatter-gather lists, which contain an internal vector of buffers. This vector is allocated, filled and the destroy whenever we try to provide buffers into a virtqueue, which would happen a lot in performance cricital code (the main transport mechanism for certain paravirtualized devices). This commit moves it over to using VirtIOQueueChains and building the chain in place in the VirtIOQueue. Also included are a bunch of fixups for the VirtIO Console device, making it use an internal VM::RingBuffer instead.
2021-05-13Kernel: Create VM::RingBuffer classSahan Fernando
2021-05-13Kernel: Move AHCIPort::ScatterList to VM::ScatterGatherListSahan Fernando
We want to move this out of the AHCI subsystem into the VM system, since other parts of the kernel may need to perform scatter-gather IO. We rename the current VM::ScatterGatherList impl that's used in the virtio subsystem to VM::ScatterGatherRefList, since its distinguishing feature from the AHCI scatter-gather list is that it doesn't own its buffers.