Commit Graph

4665 Commits

Author SHA1 Message Date
Daniel Bertalan
a3c4397432 Kernel: Re-render console after echoing characters
If we do not flush the dirty lines, characters typed in canonical mode
only appear after the virtual console has been switched away from, or
the application has been killed. Instead, we now immediately perform the
flush.
2021-06-10 17:18:02 +02:00
Daniel Bertalan
ce9460de59 Kernel+LibVT: Fix selection with scrollback wrap-around
If lines are removed from the tail of the scrollback buffer, the
previous line indices will refer to different lines; therefore we need
to offset them.
2021-06-10 17:18:02 +02:00
Daniel Bertalan
89843cd692 Kernel+LibVT: Implement left-right scrolling
This commit implements the left/right scrolling used in the `ICH`/`DCH`
escape sequences for `VirtualConsole`. This brings us one step closer to
VT420/xterm compatibility.

We can now finally remove the last escape sequence related `ifdef`s.
2021-06-10 17:18:02 +02:00
Daniel Bertalan
7419569a2b Kernel+LibVT: Add function for deleting a range of characters
Previously, this was done by telling the client to put a space at each
character in the range. This was inefficient, because a large number of
function calls took place and incorrect, as the ANSI standard dictates
that character attributes should be cleared as well.

The newly added `clear_in_line` function solves this issue. It performs
just one bounds check when it's called and can be implemented as a
pretty tight loop.
2021-06-10 17:18:02 +02:00
Daniel Bertalan
8f8fd9c5a8 LibVT+Kernel: Support clearing the scrollback buffer
As per the `xterm ctlseqs` documentation, `\e3J` should clear the
scrollback buffer, and leave the visible lines unchanged.

This commit fixes a FIXME.
2021-06-10 17:18:02 +02:00
Daniel Bertalan
ae6bdc4e29 LibVT+Kernel: Clean up scroll API
This commit cleans up some of the `#ifdef`-ed code smell in
`Terminal`, by extending the scroll APIs to take a range of lines as a
parameter. This makes it possible to use the same code for `IL`/`DL` as
for scrolling.

Note that the current scrolling implementation is very naive, and does
many insertions/deletions in the middle of arrays, whereas swaps should
be enough. This optimization will come in a later commit.

The `linefeed` override was removed from `VirtualConsole`. Previously,
it exhibited incorrect behavior by moving to column 0. Now that we use
the method defined in `Terminal`, code which relied on this behavior
stopped working. We go instead go through the TTY layer which handles
the various output flags. Passing the input character-by-character
seems a bit excessive, so a fix for it will come in another PR.
2021-06-10 17:18:02 +02:00
Liav A
b54bfdd696 Kernel/PCI: Remove UNMAP_AFTER_INIT from a few methods
This fixes #7942.

