Commit Graph

6380 Commits

Author SHA1 Message Date
Nick Johnson
08e4a1a4dc AK+Everywhere: Replace __builtin bit functions
In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount},
this commit removes all calls to these functions and replaces them with
the equivalent functions in AK/BuiltinWrappers.h.
2021-12-21 22:13:51 +01:00
Martin Bříza
86b249f02f Kernel: Implement sysconf(_SC_SYMLOOP_MAX)
Not much to say here, this is an implementation of this call that
accesses the actual limit constant that's used by the VirtualFileSystem
class.

As a side note, this is required for my eventual Qt port.
2021-12-21 12:54:11 -08:00
Martin Bříza
f75bab2a25 Kernel: Move symlink recursion limit to .h, increase it to 8
As pointed out by BertalanD on Discord, POSIX specifies that
_SC_SYMLOOP_MAX (implemented in the following commit) always needs to be
equal or more than _POSIX_SYMLOOP_MAX (8, defined in
LibC/bits/posix1_lim.h), hence I've increased it to that value to
comply with the standard.

The move to header is required for the following commit - to make this
constant accessible outside of the VFS class, namely in sysconf.
2021-12-21 12:54:11 -08:00
Liav A
30659040ed Kernel: Ensure SMP mode is not enabled if IOAPIC mode is disabled
We need to use the IOAPIC in SMP mode, so if the user requested to
disable it, we can't enable SMP mode either.
2021-12-20 11:00:31 -08:00
Liav A
5a649d0fd5 Kernel: Return EINVAL when specifying -1 for setuid and similar syscalls
For setreuid and setresuid syscalls, -1 means to set the current
uid/euid/gid/egid value, to be more convenient for programming.
However, for other syscalls where we pass only one argument, there's no
justification to specify -1.

This behavior is identical to how Linux handles the value -1, and is
influenced by the fact that the manual pages for the group of one
argument syscalls that handle ID operations is ambiguous about this
topic.
2021-12-20 11:32:16 +01:00
Andreas Kling
e0521cfb9d Kernel: Stop ProcFS stack walk on bogus userspace->kernel traversal
Unsurprisingly, the /proc/PID/stacks/TID stack walk had the same
arbitrary memory read problem as the perf event stack walk.

It would be nice if the kernel had a single stack walk implementation,
but that's outside the scope of this commit.
2021-12-19 18:18:38 +01:00
Andreas Kling
bc518e39bf Kernel: Make perfcore files owned by UID=0, GID=0
Since perfcore files can be generated during process finalization,
we can't just allow them to contain sensitive kernel information
if they're gonna be owned by the process's own UID+GID.

So instead, perfcores are now owned by 0:0. This is not the most
ergonomic solution, but I'm not sure what we could do to make it nicer.
We'll have to think more about that. In the meantime, this patches up
a kernel info leak. :^)
2021-12-19 18:18:38 +01:00
Andreas Kling
1cdc7aa038 Kernel: Mask kernel addresses in perf event streams for non-superuser
We now turn kernel addresses into 0xdeadc0de, same as /proc/PID/stacks/
2021-12-19 18:18:38 +01:00
Andreas Kling
369c7a7e9f Kernel: Don't include kmalloc perf events in JSON for non-superuser
These events contain sensitive kernel information and should not be
available to regular users.
2021-12-19 18:18:38 +01:00
Andreas Kling
8ef9b003ad Kernel: Stop perf event stack walk on bogus userspace->kernel traversal
When walking the stack to generate a perf_event sample, we now check
if a userspace stack frame points back into kernel memory.

