Commit graph

25570 commits

Author SHA1 Message Date
brapru
0095c7cb7d Kernel: Add so_error to keep track of the socket's error state
This sets the m_so_error variable every time the socket returns an
error.
2021-08-10 20:59:53 +02:00
Gunnar Beutner
f424485193 LaunchServer: Make sure launching absolute symlinks works
This was broken by 31d659d.
2021-08-10 20:17:34 +02:00
Andreas Kling
02f9ffeb7f UserspaceEmulator: Fail sys$map_time_page() with ENOSYS for now
This allows LibC to fall back to sys$clock_gettime() until we can
add support for the kernel time page to UserspaceEmulator.
2021-08-10 19:21:16 +02:00
Andreas Kling
fdfc66db61 Kernel+LibC: Allow clock_gettime() to run without syscalls
This patch adds a vDSO-like mechanism for exposing the current time as
an array of per-clock-source timestamps.

LibC's clock_gettime() calls sys$map_time_page() to map the kernel's
"time page" into the process address space (at a random address, ofc.)
This is only done on first call, and from then on the timestamps are
fetched from the time page.

This first patch only adds support for CLOCK_REALTIME, but eventually
we should be able to support all clock sources this way and get rid of
sys$clock_gettime() in the kernel entirely. :^)

Accesses are synchronized using two atomic integers that are incremented
at the start and finish of the kernel's time page update cycle.
2021-08-10 19:21:16 +02:00
Andreas Kling
f02d73db4d LibC+Kernel: Use an enum for clockid_t values 2021-08-10 13:01:39 +02:00
Andreas Kling
595ed59eb7 Kernel: Alphabetize the syscall list 2021-08-10 13:01:39 +02:00
Andreas Kling
fa64ab26a4 Kernel+UserspaceEmulator: Remove unused sys$gettimeofday()
Now that LibC uses clock_gettime() to implement gettimeofday(), we can
get rid of this entire syscall. :^)
2021-08-10 13:01:39 +02:00
Andreas Kling
5f6e0e0162 LibC: Implement gettimeofday() in terms of clock_gettime(CLOCK_REALTIME) 2021-08-10 13:01:39 +02:00
sin-ack
1be59d663a Mandelbrot: Only recalculate missing areas after panning
We can reuse the areas that we have from before and just recalculate
the areas that are fresh. This makes panning super smooth. :^)
2021-08-10 09:48:12 +02:00
sin-ack
d28802ad22 Mandelbrot: Add panning
Adds the ability to use the middle-mouse click to pan the current view.
2021-08-10 09:48:12 +02:00
sin-ack
faec8bbe45 Mandelbrot: Add mousewheel zooming
This allows the user to zoom in with a up scroll of the mousewheel and
zoom out with a down scroll.
2021-08-10 09:48:12 +02:00
sin-ack
a08dd5b99c Mandelbrot: Use a GUI::Frame to paint into
This allows us to have a frame border which looks nicer.
2021-08-10 09:48:12 +02:00
LuK1337
31d659d9a0 LaunchServer: Resolve symlinks when querying for handler application
This lets us launch proper handler application for symlinks :^)
2021-08-10 05:26:36 +04:30
sin-ack
51d559e253 Spreadsheet: Call SheetModel::update() instead of invalidate()
SheetModel has its own custom updating method, and that must be called
in order to update the spreadsheet.
2021-08-10 05:21:49 +04:30
Andreas Kling
0a02496f04 Kernel/SMP: Change critical sections to not disable interrupts
Leave interrupts enabled so that we can still process IRQs. Critical
sections should only prevent preemption by another thread.

Co-authored-by: Tom <tomut@yahoo.com>
2021-08-10 02:49:37 +02:00
Andreas Kling
364134ad4b Kernel/SMP: Skip thread registers in core dump if there is no trap frame
We can only get thread registers if there's a trap frame.
2021-08-10 02:49:37 +02:00
Andreas Kling
9babb92a4b Kernel/SMP: Make entering/leaving critical sections multi-processor safe
By making these functions static we close a window where we could get
preempted after calling Processor::current() and move to another
processor.

