Commit Graph

2619 Commits

Author SHA1 Message Date
Liav A
f33fb151b4 CPU: Allow to use IRQs in range of 50 to 178 2020-03-06 10:32:32 +01:00
Liav A
30fc78bfaf Kernel: Acquire ISA interrupt overrides from Interrupt Management
Also, InterruptDisabler were added to prevent critical function from
being interrupted. In addition, the interrupt numbers are abstracted
from IDT offsets, thus, allowing to create a better routing scheme
when using IOAPICs for interrupt redirection.
2020-03-06 10:32:32 +01:00
Liav A
d9d792d37f Kernel: Print MultiProcessor features 2020-03-06 10:32:32 +01:00
Andreas Kling
94f287b1c0 Kernel: Unmap non-readable pages
This was caught by running all crash tests with "crash -A".
Basically, non-readable pages need to not be mapped *at all* so that
a "page not present" exception is provoked on access.

Unfortunately x86 does not support write-only mappings, so this is
the best we can do.

Fixes #1336.
2020-03-06 09:58:59 +01:00
Liav A
85eb1d26d5 Kernel: Run clang-format on Process.cpp & ACPIDynamicParser.h 2020-03-05 19:04:04 +01:00
Liav A
1b8cd6db7b Kernel: Call ACPI reboot method first if possible
Now we call ACPI reboot method first if possible, and if ACPI reboot is
not available, we attempt to reboot via the keyboard controller.
2020-03-05 19:04:04 +01:00
Ben Wiederhake
4dd4dd2f3c Kernel: Fix race in clock_nanosleep
This is a complete fix of clock_nanosleep, because the thread holds the
process lock again when returning from sleep()/sleep_until().
Therefore, no further concurrent invalidation can occur.
2020-03-03 20:13:32 +01:00
Andreas Kling
686ade6b5a AK: Make quick_sort() a little more ergonomic
Now it actually defaults to "a < b" comparison, instead of forcing you
to provide a trivial less-than comparator. Also you can pass in any
collection type that has .begin() and .end() and we'll sort it for you.
2020-03-03 16:02:58 +01:00
Liav A
251b7f3776 CPU: Change debug messages to fit the latest changes 2020-03-02 22:23:39 +01:00
Liav A
f0ca29eb4b Kernel: Run clang-format on various files 2020-03-02 22:23:39 +01:00
Liav A
0fc60e41dd Kernel: Use klog() instead of kprintf()
Also, duplicate data in dbg() and klog() calls were removed.
In addition, leakage of virtual address to kernel log is prevented.
This is done by replacing kprintf() calls to dbg() calls with the
leaked data instead.
Also, other kprintf() calls were replaced with klog().
2020-03-02 22:23:39 +01:00
Liav A
19aa53e1f9 Kernel: Use IOAddress class in PATAChannel class
This change make the code a bit more readable. Also, kprintf() calls
are replaced with klog() calls.
2020-03-02 22:23:39 +01:00
Liav A
15dfca4a79 Kernel: Use IOAddress class in Network adapters' drivers
Also, kprintf() calls were replaced with klog() calls.
2020-03-02 22:23:39 +01:00
Andreas Kling
918ebabf60 Kernel: MemoryManager should create cacheable regions by default 2020-03-02 13:04:17 +01:00
Andreas Kling
47beab926d Kernel: Remove ability to create kernel-only regions at user addresses
This was only used by the mechanism for mapping executables into each
process's own address space. Now that we remap executables on demand
when needed for symbolication, this can go away.
2020-03-02 11:20:34 +01:00
Andreas Kling
e56f8706ce Kernel: Map executables at a kernel address during ELF load
This is both simpler and more robust than mapping them in the process
address space.
2020-03-02 11:20:34 +01:00
Andreas Kling
678c87087d Kernel: Load executables on demand when symbolicating
Previously we would map the entire executable of a program in its own
address space (but make it unavailable to userspace code.)

