Commit graph

40224 commits

Author SHA1 Message Date
Roberto Bampi
78bc84c2d8 Docs: Update CLion configuration for WSL
In CLion on Windows subsystem for linux (WSL) we need to set up a
CLion toolchain so that the IDE can find the correct CMake.
2022-08-19 18:10:47 +01:00
Idan Horowitz
ae9c6a9ded Kernel: Add 8-byte atomics for i686 GCC
Unlike Clang, GCC does not support 8-byte atomics on i686 with the
-mno-80387 flag set, so until that is fixed, implement a minimal set of
atomics that are currently required.
2022-08-19 19:49:38 +03:00
Tim Schumacher
df4ba7b430 Kernel: Put too small unused network packets back into the list 2022-08-19 14:51:58 +02:00
Tim Schumacher
9e7faff181 Kernel: Protect the list of unused network packets with a Spinlock 2022-08-19 14:51:58 +02:00
Andreas Kling
766bf5c89e Kernel: Don't take thread lock for signal dispatch
Signal dispatch is already protected by the global scheduler lock, but
in some cases we also took Thread::m_lock for some reason. This led to
a number of different deadlocks that started showing up with 4+ CPU's
attached to the system.

As a first step towards solving this, simply don't take the thread lock
and let the scheduler lock cover it.

Eventually, we should work in the other direction and break the
scheduler lock into much finer-grained locks, but let's get out of the
deadlock swamp first.
2022-08-19 14:39:15 +02:00
Liav A
a1a1462a22 Kernel/Memory: Use scope guard to remove a region if we failed to map it 2022-08-19 15:26:04 +03:00
Andreas Kling
23902d46f1 Kernel: Don't lock scheduler in ~Thread()
This is not necessary, and is a leftover from before Thread started
using the ListedRefCounted pattern to be safely removed from lists on
the last call to unref().
2022-08-19 14:06:03 +02:00
Andreas Kling
806ade1367 Kernel: Don't lock scheduler while updating thread scheduling times
We can use simple atomic variables with relaxed ordering for this,
and avoid locking altogether.
2022-08-19 14:05:57 +02:00
Andreas Kling
5ada38f9c3 Kernel: Reduce time under VMObject lock while handling zero faults
We only need to hold the VMObject lock while inspecting and/or updating
the physical page array in the VMObject.
2022-08-19 12:52:48 +02:00
Andreas Kling
a84d893af8 Kernel/x86: Re-enable interrupts ASAP when handling page faults
As soon as we've saved CR2 (the faulting address), we can re-enable
interrupt processing. This should make the kernel more responsive under
heavy fault loads.
2022-08-19 12:14:57 +02:00
djwisdom
037f1ae979 Base: Add new emojis U+1F58A-U1F58D U+1F5DD U+1F5DE U+1F5E1 2022-08-19 10:31:07 +01:00
electrikmilk
1da13b6247 Base: Correct Flag Code Points
This corrects code points for the English, Scottish and Wales flags.
2022-08-19 10:19:09 +01:00
Andreas Kling
e1476788ad Kernel: Make sys$anon_create() allocate physical pages immediately
This fixes an issue where a sharing process would map the "lazy
committed page" early and then get stuck with that page even after
it had been replaced in the VMObject by a page fault.

Regressed in 27c1135d30, which made it
happen every time with the backing bitmaps used for WebContent.
2022-08-18 20:59:04 +02:00
Andreas Kling
81ee870c9b FileManager: Add "open child directory" action (Alt+Down)
This mirrors the "open parent directory" action, but traverses the
breadcrumbbar segments from left-to-right instead. The name is a little
bit strange, and maybe we can come up with something better.

It does feel pretty nice to use though. :^)
2022-08-18 20:44:15 +02:00
Andreas Kling
ff37ce7408 LibGUI: Make Breadcrumbbar remember the selected segment index
We had a selected_segment() accessor, but the member it returned was
never actually updated.
2022-08-18 20:43:39 +02:00
Andreas Kling
4bc3745ce6 Kernel: Make Region's physical page accessors safer to use
Region::physical_page() now takes the VMObject lock while accessing the
physical pages array, and returns a RefPtr<PhysicalPage>. This ensures
that the array access is safe.

Region::physical_page_slot() now VERIFY()'s that the VMObject lock is
held by the caller. Since we're returning a reference to the physical
page slot in the VMObject's physical page array, this is the best we
can do here.
2022-08-18 19:20:33 +02:00
Andreas Kling
c3ad4ffcec Kernel: Schedule threads on all processors when SMP is enabled
Note that SMP is still off by default, but this basically removes the
weird "SMP on but threads don't get scheduled" behavior we had by
default. If you pass "smp=on" to the kernel, you now get SMP. :^)
2022-08-18 18:58:33 +02:00
Andreas Kling
b560442fe1 Kernel: Don't hog VMObject lock when remapping a region page
We really only need the VMObject lock when accessing the physical pages
array, so once we have a strong pointer to the physical page we want to
remap, we can give up the VMObject lock.