Co-authored-by: Tom <tomut@yahoo.com>
2021-08-10 02:49:37 +02:00
Ali Mohammad Pur
369e3da6a2 UserspaceEmulator: Move all the profiling details into the Emulator
Them being in the global namespace doesn't have a lot of fans, it seems.
2021-08-10 05:13:44 +04:30
Ali Mohammad Pur
2128ae4ab0 Profiler: Disassemble the containing function for non-function symbols
This can happen if the symbol is part of a switch-case, and not
a function, which would previously have made the disassembly view
appear empty.
Now we disassemble the containing function, starting at the given label
and continuing up until the last captured instruction.
2021-08-10 05:13:44 +04:30
Ali Mohammad Pur
4bef63fa6a Profiler: Show the symbol address in object file 2021-08-10 05:13:44 +04:30
Ali Mohammad Pur
64ccf2196c UserspaceEmulator+LibC: Add support for Region-of-Interest profiling 2021-08-10 05:13:44 +04:30
Daniel Bertalan
18b2484985 LibELF: Remove (FlatPtr)something.as_ptr() idiom
This is equivalent to `something.get()`, but more verbose.
2021-08-09 23:15:48 +02:00
Daniel Bertalan
e0e3198d51 LibELF: Fix 'applying offset produced null pointer' UBSAN failure
These integer => pointer => integer conversions were technically prone
to UB, since they were used as offsets (which are perfectly fine to be
zero), but we calculated them with pointer arithmetic. This made Clang
insert pointer overflow UBSAN checks, which trigger in case of a zero
result.
2021-08-09 23:15:48 +02:00
Liav A
d16d116b65 Kernel/USB: Tighten up USBManagement enumeration code a bit 2021-08-09 22:52:09 +02:00
Tetsui Ohkubo
1479ee3f3e LaunchServer: Do not provide file handlers for special files
With this change, LaunchServer will always return an empty list of file
handlers for special files e.g. sockets and devices. Before this change,
TextEditor was always returned as a default handler for these files.
2021-08-09 22:50:09 +02:00
Tobias Christiansen
2a77abf85e Everywhere: Use tobyase@serenityos.org for my copyright headers 2021-08-09 21:43:05 +02:00
Luke
7a86a8df90 Kernel/USB: Create controller base class and introduce USBManagement
This removes Pipes dependency on the UHCIController by introducing a
controller base class. This will be used to implement other controllers
such as OHCI.

Additionally, there can be multiple instances of a UHCI controller.
For example, multiple UHCI instances can be required for systems with
EHCI controllers. EHCI relies on using multiple of either UHCI or OHCI
controllers to drive USB 1.x devices.

This means UHCIController can no longer be a singleton. Multiple
instances of it can now be created and passed to the device and then to
the pipe.

To handle finding and creating these instances, USBManagement has been
introduced. It has the same pattern as the other management classes
such as NetworkManagement.
2021-08-09 21:05:25 +02:00
Jesse Buhagiar
c5974d3518 USB: Fix wrong port read/write in portscan daemon
Port2 logic was errantly using `portsc1` registers, meaning that
the port wouldn't be reset properly. In effect, this puts devices
connected to Port2 in an undefined state.
2021-08-09 21:04:55 +02:00
Tom
e3e52a4e61 Meta: Add SERENITY_CPUS environment variable to control number of CPUs 2021-08-09 21:02:23 +02:00
Kenneth Myhra
3e0d0847b6 Ports: Compile ncurses as a shared library
This sets the --with-shared switch for the configure script so that
ncurses is compiled as a shared library in addition the default which is
a static library.
Without the --with-shared switch ncurses will only be compiled as a
static library.

To properly set the environment variables LOCAL_LDFLAGS and
LOCAL_LDFLAGS2,  a case in the configure script had to be updated to
include '*serenity*'.
2021-08-09 20:08:36 +02:00
roytam1
6de6dff5b9 Ports: Add missing fnmatch patch for diffutils
It requires FNM_EXTMATCH in order to build.

This patch is based on an existing patch for gettext
(Ports/gettext/patches/fnmatch.patch).
2021-08-09 17:56:29 +01:00
davidot
e1573991a3 LibJS: Fix this values in arrow functions
Also added a large this value test (and strict variant) to ensure this
values have no regressions.
2021-08-09 17:33:14 +01:00
davidot
151447bdf7 LibJS: Move Object::invoke to Value::invoke and fix it for primitives
This is a tiny difference and only changes anything for primitives in
strict mode. However this is tested in test262 and can be noticed by
overriding toString of primitive values.

This does now require one to wrap an object in a Value to call invoke
but all code using invoke has been migrated.
2021-08-09 17:33:14 +01:00
Andreas Kling
74e6a70958 Kernel/SMP: Don't process SMP messages in non-SMP mode
Processing SMP messages outside of non-SMP mode is a waste of time,
and now that we don't rely on the side effects of calling the message
processing function, let's stop calling it entirely. :^)
2021-08-09 13:39:08 +02:00
Andreas Kling
a971de89d3 Kernel/SMP: Process the deferred call queue in exit_trap()
We were previously relying on a side effect of the critical section in
smp_process_pending_messages(): when exiting that section, it would
process any pending deferred calls.

Instead of relying on that, make the deferred invocations explicit by
calling deferred_call_execute_pending() in exit_trap().

This ensures that deferred calls get processed before entering the
scheduler at the end of exit_trap(). Since thread unblocking happens
via deferred calls, the threads don't have to wait until the next
scheduling opportunity when they could be ready *now*. :^)

