Commit graph

5034 commits

Author SHA1 Message Date
Andreas Kling d3cf4cd8f0 Kernel/DevFS: Remove redundant DevFS& member from DevFSInode
All Inode subclasses can get to their FileSystem via Inode::fs().
2021-07-18 02:21:34 +02:00
Andreas Kling bd37840cf5 Kernel/Ext2FS: Surface Vector allocation failures in block allocation 2021-07-18 02:15:56 +02:00
Andreas Kling 1f18558ee2 Kernel: Make FileSystem::root_inode() return a plain Inode&
All file system classes are expected to keep their root Inode object
in memory, so this function can safely return an Inode&.
2021-07-18 01:53:04 +02:00
Andreas Kling 58c6d30f6a Kernel/Ext2FS: Cache the root inode in a member variable
We often get queried for the root inode, and it will always be cached
in memory anyway, so let's make Ext2FS::root_inode() fast by keeping
the root inode in a dedicated member variable.
2021-07-18 01:53:04 +02:00
Andreas Kling 9457d83986 Kernel: Rename Locker => MutexLocker 2021-07-18 01:53:04 +02:00
Andreas Kling ab50a1480f Kernel/USB: Remove unneeded friend declaration in SysFSUSBBusDirectory 2021-07-18 01:53:04 +02:00
Andreas Kling b975a74a1d Kernel/USB: Move USB bus information from /proc to /sys
This patch moves all the USB data from /proc/bus/usb to /sys/bus/usb.
2021-07-18 00:55:16 +02:00
Andreas Kling 6fae2a5f9e Kernel/ProcFS: Remove unused ProcFSExposedComponent::entries_count() 2021-07-17 23:50:01 +02:00
Andreas Kling d686d2ef18 Kernel/SysFS: Remove unused SysFSComponent::entries_count() 2021-07-17 23:50:01 +02:00
Andreas Kling 2da0581fd2 Kernel: Replace "folder" => "directory" everywhere
Folders are a GUI concept. File systems have directories.
2021-07-17 23:50:00 +02:00
Andreas Kling b8d6c3722d Kernel: Remove Inode::directory_entry_count()
This was only used in one place: VirtualFileSystem::rmdir(), and that
has now been converted to a simple directory traversal.
2021-07-17 22:36:04 +02:00
Andreas Kling d1bbe8b652 Kernel: Count remaining children in VirtualFileSystem::rmdir() manually
To count the remaining children, we simply need to traverse the
directory and increment a counter. No need for a custom virtual that
all file systems have to implement. :^)
2021-07-17 22:34:43 +02:00
Andreas Kling a3f58a5003 Kernel/DevFS: Use KString for DevFSDeviceInode::m_name 2021-07-17 22:17:07 +02:00
Andreas Kling 0d89cfcd9a Kernel/DevFS: Use KString for DevFSLinkInode::m_link 2021-07-17 22:11:41 +02:00
Andreas Kling cd4d73e19e Kernel: Add an API for turning a UserOrKernelBuffer into a KString 2021-07-17 22:07:49 +02:00
Andreas Kling dd37d0a327 Kernel/DevFS: Use KString for DevFSLinkInode::m_name 2021-07-17 21:40:32 +02:00
Andreas Kling 61c1937d02 Kernel/DevFS: Make DevFSInode::name() return StringView 2021-07-17 21:36:54 +02:00
Andreas Kling 6766efff9c Kernel: Make Inode::create_child() take the name as a StringView
No sense in forcing callers to construct a String. One more small step
towards not using String in the kernel.
2021-07-17 21:32:59 +02:00
Andreas Kling 9359f7801f Kernel/DevFS: Remove some unnecessary inode locking
Unless we're accessing mutex-guarded metadata, there's no need to
acquire the inode lock.

