Commit Graph

7128 Commits

Author SHA1 Message Date
Timon Kruiper
1072d523e2 Kernel: Initialize and use interrupts in the aarch64 Kernel
Now that everything is in place, we can actually use interrupts in the
aarch64 Kernel build. :^)
2022-06-02 13:14:12 +01:00
Timon Kruiper
dab6dbe893 Kernel: Add interrupt support to aarch64 RPi Timer driver
Since we can now build and use the IRQHandler class, we can implement
interrupt support for the Timer in the aarch64 build.
2022-06-02 13:14:12 +01:00
Timon Kruiper
8b77c61e7d Kernel: Use AK::NeverDestroyed<Timer> to store the timer class
For an upcoming change to support interrupts in this driver, this class
has to inherit from IRQHandler. That in turn will make this class
virtual, which will then actually call the destructor of the class. We
don't want this to happen, thus we have to wrap the class in a
AK::NeverDestroyed.
2022-06-02 13:14:12 +01:00
Timon Kruiper
a0b0c4e723 Kernel: Make RPi Timer::set_clock_rate static
This allows it to be called in UART without calling the Timer
constructor. This in turn allows the UART to be used before interrupts
are enabled.
2022-06-02 13:14:12 +01:00
Timon Kruiper
3cf8d3361e Kernel: Add support for handling interrupts on aarch64
There is currently some code duplication between the aarch64
implementation and the x86 one, but this initial implementation works
for now. :^)
2022-06-02 13:14:12 +01:00
Timon Kruiper
c959344c00 Kernel: Add simple implementation for InterruptManagement on aarch64
This class currently hardcodes the use of the Raspberry Pi interrupt
controller.
2022-06-02 13:14:12 +01:00
Timon Kruiper
5eac2b9f33 Kernel: Add driver for interrupt controller on the Raspberry Pi
This implements the simpler IRQController class and adds a
pending_interrupts() function to the class.
2022-06-02 13:14:12 +01:00
Timon Kruiper
f085903f62 Kernel: Move IRQController and InterruptManagement to Arch directory
These 2 classes currently contain much code that is x86(_64) specific.
Move them to the architecture specific directory. This also allows for a
simpler implementation for aarch64.
2022-06-02 13:14:12 +01:00
Timon Kruiper
63ee2781fb Kernel: Put Raspberry Pi devices into RPi namespace
This makes it clear in the code that these drivers are specific for the
Raspberry Pi devices.
2022-06-02 13:14:12 +01:00
Timon Kruiper
77f24056e0 Kernel: Disable interrupts when halting the aarch64 processor
This will actually halt the processor.
2022-06-02 13:14:12 +01:00
Timon Kruiper
846d9ae858 Kernel: Do not specify new alignment for aarch64
Using the alignment of 4 causes a panic in the aarch64 Kernel. Instead
just don't pass the flag, which will use the default alignment.
2022-06-02 13:14:12 +01:00
Timon Kruiper
cbe1717181 Kernel: Rename idt_init() to initialize_interrupts()
Also move the function out of the x86/Interrupts.h file into the generic
Interrupts.h file and add a stub for aarch64.
2022-06-02 13:14:12 +01:00
Timon Kruiper
02b94c6f0e Kernel: Add UnhandledInterruptHandler and SharedIRQHandler to aarch64 2022-06-02 13:14:12 +01:00
Timon Kruiper
d631a3daf6 Kernel: Add Interrupts/IRQHandler.cpp to the aarch64 build
This requires a few stubs such that the compiler won't complain.
2022-06-02 13:14:12 +01:00
Timon Kruiper
a4534678f9 Kernel: Implement InterruptDisabler using generic Processor functions
Now that the code does not use architectural specific code, it is moved
to the generic Arch directory and the paths are modified accordingly.
2022-06-02 13:14:12 +01:00
Timon Kruiper
ea9cf8b6ab Kernel: Separate NonMaskableInterruptDisabler into its own file
This is for the upcoming change to make InterruptDisabler class work for
the aarch64 build.
2022-06-02 13:14:12 +01:00
Timon Kruiper
9413fe9fe5 Kernel: Add interrupt related functions to Processor class
This adds {enable, disable}_interrupts() and are_interrupts_enabled()
to the Processor class, and also implements them for x86(_64) and
aarch64.
2022-06-02 13:14:12 +01:00
Timon Kruiper
80be5f8044 Kernel: Add DAIF system register to aarch64 registers
This register can be used to check whether the 4 different types of
interrupts are masked. A different variant can be used to set/clear
specific interrupt bits.
2022-06-02 13:14:12 +01:00
Timon Kruiper
2fd5e9f729 Kernel: Add GenericInterruptHandler.cpp to aarch64 build
This requires us to add an Interrupts.h file in the Kernel/Arch
directory, which includes the architecture specific files.