This was the main reason Tom's SMP branch ran slowly in non-SMP mode.
2021-08-09 13:35:52 +02:00
Andreas Kling
57a7dfbd28 Kernel/SMP: Don't process SMP messages in exit_trap() in non-SMP mode 2021-08-09 13:23:42 +02:00
Andreas Kling
f27e7bbbf4 Kernel/SMP: Don't enable interrupts in Processor::exit_trap
Enter a critical section in Processor::exit_trap so that processing
SMP messages doesn't enable interrupts upon leaving. We need to delay
this until the end where we call into the Scheduler if exiting the
trap results in being outside of a critical section and irq handler.

Co-authored-by: Tom <tomut@yahoo.com>
2021-08-09 13:22:22 +02:00
Andreas Kling
cd0fc7f52c Kernel/SMP: Mark s_smp_enabled READONLY_AFTER_INIT
We can't enter/leave SMP mode once the kernel is up and running.
2021-08-09 13:19:26 +02:00
Andreas Kling
f357fd91da Kernel: Don't hog MM lock in Memory::Region::clone()
We don't need to hold the MM lock across all of Region::clone().
2021-08-09 11:46:31 +02:00
Andreas Kling
08b4d8f0de Kernel: Fix deadlock in ~Memory::Region()
First off: unregister the region from MemoryManager before unmapping it.
The order of operations here was a bit strange, presumably to avoid a
situation where a fault would happen while unmapping, and the fault
handler would find the MemoryManager region list in an invalid state.

Unregistering it before unmapping sidesteps the whole problem, and
allows us to easily fix another problem: a deadlock could occur due
to inconsistent acquisition order (PageDirectory must come before MM.)
2021-08-09 11:46:31 +02:00
Andreas Kling
95c8e421ae Kernel: Don't hog MM lock in find_region_from_vaddr()
We don't want to be holding the MM lock if it's a user region and we
have to consult the page directory, since that can lead to a deadlock
if we don't already have the page directory lock.
2021-08-09 11:46:31 +02:00
Andreas Kling
96c7b70de3 Kernel: Remove unused list of user regions in MemoryManager
We were putting all the user Region objects on an intrusive list
but not using it for anything.
2021-08-09 11:46:31 +02:00
Andreas Kling
ab5c422a29 Kernel/SMP: Make SMP message queueing work correctly
- Use the receiver's per-CPU entry in the message, instead of the
  sender's. (Using the sender's entry wasn't safe for broadcast
  messages since the same entry ended up on multiple message queues.)

- Retry the CAS until it *succeeds* instead of *fails*. This closes a
  race window, and also ensures a correct return value. The return value
  is used by the caller to decide whether to broadcast an IPI.
  This was the main reason smp=on was so slow. We had CPUs busy-waiting
  until someone else triggered an IPI and moved things along.

- Add a CPU pause hint to the spin loop. :^)
2021-08-09 11:46:31 +02:00
Andreas Kling
6283acb6b7 Kernel/SMP: Don't panic in inode fault if other CPU already paged it in
It may happen that CPU A manages to page in from the same inode
while we're just entering the same page fault handler on CPU B.

Handle it gracefully by checking if the data has already been paged in
(instead of VERIFY'ing that it hasn't) and then remap the page if that's
the case.
2021-08-09 11:46:31 +02:00
Andreas Kling
00bbbdeda6 Kernel/SMP: Always take PageDirectory lock before the MemoryManager lock
This prevents deadlocking due to inconsistent acquisition order.
2021-08-09 11:46:31 +02:00
Andreas Kling
d21b8f9013 Kernel/SMP: Fix ProcessorMessage deallocation bug
Due to a boolean mistake in smp_return_to_pool(), we didn't retry
pushing the message onto the freelist after a failed attempt.

This caused the message pool to eventually become completely empty
after enough contentious access attempts.

This patch also adds a pause hint to the CPU in the failed attempt
code path.
2021-08-09 11:46:30 +02:00
Andreas Kling
f3fed411d4 Kernel: Rename Processor::smp_queue_message() => smp_enqueue_message() 2021-08-09 11:46:30 +02:00
Andreas Kling
46215a8183 Kernel: Add Processor::pause() and use it to give the CPU a rest
On x86, the "pause" instruction is a "spin loop hint".
2021-08-09 11:46:30 +02:00
Andreas Kling
b7129c57df Kernel: Only get register dump when we have a trap
Co-authored-by: Tom <tomut@yahoo.com>
2021-08-09 11:46:30 +02:00
Andreas Kling
cebdb0b575 Kernel: Fix logic typo in ConsoleManagement::is_initialized()
Regressed in 2ff3c54153.
2021-08-09 11:46:30 +02:00