We can't unmap these methods because they can be called after the boot
process from lspci(8) utility, or by using the SystemMonitor program
(and looking into the "PCI devices" tab).
2021-06-09 20:15:14 +01:00
Ali Mohammad Pur
50349de38c Meta: Disable -Wmaybe-uninitialized
It's prone to finding "technically uninitialized but can never happen"
cases, particularly in Optional<T> and Variant<Ts...>.
The general case seems to be that it cannot infer the dependency
between Variant's index (or Optional's boolean state) and a particular
alternative (or Optional's buffer) being untouched.
So it can flag cases like this:
```c++
if (index == StaticIndexForF)
    new (new_buffer) F(move(*bit_cast<F*>(old_buffer)));
```
The code in that branch can _technically_ make a partially initialized
`F`, but that path can never be taken since the buffer holding an
object of type `F` and the condition being true are correlated, and so
will never be taken _unless_ the buffer holds an object of type `F`.

This commit also removed the various 'diagnostic ignored' pragmas used
to work around this warning, as they no longer do anything.
2021-06-09 23:05:32 +04:30
Liav A
c6480a0426 Kernel/Net: Support Intel 82574 adapter
We call it E1000E, because the layout for these cards is somewhat not
the same like E1000 supported cards.

Also, this card supports advanced features that are not supported on
8254x cards.
2021-06-09 22:44:09 +04:30
Liav A
2e2201e8e1 Kernel/CommandLine: Add option to disable physical networking hardware
This is useful for debugging sessions mostly.
2021-06-09 22:44:09 +04:30
Liav A
1c94b5e8eb Kernel: Introduce the NetworkingManagement singleton
Instead of initializing network adapters in init.cpp, let's move that
logic into a separate class to handle this.
Also, it seems like a good idea to shift responsiblity on enumeration
of network adapters after the boot process, so this singleton will take
care of finding the appropriate network adapter when asked to with an
IPv4 address or interface name.

With this change being merged, we simplify the creation logic of
NetworkAdapter derived classes, so we enumerate the PCI bus only once,
searching for driver candidates when doing so, and we let each driver
to test if it is resposible for the specified PCI device.
2021-06-09 22:44:09 +04:30
Brian Gianforcaro
aa63fe20a5 Kernel: Mark VirtIOConsole constructor as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
7e88ac63b9 Kernel: Mark VirtIORNG constructor as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
d27cecd729 Kernel: Mark VirtIO detection/creation functions as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
80a3cc47e5 Kernel: Mark MMIOAccess detection function as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
40ea464fb0 Kernel: Mark PCI Access enumeration functions as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
9e6f0fd925 Kernel: Mark SyncTask::spawn() as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
83841e47e5 Kernel: Mark FinalizerTask::spawn() as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
c8b6bd4b97 Kernel: Mark WorkQueue initailzation functions as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
b5d388a9b3 Kernel: Mark NE2000NetworkAdapter::ram_test() UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
e9add0bb80 Kernel: Mark E1000NetworkAdapter is_valid_device_id(..) UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Brian Gianforcaro
f124affc8e Kernel: Mark PCISerialDevice::detect() as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Max Wipfli
573664758a Kernel: Properly reset m_unveiled_paths on execve()
When a process executes another program, its unveil state is reset. For
this, we not only need to clear all nodes from m_unveiled_paths, but
also reset the metadata of m_unveiled_paths (the root node) itself.

This fixes the following bug:
1) A process unveils "/", then executes another program.
2) That other program also unveils some path.
3) "/" is now unveiled for the new program.
2021-06-08 12:15:04 +02:00
Max Wipfli
c1de46aaaf Kernel: Don't assume there are no nodes if m_unveiled_paths.is_empty()
If m_unveiled_paths.is_empty(), the root node (which is m_unveiled_paths
itself) is the matching veil. This means we should not return nullptr in
this case, but just use the code path for the general case.

This fixes a bug where calling e.g. unveil("/", "r") would refuse you
access to anything, because find_matching_unveiled_path would wrongly
return nullptr.

Since find_matching_unveiled_path can no longer return nullptr, we can
now just return a reference instead.
2021-06-08 12:15:04 +02:00
Max Wipfli
8930db0900 Kernel: Change unveil state to dropped even when node already exists
This also changes the UnveilState to Dropped when the path unveil() is
called for already has a node.

This fixes a bug where unveiling "/" would previously keep the
UnveilState as None, which meant that everything was still accessible
until unveil() was called with any non-root path (or nullptr).
2021-06-08 12:15:04 +02:00
Max Wipfli
2fcebfd6a8 Kernel: Update intermediate nodes when changing unveil permissions
When changing the unveil permissions of a preexisting node, we need to
make sure that any intermediate nodes that were created before and
should inherit permissions from the updated node are updated properly.

This fixes the following bug:
unveil("/home/anon/Documents", "r");
unveil("/home", "r");
Now there was a intermediate node for "/home/anon" which still had no
permission, even though it should have inherited the permissions from
"/home".
2021-06-08 12:15:04 +02:00
Max Wipfli
e8a317023d Kernel: Allow unveiling subfolders regardless of parent's permissions
This fixes a bug where unveiling a subdirectory of an already unveiled
path would sometimes be allowed and sometimes not (depending on what
other unveil calls have been made).

Now, it is always allowed to unveil a subdirectory of an already
unveiled directory, even if it has higher permissions.

This removes the need for the permissions_inherited_from_root flag in
UnveilMetadata, so it has been removed.
2021-06-08 12:15:04 +02:00
Max Wipfli
9d41dd2ed0 Kernel: Use LexicalPath to avoid two consecutive slashes in unveil path
This patch fixes a bug in the unveil syscall where an UnveilNode's path
would start with two slashes if it's parent node was "/".
2021-06-08 12:15:04 +02:00
Jelle Raaijmakers
d6a3f1fcd7 Kernel: Simplify execve shebang argument handling 2021-06-08 11:30:58 +02:00
Max Wipfli
cac94b1c16 Kernel: Implement InodeFile::stat() and simplify FileDescription::stat() 2021-06-08 11:12:31 +02:00
Gunnar Beutner
3bac14e19e Kernel: Remove incorrect VERIFY() in Thread::relock_process
Turns are there are legitimate cases where the thread state isn't
Thread::Running.
2021-06-07 14:45:38 +04:30
Brian Gianforcaro
77f4f6e0de Kernel: Fix error propagation if Thread::WaitBlocker constructor fails
There is logic at the end of the constructor that sets m_should_block
to false if we encountered errors. We were missing this step due to the
erroneous early return, the code then ended up waiting and then
asserting on unblock since the WaitBlocker is in a invalid state.

