Commit Graph

2553 Commits

Author SHA1 Message Date
Liav A
a506b2a48e Thread: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
d16b26f83a MemoryManager: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
8a22e93ebb VirtualConsole: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
309593d5bd TTY: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
db23703570 Process: Use dbg() instead of dbgprintf()
Also, fix a bad derefernce in sys$create_shared_buffer() method.
2020-02-27 13:05:12 +01:00
Liav A
b0d40e9495 Ext2Filesystem: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
42665817d1 RangeAllocator: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
b41e2d25b4 CPU: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
9e520fd0d6 Syscall: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
9ee6d00b57 VMWareBackdoor: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
67994cd87e ProcFS: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
03592a80fc FIFO: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
31a67ca2f9 Ksyms: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
946d9b8c24 IOAPIC: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
5cd58adfa9 PS2MouseDevice: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
fcb1426a2b Init Stage: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
3f2d5f2774 PhysicalPage: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
24d2aeda8e Region: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
bb9fba1fdd KeyboardDevice: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
3f95a7fc97 InodeVMObject: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
7deb1f07c3 PCI MMIOAccess: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
efec7448c9 ACPIStaticParser: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
62adbbc598 PageDirectory: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
2b9826a444 Scheduler: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
97e5ccd984 E1000NetworkAdapter: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
b7b2fb083d LoopbackAdapter: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
d6ae2cf46a IPv4Socket: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
4432bf41f6 DMIDecoder: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
16a5b6f7fb Kernel: Run clang-format on DMIDecoder header file 2020-02-27 13:05:12 +01:00
Liav A
fd893f834c Kernel: Don't use references or pointers to physical addresses
Now the DMIDecoder code is more safer, because we don't use raw pointers
or references to objects or data that are located in the physical
address space, so an accidental dereference cannon happen easily.
Instead, we use the PhysicalAddress class to represent those addresses.

Also, the initializer_parser() method is simplified.
2020-02-27 13:05:12 +01:00
Andreas Kling
4997dcde06 Kernel: Always disable interrupts in do_killpg()
Will caught an assertion when running "kill 9999999999999" :^)
2020-02-27 11:05:16 +01:00
Andreas Kling
4a293e8a21 Kernel: Ignore signals sent to threadless (zombie) processes
If a process doesn't have any threads left, it's in a zombie state and
we can't meaningfully send signals to it. So just ignore them.

Fixes #1313.
2020-02-27 11:04:15 +01:00
Cristian-Bogdan SIRB
5aa5ce53bc Kernel: Fix the gettid syscall
syscall_handler was not actually updating the value in regs->eax, so the
gettid() was always returning 85: the value of regs->eax was not
actually updated, and it remained the one from Userland (the value of
SC_gettid).

The syscall_handler was modified to actually get a pointer to
RegisterState, so any changes to it will actually be saved.

NOTE: This was actually more of a compiler optimization:
On the SC_gettid flow, we saved in regs.eax the return value of
sys$gettid(), but the compiler discarded it, since it followed a return.
On a normal flow, the value of regs.eax was reused in
tracer->did_syscall, so the compiler actually updated the value.
2020-02-27 10:58:43 +01:00
Andreas Kling
0c1497846e Kernel: Don't allow profiling a dead process
Work towards #1313.
2020-02-27 10:42:31 +01:00
Andreas Kling
79e79ad1d2 Kernel: Don't blindly dereference Process::executable()
When setting up profiling, don't assume that the profiled process has
a valid executable.
2020-02-27 10:41:32 +01:00
Cristian-Bogdan SIRB
05ce8586ea Kernel: Fix ASSERTION failed in join_thread syscall
set_interrupted_by_death was never called whenever a thread that had
a joiner died, so the joiner remained with the joinee pointer there,
resulting in an assertion fail in JoinBlocker: m_joinee pointed to
a freed task, filled with garbage.

Thread::current->m_joinee may not be valid after the unblock

