Commit graph

7034 commits

Author SHA1 Message Date
Tim Schumacher 94ab75d3df Kernel: Add O_SYNC into fcntl.h 2022-05-05 20:47:38 +02:00
Timon Kruiper 2cf36a1ca2 Kernel: Panic when an assertion is failed in aarch64 Kernel
This in turn makes sure that we get a nice backtrace when an assertion
failed, or when a VERIFY_NOT_REACHED() is hit.
2022-05-03 21:53:36 +02:00
Timon Kruiper 771d0719ea Kernel: Remove unused aarch64 Prekernel::panic() function 2022-05-03 21:53:36 +02:00
Timon Kruiper f8e4eecbfb Kernel: Replace calls to Prekernel::panic() with PANIC macro on aarch64 2022-05-03 21:53:36 +02:00
Timon Kruiper e81e1fa9c8 Kernel: Implement __panic() for the aarch64 Kernel
Now that dump_backtrace() works, we can actually print a helpful
backtrace when the Kernel panics.
2022-05-03 21:53:36 +02:00
Timon Kruiper e7cf591ec0 Kernel: Load the kernel symbol table for the aarch64 Kernel
Since kmalloc() now works, we can actually load the kernel symbol table!
This in turn allows us to call dump_backtrace(), and actually get a
useful backtrace in the aarch64 Kernel.
2022-05-03 21:53:36 +02:00
Timon Kruiper b464321618 Kernel: Add kmalloc_init() to the init function of the aarch64 Kernel
With the previous commits, we are now able to call kmalloc() :^)
2022-05-03 21:53:36 +02:00
Timon Kruiper 3b4d2d9b51 Kernel: Remove VERIFY_NOT_REACHED in {current, idle}_thread for aarch64
These functions are called by kmalloc, and since there is no support for
threading in the aarch64 build yet, we can simply remove the
VERIFY_NOT_REACHED().
2022-05-03 21:53:36 +02:00
Timon Kruiper 8e0bd63b0c Kernel: Add bare-minimum implementation for aarch64 Spinlock 2022-05-03 21:53:36 +02:00
Timon Kruiper 9abcb6700c Kernel: Move Arch/x86/Spinlock.h and add stubs for aarch64
The code in Spinlock.h has no architectural specific logic, thus can be
moved to the Arch directory. This contains no functional change.

Also add the Spinlock.cpp file for aarch64 which contains stubs for the
lock and unlock functions.
2022-05-03 21:53:36 +02:00
Timon Kruiper 0d6d4508df Kernel: Add the .ksyms section to the aarch64 Kernel binary
Previously the embedmap.sh script generated a warning, since there was
no section defined where the actual kernel.map could be stored. This is
necesarry for generating kernel backtraces.
2022-05-03 21:53:36 +02:00
Timon Kruiper 9f76b16124 Kernel: Implement safe_memcpy for the aarch64 build
The implementation just calls the regular memcpy, and is not safe yet.
This can be done later.
2022-05-03 21:53:36 +02:00
Timon Kruiper feba7bc8a8 Kernel: Move Kernel/Arch/x86/SafeMem.h to Kernel/Arch/SafeMem.h
The file does not contain any specific architectural code, thus it can
be moved to the Kernel/Arch directory.
2022-05-03 21:53:36 +02:00
Timon Kruiper 267febae55 Kernel: Add KSyms.cpp to the aarch64 build
This is the first step in making dump_backtrace() work.
2022-05-03 21:53:36 +02:00
Timon Kruiper 442800db3e Kernel: Fetch the frame pointer using __builtin_frame_address()
This compiler builtin abstracts away the specifics of fetching the frame
pointer. This will allow the KSyms.cpp to be build for the aarch64
target. While we're here, lets also change the
PerformanceEventBuffer.cpp to not rely on x86_64 specifics.
2022-05-03 21:53:36 +02:00
Timon Kruiper 15f32379bb Kernel: Remove UART::{print_num, print_hex} since they are unused 2022-05-03 00:59:35 +02:00
Timon Kruiper 47a58c51c6 Kernel: Modify UART::print_str() to also take into account the length
Previously in the aarch64 Kernel, this would cause dbgln() to actually
print more characters of the next string in memory, because strings in
the Kernel are not zero terminated by default. Prevent this by using the
passed in length of the string.
2022-05-03 00:59:35 +02:00
Timon Kruiper 4a2dcea685 Kernel: Remove aarch64/Utils.{cpp, h} since they are not used anymore 2022-05-03 00:59:35 +02:00
Timon Kruiper 83265b4cb2 Kernel: Replace calls to UART::print_str() with dbgln()
Since we can now use dbgln() in the aarch64 Kernel, lets use it! :^)
2022-05-03 00:59:35 +02:00
Timon Kruiper b046c82f75 Kernel: Let Processor::is_initialized() of aarch64 return false
When calling dbgln(), the formatting code in AK/Format.h calls
Processor::is_initialized() to determine whether to add some text about
the current processor to the debug output. Instead of crashing, we just
return false, such that we can use dbgln() etc in the aarch64 Kernel.
2022-05-03 00:59:35 +02:00
Timon Kruiper b9944ca905 Kernel: Add aarch64 version of kprintf.cpp
This allows us to use the AK formatting functions in the aarch64 Kernel.
Also add FIXME to make sure that this file will be removed when the
proper abstractions are in place in the normal Kernel/kprintf.cpp.
2022-05-03 00:59:35 +02:00
Timon Kruiper b3346aa08d Kernel: Fix aarch64 build by adding -Wno-nonnull flag
The compiler figured out that the MemoryManager is not initialised, and
thus MemoryManager::the() cannot return a valid reference. Once the
necesarry code is in place, this compiler flag can be removed.
2022-05-03 00:59:35 +02:00
Patrick Meyer 0bd131ad06 Kernel: Stop requiring working malloc for syscall.h includes
Fixes #13869
2022-05-02 12:44:34 +02:00
Andrew Kaster f08e91f67e Kernel: Don't check pledges or veil against code coverage data files
Coverage tools like LLVM's source-based coverage or GNU's --coverage
need to be able to write out coverage files from any binary, regardless
of its security posture. Not ignoring these pledges and veils means we
can't get our coverage data out without playing some serious tricks.