This fixes a deadlock I encountered while building DOOM on SMP.
2022-08-18 18:56:35 +02:00
Andreas Kling
10399a258f Kernel: Move Region physical page accessors out of line 2022-08-18 18:52:34 +02:00
Andreas Kling
c14dda14c4 Kernel: Add a comment about what the MM lock protects 2022-08-18 18:52:34 +02:00
Andreas Kling
75348bdfd3 Kernel: Don't require MM lock for Region::set_page_directory()
The MM lock is not required for this, it's just a simple ref-counted
pointer assignment.
2022-08-18 18:52:34 +02:00
Andreas Kling
abb84b9fcd Kernel: Fix inconsistent lock acquisition order in kmalloc
We always want to grab the page directory lock before the MM lock.
This fixes a deadlock I encountered when building DOOM with make -j4.
2022-08-18 18:52:34 +02:00
Andreas Kling
27c1135d30 Kernel: Don't remap all regions from Region::remap_vmobject_page()
When handling a page fault, we only need to remap the faulting region in
the current process. There's no need to traverse *all* regions that map
the same VMObject and remap them cross-process as well.

Those other regions will get remapped lazily by their own page fault
handlers eventually. Or maybe they won't and we avoided some work. :^)
2022-08-18 18:52:34 +02:00
Andreas Kling
45e6123de8 Kernel: Shorten time under spinlocks while handling inode faults
- Instead of holding the VMObject lock across physical page allocation
  and quick-map + copy, we now only hold it when updating the VMObject's
  physical page slot.
2022-08-18 18:52:34 +02:00
Thomas Symalla
03e9697975 TextEditor: Change cursor when reaching the ruler area
Noticed that mouse-overing the ruler area in the TextEditor
does not change the cursor to the default cursor, instead, the
beam cursor is used, which does not look nice.

This PR extends the mousemove event and introduces a new
set_editing_cursor() function that takes care of setting the
cursor for the editor area.
2022-08-18 15:59:53 +02:00
Timothy Flynn
299cebbbcb FileManager: Do not activate "Show Dotfiles" action on every startup
Commit 75d1840cf detects if the initial path provided to the FileManager
contains a dotfile, and if so, forces the FileManager to show dotfiles.
However, it does this by activating the "Show Dotfiles" action. This has
the side effect of always setting and persisting the configuration,
overriding whatever the user's preference was.

Instead, only transiently update the view to show dotfiles if the path
contains a dotfile.
2022-08-18 15:58:41 +02:00
MacDue
d26203ff90 Base: Add some repeating-linear-gradient() examples 2022-08-18 15:58:05 +02:00
MacDue
e294b7929a LibWeb: Support painting repeating-linear-gradient()s 2022-08-18 15:58:05 +02:00
MacDue
ffdcc60b03 LibWeb: Avoid NaNs from zero-length gradient color stops 2022-08-18 15:58:05 +02:00
MacDue
f9a685437f LibWeb: Parse repeating-linear-gradient()
Including `-webkit-repeating-linear-gradient()`
2022-08-18 15:58:05 +02:00
Ryan Liptak
b123309b0d LibGfx: Skip useless iterations during PNG::FilterType::Sub unfiltering 2022-08-18 11:12:59 +01:00
Ryan Liptak
b19f3b5106 LibGfx: Unfilter PNG data before unpacking it to RGBA
The order of PNG compression is raw pixel data -> filter -> compress.
For decompression, the order is reversed, so that means uncompress ->
unfilter -> raw pixel data. Previously, the PNG decoder was converting
to raw pixel data before unfiltering, which was a problem when using
indexed color palettes, since each pixel's palette index could change
during unfiltering (e.g. it was unfiltering after already choosing
the color from the palette index). This was leading to 'Palette index
out of range' errors on files that both:

- Had scanlines with some sort of filtering
- Didn't use the full range of possible palette indices for their bit
  depth.

Also, because filtering now happens before converting to pixel data,
filtering acts on bytes instead of pixels, meaning that the
implementation of each filter type now maps much more directly to
the specification:

http://www.libpng.org/pub/png/spec/1.2/PNG-Filters.html
2022-08-18 11:12:59 +01:00
djwisdom
77a135491e Base: Add new globe emojis U+1F30D-U+1F30F
🌍 - U+1F30D GLOBE SHOWING EUROPE-AFRICA
🌎 - U+1F30E GLOBE SHOWING AMERICAS
🌏 - U+1F30F GLOBE SHOWING ASIA-AUSTRALIA