It was possible to use this as an arbitrary kernel memory read. :^)
2021-12-19 18:18:38 +01:00
Hendiadyoin1
18013f3c06 Kernel: Remove a redundant check in Process::remap_range_as_stack
We already VERIFY that we have carved something out, so we don't need to
check that again.
2021-12-18 10:31:18 -08:00
Hendiadyoin1
2d28b441bf Kernel: Collapse a redundant boolean conditional return statement in …
validate_mmap_prot
2021-12-18 10:31:18 -08:00
Hendiadyoin1
f38d32535c Kernel: Access OpenFileDescriptions::max_open() statically in Syscalls 2021-12-18 10:31:18 -08:00
Hendiadyoin1
c860e0ab95 Kernel: Add implicit auto qualifiers in Syscalls 2021-12-18 10:31:18 -08:00
Hendiadyoin1
f5b495d92c Kernel: Remove else after return in Process::do_write 2021-12-18 10:31:18 -08:00
Andreas Kling
32aa623eff Kernel: Fix 4-byte uninitialized memory leak in sys$sigaltstack()
It was possible to extract 4 bytes of uninitialized kernel stack memory
on x86_64 by looking in the padding of stack_t.
2021-12-18 11:30:10 +01:00
Andreas Kling
ed839450c8 Kernel: Enable SMAP protection earlier during syscall entry
There's no reason to delay this for as long as we did.
2021-12-18 11:30:10 +01:00
Andreas Kling
0ae8702692 Kernel: Make File::stat() & friends return Error<struct stat>
Instead of making the caller provide a stat buffer, let's just return
one as a value.
2021-12-18 11:30:10 +01:00
Andreas Kling
1f2d0d0ad4 Kernel: Use ksyms in-place instead of duplicating them into eternal heap
We can leave the .ksyms section mapped-but-read-only and then have the
symbols index simply point into it.

Note that we manually insert null-terminators into the symbols section
while parsing it.

This gets rid of ~950 KiB of kmalloc_eternal() at startup. :^)
2021-12-18 11:30:10 +01:00
Andreas Kling
abf2204402 Kernel: Use copy_typed_from_user() in more places :^) 2021-12-18 11:30:10 +01:00
Andreas Kling
39d9337db5 Kernel: Make sys${ftruncate,pread} take off_t as const pointer
These syscalls don't write back to the off_t value (unlike sys$lseek)
so let's take Userspace<off_t const*> instead of Userspace<off_t*>.
2021-12-18 11:30:10 +01:00
Andreas Kling
9c7659306a Kernel: Fix getsockopt(SO_RCVTIMEO) returning wrong timeout
We were returning the send timeout for both SO_RCVTIMEO and SO_SNDTIMEO.
2021-12-18 11:30:10 +01:00
Andreas Kling
5c344f4aee Kernel: Start perf event stack capture at RBP, not EBP on x86_64 2021-12-18 11:16:24 +01:00
Andreas Kling
13680ae038 Kernel: Build with -O2 by default
We used to build with -Os in order to fit within a certain size, but
there isn't really a good reason for that kind of restriction.

Switching to -O2 yields a significant improvement in throughput,
for example `test-js` is roughly 20% faster on my machine. :^)
2021-12-16 22:48:16 +01:00
sin-ack
69ef211925 Kernel+LibC: Move errno definitions to Kernel/API/POSIX
This fixes at least half of our LibC includes in the kernel. The source
of truth for errno codes and their description strings now lives in
Kernel/API/POSIX/errno.h as an enumeration, which LibC includes.
2021-12-16 22:21:35 +03:30
sin-ack
3da0c072f4 Kernel: Return the correct result for FIONREAD on datagram sockets
Before this commit, we only checked the receive buffer on the socket,
which is unused on datagram streams. Now we return the actual size of
the datagram without the protocol headers, which required the protocol
to tell us what the size of the payload is.
2021-12-16 22:21:35 +03:30
Hendiadyoin1
e5cf395a54 Kernel: Collapse blocking logic for exclusive Mutex' restore_lock()
Clang-tidy pointed out that the `need_to_block = true;` block was
duplicate, and if we collapse these if statements, we should do so
fully.
2021-12-15 23:34:11 -08:00
Hendiadyoin1
1ad4a190b5 Kernel: Add implied auto-specifiers in Locking
As per clang-tidy.
2021-12-15 23:34:11 -08:00
Hendiadyoin1
a7209ca0f9 Kernel: Add missing includes in Locking 2021-12-15 23:34:11 -08:00
Hendiadyoin1
30458a6600 Kernel: Remove duplicate access specifier in DevTmpFSInode
As per clang-tidy.
2021-12-15 23:34:11 -08:00
Hendiadyoin1
47a39e425c Kernel: Remove else statements after return in Plan9FileSystem.cpp
As per clang-tidy.
2021-12-15 23:34:11 -08:00
Hendiadyoin1
4cec16a713 Kernel: Add implied auto-specifiers in FileSystem
As per clang-tidy.
2021-12-15 23:34:11 -08:00
Hendiadyoin1
fe2cf774c3 Kernel: Fix missing include in FileSystem/Mount.h 2021-12-15 23:34:11 -08:00
Liav A
ac7953f945 Kernel: Allow switching to IOAPIC mode even without enabling SMP
This small change allows to use the IOAPIC by default without to enable
SMP mode, which emulates Uni-Processor setup with IOAPIC instead of
using the PIC.

