Commit Graph

5028 Commits

Author SHA1 Message Date
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
Andreas Kling
98c230b370 Kernel/Ext2FS: Uncache unknown inode indices when flushing writes
Ext2FS::get_inode() will remember unknown inode indices that it has
been asked about and put them into the inode cache as null inodes.

flush_writes() was not null-checking these while iterating, which
was a bug I finally managed to hit.

Flushing also seemed like a good time to drop unknown inodes from
the cache, since there's no good reason to hold to them indefinitely.
2021-07-16 02:40:53 +02:00
Andreas Kling
a7d193951f Kernel: Don't hog file system lock when doing BlockBasedFileSystem I/O
The file system lock is meant to protect the file system metadata
(super blocks, bitmaps, etc.) Not protect processes from reading
independent parts of the disk at once.

This patch introduces a new lock to protect the *block cache* instead,
which is the real thing that needs synchronization.
2021-07-16 02:40:53 +02:00
Andreas Kling
abf0249f35 Kernel: Don't explicitly seek before I/O in BlockBasedFileSystem
Use the new FileDescription APIs to avoid doing seek+read or seek+write
as two separate operations.
2021-07-16 02:40:53 +02:00
Andreas Kling
d1395f2eb9 Kernel: Add FileDescription read/write API that bypasses current offset
Forcing users of a FileDescription to seek before they can read/write
makes it inherently racy. This patch adds variants of read/write that
simply ignore the "current offset" of the description in favor of a
caller-supplied offset.
2021-07-16 02:40:53 +02:00
Andreas Kling
ace8b9a0ee Kernel/Ext2FS: Don't hog both locks in Ext2FSInode::lookup()
This function was acquiring both the inode and file system locks (in
that order) which could lead to deadlocks.
2021-07-16 02:40:53 +02:00
Tom
82e9fe8d67 Kernel: Optionally dump scheduler state with stack traces
This will dump stack traces of all threads when pressing
Ctrl+Shift+Alt+F12
2021-07-15 23:46:37 +02:00