Commit Graph

26372 Commits

Author SHA1 Message Date
Andreas Kling
d9da513959 Kernel: Move "in-scheduler" flag from SchedulerData to Processor
This avoids a race between getting the processor-specific SchedulerData
and accessing it. (Switching to a different CPU in that window means
that we're operating on the wrong SchedulerData.)

Co-authored-by: Tom <tomut@yahoo.com>
2021-08-29 12:43:39 +02:00
Andreas Kling
249d6a490d Kernel: Add read_gs_value() and write_gs_value()
Co-authored-by: Tom <tomut@yahoo.com>
2021-08-29 12:26:40 +02:00
Andreas Kling
6ae60137d7 Kernel: Use StringView instead of C strings in Mutex 2021-08-29 02:21:01 +02:00
Andreas Kling
a28cd921a1 Kernel: Add Socket::set_role() and use it everywhere
Instead of having Socket subclasses write their role into Socket::m_role
directly, add a setter to do this.
2021-08-29 02:21:01 +02:00
Andreas Kling
70b2225b3d Kernel: Store LocalSocket address as a KString internally
Just because we deal with sockaddr_un at the userspace API layer doesn't
mean we have to store an awkward C type internally. :^)
2021-08-29 02:21:01 +02:00
sin-ack
fa4eeca0ac LibWeb: Properly handle newlines at the end of LineBoxes
This always subtracted the glyph width of a space, despite isspace
also accepting newlines and a few other characters. It now also uses
AK/CharacterTypes.h. :^)
2021-08-29 01:43:09 +02:00
sin-ack
b08bb0bdc3 LibGfx: Return 0 width for non-printable ASCII characters
Non-printable characters should always have a width of 0. This is not
true for some characters like tab, but those can be exempted as the need
arises. Doing this here saves us from a bunch of checks in any place
that needs to figure out glyph widths for text which can contain
non-printable characters.
2021-08-29 01:43:09 +02:00
sin-ack
27c5eb66f1 LibWeb: Rename wrap_breaks to respect_linebreaks
This more clearly expresses the purpose of this flag. Since only
CSS::WhiteSpace::Nowrap sets this value to false and it does not respect
linebreaks, this made the most sense as a flag name.
2021-08-29 01:43:09 +02:00
sin-ack
0342fe4e0c LibWeb: Refactor TextNode::ChunkIterator
This commit refactors the text chunking algorithm used in
TextNode::ChunkIterator. The m_start_of_chunk member parameter has been
replaced with a local variable that's anchored to the current iterator
at the start of every next() call, and the algorithm is made a little
more clear by explicitly separating what can and cannot peek into the
next character during iteration.
2021-08-29 01:43:09 +02:00
Andreas Kling
48a1a3c0ce Kernel: Rename LocalSocket::create_connected_pair() => try_*() 2021-08-29 01:33:15 +02:00
Andreas Kling
7f96288535 Kernel: Encapsulate assignment of socket origin/acceptor credentials 2021-08-29 01:33:15 +02:00
Andreas Kling
242063866f Kernel: Rename LocalSocket factory to try_create() & tighten return type
Also tighten the return type to KResultOr<NonnullRefPtr<LocalSocket>>
since it cannot return any other socket type.
2021-08-29 01:25:03 +02:00
Andreas Kling
244ede561b Kernel/SysFS: Remove unnecessary mutex lockers in SysFS metadata getters
SysFS inodes have immutable metadata once created.
2021-08-29 01:09:19 +02:00
Andreas Kling
8ebf08b6c8 Kernel: Make all ProcFS and SysFS files zero-sized
There is no value in exposing particular sizes for these files.
2021-08-29 01:09:19 +02:00
Andreas Kling
b959c1bfa9 Kernel: Remove unused members in BIOSSysFSDirectory 2021-08-29 01:09:19 +02:00
Andreas Kling
ed77b6f8cb Kernel: Remove an obviously redundant check in FIFO::read() 2021-08-29 01:09:19 +02:00
Andreas Kling
4cbe348a0f Kernel/Ext2FS: Avoid temporary String allocation during inode creation
Make sure we pass the StringView we get all the way through so it never
turns into a heap-allocated String. :^)
2021-08-29 01:09:19 +02:00
Andreas Kling
4ce99e4ab7 Kernel: Use ProcessID a bit more in Socket
Store the origin and acceptor PID's as ProcessID.
2021-08-29 01:09:19 +02:00
Andreas Kling
ae197deb6b Kernel: Strongly typed user & group ID's
Prior to this change, both uid_t and gid_t were typedef'ed to `u32`.
This made it easy to use them interchangeably. Let's not allow that.