This opens the opportunity to utilize other types of interrupts like MSI
and MSI-X interrupts.
2021-12-14 09:02:06 +01:00
Liav A
f57900a41b Kernel/Interrupts: Add ByteReaders to read possible unaligned MADT data
The MADT data could be on unaligned boundary - for example, a GSI number
(u32) on unaligned address which leads to a KUBSAN error and halting the
system.
2021-12-14 09:02:06 +01:00
Liav A
bbdb55126c Kernel/SysFS: Don't allocate ACPISysFS components in constructors
Instead defer it to a method to be called after the construction of
ACPISysFSDirectory.
2021-12-14 09:01:33 +01:00
Liav A
381fdaa163 Kernel/SysFS: Make it clear that some components must be created in boot
Using the phrase "create" doesn't give information on whether the object
must be allocated or a failure to do so can be handled gracefully.
Therefore, we must use better phrase for such purpose, so "must_create"
for the allocate-and-construct static methods is definitely good choice.
2021-12-14 09:01:33 +01:00
Liav A
478f543899 Kernel/SysFS: Prevent allocation for component name during construction
Instead, allocate before constructing the object and pass NonnullOwnPtr
of KString to the object if needed. Some classes can determine their
names as they have a known attribute to look for or have a static name.
2021-12-14 09:01:33 +01:00
Luke Wilde
62af3acf56 Kernel: Fix backtrace dumping on x86_64
- dump_backtrace was using ebp instead of rbp on x86_64, only using the
  lower 32-bits of rbp.
- The symbol loader was only fetching half of the pointer from the
  symbol table. (8 chars instead of 16 chars)
2021-12-13 09:17:32 +01:00
Clay Freeman
e3e40cca65 Kernel: Replace final loop in PhysicalRegion::return_page() with math
Since it's possible to determine where the small zones will start to
occur for each PhysicalRegion, we can use arithmetic so that the call
time for both large and small zones is identical.
2021-12-13 00:13:43 +01:00
Daniel Bertalan
8dd11ae717 Kernel+SystemServer: Add /dev/tty
This file refers to the controlling terminal associated with the current
process. It's specified by POSIX, and is used by ports like openssh to
interface with the terminal even if the standard input/output is
redirected to somewhere else.

Our implementation leverages ProcFS's existing facilities to create
process-specific symbolic links. In our setup, `/dev/tty` is a symbolic
link to `/proc/self/tty`, which itself is a symlink to the appropriate
`/dev/pts` entry. If no TTY is attached, `/dev/tty` is left dangling.
2021-12-12 22:32:35 +01:00
Jean-Baptiste Boric
23257cac52 Kernel: Remove sys$select() syscall
Now that the userland has a compatiblity wrapper for select(), the
kernel doesn't need to implement this syscall natively. The poll()
interface been around since 1987, any code still using select()
should be slapped silly.