The commit also stubs out the functions to be able to compile the
aarch64 Kernel.
2022-06-02 13:14:12 +01:00
Jesse Buhagiar
a1ed9d3c60 Kernel/USB: Rename get_interfaces to something more sensible
This name was misleading, as it wasn't really "getting" anything. It has
hence been renamed to `enumerate_interfaces` to reflect what it's
actually doing.
2022-06-02 13:14:29 +02:00
Jesse Buhagiar
29f891bb54 Kernel/USB: Flesh out USB SysFS objects
Each USB object now contains the entire descriptor chain for the device
instead of just info from the device descriptor.
2022-06-02 13:14:29 +02:00
Jesse Buhagiar
ed657e3d2b Kernel/USB: Add interface descriptor accessor 2022-06-02 13:14:29 +02:00
Jesse Buhagiar
9002e837d3 Kernel/USB: Add configuration descriptor accessor 2022-06-02 13:14:29 +02:00
Jesse Buhagiar
cd8939f4a0 Kernel/USB: Make USBInterface endpoints accessible
These weren't accessible by an accessor, so let's fix that :^)
2022-06-02 13:14:29 +02:00
Jesse Buhagiar
361737650f Kernel/USB: Make USBConfiguration interfaces accessible
These weren't accessible by an accessor, so let's fix that :^)
2022-06-02 13:14:29 +02:00
brapru
1dd22582da Kernel: Ignore interfaces without an IP address when updating ARP
For the same reason we ignore interfaces without an IP address when
choosing where to send a route, we should also ignore interfaces without
IP addresses when updating the ARP table on incoming packets from
local addresses.

On an interface with a null address, the mask checking would always
result in zero, which resulted in the system updating the ARP table on
almost every incoming packet from any address (private or public).

This patch fixes this behavior by only applying this check to interfaces
with valid addresses and now the ARP table won't get constantly
hammered.