This patch adds UserID and GroupID using the AK::DistinctNumeric
mechanism we've already been employing for pid_t/ProcessID.
2021-08-29 01:09:19 +02:00
Andreas Kling
59335bd8ea Kernel: Rename FileDescription::create() => try_create() 2021-08-29 01:09:19 +02:00
Linus Groh
31bc9565f8 LibJS: Avoid transitions for name/length of native functions/accessors 2021-08-28 23:17:01 +01:00
Linus Groh
8bcda353a2 LibJS: Avoid transitions for more object properties in global object 2021-08-28 23:17:01 +01:00
Linus Groh
45eef97906 LibJS: Avoid transitions in GlobalObject::initialize_constructor()
We don't need transitions for either of these:

- Adding the 'name' property to a constructor object
- Adding the 'constructor' property to its prototype object
2021-08-28 23:17:01 +01:00
Linus Groh
47ab84ffd9 LibJS: Add define_direct_{property,accessor}_without_transition() 2021-08-28 23:17:01 +01:00
Linus Groh
222e518a53 LibJS: Avoid pointless transitions and metadata lookups in storage_set()
- Replace the misleading abuse of the m_transitions_enabled flag for the
  fast path without lookup with a new m_initialized boolean that's set
  either by Heap::allocate() after calling the Object's initialize(), or
  by the GlobalObject in its special initialize_global_object(). This
  makes it work regardless of the shape's uniqueness.
- When we're adding a new property past the initialization phase,
  there's no need to do a second metadata lookup to retrieve the storage
  value offset - it's known to always be the shape's property count
  minus one. Also, instead of doing manual storage resizing and
  assignment via indexing, just use Vector::append().
- When we didn't add a new property but are overwriting an existing one,
  the property count and therefore storage value offset doesn't change,
  so we don't have to retrieve it either.

As a result, Object::set_shape() is now solely responsible for updating
the m_shape pointer and is not resizing storage anymore, so I moved it
into the header.
2021-08-28 23:17:01 +01:00
Andrew Kaster
d6de0613f5 LibCore: Store ObjectRegistration names as StringViews
We don't need to be allocating Strings for these names during static
initialization. The C-string literals will be stored in the .rodata ELF
section, so they're not going anywhere. We can just wrap the .rodata
storage for the class names in StringViews and use those in Object
registration and lookup APIs.
2021-08-28 23:34:30 +02:00
Luke Wilde
ea364af965 MailSettings: Add unveil 2021-08-28 23:29:28 +02:00
Luke Wilde
9e6d8f7c25 MailSettings: Use LibConfig instead of Core::ConfigFile
This also tightens the pledges.
2021-08-28 23:29:28 +02:00
Luke Wilde
173ba4e19b Mail: Add unveil 2021-08-28 23:29:28 +02:00
Luke Wilde
d486560aee Mail: Use LibConfig instead of Core::ConfigFile
This also tightens the pledges.
2021-08-28 23:29:28 +02:00
Nico Weber
585edb8cff Kernel: Omit all actual code from the kernel on aarch64 for now 2021-08-28 21:51:30 +01:00
Nico Weber
9c5e947e0e Prekernel: Make build on aarch64
Add a dummy Arch/aarch64/boot.S that for now does nothing but
let all processor cores sleep.

For now, none of the actual Prekernel code is built for aarch64.
2021-08-28 21:51:30 +01:00
Nico Weber
da785bd4bd Prekernel: Move boot.S and multiboot.S into an Arch/x86 subfolder 2021-08-28 21:51:30 +01:00
Nico Weber
ce98aa567c Meta: Don't pass net -device flags in aarch64 buils in run.sh 2021-08-28 21:51:30 +01:00
Nico Weber
ad480505af Meta: Introduce SERENITY_MACHINE variable in run.sh
Set it to all the `-m`, `-display`, `-device` flags for Intel,
and to just "-M raspi3" for aarch64 builds.
2021-08-28 21:51:30 +01:00
Nico Weber
4f3c0fa659 Meta: Disable spice in aarch64 buils in run.sh 2021-08-28 21:51:30 +01:00
Nico Weber
230ea3754d Meta: Run qemu-system-aarch64 in aarch64 builds in run.sh 2021-08-28 21:51:30 +01:00
Nico Weber
00c5e68b11 Meta: Disable kvm for aarch64 in run.sh 2021-08-28 21:51:30 +01:00
Nico Weber
23bc752c5d Meta: Make build-root-filesystem.sh omit libgcc_so.so in aarch64 builds 2021-08-28 21:51:30 +01:00
Nico Weber
57f95bd724 CMake: Don't build Userland and Tests in aarch64 builds for now 2021-08-28 21:51:30 +01:00
Nico Weber
a900792921 Toolchain: Also build aarch64-softmmu in BuildQemu.sh 2021-08-28 21:51:30 +01:00
Andrew Kaster
72de228695 Kernel: Verify interrupts are disabled when interacting with Mutexes
This should help prevent deadlocks where a thread blocks on a Mutex
while interrupts are disabled, and makes it impossible for the holder of
the Mutex to make forward progress because it cannot be scheduled in.