This patch removes that and changes the symbolication code to remap
the executable on demand (and into the kernel's own address space
instead of the process address space.)

This opens up a couple of further simplifications that will follow.
2020-03-02 11:20:34 +01:00
howar6hill
055344f346 AK: Move the wildcard-matching implementation to StringUtils
Provide wrappers in the String and StringView classes, and add some tests.
2020-03-02 10:38:08 +01:00
Andreas Kling
0acac186fb Kernel: Make the "entire executable" region shared
This makes Region::clone() do the right thing with it on fork().
2020-03-02 06:13:29 +01:00
Andreas Kling
5c2a296a49 Kernel: Mark read-only PT_LOAD mappings as shared regions
This makes Region::clone() do the right thing for these now that we
differentiate based on Region::is_shared().
2020-03-01 21:26:36 +01:00
Andreas Kling
ecfde5997b Kernel: Use SharedInodeVMObject for executables after all
I had the wrong idea about this. Thanks to Sergey for pointing it out!

Here's what he says (reproduced for posterity):

> Private mappings protect the underlying file from the changes made by
> you, not the other way around. To quote POSIX, "If MAP_PRIVATE is
> specified, modifications to the mapped data by the calling process
> shall be visible only to the calling process and shall not change the
> underlying object. It is unspecified whether modifications to the
> underlying object done after the MAP_PRIVATE mapping is established
> are visible through the MAP_PRIVATE mapping." In practice that means
> that the pages that were already paged in don't get updated when the
> underlying file changes, and the pages that weren't paged in yet will
> load the latest data at that moment.
> The only thing MAP_FILE | MAP_PRIVATE is really useful for is mapping
> a library and performing relocations; it's definitely useless (and
> actively harmful for the system memory usage) if you only read from
> the file.

This effectively reverts e2697c2ddd.
2020-03-01 21:16:27 +01:00
Andreas Kling
bb7dd63f74 Kernel: Run clang-format on Process.cpp 2020-03-01 21:16:27 +01:00
Andreas Kling
7e6c2068bf Kernel: Fix suspicious local shadowing in PerformanceEventBuffer 2020-03-01 21:08:04 +01:00
Andreas Kling
687b52ceb5 Kernel: Name perfcore files "perfcore.PID"
This way we can trace many things and we get one perfcore file per
process instead of everyone trying to write to "perfcore"
2020-03-01 20:59:02 +01:00
Andreas Kling
ecdd9a5bc6 Kernel: Reduce code duplication a little bit in Region allocation
This patch reduces the number of code paths that lead to the allocation
of a Region object. It's quite hard to follow the various ways in which
this can happen, so this is an effort to simplify.
2020-03-01 15:56:23 +01:00
Andreas Kling
5e0c4d689f Kernel: Move ProcessPagingScope to its own files 2020-03-01 15:38:09 +01:00
Andreas Kling
2839bb0be1 Kernel: Restore the previous thread state on SIGCONT after SIGSTOP
When stopping a thread with the SIGSTOP signal, we now store the thread
state in Thread::m_stop_state. That state is then restored on SIGCONT.
This fixes an issue where previously-blocked threads would unblock
upon resume. Now they simply resume in the Blocked state, and it's up
to the regular unblocking mechanism to unblock them.

Fixes #1326.
2020-03-01 15:14:17 +01:00
Andreas Kling
c3c8eae25a Kernel: Remove some unnecessary .characters() when doing dbg()<<String 2020-03-01 13:23:26 +01:00
Andreas Kling
22d0a6d92f AK: Remove unnecessary casts to size_t, after Vector changes
Now that Vector uses size_t, we can remove a whole bunch of redundant
casts to size_t.
2020-03-01 12:58:22 +01:00
Andreas Kling
fee20bd8de Kernel: Remove some more harmless InodeVMObject miscasts 2020-03-01 12:27:03 +01:00
Andreas Kling
b614462079 Kernel: Include the dirty bits when cloning an InodeVMObject
Now that (private) InodeVMObjects can be CoW-cloned on fork(), we need
to make sure we clone the dirty bits as well.
2020-03-01 12:11:50 +01:00
Andreas Kling
95e3aec719 Kernel: Fix harmless type miscast in Process::amount_clean_inode() 2020-03-01 11:23:23 +01:00
Andreas Kling
e2697c2ddd Kernel: Use PrivateInodeVMObject for loading program executables
This will be a memory usage pessimization until we actually implement
CoW sharing of the memory pages with SharedInodeVMObject.

