Commit graph

7105 commits

Author SHA1 Message Date
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
Timon Kruiper 1f3977b303 Kernel: Remove Prekernel namespace in the aarch64 Kernel
Now that we merged all the Prekernel files into the Kernel files, we can
get rid of the Prekernel namespace as well.
2022-05-12 23:14:05 +02:00
Timon Kruiper c96a3f0c48 Kernel: Move the aarch64 boot.S out of the Prekernel directory 2022-05-12 23:14:05 +02:00
Timon Kruiper e88cd338f1 Kernel: Move Prekernel{CPU, Exceptions}.cpp out of Prekernel directory
This lets us delete the Prekernel.h file, and gets us closer to deleting
the Prekernel from the aarch64 Kernel.
2022-05-12 23:14:05 +02:00
Timon Kruiper e7c5fd978b Kernel: Move Prekernel assembly utils to aarch64/ASM_wrapper.h
By moving these functions to the ASM_wrapper.h file, we can get rid of
another Prekernel file.
2022-05-12 23:14:05 +02:00
Timon Kruiper e80d8d697c Kernel: Replace Prekernel::halt with Processor::halt in aarch64 build
This allows us to get rid of one more Prekernel file.
2022-05-12 23:14:05 +02:00
Daniel Bertalan fd3e3d5e28 LibC+Kernel: Prevent string functions from calling themselves
Most of the string.h and wchar.h functions are implemented quite naively
at the moment, and GCC's pattern recognition pass might realize what we
are trying to do, and transform them into libcalls. This is usually a
useful optimization, but not when we're implementing the functions
themselves :^)

Relevant discussion from the GCC Bugzilla:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725

This prevents the infamous recursive `strlen`.

A more proper fix would be writing these functions in assembly. That
would likely give a small performance boost as well ;)
2022-05-12 13:12:37 +02:00
Daniel Bertalan f157ad8a35 Kernel: Do not implement VERIFY_NOT_REACHED() as VERIFY(false)
If a switch case ends in VERIFY_NOT_REACHED(), gcc 12 thinks it might
fall through.
2022-05-12 13:12:37 +02:00
Timon Kruiper b8854549f2 Kernel: Sort aarch64 CMake sources alphabetically 2022-05-09 21:12:56 +02:00
Timon Kruiper c515e1341a Kernel: Add initial implementation of Processor in aarch64
Instead of storing the current Processor into a core local register, we
currently just store it into a global, since we don't support SMP for
aarch64 anyway. This simplifies the initial implementation.
2022-05-09 21:12:56 +02:00
Timon Kruiper ed4bfaed12 Kernel: Call the constructors in the aarch64 init function
Now that we have separated the kmalloc.cpp constructors into a separate
library, we can actually call the constructors in the init function.
2022-05-09 21:12:56 +02:00
Timon Kruiper 2e49d6b001 Kernel: Separate kmalloc.cpp into a separate library similar to x86_64
This will allow the call the constructors of the kmalloc.cpp file
before calling the other constructors in the Kernel.
2022-05-09 21:12:56 +02:00
Timon Kruiper d449fef606 Kernel: Reorder sections in aarch64 linker script to save space
By putting the NOLOAD sections (.bss and .super_pages) at the end of the
ELF file, objcopy does not have to insert a lot of zeros to make sure
that the .ksyms section is at the right place in memory. Now the .ksyms
section comes before the two NOLOAD sections. This shrinks the
kernel8.img with 6MB, from 8.3M to 2.3M. :^)
2022-05-09 21:12:56 +02:00
Timon Kruiper a1b352fdc0 Kernel: Add some mission sections to the aarch64 linker script
The sections did end up in the ELF file, however they weren't
explicitely mentioned in the linker.ld script. In the future, we can add
the --orphan-handling=error flag to the linker options, which will
enforce that the sections used in the sources files also are mentioned
in the linker script.
2022-05-09 21:12:56 +02:00
Liav A 9bec9c2b78 Kernel: Force y offset 0 when switching between console & graphics modes
This fixes a weird bug that when sometimes a user tried to switch to
console mode, the screen was frozen on graphics mode. After a hour of
debugging this, it became apparent that the problem was that we left the
y offset of the bochs graphics device in an invalid state, so it was not
zero because the WindowServer changed it, and the framebuffer console
code is not aware of horizontal and vertical offsets of the framebuffer
screen, leading to the problem that the framebuffer console updates the
first framebuffer (y offset = 0), but hardware was indicated to show the
second framebuffer (y offset = first framebuffer height).

Therefore, when doing a switch between these modes, always set the y
offset to be zero.
2022-05-06 18:05:14 +02:00
Liav A cd08c4a5aa Kernel/HID: Take a spinlock when calling KeyboardClient::on_key_pressed
The KeyboardClient class member could be updated due to TTY switch, so
we must ensure we always use a valid pointer.
2022-05-06 18:05:14 +02:00
Liav A b8493bf70f Kernel/Graphics: Protect the list of display connectors with a Spinlock
This list could be updated in runtime if an hotplug event occurs, so we
must protect it with a spin lock to avoid corruption of the list.
2022-05-06 18:05:14 +02:00
Liav A 340773ddb7 Kernel/Graphics: Implement basic support for VMWare SVGA adapter 2022-05-06 18:04:57 +02:00
Liav A a0a1ac0656 Kernel/Graphics: Use boot console if the subsystem is disabled
This lets us actually to initialize VirtualConsoles later on.
2022-05-06 12:28:19 +02:00
Liav A 0d784de3a6 Kernel/Graphics: Implement basic cursor for FramebufferConsole 2022-05-06 12:28:02 +02:00
MacDue d951e2ca97 Kernel: Add /proc/{pid}/children to ProcFS
This exposes the child processes for a process as a directory
of symlinks to the respective /proc entries for each child.

This makes for an easier and possibly more efficient way
to find and count a process's children. Previously the only
method was to parse the entire /proc/all JSON file.
2022-05-06 02:12:51 +04:30
MacDue 222079cd80 Kernel: Expose .length() of KBufferBuilder 2022-05-06 02:12:51 +04:30
Liav A 969e5fa163 Kernel/Console: Use 8x16 character font bitmap instead of old 8x8 bitmap
This in turn makes the built-in kernel console much more nicer to look
into, so let's remove the support for 8x8 bitmap and instead add 8x16
font bitmap.
2022-05-05 21:51:57 +02:00
Liav A b96b2fb9be Kernel/Graphics: Simplify the GenericGraphicsAdapter class
The old methods are already can be considered deprecated, and now after
we removed framebuffer devices entirely, we can safely remove these
methods too, which simplfies the GenericGraphicsAdapter class a lot.
2022-05-05 20:55:57 +02:00