Note: the SerenityOS source tree mostly uses select() and not poll()
despite SerenityOS having support for poll() since early 2019...
2021-12-12 21:48:50 +01:00
Jean-Baptiste Boric
2177c2a30b Kernel: Split off sys$poll() into Syscalls/poll.cpp 2021-12-12 21:48:50 +01:00
Idan Horowitz
762e047ec9 Kernel+LibC: Implement sigtimedwait()
This includes a new Thread::Blocker called SignalBlocker which blocks
until a signal of a matching type is pending. The current Blocker
implementation in the Kernel is very complicated, but cleaning it up is
a different yak for a different day.
2021-12-12 08:34:19 +02:00
Idan Horowitz
13d98999b7 Kernel: Flip incorrect bitwise set/clear of signal mask 2021-12-12 08:34:19 +02:00
Idan Horowitz
1397a5ab02 Kernel: Unblock threads only on unmasked signals
Signals that were explicitly masked should not unblock threads.
2021-12-12 08:34:19 +02:00
Idan Horowitz
81a76a30a1 Kernel: Preserve pending signals across execve(2)s
As required by posix. Also rename Thread::clear_signals to
Thread::reset_signals_for_exec since it doesn't actually clear any
pending signals, but rather does execve related signal book-keeping.
2021-12-12 08:34:19 +02:00
Idan Horowitz
31fa3f8b1b Kernel: Remove alternative signal stack settings on execve(2)
A successful call to execve(2) removes any existing alternate signal
stack.
2021-12-12 08:34:19 +02:00
Idan Horowitz
0ca1231d8f Kernel: Inherit alternative signal stack on fork(2)
A child process created via fork(2) inherits a copy of its parent's
alternate signal stack settings.
2021-12-12 08:34:19 +02:00
Idan Horowitz
92a6c91f4e Kernel: Preserve signal mask across fork(2) and execve(2)
A child created via fork(2) inherits a copy of its parent's signal
mask; the signal mask is preserved across execve(2).
2021-12-12 08:34:19 +02:00
Hendiadyoin1
7a206868f8 Kernel: Move architecture dependent includes to the top in Processor.h
With the declaration order dependency resolved in the last two commits
we can now do this, which looks a lot nicer.
2021-12-11 13:23:27 -08:00
Hendiadyoin1
3f434506f5 Kernel: Extract ProcessorSpecificDataID from from Arch/Processor.h 2021-12-11 13:23:27 -08:00
Hendiadyoin1
556b516182 Kernel: Extract DeferredCallEntry from Arch/Processor.h 2021-12-11 13:23:27 -08:00
Hendiadyoin1
e34eb3e36d Kernel: Remove unused String.h includes
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-11 13:15:26 -08:00
Daniel Bertalan
4a81b33c07 Everywhere: Fix -Winconsistent-missing-override warnings from Clang
This option is already enabled when building Lagom, so let's enable it
for the main build too. We will no longer be surprised by Lagom Clang
CI builds failing while everything compiles locally.

Furthermore, the stronger `-Wsuggest-override` warning is enabled in
this commit, which enforces the use of the `override` keyword in all
classes, not just those which already have some methods marked as
`override`. This works with both GCC and Clang.
2021-12-11 13:14:15 -08:00
Andreas Kling
813593a485 Kernel: Fix overly loose MemoryManager::kernel_region_from_vaddr()
It's not enough to just find the largest-address-not-above the argument,
we must also check that the found region actually contains the argument.

Regressed in a23edd42b8, thanks to Idan
for pointing this out.
2021-12-11 21:18:42 +01:00
Andreas Kling
259cca456f Kernel: Make PhysicalRegion::return_page() do arithmetic instead of loop
Most of the time, we will be freeing physical pages within the
full-sized zones. We can do some simple math to find the right zone
immediately instead of looping through the zones, checking each one.

We still do loop through the slack/remainder zones at the end.
There's probably an even nicer way to solve this, but this is already a
nice improvement. :^)
2021-12-11 20:13:32 +01:00
Andreas Kling
63117f826b Kernel: Simplify 64-bit HPET reads on x86_64
We don't have to worry about racy 32-bit reads when we're reading the
64-bit HPET value using a 64-bit CPU. :^)
2021-12-11 20:13:25 +01:00
Andreas Kling
a23edd42b8 Kernel: Store kernel memory regions in a RedBlackTree
We were already doing this for userspace memory regions (in the
Memory::AddressSpace class), so let's do it for kernel regions as well.