Properly return the joinee exit value to the joiner thread.
2020-02-27 10:09:44 +01:00
Andreas Kling
d28fa89346 Kernel: Don't assert on sys$kill() with pid=INT32_MIN
On 32-bit platforms, INT32_MIN == -INT32_MIN, so we can't expect this
to always work:

    if (pid < 0)
        positive_pid = -pid; // may still be negative!

This happens because the -INT32_MIN expression becomes a long and is
then truncated back to an int.

Fixes #1312.
2020-02-27 10:02:04 +01:00
Andreas Kling
4e394862ce Kernel: Disallow assigning a TTY to an arbitrary process group ID
It was possible to send signals to processes that you were normally not
allowed to send signals to, by calling ioctl(tty, TIOCSPGRP, targetpid)
and then generating one of the TTY-related signals on the calling
process's TTY (e.g by pressing ^C, ^Z, etc.)
2020-02-26 21:33:14 +01:00
Andreas Kling
d5fe839166 Kernel: Remove unused artifacts of the Custody cache
We'll probably want some kind of Custody caching in the future, but as
it's not used at the moment, let's simplify things a bit.
2020-02-26 15:25:53 +01:00
Andreas Kling
987dbedf4a Kernel: Sanitize memory coming in/out of the slab allocator
We were using SANITIZE_KMALLOC which was never defined in this .cpp
file, oops. Now we actually scrub on slab_alloc() and slab_dealloc().
2020-02-26 15:25:53 +01:00
Cristian-Bogdan SIRB
717cd5015e Kernel: Allow process with multiple threads to call exec and exit
This allows a process wich has more than 1 thread to call exec, even
from a thread. This kills all the other threads, but it won't wait for
them to finish, just makes sure that they are not in a running/runable
state.

In the case where a thread does exec, the new program PID will be the
thread TID, to keep the PID == TID in the new process.

This introduces a new function inside the Process class,
kill_threads_except_self which is called on exit() too (exit with
multiple threads wasn't properly working either).

Inside the Lock class, there is the need for a new function,
clear_waiters, which removes all the waiters from the
Process::big_lock. This is needed since after a exit/exec, there should
be no other threads waiting for this lock, the threads should be simply
killed. Only queued threads should wait for this lock at this point,
since blocked threads are handled in set_should_die.
2020-02-26 13:06:40 +01:00
Andreas Kling
7f9a86b495 ProcFS: Expose the physical page map of each region in /proc/PID/vm
You can now see the state of each underlying physical page slot in a
VM region.
2020-02-25 23:06:40 +01:00
Andreas Kling
ceec1a7d38 AK: Make Vector use size_t for its size and capacity 2020-02-25 14:52:35 +01:00
Andreas Kling
d0f5b43c2e Kernel: Use Vector::unstable_remove() when deallocating a region
Process::m_regions is not sorted, so we can use unstable_remove()
to avoid shifting the vector contents. :^)
2020-02-24 18:34:49 +01:00
Andreas Kling
f59747a3d8 Kernel: Fix some formatting goofs in Process.h 2020-02-24 16:17:03 +01:00
Andreas Kling
cb9d9846e0 Kernel: Fail with ENOMEM if there's insufficient VM for a SharedBuffer 2020-02-24 13:33:10 +01:00
Andreas Kling
30a8991dbf Kernel: Make Region weakable and use WeakPtr<Region> instead of Region*
This turns use-after-free bugs into null pointer dereferences instead.
2020-02-24 13:32:45 +01:00
Andreas Kling
79576f9280 Kernel: Clear the region lookup cache on exec()
Each process has a 1-level lookup cache for fast repeated lookups of
the same VM region (which tends to be the majority of lookups.)
The cache is used by the following syscalls: munmap, madvise, mprotect
and set_mmap_name.