However this is pretty terrible for normal exeuction, so only skip these
checks when we explicitly configured userspace for coverage.
2022-05-02 01:46:18 +02:00
Maciej 66ab4d61a4 Kernel: Stop exposing gateway field
It doesn't make sense after introduction of routing table which allows
having multiple gateways for every interface, and isn't used by any of
the userspace programs now.
2022-05-01 13:34:27 +02:00
brapru 0866a0cd1e Kernel+route: Support global routing table deletion 2022-04-30 16:24:33 +02:00
brapru 863c14c4f4 Kernel: Make Route's operator== overload const 2022-04-30 16:24:33 +02:00
Peter Elliott 12c7b954e1 Kernel+WindowServer: Move setting tty graphical mode to Userspace
This will allow using the console tty and WindowServer regardless of
your kernel command line. Also this fixes a bug where, when booting in
text mode, the console was in graphical mode, and would not accept
input.
2022-04-29 19:52:32 +02:00
Peter Elliott 4b0be17c71 Kernel: Support userspace TTY graphics modesetting
This is a copy of linux's KDSETMODE/KDGETMODE console ioctl(2)
interface.
2022-04-29 19:52:32 +02:00
Liav A 5ed3f7c6bf Kernel/Storage: Migrate the partition code to use the ErrorOr container
That code used the old AK::Result container, which leads to overly
complicated initialization flow when trying to figure out the correct
partition table type. Instead, when using the ErrorOr container the code
is much simpler and more understandable.
2022-04-28 22:13:54 +02:00
brapru 19912a0b32 Kernel+Utilities: Add the route utility
This exposes the global routing table in the /proc directory and adds
the userspace utility to query dynamically add from the table.
2022-04-28 08:41:11 -07:00
brapru 419cd479e2 Kernel: Use TRY to handle string copies in GlobalProcessExposed
Each of these string copies are already inside of an ErrorOr context so
any failed copy should propagate.
2022-04-28 08:41:11 -07:00
brapru 8596b1e0c3 Kernel: Add a global routing table
Previously the system had no concept of assigning different routes for
different destination addresses as the default gateway IP address was
directly assigned to a network adapter. This default gateway was
statically assigned and any update  would remove the previously existing
route.

This patch is a beginning step towards implementing #180. It implements
a simple global routing table that is referenced during the routing
process. With this implementation it is now possible for a user or
service (i.e. DHCP) to dynamically add routes to the table.

The routing table will select the most specific route when possible. It
will select any direct match between the destination and routing entry
addresses. If the destination address overlaps between multiple entries,
the Kernel will use the longest prefix match, or the longest number of
matching bits between the destination address and the routing address.
In the event that there is no entries found for a specific destination
address, this implementation supports entries for a default route to be
set for any specified interface.