However, it's a huge architectural improvement, so let's take it and
improve on this incrementally.

fork() should still be neutral, since all private mappings are CoW'ed.
2020-03-01 11:23:10 +01:00
Andreas Kling
48bbfe51fb Kernel: Add some InodeVMObject type assertions in Region::clone()
Let's make sure that we're never cloning shared inode-backed objects
as if they were private, and vice versa.
2020-03-01 11:23:10 +01:00
Andreas Kling
88b334135b Kernel: Remove some Region construction helpers
It's now up to the caller to provide a VMObject when constructing a new
Region object. This will make it easier to handle things going wrong,
like allocation failures, etc.
2020-03-01 11:23:10 +01:00
Andreas Kling
fddc3c957b Kernel: CoW-clone private inode-backed memory regions on fork()
When forking a process, we now turn all of the private inode-backed
mmap() regions into copy-on-write regions in both the parent and child.

This patch also removes an assertion that becomes irrelevant.
2020-03-01 11:23:10 +01:00
Andreas Kling
8b6d548b55 Kernel: Disable interrupts throughout Thread::raw_backtrace()
Otherwise we may hit an assertion when validating stack addresses.
2020-02-29 22:06:56 +01:00
Andreas Kling
4badef8137 Kernel: Return bytes written if sys$write() fails after writing some
If we wrote anything we should just inform userspace that we did,
and not worry about the error code. Userspace can call us again if
it wants, and we'll give them the error then.
2020-02-29 18:42:35 +01:00
Andreas Kling
7cd1bdfd81 Kernel: Simplify some dbg() logging
We don't have to log the process name/PID/TID, dbg() automatically adds
that as a prefix to every line.

Also we don't have to do .characters() on Strings passed to dbg() :^)
2020-02-29 13:39:06 +01:00
Liav A
c616eb6aaf Init Stage: Use latest changes
Now we setup interrupts before ACPI, and we don't use the ACPI
parser to find the MADT table anymore.
2020-02-29 00:12:46 +01:00
Liav A
6f914ed0a4 Kernel: Simplify interrupt management
The IRQController object is RefCounted, and is shared between the
InterruptManagement class & IRQ handlers' classes.

IRQHandler, SharedIRQHandler & SpuriousInterruptHandler classes
use a responsible IRQ controller directly instead of calling
InterruptManagement for disable(), enable() or eoi().

Also, the initialization process of InterruptManagement is
simplified, so it doesn't rely on an ACPI parser to be initialized.
2020-02-29 00:12:46 +01:00
Liav A
f96cf250f9 PCI: Adopt changes in ACPI definitions file 2020-02-29 00:12:46 +01:00
Liav A
b9c65ea746 ACPI: Adopt the changes in the definitions file
Also, the functions for StaticParsing namespace were added.
Therefore, some early access functionality is being used also
in ACPI::StaticParser class.
2020-02-29 00:12:46 +01:00
Liav A
bf55d83c1f ACPI: Reorganize the definitions file
More namespaces have been added to organize the declarations
in a more sensible way.
Also, a namespace StaticParsing has been added to allow early
access to ACPI tables.
2020-02-29 00:12:46 +01:00
Liav A
976562307a Kernel: Initialize Spurious IRQ handlers in switch_to_pic_mode() 2020-02-29 00:12:46 +01:00
Liav A
86395810a9 CPU: Simplify handle_interrupt() function 2020-02-29 00:12:46 +01:00
Liav A
800a46ace9 Kernel: Delete unnecessary register & unregister calls 2020-02-29 00:12:46 +01:00
Liav A
b2e5425426 Kernel: Add SpuriousInterruptHandler class
This type of interrupt handler should handle spurious IRQs.
2020-02-29 00:12:46 +01:00
Liav A
e22ab33a4d Kernel: Add SpuriousInterruptHandler type into HandlerPurpose 2020-02-29 00:12:46 +01:00
Andreas Kling
5f7056d62c Kernel: Expose the VMObject type of each Region in /proc/PID/vm 2020-02-28 23:25:40 +01:00
Andreas Kling
8fbdda5a2d Kernel: Implement basic support for sys$mmap() with MAP_PRIVATE
You can now mmap a file as private and writable, and the changes you
make will only be visible to you.