After a succesful exec(), there could be a stale Region* in the lookup
cache, and the new executable was able to manipulate it using a number
of use-after-free code paths.
2020-02-24 12:37:27 +01:00
Liav A
5ce6215af7 ACPI: Don't set Smart Pointers to be nullptr
Instead of setting the smart pointers to be nullptr in the
initializer list, it's done automatically by OwnPtr.
2020-02-24 11:27:03 +01:00
Liav A
85307dd26e Kernel: Don't use references or pointers to physical addresses
Now the ACPI & PCI code is more safer, because we don't use raw pointers
or references to objects or data that are located in the physical
address space, so an accidental dereference cannot happen easily.
Instead, we use the PhysicalAddress class to represent those addresses.
2020-02-24 11:27:03 +01:00
Liav A
fe664965c2 Kernel: Change get_sharing_devices_count() in GenericInterruptHandler
The new method' name is sharing_devices_count().
The Serenity Coding Style tends to not accept the word "get" in
methods' names if possible.
2020-02-24 11:27:03 +01:00
Liav A
a7d7c0e60c Kernel: Change get_pci_address() to pci_address() in PCI::Device class
The Serenity Coding Style tends to not accept the word "get" in
methods' names if possible.
2020-02-24 11:27:03 +01:00
Liav A
80eea6cd8b Kernel: Create an entry for viewing interrupts in ProcFS 2020-02-24 11:27:03 +01:00
Liav A
e3b24d0478 Kernel: Delete unused files 2020-02-24 11:27:03 +01:00
Liav A
36eea5fa60 Build: Update the Kernel makefile to build the latest changes 2020-02-24 11:27:03 +01:00
Liav A
4448597c64 Kernel: Update the init stage to use all the latest changes
gdt_init() and idt_init() will be invoked earlier in the boot process.
Also, setup_interrupts() will be called to setup the interrupt mode.
2020-02-24 11:27:03 +01:00
Liav A
bb73802b15 CPU: Use the new interrupt components
Now we use the GenericInterruptHandler class instead of IRQHandler in
the CPU functions.
This commit adds an include to the ISR stub macros header file.
Also, this commit adds support for IRQ sharing, so when an IRQHandler
will try to register to already-assigned IRQ number, a SharedIRQHandler
will be created to register both IRQHandlers.
2020-02-24 11:27:03 +01:00
Liav A
9e66eb160c Kernel: Add the new APIC namespace
Also, the enable() function is now correct and will use the right
registers and values. In addition to that, write_register() and
read_registers() are not relying on identity mapping anymore.
2020-02-24 11:27:03 +01:00
Liav A
71371d39b3 CPU: Add 2 files with ISR stub macros 2020-02-24 11:27:03 +01:00
Liav A
c51a57fb32 Kernel: Update SB16 driver to use the new IRQHandler class
Also, add methods to allow changing of IRQ line in the SB16 card.
2020-02-24 11:27:03 +01:00
Liav A
895e874eb4 Kernel: Include the new PIT class in system components 2020-02-24 11:27:03 +01:00
Liav A
b3c132ffb7 Kernel: Update PATAChannel implementation to use the PIT class
Also, update the class implementation to use PCI::Device class
accordingly.
The create() helper will now search for an IDE controller in the
PCI bus, allowing to simplify the initialize() method.
2020-02-24 11:27:03 +01:00
Liav A
83aa868c17 Kernel: Update PATAChannel class to use the PCI::Device class
PATAChannel class will inherit from the PCI::Device class, thus,
can still implement IRQ handling.
2020-02-24 11:27:03 +01:00
Liav A
12dbb7ca49 Kernel: Add MSIHandler class
This is a stub for now, since we don't support Message Signaled
Interrupts yet.
2020-02-24 11:27:03 +01:00
Liav A
9d281b4b15 Kernel: Add UnhandledInterruptHandler class
This class will be used to represent an IRQ vector handler that wasn't
assigned to any IRQ Handler.
2020-02-24 11:27:03 +01:00
Liav A
9587f2d3ee Kernel: Add SharedIRQHandler class
This class represents a shared interrupt handler. This class will not be
created automatically but only if two IRQ Handlers are sharing the same
IRQ number.
2020-02-24 11:27:03 +01:00
Liav A
740534cd67 Kernel: Update system components to use the new IRQHandler class 2020-02-24 11:27:03 +01:00
Liav A
a46120b4a8 ACPI: Run clang-format on the definitions file 2020-02-24 11:27:03 +01:00
Liav A
16055de978 Kernel: Introduce the PIT class
The PIT class inherits from HardwareTimer class, and is replacing
the PIT namespace.
2020-02-24 11:27:03 +01:00
Liav A
d83a3eff1f Kernel: Update Network adapter classes to use the PCI::Device class
Those classes will inherit from the PCI::Device class, thus,
they can still implement IRQ handling.
2020-02-24 11:27:03 +01:00
Liav A
73a7e5875e Kernel: Update PCI::Device class to use the new IRQHandler class 2020-02-24 11:27:03 +01:00
Liav A
ea1251d465 Kernel: Add HardwareTimer class
This is an abstraction layer for future hardware timers
that will be implemented.
2020-02-24 11:27:03 +01:00
Liav A
dd7522bdb2 Kernel: Add new IRQHandler class
This class will replace the old IRQHandler class later.
2020-02-24 11:27:03 +01:00
Liav A
b201b23363 Kernel: Add Interrupt Management and Generic Interrupt Handler
The GenericInterruptHandler class will be used to represent
an abstract interrupt handler. The InterruptManagement class will
represent a centralized component to manage interrupts.
2020-02-24 11:27:03 +01:00
Liav A
ebe30ed11e ACPI: Adding definitions for HPET
Also, definitions were added for MADT entries, like IOAPIC and GSI
overriding information.
2020-02-24 11:27:03 +01:00
Liav A
e760ebcacb Kernel: Add the IOAPIC class
This class inherits from IRQController class, and represents
the 82093AA IOAPIC chip.
2020-02-24 11:27:03 +01:00
Liav A
7d59a67504 Kernel: Add the PIC class
This class inherits from IRQController class, and represents
the common Intel 8259 PIC chip.
2020-02-24 11:27:03 +01:00
Liav A
b56afbea17 Kernel: Add IRQController class
This class is an abstraction layer for different IRQ controllers
that are present in a typical system.
2020-02-24 11:27:03 +01:00
Liav A
35f27231b3 Kernel: Fix a wrong debug message in ACPIStaticParser 2020-02-24 11:27:03 +01:00
Liav A
3539666ac9 Kernel: Add PCI helpers to enable and disable the interrupt line 2020-02-24 11:27:03 +01:00
Liav A
ca05d54b2b Kernel: Add MultiProcessor Parser 2020-02-24 11:27:03 +01:00
Andreas Kling
0763f67043 AK: Make Bitmap use size_t for its size
Also rework its API's to return Optional<size_t> instead of int with -1
as the error value.
2020-02-24 09:56:07 +01:00
thatlittlegit
ab9e5755ba Userland+Kernel: Set shutdown/reboot to only be run by the phys group 2020-02-23 22:03:03 +01:00
thatlittlegit
30556a0a93 SystemMenu: Move SystemDialog into SystemMenu and remove INI config
I probably would've done INI config removal in another commit, but it
fit well here because I didn't want to pledge wpath for SystemMenu if I
didn't need to.

