Commit Graph

20323 Commits

Author SHA1 Message Date
Brian Gianforcaro
fb40da0429 Kernel: Replace make<T>() with adopt_own_if_nonnull() in Ext2FileSystem
The make<T> factory function allocates internally and immediately
dereferences the pointer, and always returns a NonnullOwnPtr<T> making
it impossible to propagate an error on OOM.
2021-05-13 16:21:53 +02:00
Brian Gianforcaro
5dc5f31f76 Kernel: Replace bare new in Custody::create() with adopt_ref_if_nonnull 2021-05-13 16:21:53 +02:00
Brian Gianforcaro
956314f0a1 Kernel: Make Process::start_tracing_from API OOM safe
Modify the API so it's possible to propagate error on OOM failure.
NonnullOwnPtr<T> is not appropriate for the ThreadTracer::create() API,
so switch to OwnPtr<T>, use adopt_own_if_nonnull() to handle creation.
2021-05-13 16:21:53 +02:00
Timothy Flynn
dba261f79b LibWeb: Propagate body background properties to root HTML element
The Acid1 test has a bit of an unusual background - the html and body
tags have different background colors. Our painting order of the DOM was
such that the body background was painted first, then all other elements
were painted in-phase according to Appendix E of CSS 2.1. So the html
element's background color was painted over the body background.

This removes the special handling of the body background from
InitialContainingBlockBox and now all boxes are painted in-phase. Doing
this also exposed that we weren't handling Section 2.11.2 of the spec;
when the html background is unset, the body's background should be
propagated to the html element.
2021-05-13 16:16:25 +02:00
Tobias Christiansen
d1ed6bce5d LibWeb: Fix off-by-one for alphabetical markers in <ol>s
The ListItemMarker gets its index 1-based while the
String::bijective_base_from expects its index to be 0-based. This patch
adjusts the index passed around accordingly.
2021-05-13 15:43:51 +02:00
Sahan Fernando
ed0e7b53a5 Kernel: Move VirtIO code away from using a scatter gather list
Currently, when passing buffers into VirtIOQueues, we use scatter-gather
lists, which contain an internal vector of buffers. This vector is
allocated, filled and the destroy whenever we try to provide buffers
into a virtqueue, which would happen a lot in performance cricital code
(the main transport mechanism for certain paravirtualized devices).

This commit moves it over to using VirtIOQueueChains and building the
chain in place in the VirtIOQueue. Also included are a bunch of fixups
for the VirtIO Console device, making it use an internal VM::RingBuffer
instead.
2021-05-13 10:00:42 +02:00
Sahan Fernando
13d5cdcd08 Kernel: Create VM::RingBuffer class 2021-05-13 10:00:42 +02:00
Sahan Fernando
8131c0de8c Kernel: Move AHCIPort::ScatterList to VM::ScatterGatherList
We want to move this out of the AHCI subsystem into the VM system,
since other parts of the kernel may need to perform scatter-gather IO.

We rename the current VM::ScatterGatherList impl that's used in the
virtio subsystem to VM::ScatterGatherRefList, since its distinguishing
feature from the AHCI scatter-gather list is that it doesn't own its
buffers.
2021-05-13 10:00:42 +02:00
Stephan Unverwerth
b63b15eeb5 LibGL: SoftwareRasterizer: Use perspective correct interpolation 2021-05-13 08:34:26 +02:00
Stephan Unverwerth
4b55aea307 LibGL: Generate coverage and depth masks in the software rasterizer
This untangles several concepts in the rasterizer and makes it possible
to toggle different stages on a per-block level rather than having to
check whether the feature is enabled for every pixel.
2021-05-13 08:34:26 +02:00
Stephan Unverwerth
f112c594a7 LibGL: Use integer math in rasterizer coverage calculations
This makes the software rasterizer use integers for triangle coverage
calculations. The previously used floating point algorithm was not
precise enough in certain situations and showed gaps between triangles.

