summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-07-23Kernel: Simplify VMObject locking & page fault handlersAndreas Kling
This patch greatly simplifies VMObject locking by doing two things: 1. Giving VMObject an IntrusiveList of all its mapping Region objects. 2. Removing VMObject::m_paging_lock in favor of VMObject::m_lock Before (1), VMObject::for_each_region() was forced to acquire the global MM lock (since it worked by walking MemoryManager's list of all regions and checking for regions that pointed to itself.) With each VMObject having its own list of Regions, VMObject's own m_lock is all we need. Before (2), page fault handlers used a separate mutex for preventing overlapping work. This design required multiple temporary unlocks and was generally extremely hard to reason about. Instead, page fault handlers now use VMObject's own m_lock as well.
2021-07-23Kernel: Remove unused MAP_SHARED_ZERO_PAGE_LAZILY code pathAndreas Kling
2021-07-22Kernel: Convert Region to east-const styleAndreas Kling
2021-07-22Kernel: Fix the variable declaration for some linker script symbolsGunnar Beutner
Despite what the declaration would have us believe these are not "u8*". If they were we wouldn't have to use the & operator to get the address of them and then cast them to "u8*"/FlatPtr afterwards.
2021-07-22Kernel: Add /proc/kernel_base (superuser only)Andreas Kling
This file contains the kernel base address as a decimal integer.
2021-07-22Kernel: Make committed physical page allocation return NonnullRefPtrAndreas Kling
Since we're taking from the committed set of pages, there should never be a reason for this call to fail. Also add a Badge to disallow taking committed pages from anywhere but the Region class.
2021-07-22Kernel: Consolidate API for creating AnonymousVMObject with given pagesAndreas Kling
We don't need to have a dedicated API for creating a VMObject with a single page, the multi-page API option works in all cases. Also make the API take a Span<NonnullRefPtr<PhysicalPage>> instead of a NonnullRefPtrVector<PhysicalPage>.
2021-07-22Kernel: Convert VMObject & subclasses to east-const styleAndreas Kling
2021-07-22Kernel: Fix incorrect format templateGunnar Beutner
2021-07-22Kernel: Make sure crash dumps are properly aligned on x86_64Gunnar Beutner
2021-07-22Everywhere: Prefer using {:#x} over 0x{:x}Gunnar Beutner
We have a dedicated format specifier which adds the "0x" prefix, so let's use that instead of adding it manually.
2021-07-22Everywhere: Prefix hexadecimal numbers with 0xGunnar Beutner
Depending on the values it might be difficult to figure out whether a value is decimal or hexadecimal. So let's make this more obvious. Also this allows copying and pasting those numbers into GNOME calculator and probably also other apps which auto-detect the base.
2021-07-21Revert "Kernel: Use IntrusiveList for keeping track of InodeWatchers"Andreas Kling
This reverts commit 43d6a7e74ec76bf23f78ca281d54c60bb7b952d1. This breaks multi-inode watchers.
2021-07-21Kernel: Use IntrusiveList for keeping track of GenericInterruptHandlersAndreas Kling
2021-07-21Kernel: Remove Inode's inheritance from WeakableAndreas Kling
Nobody was using WeakPtr<Inode> anywhere, so there's no need for this to inherit from Weakable.
2021-07-21Kernel: Use IntrusiveList for keeping track of InodeWatchersAndreas Kling
2021-07-21Kernel: VirtIO framebuffer should clamp pending dirty rects if neededTom
If we change to a resolution smaller than what any pending dirty rectangles contain, we need to clamp them to the new resolution.
2021-07-20Kernel: Remove KBufferBuilder's can_expand restrictionAndreas Kling
KBufferBuilder is always allowed to expand if it wants to. This restriction was added a long time ago when it was unsafe to allocate VM while generating ProcFS contents.
2021-07-20Kernel: Remove KBufferBuilder API for reusing an existing bufferAndreas Kling
This is not used anywhere anymore anyway.
2021-07-20Kernel: Simplify ProcFS generated buffer cachingAndreas Kling
Use a Mutex instead of a SpinLock to protect the per-FileDescription generated data cache. This allows processes to go to sleep while waiting their turn. Also don't try to be clever by reusing existing cache buffers. Just allocate KBuffers as needed (and make sure to surface failures.)
2021-07-20Kernel: Remove confused comment in KBufferBuilder::appendff()Andreas Kling
KBufferBuilder exists for code that wants to build a KBuffer instead of a String. KBuffer is backed by anonymous VM, while String is backed by a kernel heap allocation.
2021-07-20Kernel+LibC: Implement fcntl(2) advisory locksPeter Elliott
Advisory locks don't actually prevent other processes from writing to the file, but they do prevent other processes looking to acquire and advisory lock on the file. This implementation currently only adds non-blocking locks, which are all I need for now.
2021-07-20Prekernel: Make sure to reload CR3 after modifying the page tablesGunnar Beutner
2021-07-20Prekernel: Don't wrap around the PTE index improperlyGunnar Beutner
The boot_pd0_pts variable contains more than 512 PTEs so we shouldn't wrap the index here.
2021-07-20Prekernel: Properly initialize variablesGunnar Beutner
2021-07-20Kernel: Specify protection flags for ELF load headersGunnar Beutner
These are currently unused by the prekernel and ld used the same flags by default - except for the .ksyms section which was marked as read-write.
2021-07-20Kernel: Use the C preprocessor to avoid two copies of the linker scriptGunnar Beutner
2021-07-20Prekernel: Don't assume that PT_LOAD headers are ordered by addressGunnar Beutner
These headers are ordered by virtual address - at least with GCC - but that might not always be the case.
2021-07-20Kernel: Rename .boot_bss to .super_pages to better reflect what it isGunnar Beutner
This also removes the section attribute for kernel_base which had no effect because the section wasn't included in the linker script.
2021-07-20Prekernel: Use physical addresses for some of the BootInfo parametersGunnar Beutner
The kernel would just turn those virtual addresses into physical addresses later on, so let's just use physical addresses right from the start.
2021-07-20Kernel: Move boot info declarations to a header fileGunnar Beutner
Instead of manually redeclaring those variables in various files this now adds a header file for them.
2021-07-20Kernel: Initialize serial debug after setting kernel command-lineGunnar Beutner
2021-07-20Kernel: Disable big process lock for sys$yield()Brian Gianforcaro
2021-07-20Kernel: Disable big process lock for sys$gettid()Brian Gianforcaro
This syscall reads a read only value from the current thread, and hence has no need for the big process lock.
2021-07-20Kernel: Disable big process lock for sys$getpid()Brian Gianforcaro
2021-07-20Kernel: Disable big process lock for sys$uname()Brian Gianforcaro
2021-07-20Kernel: Disable big process lock in sys$gethostname() sys$sethostname()Brian Gianforcaro
2021-07-20Kernel: Annotate all syscalls with VERIFY_PROCESS_BIG_LOCK_ACQUIREDBrian Gianforcaro
Before we start disabling acquisition of the big process lock for specific syscalls, make sure to document and assert that all the lock is held during all syscalls.
2021-07-20Kernel: Conditionally acquire the big lock based on syscall metadataBrian Gianforcaro
2021-07-20Kernel: Allow MutexLocker to be conditionally initializedBrian Gianforcaro
There are cases where we want to conditionally take a lock, but still would like to use an RAII type to make sure we don't leak the lock. This was previously impossible to do with `MutexLocker` due to it's design. This commit tweaks the design to allow the object to be initialized to an "empty" state without a lock associated, so it does nothing, and then later a lock can be "attached" to the locker. I realized that the get_lock() API's where also unused, and would no longer make sense for empty locks, so they were removed.
2021-07-20Kernel: Move validate_syscall_preconditions outside of the big lockBrian Gianforcaro
Now that we hold the space lock for the duration of the validation it should be safe to move the validation outside the big lock.
2021-07-20Kernel: Mark read only RegisterState function parameters as constBrian Gianforcaro
2021-07-20Kernel: Move syscall precondition validates to MMBrian Gianforcaro
Move these to MM to simplify the flow of the syscall handler. While here, also make sure we hold the process space lock for the duration of the validation to avoid potential issues where another thread attempts to modify the process space during the validation. This will allow us to move the validation out of the big process lock scope in a future change. Additionally utilize the new no_lock variants of functions to avoid unnecessary recursive process space spinlock acquisitions.
2021-07-20Kernel: Instrument syscalls with their process big lock requirementsBrian Gianforcaro
Currently all syscalls run under the Process:m_big_lock, which is an obvious bottleneck. Long term we would like to remove the big lock and replace it with the required fine grained locking. To facilitate this goal we need a way of gradually decomposing the big lock into the all of the required fine grained locks. This commit introduces instrumentation to the syscall table, allowing the big lock requirement to be toggled on/off per syscall. Eventually when we are finished, no syscall will required the big lock, and we'll be able to remove all of this instrumentation.
2021-07-20Kernel: No lock validate_user_stack variant, switch to Space as argumentBrian Gianforcaro
The entire process is not needed, just require the user to pass in the Space. Also provide no_lock variant to use when you already have the VM/Space lock acquired, to avoid unnecessary recursive spinlock acquisitions.
2021-07-20Prekernel: Make sure we're not overwriting the ELF headerGunnar Beutner
This copies the ELF header because we might end up overwriting when loading the ELF sections.
2021-07-19VirtualFileSystem: Check for '.' '..' and empty filenamesls
This commit adds a check, to prevent empty dot or dot-dot filenames when renaming a file and returns EINVAL in that case.
2021-07-19Prekernel: Make sure the last few bytes of the kernel image are mappedGunnar Beutner
Depending on the exact layout of the .ksyms section the kernel would fail to boot because the kernel_load_end variable didn't account for the section's size.
2021-07-19Kernel: Remove obsolete codeGunnar Beutner
2021-07-19Kernel: Simplify the linker script for the prekernelGunnar Beutner