This fix is to not return early, and let normal control flow handle it.

Fixes: #7857

Verified with `stress-ng --yield=10` locally.
2021-06-07 09:43:30 +02:00
Brian Gianforcaro
9fccbde371 Kernel: Switch Process to InstrusiveList from InlineLinkedList 2021-06-07 09:42:55 +02:00
Brian Gianforcaro
252e98761a Kernel: Remove unnecessary cast to int during ensure capacity 2021-06-07 09:42:55 +02:00
Gunnar Beutner
3c2a6a25da Kernel: Don't finalize a thread while it still has code running
After marking a thread for death we might end up finalizing the thread
while it still has code to run, e.g. via:

Thread::block -> Thread::dispatch_one_pending_signal
-> Thread::dispatch_signal -> Process::terminate_due_to_signal
-> Process::die -> Process::kill_all_threads -> Thread::set_should_die

This marks the thread for death. It isn't destroyed at this point
though.

The scheduler then gets invoked via:

Thread::block -> Thread::relock_process

At that point we still have a registered blocker on the stack frame
which belongs to Thread::block. Thread::relock_process drops the
critical section which allows the scheduler to run.

When the thread is then scheduled out the scheduler sets the thread
state to Thread::Dying which allows the finalizer to destroy the Thread
object and its associated resources including the kernel stack.

This probably also affects objects other than blockers which rely
on their destructor to be run, however the problem was most noticible
because blockers are allocated on the stack of the dying thread and
cause an access violation when another thread touches the blocker
which belonged to the now-dead thread.

Fixes #7823.
2021-06-06 15:58:48 +02:00
Gunnar Beutner
0625342382 Kernel: Return EPIPE when trying to write to an unconnected socket
When attempting to write to a socket that is not connected or - for
connection-less protocols - doesn't have a peer address set we should
return EPIPE instead of blocking the thread.
2021-06-05 22:11:49 +02:00
Daniel Bertalan
169e93f0a7 Kernel: Perform output processing on echo
Previously, we would echo characters back just as they were passed to
us, even in canonical mode. This caused newlines to not work correctly
in some programs.

Fixes #7802
2021-06-05 13:01:39 +02:00
Jelle Raaijmakers
3dab9d0b5c Kernel: Implement offset for lseek with SEEK_END 2021-06-04 23:49:48 +02:00
Jelle Raaijmakers
f6d372b2ab Kernel: Process::exec(): Check if path is a regular file
https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html

  [EACCES] The new process image file is not a regular file and the
           implementation does not support execution of files of its
           type.

Let's check whether the passed `path` is indeed a regular file.
2021-06-04 23:45:17 +02:00
Gunnar Beutner
a42383523a Kernel: Update the TX byte counter when sending network packets
This previously worked but was broken by b436dd1.
2021-06-05 00:36:55 +04:30
Gunnar Beutner
60298121d8 Kernel: Make sure we increment the TX counter
This was broken by b436dd1.
2021-06-04 19:06:47 +02:00
Liav A
6a9dc5562d Kernel: Use IO ports instad of MMIO with Bochs graphics in VirtualBox
This is needed for VirtualBox, because it doesn't support controlling
the device with MMIO.

Fixes #7558.
2021-06-04 13:02:32 +02:00
Liav A
d18d91dedc Kernel/Graphics: Add a proper method to check if Intel GPU is supported 2021-06-04 13:02:32 +02:00
Jelle Raaijmakers
e483de93ce LibC: Define MSG_OOB 2021-06-04 10:39:41 +02:00
Jelle Raaijmakers
496988de47 LibC: Add POSIX timer constants 2021-06-04 10:39:41 +02:00
Daniel Bertalan
99033876ec LibVT+Kernel: Create Color class
Previously, we converted colors to their RGB values immediately when
they were set. This meant that their semantic meaning was lost, we could
not tell a precise RGB value apart from a named/indexed color.