This gives a nice speed-up on test-js and probably basically everything
else as well. :^)
2021-12-11 20:13:20 +01:00
Hendiadyoin1
9be409585c Kernel: Some clang-tidy fixes in Bus/VirtIO 2021-12-09 22:53:42 -08:00
Hendiadyoin1
471b38db68 Kernel: Some clang-tidy fixes in Bus/USB 2021-12-09 22:53:42 -08:00
Hendiadyoin1
b03b7f806a Kernel: Mark USBTransfer's constructor as private
We have a try_create method for that.
2021-12-09 22:53:42 -08:00
Hendiadyoin1
21c5c4026b Kernel: Mark ACPI::Parser's empty destructor as default 2021-12-09 22:53:42 -08:00
Hendiadyoin1
73aa5c75d5 Kernel: Fix some clang-tidy warnings in PCI::Access 2021-12-09 22:53:42 -08:00
Hendiadyoin1
19ba32651d Kernel: Use AK:any_of in PCI::Device capability checks
This is equivalent to std::any_of as clang-tidy suggests.
2021-12-09 22:53:42 -08:00
Hendiadyoin1
5adf5f4dee Kernel: Construct PCIDeviceAttributeSysFSComponent with StringViews
There is no use to create a temporary String of a char const* to just
cast it to a StringView on SysFSComponent construction again.
Also this could have lead to a UAF bug.
2021-12-09 22:53:42 -08:00
Hendiadyoin1
de26dd253b Kernel: Pass capabilities as const reference in PCI::Address 2021-12-09 22:53:42 -08:00
Hendiadyoin1
3070252090 Kernel: Mark PCI::Address as trivially copyable 2021-12-09 22:53:42 -08:00
Hendiadyoin1
f9e8fe557c Kernel: Add missing include to SlabAllocator 2021-12-09 22:53:42 -08:00
Idan Horowitz
39ecb832e4 Kernel: Don't try to dispatch urgent signals for kernel crashes
If we crashed in the kernel there's no point to sending a signal to the
active process, we're going to panic soon anyway.
2021-12-06 19:36:42 +01:00
Idan Horowitz
548488f050 Kernel: Terminate current thread immediately on unhandled urgent signal
If we're sending an urgent signal (i.e. due to unexpected conditions)
and the Process did not setup any signal handler, we should immediately
terminate the Thread, to ensure the current trap frame is preserved for
the impending core dump.
2021-12-06 19:36:42 +01:00
Andreas Kling
0f9ca51c76 Kernel: Remove unused Inode::preopen_fd() 2021-12-06 19:22:16 +01:00
Ben Wiederhake
0e6e1092f0 Kernel: Make ptrace return an error on error
Returning 'result.error().code()' erroneously creates an
ErrorOr<FlatPtr> of the positive errno code, which breaks our
error-returning convention.

This seems to be due to a forgotten minus-sign during the refactoring in
9e51e295cf. This latent bug was never
discovered, because currently the error-handling paths are rarely
exercised.
2021-12-05 22:59:09 +01:00
Ben Wiederhake
0f8483f09c Kernel: Implement new ptrace function PT_PEEKBUF
This enables the tracer to copy large amounts of data in a much saner
way.
2021-12-05 22:59:09 +01:00
Ben Wiederhake
3e223185b3 Kernel+strace: Remove unnecessary indirection for PEEK
Also, remove incomplete, superfluous check.
Incomplete, because only the byte at the provided address was checked;
this misses the last bytes of the "jerk page".
Superfluous, because it is already correctly checked by peek_user_data
(which calls copy_from_user).