Frankly, that's something that I think should be done: allow ConfigFile
to be used read-only.
2020-02-23 22:03:03 +01:00
Andreas Kling
bbc02af090 Demos: Remove silly HelloWorld2 demo
This was just a tiny test app made with the old VisualBuilder. It's not
really useful for anything.
2020-02-23 12:27:53 +01:00
Andreas Kling
7ec758773c Kernel: Dump all kernel regions when we hit a page fault during IRQ
This way you can try to figure out what the faulting address is.
2020-02-23 11:10:52 +01:00
Andreas Kling
a70cc5ca1d Kernel: Commit the entire region up front in KBuffer::copy()
Since we know exactly how much physical memory we'll need, we might as
well commit it up front instead of letting page faults drive it.
2020-02-23 11:10:52 +01:00
Andreas Kling
a731ccd4a0 Kernel: Build without debugging symbols by default
Compiling with -g adds roughly 30% to kernel build times. Anyone who
wants this can turn it on locally instead.
2020-02-22 21:27:08 +01:00
Andreas Kling
97e9deccf0 Ext2FS: Add Missing HashMap.h include 2020-02-22 16:37:51 +01:00
Andreas Kling
e334c36757 Kernel: Remove unnecessary allocation metadata from kmalloc() chunks
Each allocation header was tracking its index into the chunk bitmap,
but that index can be computed from the allocation address anyway.