Hide it behind a new debug macro LOCK_IN_CRITICAL_DEBUG for now, because
Ext2FS takes a series of Mutexes from the page fault handler, which
executes with interrupts disabled.
2021-08-28 20:53:38 +02:00
Andrew Kaster
4f2520674c Kernel: Don't acquire Mutex for hostname() before scheduling is enabled
There's no reason to acquire the mutex for this resource before APs are
booted, before scheduling is enabled, and before interrupts are enabled.
2021-08-28 20:53:38 +02:00
Andrew Kaster
54161bf5b4 Kernel: Acquire reference to waitee before trying to block in sys$waitid
Previously, we would try to acquire a reference to the all processes
lock or other contended resources while holding both the scheduler lock
and the thread's blocker lock. This could lead to a deadlock if we
actually have to block on those other resources.
2021-08-28 20:53:38 +02:00
Andrew Kaster
dea62fe93c Kernel: Guard the all processes list with a Spinlock rather than a Mutex
There are callers of processes().with or processes().for_each that
require interrupts to be disabled. Taking a Mutexe with interrupts
disabled is a recipe for deadlock, so convert this to a Spinlock.
2021-08-28 20:53:38 +02:00
Andrew Kaster
70518e69f4 Kernel: Unlock ptrace lock before entering a critical section in execve
While it might not be as bad to release a mutex while interrupts are
disabled as it is to acquire one, we don't want to mess with that.
2021-08-28 20:53:38 +02:00
Andrew Kaster
8e70b85215 Kernel: Don't disable interrupts in validate_inode_mmap_prot
There's no need to disable interrupts when trying to access an inode's
shared vmobject. Additionally, Inode::shared_vmobject() acquires a Mutex
which is a recipe for deadlock if acquired with interrupts disabled.
2021-08-28 20:53:38 +02:00
Brian Gianforcaro
2038d2c49e LibELF: Apply some minor optimizations to symbol lookup
Optimizations:

- Make sure `DT_SYMTAB` is a string view literal, instead of string.

- DynamicObject::HashSection::lookup_sysv_symbol should be using
  raw_name() from symbol comparison to avoid needlessly calling
  `strlen`, when the StrinView::operator= walks the cstring without
  calling `strlen` first.

- DynamicObject::HashSection::lookup_gnu_symbol shouldn't create a
  symbol unless we know the hashes match first.

In order to test these changes I enabled Undefined behavior sanitizer
which creates a huge amount of relocations, and then ran the browser
with the help argument 100 times. The browser is a fairly big app with
a few different libraries being loaded, so it seemed liked a good
target.

Command: `time -n 100 br --help`

Before:
```
Timing report:
==============
Command:         br --help
Average time:    3897.679931 ms
Excluding first: 3901.242431 ms
```

After:
```
Timing report:
==============
Command:         br --help
Average time:    3612.860107 ms
Excluding first: 3613.54541 ms
```
2021-08-28 20:03:08 +02:00
Brian Gianforcaro
ad1051089c UserspaceEmulator: Profiles are now expected to have a strings array
The kernel profiles were recently changed to have a `strings` array
as part of the profile objects. The `ProfileViewer` now checks for
that during startup and declares the profile invalid if the array
is not present.

The UserspaceEmulator doesn't use the API which the kernel exposed
the string array for, so just fake it by always adding an empty array
to the generated profiles.
2021-08-28 20:03:08 +02:00
Brian Gianforcaro
e00c871f65 UserspaceEmulator: Make generated profiles debugable with cli tools
The fact that profiles are json on one giant line makes them very
difficult to debug when things go wrong. Instead make sure to wrap
each event or sample on a newline so you can easily grep/heap/tail
the profile files.
2021-08-28 20:03:08 +02:00