The caller/tracer should not typically attempt to read non-userspace
addresses, we don't need to "hot-path" it either.
2021-12-05 22:59:09 +01:00
Sam Atkins
c6a97ea843 Kernel: Mark kernel smart-pointer classes as [[nodiscard]]
And cast the unused return values to void.
2021-12-05 15:31:03 +01:00
Sam Atkins
907feb84a0 Kernel: Cast unused smart-pointer return value to void 2021-12-05 15:31:03 +01:00
Idan Horowitz
b2464cf4c0 Kernel: Define PT_WRITE_I and PT_WRITE_D
These are aliases for PT_POKE that are used in some *BSDs.
2021-12-05 12:53:29 +01:00
Idan Horowitz
265764ff2f Kernel: Add support for the POLLWRBAND poll event 2021-12-05 12:53:29 +01:00
Idan Horowitz
f2fef049e1 Kernel: Define the POLLRDNORM alias for POLLIN
This flag is equivalent to POLLIN.
2021-12-05 12:53:29 +01:00
Idan Horowitz
05aa764402 Kernel: Define the POLLWRNORM alias for POLLOUT
This is defined by posix to be equivalent to POLLOUT
2021-12-05 12:53:29 +01:00
Idan Horowitz
8074157c10 Kernel: Add the IPPROTO_{IGMP, IPIP, RAW} protocol macros
These are not implemented currently, but are required for some ports to
compile.
2021-12-05 12:53:29 +01:00
Idan Horowitz
2860637ff3 Kernel: Add the IP_{BLOCK_SOURCE, UNBLOCK_SOURCE, OPTIONS} macros
These are not implemented currently, but are required for some ports to
compile.
2021-12-05 12:53:29 +01:00
Idan Horowitz
d18b3eb53d Kernel: Add the SO_OOBINLINE SOL_SOCKET-level option macro
This is not actually implemented, as we don't have any support for
out-of-band right now, but this is required for some ports to compile.
2021-12-05 12:53:29 +01:00
Idan Horowitz
613ade9dec Kernel: Implement the SO_DONTROUTE SOL_SOCKET-level option 2021-12-05 12:53:29 +01:00
Idan Horowitz
641498954f Kernel: Implement the SO_ACCEPTCONN SOL_SOCKET-level option 2021-12-05 12:53:29 +01:00
Idan Horowitz
a0e2fedc20 Kernel: Stub out the SO_DEBUG SOL_SOCKET-level option 2021-12-05 12:53:29 +01:00
Idan Horowitz
e521ffd156 Kernel: Add support for the MSG_WAITALL sys$recvmsg flag 2021-12-05 12:53:29 +01:00
Idan Horowitz
5514d60d8d Kernel: Add support for the MSG_DONTROUTE sys$sendmsg flag 2021-12-05 12:53:29 +01:00
Idan Horowitz
0a36d1459a Kernel: Return EINVAL on unsupported LocalSocket ioctl
ENOTTY is used to signify that no ioctl interface is provided at all,
but LocalSockets do support the FIONREAD ioctl.
2021-12-05 12:53:29 +01:00
Daniel Bertalan
294cb3cef4 Kernel: Wrap x86 assembly behind ARCH(...) in Syscall.h
Unlike GCC, Clang parses assembly eagerly, and immediately rejects
inline assembly that's not for the right architecture.
2021-12-04 11:59:59 -08:00
Daniel Bertalan
9b90f1fed5 Kernel: Do not do integer to pointer conversion in constexpr functions
Creating pointers from arbitrary values is not a valid thing to do in
constexpr functions. Furthermore, this functions is always called with
runtime values anyways, so there's no use in having it be constexpr.
Instead, make it ALWAYS_INLINE.
2021-12-04 11:59:59 -08:00
Daniel Bertalan
8e2d0c8d5c Kernel: Do not return a null ref in Processor::current on aarch64
Clang rejects binding a reference to a null pointer at compile-time.
Let's just crash explicitly, instead of waiting for a null dereference
to mess things up.
2021-12-04 11:59:59 -08:00
Idan Horowitz
711a7104f3 Kernel: Handle invalid stack pointer during signal dispatch
Instead of crashing the kernel, we simply terminate the process.
2021-12-01 21:44:11 +02:00
Idan Horowitz
40f64d7379 Kernel: Dispatch handle-able signals instead of crashing if possible
This matches the behaviour of the other *nixs and allows processes to
try and recover from such signals in userland.
2021-12-01 21:44:11 +02:00
Idan Horowitz
f415218afe Kernel+LibC: Implement sigaltstack()
This is required for compiling wine for serenity
2021-12-01 21:44:11 +02:00
Idan Horowitz
d5d0eb45bf Kernel: Clear up some comments in the sys$mprotect implementation 2021-12-01 21:44:11 +02:00
Idan Horowitz
f27bbec7b2 Kernel: Move incorrect early return in sys$mprotect
Since we're iterating over multiple regions that interesect with the
requested range, just one of them having the requested access flags
is not enough to finish the syscall early.
2021-12-01 21:44:11 +02:00
Idan Horowitz
a9e436c4a3 Kernel: Replace usages of SIGSTKFLT with SIGSEGV
SIGSTKFLT is a signal that signifies a stack fault in a x87 coprocessor,
this signal is not POSIX and also unused by Linux and the BSDs, so let's
use SIGSEGV so programs that setup signal handlers for the common
signals could still handle them in serenity.
2021-12-01 21:44:11 +02:00
Idan Horowitz
4ca39c7110 Kernel: Move the expand_range_to_page_boundaries helper to MemoryManager
This helper can (and will) be used in more parts of the kernel besides
the mmap-family of syscalls.
2021-12-01 21:44:11 +02:00
Idan Horowitz
ff6b43734c Kernel: Add Region::clear_to_zero
This helper method can be used to quickly and efficiently zero out a
region.
2021-12-01 21:44:11 +02:00
Idan Horowitz
5f95a1a7b7 LibC: Define the MADV_DONTNEED madvise advice macro
This isn't actually implemented at the moment, but it is required for
wine to compile
2021-12-01 21:44:11 +02:00
Idan Horowitz
fc13d0782f LibC: Make the madvise advice field a value instead of a bitfield
The advices are almost always exclusive of one another, and while POSIX
does not define madvise, most other unix-like and *BSD systems also only
accept a singular value per call.
2021-12-01 21:44:11 +02:00
Idan Horowitz
48f92f6482 LibC: Add the SIGFPE si_code macros 2021-12-01 21:44:11 +02:00
James Mintram
224b865fda Kernel: Add an x86 include check+error in x86/TSS.h 2021-12-01 11:22:04 -08:00
James Mintram
b08eb37b11 Kernel: Add an x86 include check+error in x86/TrapFrame.h 2021-12-01 11:22:04 -08:00
James Mintram
80cdfee10a Kernel: Add an x86 include check+error in x86/Spinlock.h 2021-12-01 11:22:04 -08:00
James Mintram
34b341e35d Kernel: Add an x86 include check+error in x86/RegisterState.h 2021-12-01 11:22:04 -08:00
James Mintram
1dc1412dee Kernel: Add an x86 include check+error in x86/ProcessorInfo.h 2021-12-01 11:22:04 -08:00
James Mintram
e20884dc0c Kernel: Add an x86 include check+error in x86/Processor.h 2021-12-01 11:22:04 -08:00
James Mintram
eb33df0c30 Kernel: Add an x86 include check+error in x86/PageFault.h 2021-12-01 11:22:04 -08:00
James Mintram
17fb2adf61 Kernel: Add an x86 include check+error in x86/PageDirectory.h 2021-12-01 11:22:04 -08:00
James Mintram
70a18a2271 Kernel: Add an x86 include check+error in x86/MSR.h 2021-12-01 11:22:04 -08:00
James Mintram
bffc3da9d7 Kernel: Add an x86 include check+error in x86/ISRStubs.h 2021-12-01 11:22:04 -08:00
James Mintram
1e5b82f0c6 Kernel: Add an x86 include check+error in x86/IO.h 2021-12-01 11:22:04 -08:00
James Mintram
b9ae6daa02 Kernel: Add an x86 include check+error in x86/Inerrupts.h 2021-12-01 11:22:04 -08:00
James Mintram
ed2aa96511 Kernel: Add an x86 include check+error in x86/InerruptDisabler.h 2021-12-01 11:22:04 -08:00
James Mintram
62d86afee9 Kernel: Add an x86 include check+error in x86/DescriptorTable.h 2021-12-01 11:22:04 -08:00
James Mintram
db1fbdabf9 Kernel: Add an x86 include check+error in x86/CPUID.h 2021-12-01 11:22:04 -08:00
James Mintram
8350b44ebd Kernel: Add an x86 include check+error in x86/CPU.h 2021-12-01 11:22:04 -08:00
James Mintram
3e3c632969 Kernel: Add an x86 include check+error in x86/ASM_Wrapper.h 2021-12-01 11:22:04 -08:00
James Mintram
1c86b7043b Kernel: Remove ASM_Wrapper include from platform independent processor.h 2021-12-01 11:22:04 -08:00
Hendiadyoin1
c7b90fa7d3 Kernel: Don't rewrite the whole file on sys$msync 2021-12-01 09:47:46 +01:00
Hendiadyoin1
259f78545a Kernel: Allow flushing of partial regions in sys$msync 2021-12-01 09:47:46 +01:00
Hendiadyoin1
49d6ad6633 Kernel: Handle more error cases in sys$msync 2021-12-01 09:47:46 +01:00
Brian Gianforcaro
d7568b28b4 Kernel: Surface errors when generating a process core dump :^) 2021-11-30 11:16:35 +01:00
Brian Gianforcaro
fa517b213a Kernel: Handle string format errors in FileSystem APIs :^) 2021-11-30 11:16:35 +01:00
Brian Gianforcaro
e626d7098d Kernel: Handle string format errors in Device::pseudo_path(..) :^) 2021-11-30 11:16:35 +01:00
Brian Gianforcaro
1f65728d8b Kernel: Handle string format errors in PCIDeviceAttributeSysFSComponent 2021-11-30 11:16:35 +01:00
Brian Gianforcaro
74ee491b84 Kernel: Handle string format errors in SlabAllocator stats :^)
Switch to KString::formatted and fix API so we can propagate errors.
2021-11-30 11:16:35 +01:00
Brian Gianforcaro
a0e59099fc Kernel: Handle string format errors in KCOVInstance :^) 2021-11-30 11:16:35 +01:00
Brian Gianforcaro
a5cec06135 Kernel: Handle string format error in page_fault_handler(..) :^)
Utilize the new KString::formatted to provide a fallback
if formatting fails because of OOM or whatever reason.
2021-11-30 11:16:35 +01:00
Brian Gianforcaro
4cc41ea186 Kernel: Add an error propagating KString::format(..) API :^)
In the continuous effort of better handling OOM in the kernel,
we want to move away from all AK::String usage. One of the final
pieces left to accomplish this goal is replacing all of the usages
of `String::formatted` with something that can actually propagate
failure.

