summaryrefslogtreecommitdiff
path: root/Kernel/VM
AgeCommit message (Collapse)Author
2020-08-26Kernel: Fix losing PTEsTom
We can't use a HashMap with a small key that doesn't guarantee collisions. Change it to a HashTable instead. Fixes #3254
2020-08-26Kernel: Protect looping over VMObject regionsTom
We need to hold the memory manager lock so nobody else can modify these lists while we're iterating them.
2020-08-25Kernel: Switch singletons to use new Singleton classTom
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance. Fixes #3226
2020-08-25Kernel: Fix kmalloc memory corruptionTom
Rather than hardcoding where the kmalloc pool should be, place it at the end of the kernel image instead. This avoids corrupting global variables or other parts of the kernel as it grows. Fixes #3257
2020-08-25Kernel: Make PhysicalPage not movable and use atomic ref countingTom
We should not be moving ref-counted objects.
2020-08-22Revert "Kernel: Switch singletons to use new Singleton class"Andreas Kling
This reverts commit f48feae0b2a300992479abf0b2ded85e45ac6045.
2020-08-22Revert "Kernel: Move Singleton class to AK"Andreas Kling
This reverts commit f0906250a181c831508a45434b9f645ff98f33e4.
2020-08-22Revert "Kernel: Fix regression where MemoryManager is initialized twice"Andreas Kling
This reverts commit 8a75e0b892ab8e1c4765ac4e2f7289b258f1bf5a.
2020-08-22Revert "AK: Get rid of make_singleton function"Andreas Kling
This reverts commit 5a98e329d157a2db8379e0c97c6bdc1328027843.
2020-08-22Revert "Kernel: Make PhysicalPage not movable and use atomic ref counting"Andreas Kling
This reverts commit a89ccd842becdfbc951436da5384d8819374e0f4.
2020-08-22Kernel: Make PhysicalPage not movable and use atomic ref countingTom
We should not be moving ref-counted objects.
2020-08-22AK: Get rid of make_singleton functionTom
Just default the InitFunction template argument.
2020-08-22Kernel: Fix regression where MemoryManager is initialized twiceTom
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance.
2020-08-22Kernel: Move Singleton class to AKTom
2020-08-21Kernel: Fix assertion when releasing contiguous memory regionTom
There is no guarantee that the memory manager lock is held when physical pages are released, so just acquire the memory manager lock.
2020-08-21Kernel: Switch singletons to use new Singleton classTom
Fixes #3226
2020-08-16Kernel: Switch a comment to GiBNico Weber
2020-08-16AK: Rename KB, MB, GB to KiB, MiB, GiBNico Weber
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9". The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30". Let's use the correct name, at least in code. Only changes the name of the constants, no other behavior change.
2020-08-13Kernel: Don't request a random u32 when all but 5 bits are immediately ↵Nico Weber
masked off
2020-08-02AK: Fix overflow and mixed-signedness issues in binary_search() (#2961)Muhammad Zahalqa
2020-07-30Kernel: Rename region_from_foo() => find_region_from_foo()Andreas Kling
Let's emphasize that these functions actually go out and find regions.
2020-07-30Kernel: Move syscall implementations out of Process.cppAndreas Kling
This is something I've been meaning to do for a long time, and here we finally go. This patch moves all sys$foo functions out of Process.cpp and into files in Kernel/Syscalls/. It's not exactly one syscall per file (although it could be, but I got a bit tired of the repetitive work here..) This makes hacking on individual syscalls a lot less painful since you don't have to rebuild nearly as much code every time. I'm also hopeful that this makes it easier to understand individual syscalls. :^)
2020-07-26Kernel: Switch to using AK::is and AK::downcastAndreas Kling
2020-07-26Refactor: Change the AK::binary_search signature to use AK::Span.asynts
2020-07-06Kernel: Aggregate TLB flush requests for Regions for SMPTom
Rather than sending one TLB flush request for each page, aggregate them so that we're not spamming the other processors with FlushTLB IPIs.
2020-07-06Kernel: Minor MM optimization for SMPTom
MemoryManager::quickmap_pd and MemoryManager::quickmap_pt can only be called by one processor at the time anyway, since anything using these must have the MM lock held. So, no need to inform the other CPUs to flush their TLBs, we can just flush our own.
2020-07-06Kernel: Add SMP IPI supportTom
We can now properly initialize all processors without crashing by sending SMP IPI messages to synchronize memory between processors. We now initialize the APs once we have the scheduler running. This is so that we can process IPI messages from the other cores. Also rework interrupt handling a bit so that it's more of a 1:1 mapping. We need to allocate non-sharable interrupts for IPIs. This also fixes the occasional hang/crash because all CPUs now synchronize memory with each other.
2020-07-03Kernel: Consolidate features into CPUFeature enumTom
This allows us to consolidate printing out all the CPU features into one log statement. Also expose them in /proc/cpuinfo
2020-07-03Kernel: Fix signal deliveryTom
When delivering urgent signals to the current thread we need to check if we should be unblocked, and if not we need to yield to another process. We also need to make sure that we suppress context switches during Process::exec() so that we don't clobber the registers that it sets up (eip mainly) by a context switch. To be able to do that we add the concept of a critical section, which are similar to Process::m_in_irq but different in that they can be requested at any time. Calls to Scheduler::yield and Scheduler::donate_to will return instantly without triggering a context switch, but the processor will then asynchronously trigger a context switch once the critical section is left.
2020-07-01Kernel: Add a quickmap region for each processorTom
Threads need to be able to concurrently quickmap things.
2020-07-01Kernel: Turn Thread::current and Process::current into functionsTom
This allows us to query the current thread and process on a per processor basis
2020-07-01Kernel: List all CPUs in /proc/cpuinfoTom
2020-07-01Kernel: Implement software context switching and Processor structureTom
Moving certain globals into a new Processor structure for each CPU allows us to eventually run an instance of the scheduler on each CPU.
2020-06-27Kernel: Make Random work on CPUs without rdrandPeter Elliott
- If rdseed is not available, fallback to rdrand. - If rdrand is not available, block for entropy, or use insecure prng depending on if user wants fast or good random.
2020-06-04Kernel: Add mechanism to identity map the lowest 2MBTom
2020-05-26Kernel: Create page structures correctly in boot.setaIneLp
2020-05-23Kernel: Add non-const version of TypedMapping::operator->()Andreas Kling
2020-05-22Kernel: Simplify scanning BIOS/EBDA and MP parser initializationAndreas Kling
Add a MappedROM::find_chunk_starting_with() helper since that's a very common usage pattern in clients of this code. Also convert MultiProcessorParser from a persistent singleton object to a temporary object constructed via a failable factory function.
2020-05-22Kernel: Add convenient ways to map whole BIOS and EBDA into memoryAndreas Kling
This patch adds a MappedROM abstraction to the Kernel VM subsystem. It's basically the read-only byte buffer equivalent of a TypedMapping. We use this in the ACPI and MP table parsers to scan for interesting stuff in low memory instead of doing a bunch of address arithmetic.
2020-05-20Kernel: Validate access to whole regionsSergey Bugaev
2020-05-20Kernel: Look for a user region firstSergey Bugaev
We're far more likely to be looking for a user region than otherwise, so optimize for that case.
2020-05-16Kernel: Absorb LibBareMetal back into the kernelAndreas Kling
This was supposed to be the foundation for some kind of pre-kernel environment, but nobody is working on it right now, so let's move everything back into the kernel and remove all the confusion.
2020-05-14Build: Switch to CMake :^)Sergey Bugaev
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-08Kernel: Assert on startup if we don't find any physical pagesAndreas Kling
Instead of checking this on every page allocation, just check it once on startup. :^)
2020-05-08Kernel: Add for_each_vmobject_of_type<T>Andreas Kling
This makes iterating over a specific type of VMObjects a bit nicer.
2020-05-08Kernel: Propagate failure to commit VM regions in more placesAndreas Kling
Ultimately we should not panic just because we can't fully commit a VM region (by populating it with physical pages.) This patch handles some of the situations where commit() can fail.
2020-05-08Kernel: Use NonnullRefPtrVector<T> instead of Vector<RefPtr<T>> someAndreas Kling
2020-05-07Kernel: Memory purging was incorrectly "purging" the shared zero pageAndreas Kling
This caused us to report one purged page per occurrence of the shared zero page in a purgeable memory region, despite it being a no-op. Thanks to Sergey for spotting the bad assertion removal that led to this being found!
2020-05-06Kernel: Crash the current process on OOM (instead of panicking kernel)Andreas Kling
This patch adds PageFaultResponse::OutOfMemory which informs the fault handler that we were unable to allocate a necessary physical page and cannot continue. In response to this, the kernel will crash the current process. Because we are OOM, we can't symbolicate the crash like we normally would (since the ELF symbolication code needs to allocate), so we also communicate to Process::crash() that we're out of memory. Now we can survive "allocate 300 MB" (only the allocate process dies.) This is definitely not perfect and can easily end up killing a random innocent other process who happened to allocate one page at the wrong time, but it's a *lot* better than panicking on OOM. :^)
2020-05-06Kernel: Assert on OOM in Region::commit()Andreas Kling
This function has a lot of callers that don't bother checking if it returns successfully or not. We'll need to handle failure in a bunch of places and then we can remove this assertion.