Removing this means that each allocation gets 4 more bytes of memory
and this avoids allocating an extra chunk in many cases. :^)
2020-02-22 15:11:31 +01:00
Andreas Kling
3e973bfe14 Kernel: Make FileDescription slab-allocated 2020-02-22 14:37:58 +01:00
Andreas Kling
9fc54ba931 Kernel: Tweak SlabAllocator's slab sizes
Nobody was using the 8-byte slab size, so get rid of it and move all of
its capacity to the new 64-byte slab size (which replaces 48-byte.)
2020-02-22 14:36:45 +01:00
Andreas Kling
6428669a37 Kernel: Make Custody slab-allocated 2020-02-22 14:33:51 +01:00
Andreas Kling
ba83bf8a0d Kernel: Increase kmalloc chunk size from 8 bytes to 32 bytes
This gives a huge speedup when running "git status" in a SerenityOS
repository directory. Most of the time was spent allocating strings.
2020-02-22 14:18:34 +01:00
Andreas Kling
fc5ebe2a50 Kernel: Disown shared buffers on sys$execve()
When committing to a new executable, disown any shared buffers that the
process was previously co-owning.

Otherwise accessing the same shared buffer ID from the new program
would cause the kernel to find a cached (and stale!) reference to the
previous program's VM region corresponding to that shared buffer,
leading to a Region* use-after-free.

Fixes #1270.
2020-02-22 12:29:38 +01:00
Andreas Kling
ece2971112 Kernel: Disable profiling during the critical section of sys$execve()
Since we're gonna throw away these stacks at the end of exec anyway,
we might as well disable profiling before starting to mess with the
process page tables. One less weird situation to worry about in the
sampling code.
2020-02-22 11:09:03 +01:00
Andreas Kling
d7a13dbaa7 Kernel: Reset profiling state on exec() (but keep it going)
We now log the new executable on exec() and throw away all the samples
we've accumulated so far. But profiling keeps going.
2020-02-22 10:54:50 +01:00
Andreas Kling
983b4bd9f2 Kernel+ProfileViewer: Move symbolication to userspace for time profiles
This makes the time profiles look like the memory profiles so we can
use the userspace symbolication code in ProfileViewer.
2020-02-22 10:09:54 +01:00
Andreas Kling
94652fd2fb Kernel: Fully validate pointers when walking stack during profiling
It's not enough to just check that things wouldn't page fault, we also
need to verify that addresses are accessible to the profiled thread.
2020-02-22 10:09:54 +01:00
Andreas Kling
f020081a38 Kernel: Put "Couldn't find user region" spam behind MM_DEBUG
This basically never tells us anything actionable anyway, and it's a
real annoyance when doing something validation-heavy like profiling.
2020-02-22 10:09:54 +01:00
Andreas Kling
b6887bd9cd Ext2FS: The max current block count of a file is size/block_size
Turns out that i_blocks does not take block list holes into account.
2020-02-21 19:07:23 +01:00
Andreas Kling
b298c01e92 Kernel: Log instead of crashing when getting a page fault during IRQ
This is definitely a bug, but it seems to happen randomly every now
and then and we need more info to track it down, so let's log for now.
2020-02-21 19:05:45 +01:00
Andreas Kling
59c052a72a Ext2FS: Allow holes in block lists
Linux creates holes in block lists for all-zero content. This is very
reasonable and we can now handle that situation as well.