The new way of storing colors will allow us to retain this information,
so we can change a color scheme on the fly, and previously emitted text
will also be affected.
2021-06-04 09:02:43 +01:00
Gunnar Beutner
7f7897c900 Kernel: Make sure outgoing ICMP packets have the correct checksum
The internet_checksum() function relies on the buffer - or at least the
checksum field - to be all zeroes.
2021-06-03 20:59:30 +02:00
Liav A
47c1a31f89 Kernel: Support new lines when doing critical printing
If we are printing strings in the critical path, handling new lines
require us to break abstraction a bit to print new lines.

Fixes #7562.
2021-06-03 16:16:22 +01:00
Liav A
e8d85b0694 Kernel/Graphics: Remove unused overloaded write methods of Console
If we happen to print a string, we could use a StringView instead. For
now, let's remove them entirely.
2021-06-03 16:16:22 +01:00
Luke
01d7c1b722 Kernel: Fix "sv" being inside of "no-fbdev" instead of outside
It was previously "no-fbdevsv" when it should be "no-fbdev"sv.
2021-06-03 17:08:06 +02:00
Brian Gianforcaro
7e691f96e1 Kernel: Switch ProcessGroup to IntrusiveList from InlineLinkedList 2021-06-03 13:27:40 +02:00
Gunnar Beutner
ed0068d04d AK: Allow inlining ref-count functionality
Previously we'd incur the costs for a function call via the PLT even
for the most trivial ref-count actions like increasing/decreasing the
reference count.

By moving the code to the header file we allow the compiler to inline
this code into the caller's function.
2021-06-03 08:06:51 +02:00
Gunnar Beutner
6f38ce8f47 Kernel: Avoid allocations in the VMObject constructor
This avoids allocations in the VMObject constructor. The number of
inline elements was determined empirically and covers most common cases
including LibC malloc.
2021-06-02 23:00:14 +01:00
Gunnar Beutner
596361791c Kernel: Add operator delete for KString
This doesn't change anything because our global operator delete also
calls kfree() - however instead of relying on this implementation
detail this makes this dependency more explicit.
2021-06-02 22:59:39 +01:00
Gunnar Beutner
87ff76bd57 Kernel: Make KString non-copyable and non-movable
The user is supposed to hold these in an OwnPtr but bad things would
happen if the user takes these out of the OwnPtr so let's make the
class non-copyable and non-movable.
2021-06-02 18:00:13 +02:00
Gunnar Beutner
fe0ae3161a Kernel: Fix use-after-free in sys$mremap
Now that Region::name() has been changed to return a StringView we
can't rely on keeping a copy of the region's name past the region's
destruction just by holding a copy of the StringView.
2021-06-02 18:00:13 +02:00
Brian Gianforcaro
7c0b2eb0f5 Kernel: Handle OOM of file system in sys$mount 2021-06-01 23:14:40 +01:00
Brian Gianforcaro
cbe1e05771 Kernel: Move ProcFS API towards OOM safety 2021-06-01 23:14:40 +01:00
Brian Gianforcaro
23c021912e Kernel: Move TmpFS towards OOM safety 2021-06-01 23:14:40 +01:00
Brian Gianforcaro
8f9872581b Kernel: Move DevFS APIs towards OOM safety 2021-06-01 23:14:40 +01:00
Brian Gianforcaro
d2d6ab40f9 Kernel: Make AnonymousFile::create API OOM safe 2021-06-01 23:14:40 +01:00
stelar7
01e5af487f Kernel: Dont try to register ephemeral TCP ports twice 2021-06-01 23:32:27 +04:30
Luke
4ee58d36c0 Kernel/ACPI: Sprinkle links to the specification all over
The latest version of the ACPI specification (6.4) now has a web
version, making it possible to link directly to the relevant sections
of the specification.

I added links to the stuff that was easy to find.

The spec can be found here: https://uefi.org/specs/ACPI/6.4/index.html
2021-05-31 19:06:46 +01:00
Nick Miller
10ba6f254c Kernel: Rename instances of IO port 0xe9 to BOCHS_DEBUG_PORT 2021-05-31 19:06:13 +01:00
Liav A
10c747f2be Documentation: Add explanation about AHCI locking 2021-05-31 18:28:25 +01:00
Sebastian Zaha
77044dd383
Kernel: Fix crash when switching to console 5 & 6
The changes in commit 20743e8 removed the s_max_virtual_consoles
constant and hardcoded the number of consoles to 4. But in
PS2KeyboardDevice the keyboard shortcuts for switching to consoles were
hardcoded to 6.