Coverage: https://emoji.serenityos.net
2022-08-18 09:59:06 +01:00
kleines Filmröllchen
c0079cf963 LibCore: Make EventLoop's connection to InspectorServer work again
This path was changed to the uid templated version without actually
using the template resolver function in Account.
2022-08-17 16:40:42 -07:00
Andreas Kling
04c362b4dd Kernel: Fix TOCTOU in sys$unveil()
Make sure we reject the unveil attempt with EPERM if the veil was locked
by another thread while we were parsing argument (and not holding the
veil state spinlock.)

Thanks Brian for spotting this! :^)

Amendment to #14907.
2022-08-18 01:04:28 +02:00
Andreas Kling
ae3fa20252 Kernel/x86: Don't re-enable interrupts too soon when unlocking spinlocks
To ensure that we stay on the same CPU that acquired the spinlock until
we're completely unlocked, we now leave the critical section *before*
re-enabling interrupts.
2022-08-18 00:58:34 +02:00
Andreas Kling
cb04caa18e Kernel: Protect the Custody cache with a spinlock
Protecting it with a mutex meant that anyone unref()'ing a Custody
might need to block on said mutex.
2022-08-18 00:58:34 +02:00
Andreas Kling
17de393253 Kernel: Remove outdated FIXME in Custody.h 2022-08-18 00:58:34 +02:00
Andreas Kling
ec330c2ce6 Kernel: Use consistent lock acquisition order in Thread::block*()
We want to grab g_scheduler_lock *before* Thread::m_block_lock.
This appears to have fixed a deadlock that I encountered while building
DOOM with make -j2.
2022-08-18 00:58:34 +02:00
Andreas Kling
ae8558dd5c Kernel: Don't do path resolution in sys$chdir() while holding spinlock
Path resolution may do blocking I/O so we must not do it while holding
a spinlock. There are tons of problems like this throughout the kernel
and we need to find and fix all of them.
2022-08-18 00:58:34 +02:00
Andreas Kling
51bc87d15a Kernel/x86: Disable interrupts when leaving critical sections
This fixes an issue where we could get preempted after acquiring the
current Processor pointer, but before calling methods on it.

I strongly suspect this was the cause of "Processor::current() == this"
assertion failures.
2022-08-18 00:58:34 +02:00
Andreas Kling
cd348918f9 Kernel/x86: Move Processor::{leave,clear}_critical() out of line
I don't think this code needs to be ALWAYS_INLINE, and moving it out
of line will make backtraces nicer.
2022-08-18 00:58:34 +02:00
davidot
28e552f853 LibJS: Resolve the correct this value for calls in with statements 2022-08-17 23:56:24 +01:00
davidot
3a8dd3e78d LibJS: Implement tagged literals evaluation like the spec
We cache on the AST node side as this is easier to track a position, we
just have to take care to wrap the values in a handle to make sure they
are not garbage collected.
2022-08-17 23:56:24 +01:00
davidot
e5adc51e27 LibJS: Allow invalid string in tagged template literals
Since tagged template literals can inspect the raw string it is not a
syntax error to have invalid escapes. However the cooked value should be
`undefined`.
We accomplish this by tracking whether parse_string_literal
fails and then using a NullLiteral (since UndefinedLiteral is not a
thing) and finally converting null in tagged template execution to
undefined.
2022-08-17 23:56:24 +01:00
davidot
0f9434a02c LibJS: Make StringToNumber case sensitive when falling back to strtod
We use strtod to convert a string to number after checking whether the
string is [+-]Infinity, however strtod also checks for either 'inf' or
'infinity' in a case-insensitive.
There are still valid cases for strtod to return infinity like 10e100000
so we just check if the "number" contains 'i' or 'I' in which case
the strtod infinity is not valid.
2022-08-17 23:56:24 +01:00
davidot
9d05ca7b20 LibJS: Don't assume a this argument for function.prototype.bind
Assuming we had at least one argument meant that the ...arg count would
underflow causing the bound function to have length 0 instead of the
given length when binding with no arguments.
2022-08-17 23:56:24 +01:00
davidot
c4f3d44be1 LibJS: Add the HostEnsureCanAddPrivateElement hook
This hook allows us to reject private elements on certain exotic
objects like the window object in browser.
Note that per the spec we should only call this hook if the host is a
web browser, however because LibJS has no way of knowing whether it is
in a web browser environment we just always call the host hook.
2022-08-17 23:56:24 +01:00
Samuel Bowman
b5a2f59320 Kernel: Make sys$unveil() not take the big process lock
The unveil syscall uses the UnveilData struct which is already
SpinlockProtected, so there is no need to take the big lock.
2022-08-18 00:04:31 +02:00
Linus Groh
146903a3b5 Kernel: Require semicolon after VERIFY_{NO_,}PROCESS_BIG_LOCK_ACQUIRED
This matches out general macro use, and specifically other verification
macros like VERIFY(), VERIFY_NOT_REACHED(), VERIFY_INTERRUPTS_ENABLED(),
and VERIFY_INTERRUPTS_DISABLED().
2022-08-17 22:56:51 +02:00