Note that we're not smart enough to generate these holes ourselves yet,
but now we can at least read from such files.
2020-02-21 17:50:51 +01:00
Andreas Kling
04e40da188 Kernel: Fix crash when reading /proc/PID/vmobjects
InodeVMObjects can have nulled-out physical page slots. That just means
we haven't cached that page from disk right now.
2020-02-21 16:03:56 +01:00
Andreas Kling
59b9e49bcd Kernel: Don't trigger page faults during profiling stack walk
The kernel sampling profiler will walk thread stacks during the timer
tick handler. Since it's not safe to trigger page faults during IRQ's,
we now avoid this by checking the page tables manually before accessing
each stack location.
2020-02-21 15:49:39 +01:00
Andreas Kling
f9a138aa4b Kernel: Commit the profiling sample buffer memory up front
This avoids getting page faults while storing samples in the timer IRQ.
2020-02-21 15:49:37 +01:00
Andreas Kling
8047ff8205 Kernel: Expose the underlying Region of a KBuffer 2020-02-21 15:49:35 +01:00
Andreas Kling
d46071c08f Kernel: Assert on page fault during IRQ
We're not equipped to deal with page faults during an IRQ handler,
so add an assertion so we can immediately tell what's wrong.

This is why profiling sometimes hangs the system -- walking the stack
of the profiled thread causes a page fault and things fall apart.
2020-02-21 15:49:34 +01:00
Andreas Kling
2a679f228e Kernel: Fix bitrotted DEBUG_IO logging 2020-02-21 15:49:30 +01:00
Sergey Bugaev
1d2986ea15 Kernel: Fix a panic in VFS::rename()
If we get an -ENOENT when resolving the target because of some part, that is not
the very last part, missing, we should just return the error instead of panicking
later :^)

To test:
    $ mkdir /tmp/foo/
    $ mv /tmp/foo/ /tmp/bar/

Related to https://github.com/SerenityOS/serenity/issues/1253
2020-02-20 19:13:20 +01:00
Sergey Bugaev
3439498744 Kernel: Support trailing slashes in VFS::mkdir()
This is apparently a special case unlike any other, so let's handle it
directly in VFS::mkdir() instead of adding an alternative code path into
VFS::resolve_path().

Fixes https://github.com/SerenityOS/serenity/issues/1253
2020-02-20 19:13:20 +01:00
Andreas Kling
7592f9afd5 AK: Use size_t for CircularQueue and CircularDeque 2020-02-20 13:20:34 +01:00
Andreas Kling
88b9fcb976 AK: Use size_t for ByteBuffer sizes
This matches what we already do for string types.
2020-02-20 13:20:34 +01:00
Andreas Kling
0ba458cfa0 Kernel+LibC: Add SO_REUSEADDR macro
Note that this is not actually implemented, I'm just defining it.
2020-02-20 06:57:01 +01:00
Andreas Kling
a87544fe8b Kernel: Refuse to allocate 0 bytes of virtual address space 2020-02-19 22:19:55 +01:00
Andreas Kling
f17c377a0c Kernel: Use bitfields in Region
This makes Region 4 bytes smaller and we can use bitfield initializers
since they are allowed in C++20. :^)
2020-02-19 12:03:11 +01:00
Andreas Kling
a31ca1282e Base: Rename /dev/psaux to /dev/mouse
Since this device doesn't actually hand out raw PS/2 aux packets,
let's just call it "mouse" instead. :^)
2020-02-18 14:30:39 +01:00
Andreas Kling
bead20c40f Kernel: Remove SmapDisabler in sys$create_shared_buffer() 2020-02-18 14:12:39 +01:00
Andreas Kling
9aa234cc47 Kernel: Reset FPU state on exec() 2020-02-18 13:44:27 +01:00
Jesse Buhagiar
35ba4bf005 TTY: Reset VGA start row when setting graphical TTY
This was causing the screen (on a real machine) to be split in half.
2020-02-18 12:55:31 +01:00
Andreas Kling
a7dbb3cf96 Kernel: Use a FixedArray for a process's extra GIDs
There's not really enough of these to justify using a HashTable.
2020-02-18 11:35:47 +01:00
Andreas Kling
4b16ac0034 Kernel: Purging a page should point it back to the shared zero page
Anonymous VM objects should never have null entries in their physical
page list. Instead, "empty" or untouched pages should refer to the
shared zero page.