I reintroduced the constant and added it in both places.
2021-05-31 17:42:21 +01:00
Ali Mohammad Pur
2b5732ab77 AK+Kernel: Disallow implicitly lifting pointers to OwnPtr's
This doesn't really _fix_ anything, it just gets rid of the API and
instead makes the users explicitly use `adopt_own_if_non_null()`.
2021-05-31 17:09:12 +04:30
Brian Gianforcaro
d838a02e74 Kernel: Add KString::must_{..} factory methods
There are a bunch of places like drivers which for all intense and
purposes can't really fail allocation during boot, and if they do
fail we should crash immediately.

This change adds `KString::must_create_uninitialized(..)` as well as
`KString::must_create(..)` for use during early boot initialization of
the Kernel. They enforce that they are only used during early boot.
2021-05-31 14:50:49 +04:30
Brian Gianforcaro
35a97884aa Kernel: Move CommandLine API to use AK::StringView instead of AK::String
The current CommandLine API unfortunately allocates Strings just to
query the presence of arguments on the command line. Switch the API
to use StringView instead to reduce the number of String allocations.
2021-05-31 14:04:00 +04:30
Andreas Kling
3e0266c9e9 Kernel: Unnamed regions still need a null-terminator in core dumps
Fixes #7595.
2021-05-30 20:00:03 +02:00
Gunnar Beutner
01c75e3a34 Kernel: Don't log profile data before/after the process/thread lifetime
There were a few cases where we could end up logging profiling events
before or after the associated process or thread exists in the profile:

After enabling profiling we might end up with CPU samples before we
had a chance to synthesize process/thread creation events.

After a thread exits we would still log associated kmalloc/kfree
events. Instead we now just ignore those events.
2021-05-30 19:03:03 +02:00
Ben Wiederhake
a7c265f341 Everywhere: Sort out superfluous QuickSort.h imports
They were sorta unneeded. :^)
2021-05-29 23:41:54 +01:00
Ali Mohammad Pur
90de1ded55 Kernel: Ensure that an unveil node with no permission is never accepted
Otherwise nodes inheriting from root may still be accessed with
`access(..., F_OK)`.
Also adds a test case to TestKernelUnveil about this behaviour.
2021-05-29 22:05:34 +02:00
Andreas Kling
1123af361d Kernel: Convert Process::get_syscall_path_argument() to KString
This API now returns a KResultOr<NonnullOwnPtr<KString>> and allocation
failures should be propagated everywhere nicely. :^)
2021-05-29 20:18:57 +02:00
Andreas Kling
66f3ec687b AK: Move RefCountedBase definitions out-of-line
This dramatically reduces code size since we no longer inline all these
VERIFY() checks everywhere. Appears to be performance neutral.
2021-05-29 20:18:57 +02:00
Gunnar Beutner
42d667645d Kernel: Make sure we free the thread stack on thread exit
This adds two new arguments to the thread_exit system call which let
a thread unmap an arbitrary VM range on thread exit. LibPthread
uses this functionality to unmap the thread stack.

Fixes #7267.
2021-05-29 15:53:08 +02:00
Gunnar Beutner
95c2166ca9 Kernel: Move sys$munmap functionality into a helper method 2021-05-29 15:53:08 +02:00
Gunnar Beutner
b9d693665b Kernel: Make sure we unmap the TLS region when a thread exits
Previously the TLS region would get leaked which was noticible
when creating/destroying a lot of threads and then inspecting
the region map.
2021-05-29 15:53:08 +02:00
Liav A
907b3dd0f3 Kernel/Storage: Enable interrupts for AHCI ports if PHY is not enabled
This change allows the controller to utilize interrupts even if no
device was connected to a port when we initialize it, so we can support
hotplug events now.
2021-05-29 15:51:52 +02:00
Liav A
d431e4cd01 Kernel/Storage: Remove the None option from AHCI reset policy
This was proved to be a problematic option. I tested this option on
bare metal AHCI controller, and if we didn't reset the controller, the
firmware (SeaBIOS) could leave the controller state not clean, so an
plugged device signature was in place although the specific port had no
plugged device after rebooting.
Therefore, we need to ensure we use the controller in a clean state
always.