This is not yet subpixel accurate.
2021-05-13 08:34:26 +02:00
Stephan Unverwerth
aff6426000 LibGfx: Add Vector2 class 2021-05-13 08:34:26 +02:00
Stephan Unverwerth
077c340ea2 LibGfx: Add component wise * and / operators to Vector3 and Vector4 2021-05-13 08:34:26 +02:00
Brian Gianforcaro
b8fd52fad6 Kernel: Remove unused header from FileDescription.cpp 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
a643ee5759 Kernel: Move FileDescription::get_dir_entries to KResultOr<ssize_t>
This normalizes the error handling with the rest of the subsystem.
2021-05-13 08:29:01 +02:00
Brian Gianforcaro
12ab0dcee0 Kernel: Make FileDescription::create() APIs OOM safe 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
11bd2002bb Kernel: Make InodeFile::create() API OOM safe 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
112393b38a Kernel: Make Thread::try_create API OOM safe 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
d07309a180 AK: Introduce adopt_ref_if_nonnull(..) to aid in Kernel OOM hardening
Unfortunately adopt_ref requires a reference, which obviously does not
work well with when attempting to harden against allocation failure.
The adopt_ref_if_nonnull() variant will allow you to avoid using bare
pointers, while still allowing you to handle allocation failure.
2021-05-13 08:29:01 +02:00
Brian Gianforcaro
b0fef03e3f AK: Introduce adopt_own_if_nonnull(..) to aid in Kernel OOM hardening
Unfortunately adopt_own requires a reference, which obviously does not
work well with when attempting to harden against allocation failure.
The adopt_own_if_nonnull() variant will allow you to avoid using bare
pointers, while still allowing you to handle allocation failure.
2021-05-13 08:29:01 +02:00
Brian Gianforcaro
6d39b792f0 Kernel: Declare operator new/delete noexcept for MAKE_SLAB_ALLOCATED 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
788075c58b Kernel: Declare operator new/delete noexcept for MAKE_ALIGNED_ALLOCATED 2021-05-13 08:29:01 +02:00
Brian Gianforcaro
97adaaf933 Kernel: Declare operator new/delete as noexcept for the Kernel
For Kernel OOM hardening to work correctly, we need to be able to
call a "nothrow" version of operator new. Unfortunately the default
"throwing" version of operator new assumes that the allocation will
never return on failure and will always throw an exception. This isn't
true in the Kernel, as we don't have exceptions. So if we call the
normal/throwing new and kmalloc returns NULL, the generated code will
happily go and dereference that NULL pointer by invoking the constructor
before we have a chance to handle the failure.

To fix this we declare operator new as noexcept in the Kernel headers,
which will allow the caller to actually handle allocation failure.

The delete implementations need to match the prototype of the new which
allocated them, so we need define delete as noexcept as well. GCC then
errors out declaring that you should implement sized delete as well, so
this change provides those stubs in order to compile cleanly.

Finally the new operator definitions have been standardized as being
declared with [[nodiscard]] to avoid potential memory leaks. So lets
declares the kernel versions that way as well.
2021-05-13 08:29:01 +02:00
Gunnar Beutner
8b079a6b0d Kernel: Avoid unnecessary allocations for TTY::tty_name() 2021-05-13 08:27:42 +02:00
Gunnar Beutner
93c3b6bdd2 Kernel: Avoid allocations in KBufferBuilder::appendff
This avoids some of the the shortest-lived allocations in the kernel:

StringImpl::create_uninitialized(unsigned long, char*&)
StringImpl::create(char const*, unsigned long, ShouldChomp)
StringBuilder::to_string() const
String::vformatted(StringView, TypeErasedFormatParams)
void Kernel::KBufferBuilder::appendff<unsigned int>(...)
JsonObjectSerializer<Kernel::KBufferBuilder>::add(..., unsigned int)
Kernel::procfs$all(Kernel::InodeIdentifier, ...) const
Kernel::procfs$all(Kernel::InodeIdentifier, Kernel::KBufferBuilder&)
2021-05-13 08:27:42 +02:00
Gunnar Beutner
1bb20a255f Kernel: Avoid unnecessary allocations in NetworkAdapter::for_each
This avoids allocations for initializing the Function<T>
for the NetworkAdapter::for_each callback argument.