The StringBuilder API was enhanced in the recent past to propagate
failure and thus a slightly modified version of what exists in
`AK::format` will work well for implementing failable format with
`KString`.
2021-11-30 11:16:35 +01:00
Jelle Raaijmakers
e187207610 Kernel: Register Virtio console ports with device management
Previously, Virtio console ports would not show up in `/sys/dev/char/`.
Also adds support to `SystemServer` to create more than one console
port device in `/dev/` in the multiport case.
2021-11-30 10:53:41 +01:00
James Mintram
f7c0cdcc19 Kernel: Use peripheral addresses returned from MMIO to map prekernel mem 2021-11-28 22:01:21 -08:00
James Mintram
4e9777243e Kernel: Refactor prekernel MMU to use a bump allocator 2021-11-28 22:01:21 -08:00
James Mintram
4a4a3193f8 Kernel: Rename Aarch64Asm -> ASM_wrapper and add Aarch64::Asm namespace 2021-11-28 22:01:21 -08:00
James Mintram
34709c8d39 Kernel: Rename Aarch64Registers -> Registers and add Aarch64 namespace 2021-11-28 22:01:21 -08:00
James Mintram
271b9b8da3 Kernel: Set up and activate the MMU in the aarch64 perkernel 2021-11-28 22:01:21 -08:00
James Mintram
c2d7e200eb Kernel: Move common aarch64 asm functions into kernel folder and NS 2021-11-28 22:01:21 -08:00
James Mintram
68b5d00f42 Kernel: Split prekernel exception level code into its own file 2021-11-28 22:01:21 -08:00
James Mintram
18f1530c84 Kernel: Change prekernel to use shared SP across Exception Levels 2021-11-28 22:01:21 -08:00
James Mintram
5a75bd31b0 Kernel: Replace inline asm with typesafe static member functions 2021-11-28 22:01:21 -08:00
James Mintram
4bc5936a57 Kernel: Remove unused header from Aarch64_asm_utils 2021-11-28 22:01:21 -08:00
Jelle Raaijmakers
497180a650 Kernel: Ignore AC97 non-completion interrupts
Fixes #11094
2021-11-28 19:26:22 +02:00
Jelle Raaijmakers
689ad0752c Kernel: Add AC97_DEBUG macro 2021-11-28 19:26:22 +02:00
Sam Atkins
6dd2ebfe8e Kernel: Log when a process exits with an unlocked veil
This catches applications that make use of `unveil()`, but then do not
lock the veil with `unveil(nullptr, nullptr)`.
2021-11-28 09:16:37 -08:00
Liav A
8abc4fa8c2 Kernel/Audio: Implement 2 correctness fixes in AC97
The fixes are:
1. Don't copy PCI::DeviceIdentifier during construction. This is a heavy
structure to copy so we definitely don't want to do that. Instead, use
a const reference to it like what happens in other parts in the Kernel.
2. Declare the constructor as explicit to avoid construction errors.
2021-11-27 23:43:56 -08:00
Liav A
ed5a4f2938 Kernel/Storage: Restore booting from MBR partitions functionality
We had such functionality in the past, but it was regressed and now is
restored.
2021-11-28 08:05:58 +01:00
Jelle Raaijmakers
58bcb93777 Kernel: Implement variable rate audio support for AC97 devices
Previously we `VERIFY()`ed that the device supports variable-rate audio
(VRA). Now, we query the VRA bit and if VRA is not supported, we do not
enable double-rate audio and disallow setting any sample rate except
the fixed 48kHz rate as defined by the AC'97 specification. This should
allow the driver to function on a wider array of hardware.

Note that in the AC'97 specification, DRA without VRA is allowed when
supported: this effectively doubles the sample rate to 96kHZ. For now,
we ignore that possibility and let it default to 48kHZ.
2021-11-26 22:15:29 +01:00