This works because internally a MAP_PRIVATE region is backed by a
unique PrivateInodeVMObject instead of using the globally shared
SharedInodeVMObject like we always did before. :^)

Fixes #1045.
2020-02-28 23:25:00 +01:00
Andreas Kling
aa1e209845 Kernel: Remove some unnecessary indirection in InodeFile::mmap()
InodeFile now directly calls Process::allocate_region_with_vmobject()
instead of taking an awkward detour via a special Region constructor.
2020-02-28 20:29:14 +01:00
Andreas Kling
651417a085 Kernel: Split InodeVMObject into two subclasses
We now have PrivateInodeVMObject and SharedInodeVMObject, corresponding
to MAP_PRIVATE and MAP_SHARED respectively.

Note that PrivateInodeVMObject is not used yet.
2020-02-28 20:20:35 +01:00
Andreas Kling
07a26aece3 Kernel: Rename InodeVMObject => SharedInodeVMObject 2020-02-28 20:07:51 +01:00
Andreas Kling
5af95139fa Kernel: Make Process::m_master_tls_region a WeakPtr
Let's not keep raw Region* variables around like that when it's so easy
to avoid it.
2020-02-28 14:05:30 +01:00
Andreas Kling
b0623a0c58 Kernel: Remove SmapDisabler in sys$connect() 2020-02-28 13:20:26 +01:00
Andreas Kling
dcd619bd46 Kernel: Merge the shbuf_get_size() syscall into shbuf_get()
Add an extra out-parameter to shbuf_get() that receives the size of the
shared buffer. That way we don't need to make a separate syscall to
get the size, which we always did immediately after.
2020-02-28 12:55:58 +01:00
Andreas Kling
f72e5bbb17 Kernel+LibC: Rename shared buffer syscalls to use a prefix
This feels a lot more consistent and Unixy:

    create_shared_buffer()   => shbuf_create()
    share_buffer_with()      => shbuf_allow_pid()
    share_buffer_globally()  => shbuf_allow_all()
    get_shared_buffer()      => shbuf_get()
    release_shared_buffer()  => shbuf_release()
    seal_shared_buffer()     => shbuf_seal()
    get_shared_buffer_size() => shbuf_get_size()

Also, "shared_buffer_id" is shortened to "shbuf_id" all around.
2020-02-28 12:55:58 +01:00
Liav A
8dbd1cb9fb Kernel: Validate changed framebuffer resolution
Now we check before we set a FBResolution if the BXVGA device is capable
of setting the requested resolution.
If not, we revert the resolution to the previous one and return an error
to userspace.

Fixes #451.
2020-02-28 12:16:05 +01:00
Liav A
fc611be592 Kernel: Run clang-format on PCI definitions file 2020-02-27 13:05:12 +01:00
Liav A
d376e17b5c SharedBuffer: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
1f13f51ebd SlavePTY: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
63a27992e8 MasterPTY: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
900865e87c Kernel: Run clang-format on Heap/kmalloc.cpp 2020-02-27 13:05:12 +01:00
Liav A
46a7ee97ac Heap kmalloc: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
ac9a001b92 PTYMultiplexer: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
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