Applying this patch decreases CPU utilization for NetworkTask
from 40% to 28% when receiving TCP packets at a rate of 100Mbit/s.
2021-05-13 08:27:42 +02:00
Gunnar Beutner
76deda802d Kernel: Avoid allocating and then freeing packet buffers
We already have another limit for the total number of packet buffers
allowed (max_packet_buffers). This second limit caused us to
repeatedly allocate and then free buffers.
2021-05-13 08:27:42 +02:00
Jelle Raaijmakers
55c3a5969c FileManager: Set minimum folder pane width 2021-05-13 00:43:41 +01:00
Jelle Raaijmakers
e5647e2ddf LibGUI/Splitter: Support setting minimum resizee size 2021-05-13 00:43:41 +01:00
Linus Groh
fd896ad29d Base: Add KeyboardMapper.af
Joining applications like Font Editor and Theme Editor, Keyboard Mapper
now has its own entry in the "Development" system menu section.
2021-05-12 23:12:54 +01:00
Linus Groh
292cd009ea KeyboardMapper: Embed icon in executable
By using serenity_app() instead of serenity_bin() in the CMakeLists.txt,
we can embed an icon as usual.
2021-05-12 23:12:29 +01:00
Linus Groh
847a49209e KeyboardMapper: Stylize title as "Keyboard Mapper"
We already do this in the about dialog and across the system in general.
2021-05-12 23:06:06 +01:00
Linus Groh
76c6bc3186 KeyboardMapper: Remove two useless comments 2021-05-12 23:05:26 +01:00
Linus Groh
f47153d437 2048: Add separator before quit menu action 2021-05-12 23:04:36 +01:00
Linus Groh
9a27ef6523 WindowServer: Re-render window frame when setting unresponsive status
Otherwise "(not responding)" would not appear in the window title until
the window is moved/resized.
2021-05-12 22:51:56 +01:00
sin-ack
60eb4adac2 Tests: Add InodeWatcher and FileWatcher tests
This patch adds some rudimentary tests for InodeWatcher.  It tests the
basic functionality, but maybe there are corner cases I haven't caught.
Additionally, this is our first LibCore test. :^)
2021-05-12 22:38:20 +02:00
sin-ack
ae9e352104 LibCore: Add unit to Core::Timer interval arguments
This patch adds the _ms suffix to the interval arguments in Core::Timer,
to make it a little clearer what the interval unit is to others.
2021-05-12 22:38:20 +02:00
sin-ack
2159f90e00 Userland+LibCore: Update FileWatcher + its users for InodeWatcher 2.0
With the new InodeWatcher API, the old style of creating a watcher per
inode will no longer work.  Therefore the FileWatcher API has been
updated to support multiple watches, and its users have also been
refactored to the new style.  At the moment, all operations done on a
(Blocking)FileWatcher return Result objects, however, this may be
changed in the future if it becomes too obnoxious. :^)

Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
2021-05-12 22:38:20 +02:00
sin-ack
fe5ca6ca27 Kernel: Implement multi-watch InodeWatcher :^)
This patch modifies InodeWatcher to switch to a one watcher, multiple
watches architecture.  The following changes have been made:

- The watch_file syscall is removed, and in its place the
  create_iwatcher, iwatcher_add_watch and iwatcher_remove_watch calls
  have been added.
- InodeWatcher now holds multiple WatchDescriptions for each file that
  is being watched.
- The InodeWatcher file descriptor can be read from to receive events on
  all watched files.

Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
2021-05-12 22:38:20 +02:00
sin-ack
2de11b0dc8 AK: Add LexicalPath::append and LexicalPath::join
This patch adds two new methods to LexicalPath.  LexicalPath::append
appends a new path component to a LexicalPath, and LexicalPath::join
constructs a new LexicalPath from one or more components.

Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
2021-05-12 22:38:20 +02:00
Tom
3f9927b0c3 Kernel: Fix issues supporting HPETs with 32-bit-only main counter
If the HPET main counter does not support full 64 bits, we should
not expect the upper 32 bit to work. This is a problem when writing
to the upper 32 bit of the comparator value, which requires the
TimerConfiguration::ValueSet bit to be set, but if it's not 64 bit
capable then the bit will not be cleared and leave it in a bad state.

Fixes #6990
2021-05-12 21:44:16 +02:00
Andreas Kling
a6a57830d0 FileManager: Reorganize main toolbar a little bit
Re-group things so they match the menus better.
2021-05-12 21:37:37 +02:00
Andreas Kling
bed2356b11 FileManager: Reorganize menus a little bit
Move the common editing actions (cut/copy/paste/select-all) into a new
"Edit" menu. And move the "Open Terminal Here" action to the "Go" menu.
2021-05-12 21:32:54 +02:00
Andreas Kling
bc0146932e LibGUI: Never resolve Key_Invalid to a GUI::Action
Fixes #7047.
2021-05-12 20:59:07 +02:00
Andreas Kling
8c7bce818d LibGUI: Move action-from-key-event code to a separate function
The logic that figures out which (if any) action should be activated
by a keydown event was getting a bit unwieldy. This patch moves it to
a separate helper function.
2021-05-12 20:51:45 +02:00
Linus Groh
91eda22208 Everywhere: Add Alt shortcuts to remaining top-level menus
Not sure why some menus did have one and others didn't, even in the
same application - now they all do. :^)
I added character shortcuts to some menu actions as well.
2021-05-12 18:09:42 +01:00
Linus Groh
f2154bca17 Browser: Use URL for window title if tab title is empty
Seeing " - Browser" for loading pages is annoying, so let's do something
more sensible instead for empty tab document titles: "<URL> - Browser".
Also consolidate the two places where this code is used into a lambda to
make any future changes easier.
2021-05-12 17:55:48 +01:00
Linus Groh
c8738bbd7e SystemMonitor: Spell process window title as "System Monitor"
This is what we use for the main window and elsewhere.
2021-05-12 17:52:56 +01:00
Linus Groh
ff1d3f53c4 Everywhere: Rename app_menu to file_menu, continued
These were missed in 4b0098e.
2021-05-12 17:50:48 +01:00
Gunnar Beutner
790d68ac5e Kernel: Route packets destined for us through the loopback adapter
Without this patch we'd send packets through the physical adapter
and they'd incorrectly end up on the network.
2021-05-12 16:31:29 +02:00