The file system ID or inode index of a constructed inode will never
change, for example.
2021-07-17 21:26:47 +02:00
Andreas Kling 3b805a57e6 Kernel: Rename Inode::m_lock => m_inode_lock
This makes file system code much easier to read since it was hard when
both the file system and inode locks were called "m_lock".
2021-07-17 21:17:39 +02:00
Andreas Kling 63e1423830 Kernel: Remove unused Inode::is_shared_vmobject() 2021-07-17 21:11:12 +02:00
Andreas Kling cee9528168 Kernel: Rename Lock to Mutex
Let's be explicit about what kind of lock this is meant to be.
2021-07-17 21:10:32 +02:00
Andreas Kling a803c4026c Kernel: Make FileSystem::class_name() return a StringView 2021-07-17 20:59:48 +02:00
Brian Gianforcaro c0987453e6 Kernel: Remove double RedBlackTree lookup in VM/Space region removal
We should never request a regions removal that we don't currently
own. We currently assert this everywhere else by all callers.

Instead lets just push the assert down into the RedBlackTree removal
and assume that we will always successfully remove the region.
2021-07-17 16:22:59 +02:00
Brian Gianforcaro d879709ec7 Kernel: Convert the PhysicalPage bool parameter to an enum 2021-07-17 18:38:28 +04:30
Brian Gianforcaro eb282ad410 Kernel: Declare VM/RangeAllocator trivial destructor as default
This is a clang tidy recommendation.
2021-07-17 13:02:09 +02:00
Brian Gianforcaro 24bd664980 Kernel: Remove stale include from VM/RangeAllocator.cpp
This was left over after the latest big refactor of the VM subsystem.
2021-07-17 13:02:09 +02:00
Brian Gianforcaro dbc77148c9 Kernel: Convert RangeAllocator VERIFY to proper error handling
If a user allocates above 0x0 and below the allowable usermode
virtual address space, we need to return error instead of asserting.

Fixes: #8484
2021-07-17 13:00:21 +02:00
Peter Bindels a5a62f99c5 LibC: Use 64-bit stack smash value for 64-bit mode
Otherwise it'll use the first 32 bits that happen to come after,
leading to very weird bugs. Fixes #8601
2021-07-17 01:45:20 +02:00
Hediadyoin1 432a34a496 Kernel: Make PAGE_MASK architecture independent 2021-07-17 01:12:15 +02:00
Tom 3cca9e6704 Kernel: Initialize TimeManagement before using KernelRNG
We should initialize the timers before KernelRNG as the RNG may want
to utilize system time as an entropy source.

Fixes #8710
2021-07-17 00:04:57 +02:00
Tom 7bdd66ed89 Kernel: Remove TimeManagement::initialized that wasn't implemented 2021-07-17 00:04:57 +02:00
Daniel Bertalan 3099a6bf2a Kernel+AK: Generate compile-time error for non-sized delete
This is a much more ergonomic option than getting a
`VERIFY_NOT_REACHED()` failure at run-time. I encountered this issue
with Clang, where sized deallocation is not the default due to ABI
breakage concerns.

Note that we can't simply just not declare these functions, because the
C++ standard states:
> If this function with size parameter is defined, the program shall
> also define the version without the size parameter.
2021-07-16 20:51:13 +02:00
Daniel Bertalan dd4ed4d22d Kernel: Implement aligned operator new and use it
The compiler will use these to allocate objects that have alignment
requirements greater than that of our normal `operator new` (4/8 byte
aligned).

This means we can now use smart pointers for over-aligned types.

Fixes a FIXME.
2021-07-16 20:51:13 +02:00
Daniel Bertalan c176680443 Kernel: Tell the compiler about operator new's alignment
By default, the compiler will assume that `operator new` returns
pointers that are aligned correctly for every built-in type. This is not
the case in the kernel on x64, since the assumed alignment is 16
(because of long double), but the kmalloc blocks are only
`alignas(void*)`.
2021-07-16 20:51:13 +02:00
Tom 704e1c2e3d Kernel: Rename functions to be less confusing
Thread::yield_and_release_relock_big_lock releases the big lock, yields
and then relocks the big lock.