Closes #13713
2022-05-31 10:22:46 +01:00
SeekingBlues
df8df947f6 Kernel: Do not include AK/Platform.h in mcontext headers
Including signal.h would cause several ports to fail on build,
because it would end up including AK/Platform.h through these
mcontext headers. This is problematic because AK/Platform.h defines
several macros with very common names, such as `NAKED` (breaks radare2),
and `NO_SANITIZE_ADDRESS` and `ALWAYS_INLINE` (breaks ruby).
2022-05-30 21:39:41 +02:00
Lucas CHOLLET
a506ec08d8 Kernel: Expose cache size for Intel CPUs
The patch also prevents any try if the CPU's vendor isn't known and
improves the const-correctness of the AMD version.
2022-05-30 13:41:23 +01:00
Liav A
58acdce41f Kernel/FileSystem: Simplify even more the mount syscall
As with the previous commit, we put a distinction between filesystems
that require a file description and those which don't, but now in a much
more readable mechanism - all initialization properties as well as the
create static method are grouped to create the FileSystemInitializer
structure. Then when we need to initialize an instance, we iterate over
a table of these structures, checking for matching structure and then
validating the given arguments from userspace against the requirements
to ensure we can create a valid instance of the requested filesystem.
2022-05-29 19:31:02 +01:00
Liav A
4c588441e3 Kernel: Simplify mount syscall flow for regular calls
We do this by putting a distinction between two types of filesystems -
the first type is backed in RAM, and includes TmpFS, ProcFS, SysFS,
DevPtsFS and DevTmpFS. Because these filesystems are backed in RAM,
trying to mount them doesn't require source open file description.
The second type is filesystems that are backed by a file, therefore the
userspace program has to open them (hence it has a open file description
on them) and provide the appropriate source open file description.
By putting this distinction, we can early check if the user tried to
mount the second type of filesystems without a valid file description,
and fail with EBADF then.
Otherwise, we can proceed to either mount either type of filesystem,
provided that the fs_type is valid.
2022-05-29 19:31:02 +01:00
Linus Groh
20e2e39fcc Kernel: Expose size of L1 data/instruction, L2, and L3 CPU caches :^)
These are added as properties of the "caches" object to each processor,
if available.
2022-05-29 15:23:57 +02:00
brapru
7a4e41f8f8 Kernel: Add support for route flags
Previously the routing table did not store the route flags. This
adds basic support and exposes them in the /proc directory so that a
userspace caller can query the route and identify the type of each
route.
2022-05-26 16:33:10 +02:00
Peter Elliott
f6943c85b0 Kernel: Fix EINVAL when mmaping with address and no MAP_FIXED
The current behavior accidently trys to allocate 0 bytes when a non-null
address is provided and MAP_FIXED is specified. This is clearly a bug.
2022-05-23 00:13:26 +02:00
Peter Elliott
1c86678a64 Kernel: Change values of SHUT_{RD,WR,RDWR}
For some reason, guile requires these to be specific values.
2022-05-23 00:13:26 +02:00
b14ckcat
8a7876d65c Kernel/USB: Add support for bulk transfers 2022-05-21 22:12:05 +02:00
Timon Kruiper
5fc66c6072 Kernel: Fix capitalization of MiniStdLib.cpp in CMakeLists.txt
Commit fd3e3d5e28 added this, however
misspelled MiniStdLib.cpp. CMake wasn't complaining about this, but the
flags were also not applied to the file.
2022-05-21 20:23:32 +01:00
Timon Kruiper
9f3303c869 Kernel: Add -mgeneral-regs-only flag to aarch64 Kernel build
With the update to GCC 12.1.0, the compiler now vectorizes code with
-O2. This causes vector ops to be emitted, which are not supported in
the Kernel. Add the -mgeneral-regs-only flag to force the compiler to
not emit floating-point and SIMD ops.
2022-05-21 20:23:32 +01:00
Timon Kruiper
cc7723b6c4 Meta: Add option to disable Kernel Address Sanitizer
By default we enable the Kernel Undefined Behavior Sanitizer, which
checks for undefined behavior at runtime. However, sometimes a developer
might want to turn that off, so now there is a easy way to do that.
2022-05-21 20:23:32 +01:00
Timon Kruiper
1461a7601d Kernel: Report value of ESR_EL1 when exception happens on aarch64 2022-05-21 20:23:32 +01:00
Timon Kruiper
2c05afaa7b Kernel: Add Exception Syndrome Register to aarch64 Registers.h
This allows us to print more information about what kind of exception
happend.
2022-05-21 20:23:32 +01:00
Timon Kruiper
e43fdcc77e Kernel: Add more exception handlers for aarch64 Kernel
The aarch64 Kernel runs with SP_EL0, thus exceptions that happen can now
be handled.
2022-05-21 20:23:32 +01:00
Timon Kruiper
06432719fd Kernel: Set up initial exception stack when going into EL1 on aarch64
When an exception is triggered on aarch64, the processor always switches
to the exception stack which is defined by the SP_EL1 register.
2022-05-21 20:23:32 +01:00
Timon Kruiper
9f730fab8d Kernel: Add alignment specifier to aarch64 register definitions
When disabling UBSAN, the compiler would complain that the constraints
of the inline assembly could not be met. By adding the alignas specifier
the compiler can now determine that the struct can be passed into a
register, and thus the constraints are met.
2022-05-21 20:23:32 +01:00
Ariel Don
8a854ba309 Kernel+LibC: Implement futimens(3)
Implement futimes() in terms of utimensat(). Now, utimensat() strays
from POSIX compliance because it also accepts a combination of a file
descriptor of a regular file and an empty path. utimensat() then uses
this file descriptor instead of the path to update the last access
and/or modification time of a file. That being said, its prior behavior
remains intact.

With the new behavior of utimensat(), `path` must point to a valid
string; given a null pointer instead of an empty string, utimensat()
sets `errno` to `EFAULT` and returns a failure.
2022-05-21 18:15:00 +02:00
Ariel Don
9a6bd85924 Kernel+LibC+VFS: Implement utimensat(3)
Create POSIX utimensat() library call and corresponding system call to
update file access and modification times.
2022-05-21 18:15:00 +02:00
Jesse Buhagiar
964f8fbf3a Kernel: Implement AVX XSAVE support
This adds some new buffers to the `FPUState` struct, which contains
enough space for the `xsave` instruction to run. This instruction writes
the upper part of the x86 SIMD registers (YMM0-15) to a seperate
256-byte area, as well as an "xsave header" describing the region.

If the underlying processor supports AVX, the `fxsave` instruction is no
longer used, as `xsave` itself implictly saves all of the SSE and x87
registers.

Co-authored-by: Leon Albrecht <leon.a@serenityos.org>
2022-05-15 12:25:23 +02:00
Timon Kruiper
18cad73b01 Kernel: Put code in the aarch64 init.cpp file into the Kernel namespace 2022-05-12 23:14:05 +02:00
Timon Kruiper
9282e0db16 Kernel: Move __assertion_failed to aarch64/Panic.cpp
This is for an upcoming change to add the Kernel namespace to the
init.cpp file.
2022-05-12 23:14:05 +02:00
Timon Kruiper
d451bdec6f Kernel: Remove PREKERNEL_SOURCES from aarch64 CMakeLists.txt 2022-05-12 23:14:05 +02:00
Timon Kruiper
4db44c09a4 Kernel: Use the Kernel UBSanitizer implementation in the aarch64 Kernel
Now we actually print useful information when an UBSAN fault is
detected. :^)
2022-05-12 23:14:05 +02:00