This is a small first step towards enhancing the system's routing
capabilities. Future enhancements would include referencing a
configuration file at boot to load pre-defined static routes.
2022-04-28 08:41:11 -07:00
brapru 0718b20df0 Kernel: Generalize the UpdateArp table to UpdateTable
We can use the same enum cases to apply to updates on different
networking tables within the Kernel (i.e. a routing table)
2022-04-28 08:41:11 -07:00
b14ckcat c65a6b6b22 Kernel: Use C++17 namespace style for nested PCI namespace
Adjust the nested namespace formatting in PCI files to use the nicer
and more consistent C++17 style.
2022-04-26 22:56:45 +02:00
b14ckcat d8d7b5d82c Kernel: Put USB request constants in namespace
Moved constants in USBRequest.h from global scope to the Kernel::USB
namespace.
2022-04-26 22:56:45 +02:00
Linus Groh cd3e337487 Kernel: Strip null terminators from all CPUID strings, not just brand
I've noticed that the KVM hypervisor vendor ID string contained null
terminators in the serialized JSON string in /proc/cpuinfo - let's avoid
that, and err on the side of caution and strip them from all strings
built from CPUID register values. They may not be fixed width after all.
2022-04-26 20:20:44 +02:00
Andreas Kling b85c8a0b80 Kernel: Add FIOCLEX and FIONCLEX ioctls
These allow you to turn the close-on-exec flag on/off via ioctl().
2022-04-26 14:32:12 +02:00
Andreas Kling 20d21fad7b Kernel: Add ESTALE errno code (stale network file handle) 2022-04-26 14:05:49 +02:00
sin-ack bc7c8879c5 Kernel+LibC+LibCore: Implement the unlinkat(2) syscall 2022-04-23 10:43:32 -07:00
b14ckcat 70a55ccf73 Kernel: Fix typo in Ramdisk
Remove the duplicate/extraneous access specifier.
2022-04-22 22:20:57 -07:00
Jesse Buhagiar 48c3c01de4 Kernel/USB: Send correct data for Root Hub Configuration Descriptor
A request of `GET_DESCRIPTOR` should be sending the entire configuration
chain, and not just the configuration descriptor.
2022-04-22 15:16:56 +02:00
Jesse Buhagiar 300dcb6f5e Kernel/USB: Get all interface descriptors on enumeration
This creates all interfaces when the device is enumerated, with a link
to the configuration that it is a part of. As such, a new class,
`USBInterface` has been introduced to express this state.
2022-04-22 15:16:56 +02:00
Jesse Buhagiar d313fa98ec Kernel/USB: Add new USBHIDDescriptor type 2022-04-22 15:16:56 +02:00
Jesse Buhagiar a1df8a1896 Kernel/USB: Add control_transfer() function USB::Device
Some other parts of the USB stack may require us to perform a control
transfer. Instead of abusing `friend` to expose the default pipe, let's
just expose it via a function.
2022-04-22 15:16:56 +02:00
Jesse Buhagiar dac26f89cb Kernel/USB: Fetch configuration descriptors on enumeration
This also introduces a new class, `USBConfiguration` that stores a
configuration. The device, when instructed, sets this configuration and
holds a pointer to it so we have a record of what configuration is
currently active.
2022-04-22 15:16:56 +02:00
Andreas Kling 5e4d5a436e Kernel: Allow sys$bind() on local sockets with short socket address
Previously, we required local socket addresses to be exactly
sizeof(sockaddr_un). There was no real reason for this, so let's not
enforce it.
2022-04-21 16:31:53 +02:00
Andreas Kling 8e9676c28c Kernel: Report AF_UNIX address family when accepting local sockets
Previously we just wrote the local socket bind path into the sockaddr_un
buffer. With this patch, we actually report the family as well.
2022-04-21 16:31:53 +02:00
kleines Filmröllchen b0a2572577 Kernel: Don't require AnonymousFiles to be mmap'd completely
AnonymousFile always allocates in multiples of a page size when created
with anon_create. This is especially an issue if we use AnonymousFile
shared memory to store a shared data structure that isn't exactly a
multiple of a page in size. Therefore, we can just allow mmaps of
AnonymousFile to map only an initial part of the shared memory.

This makes SharedSingleProducerCircularQueue work when it's introduced
later.
2022-04-21 13:55:00 +02:00
Tim Schumacher 71f2c342c4 Kernel: Limit free space between randomized memory allocations 2022-04-21 13:16:56 +02:00