Thread::yield_assuming_not_holding_big_lock yields assuming the big
lock is not being held.
2021-07-16 20:30:04 +02:00
Tom 0536a4ff41 Kernel: Release big lock when blocking on another lock
When blocking on a Lock other than the big lock and we're holding the
big lock, we need to release the big lock first. This fixes some
deadlocks where a thread blocks while holding the big lock, preventing
other threads from getting the big lock in order to unblock the waiting
thread.
2021-07-16 20:30:04 +02:00
Tom 710cf14c55 Kernel: Fix some Lock problems and VERIFY statements
When a Lock blocks (e.g. due to a mode mismatch or because someone
else holds it) the lock mode will be updated to what was requested.

There were also some cases where restoring locks may have not worked
as intended as it may have been held already by the same thread.

Fixes #8787
2021-07-16 20:30:04 +02:00
Gunnar Beutner 22a588d394 Kernel: Make the page table for the kernel image larger
Building the x86_64 kernel with ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS
results in an image that is larger than 0x2000000 bytes.
2021-07-16 18:50:59 +02:00
Gunnar Beutner a17c25e45e Kernel: Make resizing the page tables for the kernel image easier
By using the KERNEL_PD_OFFSET constant we can avoid some of the
hard-coded values in the boot code.
2021-07-16 18:50:59 +02:00
Gunnar Beutner cbdb488578 Kernel: Move end_of_kernel_image after the .ksyms section
Without this we won't be able to detect whether .ksyms overlaps the end
of the page table we set up for the kernel image.
2021-07-16 18:50:59 +02:00
Gunnar Beutner acf8f2a2a3 Kernel: Support specifying a 64-bit KERNEL_BASE address
The kernel doesn't currently boot when using an address other than
0xc0000000 because the page tables aren't set up properly for that
but this at least lets us build the kernel.
2021-07-16 18:50:59 +02:00
Gunnar Beutner 9b431cbe42 Kernel: Avoid unnecessary jump in the boot code
The 32-bit boot code jumps to 0xc0000000 + entry address once page
tables are set up. This is unnecessary for 64-bit mode because we'll
do another far jump just moments later.
2021-07-16 18:50:59 +02:00
Gunnar Beutner eb1935b62e Kernel: Avoid hard-coding kernel virtual base 2021-07-16 18:50:59 +02:00
Liav A 9e36158ece Kernel: Remove stale forward declaration of BochsFramebufferDevice 2021-07-16 18:50:16 +02:00
Andreas Kling 3108aa0a6b Kernel: Fix bogus check in Thread::WaitBlockCondition::finalize()
I botched this in 859e5741ff, the check
was supposed to be with Process::is_kernel_process().

This fixes an issue with zombie processes hanging around forever.
Thanks tomuta for spotting it! :^)
2021-07-16 15:18:47 +02:00
Timothy 9715311837 AK+Kernel: Implement and use EnumBits has_any_flag()
This duplicates the old functionality of has_flag and will return true
when any flags present in the mask are also in the value.
2021-07-16 11:49:50 +02:00
Luke 2df4d977e2 Kernel: Return ENOMEM on allocation failures in FramebufferDevice::mmap 2021-07-16 11:15:30 +02:00
Andreas Kling 41c0009f6d Kernel/Ext2FS: Don't hog inode lock in traverse_as_directory()
Reimplement directory traversal in terms of read_bytes() instead of
doing direct block access. This lets us avoid taking the inode lock
while iterating over the directory contents.
2021-07-16 02:40:53 +02:00
Andreas Kling abbd237ec1 Kernel/Ext2FS: Don't hog FS lock when calling base class flush_writes()
Once we've finalized all the file system metadata in flush_writes(),
we no longer need to hold the file system lock during the call to
BlockBasedFileSystem::flush_writes().
2021-07-16 02:40:53 +02:00