Fixes #1237.
2020-02-18 09:56:11 +01:00
Andreas Kling
737e455cbc SystemMenu: Add a separate program to host the system menu
This will allow us to run the system menu as any user. It will also
enable further lockdown of the WindowServer process since it should no
longer need to pledge proc and exec. :^)

Note that this program is not finished yet.

Work towards #1231.
2020-02-17 16:50:48 +01:00
Andreas Kling
48f7c28a5c Kernel: Replace "current" with Thread::current and Process::current
Suggested by Sergey. The currently running Thread and Process are now
Thread::current and Process::current respectively. :^)
2020-02-17 15:04:27 +01:00
Andreas Kling
4f4af24b9d Kernel: Tear down process address space during finalization
Process teardown is divided into two main stages: finalize and reap.

Finalization happens in the "Finalizer" kernel and runs with interrupts
enabled, allowing destructors to take locks, etc.

Reaping happens either in sys$waitid() or in the scheduler for orphans.

The more work we can do in finalization, the better, since it's fully
pre-emptible and reduces the amount of time the system runs without
interrupts enabled.
2020-02-17 14:33:06 +01:00
Andreas Kling
0e33f53cf8 Kernel: Allow multiple inspectors of a process (in /proc)
Replace Process::m_being_inspected with an inspector reference count.
This prevents an assertion from firing when inspecting the same process
in /proc from multiple processes at the same time.

It was trivially reproducible by opening multiple FileManagers.
2020-02-17 13:29:49 +01:00
Andreas Kling
9f54ea9bcd NotificationServer: Add a system service for desktop notifications
This patch adds NotificationServer, which runs as the "notify" user
and provides an IPC API for desktop notifications.

LibGUI gains the GUI::Notification class for showing notifications.

NotificationServer is spawned on demand and will unspawn after
dimissing all visible notifications. :^)

Finally, this also comes with a small /bin/notify utility.
2020-02-16 21:58:17 +01:00
Andreas Kling
9794e18a20 Base: Run WindowServer as a separate "window" user
This was actually rather painless and straightforward. WindowServer now
runs as the "window" user. Users in the "window" group can connect to
it via the socket in /tmp/portal/window as usual.
2020-02-16 21:58:17 +01:00
Andreas Kling
31e1af732f Kernel+LibC: Allow sys$mmap() callers to specify address alignment
This is exposed via the non-standard serenity_mmap() call in userspace.
2020-02-16 12:55:56 +01:00
Andreas Kling
7a8be7f777 Kernel: Remove SmapDisabler in sys$accept() 2020-02-16 08:20:54 +01:00
Andreas Kling
7717084ac7 Kernel: Remove SmapDisabler in sys$clock_gettime() 2020-02-16 08:13:11 +01:00
Andreas Kling
7533d61458 Kernel: Fix weird whitespace mistake in RangeAllocator 2020-02-16 08:01:33 +01:00
Andreas Kling
e90765e957 Kernel: Remove Process inheriting from Weakable
This mechanism wasn't actually used to create any WeakPtr<Process>.
Such pointers would be pretty hard to work with anyway, due to the
multi-step destruction ritual of Process.
2020-02-16 02:16:22 +01:00
Andreas Kling
635ae70b8f Kernel: More header dependency reduction work 2020-02-16 02:15:33 +01:00
Andreas Kling
16818322c5 Kernel: Reduce header dependencies of Process and Thread 2020-02-16 02:01:42 +01:00
Andreas Kling
e28809a996 Kernel: Add forward declaration header 2020-02-16 01:50:32 +01:00
Andreas Kling
1d611e4a11 Kernel: Reduce header dependencies of MemoryManager and Region 2020-02-16 01:33:41 +01:00
Andreas Kling
a356e48150 Kernel: Move all code into the Kernel namespace 2020-02-16 01:27:42 +01:00
Andreas Kling
1f55079488 Kernel: Remove SmapDisabler in sys$getgroups() 2020-02-16 00:30:00 +01:00
Andreas Kling
eb7b0c76a8 Kernel: Remove SmapDisabler in sys$setgroups() 2020-02-16 00:27:10 +01:00
Andreas Kling
0341ddc5eb Kernel: Rename RegisterDump => RegisterState 2020-02-16 00:15:37 +01:00
Andreas Kling
5507945306 Kernel: Widen PhysicalPage refcount to 32 bits
A 16-bit refcount is just begging for trouble right nowl.
A 32-bit refcount will be begging for trouble later down the line,
so we'll have to revisit this eventually. :^)
2020-02-15 22:34:48 +01:00
Andreas Kling
c624d3875e Kernel: Use a shared physical page for zero-filled pages until written
This patch adds a globally shared zero-filled PhysicalPage that will
be mapped into every slot of every zero-filled AnonymousVMObject until
that page is written to, achieving CoW-like zero-filled pages.