In addition to that, the Complete option was renamed to Aggressive, as
it represents better the consequences of choosing this option.
2021-05-29 15:51:52 +02:00
Liav A
5c1073a62d Kernel/Storage: Rename the method hba_region => default_hba_region
Also, make sure we unmap it after the init process.
2021-05-29 15:51:52 +02:00
Gunnar Beutner
77f9f442d8 Kernel: Don't overrun the buffer in krealloc()
The allocation_size_in_chunks field contains the bytes necessary for
the AllocationHeader so we need to subtract that when we try to figure
out how much user data we have to copy.

Fixes #7549.
2021-05-29 17:28:45 +04:30
Brian Gianforcaro
9b1ff3d3ac Kernel: Make Region creation API OOM safe
- Make Region::create_kernel_only OOM safe.

- Make Region::create_user_accessible mostly OOM safe, there are still
  some tendrils to untangle before it and be completely fixed.
2021-05-29 09:04:05 +02:00
Brian Gianforcaro
ab63449ab7 Kernel: Make PerformanceEventBuffer creation API OOM safe 2021-05-29 09:04:05 +02:00
Brian Gianforcaro
8fc6168f21 Kernel: Make Space::create API OOM safe 2021-05-29 09:04:05 +02:00
Brian Gianforcaro
d570048c9e Kernel: Make CoreDump::create API OOM safe 2021-05-29 09:04:05 +02:00
Brian Gianforcaro
32f96eb937 Kernel: Remove usage of adopt_own in MultiProcessorParser 2021-05-29 09:04:05 +02:00
Brian Gianforcaro
af2c3ab524 Kernel: Remove usage of adopt_own in KString 2021-05-29 09:04:05 +02:00
Brian Gianforcaro
f4d7151c3c Kernel: Make KBuffer APIs OOM safe 2021-05-29 09:04:05 +02:00
Brian Gianforcaro
864b1a65e3 Kernel: Make ContiguousVMObject factory API OOM safe 2021-05-29 09:04:05 +02:00
Brian Gianforcaro
cb45b2c001 Kernel: Make AnonymousVMObject::clone() API OOM safe
Propagate allocation failure of m_shared_committed_cow_pages,
and uncommit previously committed COW pages on failure.

This method needs a closer look in terms of error handling, as we
will eventually need to rollback all changes on allocation failure.
Alternatively we could allocate the anonymous object much earlier
and only initialize it once the other steps have succeeded.
2021-05-29 09:04:05 +02:00
Brian Gianforcaro
65d5f81afc Kernel: Make PrivateInodeVMObject factory APIs OOM safe 2021-05-29 09:04:05 +02:00
Gunnar Beutner
4fca9ee060 Kernel: Allow building the kernel with -O0
Unfortunately the kernel doesn't run with -O0 but at least it can be
successfully built with this change.
2021-05-28 19:52:22 +01:00
Gunnar Beutner
9adcfd5726 Kernel: Don't crash when writing a coredump with an unnamed region
Previously we'd try to call ByteBuffer::append(nullptr, 1) when we
came across a VM region that had no name.
2021-05-28 16:48:17 +02:00
Andreas Kling
9d801d2345 Kernel: Rename Custody::create() => try_create()
The try_ prefix indicates that this may fail. :^)
2021-05-28 11:23:00 +02:00
Andreas Kling
9a827ad3da Kernel: Use a KString for Custody::m_name 2021-05-28 11:21:00 +02:00
Andreas Kling
fc9ce22981 Kernel: Use KString for Region names
Replace the AK::String used for Region::m_name with a KString.

This seems beneficial across the board, but as a specific data point,
it reduces time spent in sys$set_mmap_name() by ~50% on test-js. :^)
2021-05-28 09:37:09 +02:00
Andreas Kling
a1944ec966 Kernel: Add missing AK/Format.h include in KResult.h 2021-05-28 09:37:09 +02:00
Andreas Kling
856f20f91f Kernel: Add try_copy_kstring_from_user()
This is a convenience function that works the same as our old
copy_string_from_user(), but this returns a KString (and can fail!)
2021-05-28 09:37:09 +02:00
Andreas Kling
279383a8f3 Kernel: Add KString, a single-owner string with OOM failure exposion
This is a simple string class for use in the kernel. It encapsulates
a length + character array in a single-allocation object.

Main differences from AK::String:

- Single-owner (no reference counting.)
- Allocation failures are exposed, not hidden.

The basic idea is to allow better and more precise string management
in the kernel.
2021-05-28 09:37:09 +02:00