Initial testing show that this doesn't actually achieve any sharing yet
but it seems like a good design regardless, since it may reduce the
number of page faults taken by programs.

If you look at the refcount of MM.shared_zero_page() it will have quite
a high refcount, but that's just because everything maps it everywhere.
If you want to see the "real" refcount, you can build with the
MAP_SHARED_ZERO_PAGE_LAZILY flag, and we'll defer mapping of the shared
zero page until the first NP read fault.

I've left this behavior behind a flag for future testing of this code.
2020-02-15 13:17:40 +01:00
Andreas Kling
1828d9eadd Kernel: Remove some commented-out code in Scheduler::yield() 2020-02-10 20:16:50 +01:00
Andreas Kling
7cf33a8ccb Kernel: Remove outdated FIXME from Scheduler 2020-02-10 20:15:53 +01:00
Andreas Kling
27f0102bbe Kernel: Add getter and setter for the X86 CR3 register
This gets rid of a bunch of inline assembly.
2020-02-10 20:00:32 +01:00
Andreas Kling
580a94bc44 Kernel+LibC: Merge sys$stat() and sys$lstat()
There is now only one sys$stat() instead of two separate syscalls.
2020-02-10 19:49:49 +01:00
Andreas Kling
ccfee3e573 Kernel: Remove more <LibBareMetal/Output/kstdio.h> includes 2020-02-10 12:07:48 +01:00
Andreas Kling
6cbd72f54f AK: Remove bitrotted Traits::dump() mechanism
This was only used by HashTable::dump() which I used when doing the
first HashTable implementation. Removing this allows us to also remove
most includes of <AK/kstdio.h>.
2020-02-10 11:55:34 +01:00
Shannon Booth
fe668db999 Meta: Fix shellcheck warnings in various scripts
Warnings fixed:
 * SC2086: Double quote to prevent globbing and word splitting.
 * SC2006: Use $(...) notation instead of legacy backticked `...`
 * SC2039: In POSIX sh, echo flags are undefined
 * SC2209: Use var=$(command) to assign output (or quote to assign string)
 * SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails
 * SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
 * SC2034: i appears unused. Verify use (or export if used externally)
 * SC2046: Quote this to prevent word splitting.
 * SC2236: Use -z instead of ! -n.

There are still a lot of warnings in Kernel/run about:
 - SC2086: Double quote to prevent globbing and word splitting.

However, splitting on space is intentional in this case, and not trivial to
change. Therefore ignore the warning for now - but we should fix this in
the future.
2020-02-10 10:46:25 +01:00