100 Commits
Author SHA1 Message Date
Sönke Holz d2d78ed715 LibC: Add Kernel/API/POSIX/winsize.h to HEADERS
I forgot to do this in be0e1aaf8f.

This makes us actually install that header into the sysroot, unbreaking
ports like openssl, which previously failed to build with:
"fatal error: Kernel/API/POSIX/winsize.h: No such file or directory"
2026-11-05 14:53:49 +01:00
Sönke Holz be0e1aaf8f Kernel: Make both Ioctl.h and POSIX/termios.h define struct winsize
FreeBSD also makes it available from both sys/ioctl.h and termios.h.
glibc doesn't have the POSIX 2024 tc{set,get}winsize() wrappers yet,
so it doesn't even define it in termios.h at the moment.

LLVM relies on sys/ioctl.h defining struct winsize, so the llvm port and
the zig port failed to build after 312b4440bf.
2026-11-04 10:04:39 +01:00
Sönke Holz 312b4440bf Kernel: Move struct winsize definition to API/POSIX/termios.h
POSIX requires it to be defined in this header:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/termios.h.html
"The <termios.h> header shall define the winsize structure, [...]"

This unbreaks the readline port after 8e34c970b5, which made it
use tc{get,set}winsize() instead of the ioctl.
Previously, it failed to compile with a -Wincompatible-pointer-types
warning:

"expected 'struct winsize *' but argument is of type 'struct winsize *'"

ioctl() takes the argument as a vararg, so it didn't trigger this
warning.
2026-11-03 13:18:30 -05:00
Sönke Holz cb9e1feee3 LibGL+LibSoftGPU: Support GL_{UN,}PACK_SKIP_{PIXELS,ROWS}
We already store these glPixelStorei() parameters in
m_unpacking_parameters/m_packing_parameters, but didn't do anything
with them.

Setting these parameters is equivalent to offsetting the input/output
texture data pointer by a constant offset.
2026-11-01 21:27:28 +01:00
Sönke Holz 54c20eb309 Meta: Disable "portability-no-assembler" clang-tidy check
"hicpp-no-assembler" was renamed to "portability-no-assembler" in
clang-tidy 23, so our "portability-*" wildcard enabled this check.
2026-10-31 12:54:29 -04:00
Sönke Holz 7af126f893 LibGL: Support GL_PROXY_TEXTURE_2D
Proxy textures don't have any image data. They can be used to determine
if a given texture configuration is supported by the implementation.

To support proxy textures in gl_tex_image_2d, we need to tweak the error
handling, since proxy textures don't report an error for unsupported
dimensions:
GL spec 1.5, 3.8.11 Texture State and Proxy State:
"When TexImage3D is executed with target specified as PROXY_TEXTURE_3D,
 the three-dimensional proxy state values of the specified
 level-of-detail are recomputed and updated. If the image array would
 not be supported by TexImage3D called with target set to TEXTURE_3D,
 no error is generated, but the proxy width, height, depth,
 border width, and component resolutions are set to zero."
(The same also applies to TexImage2D.)
2026-10-28 15:15:37 +01:00
Sönke Holz e225bb4255 LibGL: Make null textures have a size of 0x0
GL spec 1.5, 3.8.11 Texture State and Proxy State:
"Each initial texture array is null (zero width, height, and depth,
 zero border width, internal format 1, with the compressed flag
 set to FALSE, a zero compressed size, and zero-sized components)."

GL spec 1.5, 3.8.1 Texture Image Specification:
"An image with zero width, height, or depth indicates the null texture."

Previously, retrieving the texture size for an uninitialized texture
would have resulted in a crash. Since Texture2D initially has a null
device image and device images are not allowed to be 0x0 (GPU::Image
VERIFYs that), represent 0x0 textures by having a null device image.
2026-10-28 15:15:37 +01:00
Sönke Holz a9f9a09406 Ports: Update neovim to 0.12.6 2026-10-27 10:57:51 +01:00
Sönke Holz a9cceea102 Ports: Update luv checksum
The release tarball was modified two days after 6e1780bd0b updated
it to this version.
2026-10-27 10:57:51 +01:00
Sönke Holz 31ed5be377 LibSoftGPU: Clamp fog factor between 0 and 1
We would otherwise pass factors outside of this range to mix(), leading
to weird colors.
2026-10-18 17:40:16 +02:00
Sönke Holz 80baeb2970 Meta: Enable the "vc4-kms-v3d.dtbo" Raspberry Pi devicetree overlay
Despite its name, this overlay isn't Linux-specific. It enables the v3d
node next to other things.

Raspberry Pi OS also enables this overlay by default.
2026-10-08 16:07:29 +02:00
Sönke Holz f54eb331a8 3DFileViewer: Unveil "/dev/gpu"
This is required for all LibGL drivers other than LibSoftGPU.
2026-10-08 16:07:29 +02:00
Sönke Holz 110c3a1cba Userland: Pledge "wpath" in applications using LibGL
The "wpath" pledge is required for the V3D LibGL driver to make writable
memory mappings.
2026-10-08 16:07:29 +02:00
Sönke Holz 854a84b08b LibGL: Make GPU driver configurable via LIBGL_GPU_DRIVER
This allows selecting GPU drivers other than LibSoftGPU at runtime.
2026-10-08 16:07:29 +02:00
Sönke Holz 7e510d374a Libraries: Add an initial LibGL driver for the VideoCore VII 3D
This initial version of the driver only supports glClear{,Color,Depth}()
for now.

Since the only publicly available documentation for the VideoCore 3D
architecture (the VideoCore IV 3D Architecture Reference Guide) just
covers an older revision of the VideoCore 3D architecture, I used
Mesa's v3d_packet.xml as a reference to get definitions for the control
records of the VideoCore VII.

To determine which control records need to be generated for a minimal
example, I used Mesa's `V3D_DEBUG` environment variable and set it to
`cl` to make it dump the control lists it generates for a basic OpenGL
test program.
2026-10-08 16:07:29 +02:00
Sönke Holz 7125a6cc6c Ports/SDL2: Manually disable libsamplerate dependency again
This workaround was erroneously removed in e5cd17eab1. The port was
still picking up my system libsamplerate and therefore failed to build.
This workaround was originally added in adf85c719a
2026-10-05 15:04:13 +02:00
Sönke Holz 6d42b13c1a Kernel/SDHC: Increase the timeout to 20'000 * 100 us = 2 s
The previous timeout of 100 us was way too low on real hardware.
On an old 2GB microSD card, some reads are so slow that 500 ms wasn't
even enough.
2026-09-27 18:17:45 +02:00
Sönke Holz 104d9b9533 Kernel/SDHC: Correct 64-bit ADMA2 host controller version check
The "64-bit System Address Support for V3" field was added in host
controller version 3.00. Since we only support version 2 and 3 host
controllers, this check was previously never true.

Once we support version 4.x in the future, we likely need to change this
code since Version 4.x introduced a new V4 mode. The exact meaning of
this capabilities register field differs between version 4.00 and 4.10
and later. In version 4.00 it means that both V3 and V4 mode is
supported, while in 4.10 and later it only means that V3 mode is
supported. Support for V4 mode is instead indicated by a separate field
in that version.

Remove the FIXMEs mentioning that 64-bit ADMA2 and the check for it
don't work in QEMU, since 64-bit ADMA2 appears to work fine in QEMU.
Note that 64-bit ADMA2 needs to be explicitly enabled by setting the
`sd-spec-version` `sdhci-pci` device parameter to `3` and `capareg`
to a value that has the "64-bit System Address Support for V3" field
set, like 0x157834B4.
2026-09-27 18:17:45 +02:00
Sönke Holz 110cdf0f93 Kernel/SDHC: Support DMA on non-PCI host controllers
We previously only enabled it in PCISDHostController for some reason.
2026-09-27 18:17:45 +02:00
Sönke Holz d45a3c055a Kernel/aarch64: Enable SD card power in raspberry_pi_5_platform_init()
Since we currently don't support devicetree drivers depending on other
devicetree drivers (like the SD host controller driver depending on
the SD power regulators), do this in the platform init function for now.
In the future, we should have proper devicetree drivers for
"regulator-gpio" and "regulator-fixed" and use them to enable the
regulators in the SD host controller driver.
2026-09-27 18:17:45 +02:00
Sönke Holz 2986c7d6b6 Kernel/aarch64: Add a very basic driver for the BCM2712 GPIO controllers
Next to the GPIO controller in the RP1, the Pi 5 also has two GPIO
controllers in the SoC itself. The driver is named after their
devicetree compatible string "brcm,brcmstb-gpio".
2026-09-27 18:17:45 +02:00
Sönke Holz e1fd729c8b Kernel/aarch64: Retrieve Pi 5 EMMC2 clock frequency from the devicetree 2026-09-27 18:17:45 +02:00
Sönke Holz b592b8a059 Kernel/aarch64: Properly reset the Pi 5's Ethernet PHY via its reset pin
I previously didn't notice this was necessary since I always use netboot
to boot the kernel on my Pi 5. When using netboot, the firmware resets
the PHY for us.

Similar to the fan driver, this code now hardcodes the reset pin
number. In the future, it might be a better idea to use the devicetree
for this. Upstream linux and the downstream Raspberry Pi fork
unfortunately have incompatible devicetree bindings, so we will have
choose one of them.
2026-09-21 12:14:42 +02:00
Sönke Holz 5962730d78 Kernel/aarch64: Allow manually driving RP1 GPIOs from software
This currently uses the output (enable) override fields in the control
registers. There's also a dedicated Registered IO (RIO) interface
mentioned in the datasheet, which might be a better fit.
2026-09-21 12:14:42 +02:00
Sönke Holz ef456c3d29 Kernel/aarch64: Don't rely on firmware enabling the Pi 5 fan GPIO pin
The firmware appears to always enable this pin, but explicitly enabling
it should still be a good idea.
2026-09-21 12:14:42 +02:00
Sönke Holz 5137776ee1 Kernel/aarch64: Add RP1GPIO::set_pin_enabled()
We previously accidentally relied on the firmware enabling output pads
for us.

Each GPIO pin in the RP1 has two output enables: one controlled by the
function and one controlled by the pad registers.

This requires us to now use also the pad registers next to the IO bank
registers.
2026-09-21 12:14:42 +02:00
Sönke Holz 7557b8664e Kernel/aarch64: Allow setting RP1 GPIO pin function to "none" 2026-09-21 12:14:42 +02:00
Sönke Holz 724426185a Kernel/aarch64: Factor out relative pin number logic in RP1 GPIO driver
We will need to use this code in more places.
2026-09-21 12:14:42 +02:00
Sönke Holz 8f8c61b70d AK: Silence false positive -Wstringop-overflow GCC warning in Vector
This silences the following warning when building lagom with recent GCC
versions:
"error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]"

It only seems to be reported when this function is inlined into
GIFLoader's usage of LzwDecompressor::get_output().
2026-09-19 11:26:44 +02:00
Sönke Holz bb35ba0a83 Kernel: Add a VideoCore VII 3D driver
This driver is split into two main .cpp files: DeviceNode.cpp and
V3D.cpp. V3D is the core driver, while DeviceNode.cpp implements the
userspace API that exposes the device a device node (file).

Job submission is currently implemented in a very basic synchronous way
by simply using a Mutex.
The driver is currently not able to cancel or abort any jobs, meaning
that a GPU page fault or hang will currently make the GPU unusable until
rebooting the system. Similarly, EINTRs will also interrupt the code
waiting for job completion, but since we have no way of cancelling the
job, the GPU might be in some undefined state.
2026-09-18 17:25:42 +02:00
Sönke Holz 38c162aeea Kernel: Pass OpenFileDescription to vmobject_and_memory_type_for_mmap
This is more useful than passing a reference to the Process, which
can be easily obtained with Process::current(). Only KCOVDevice
previously used this argument.
We will need this new argument in the next commit.
2026-09-18 17:25:42 +02:00
Sönke Holz 15fcac7f87 Kernel: Make VirtualRangeBase constructor constexpr 2026-09-18 17:25:42 +02:00
Sönke Holz b5150ee24a Kernel/Memory: Make page size used by RegionTrees configurable 2026-09-18 17:25:42 +02:00
Sönke Holz 6823eabb01 Kernel/Memory: Make RegionTree usable with other Region-like classes 2026-09-18 17:25:42 +02:00
Sönke Holz 41fa690404 Kernel/MM: Remove unnecessary RegionTree friend 2026-09-18 17:25:42 +02:00
Sönke Holz f9779257de Kernel/Memory: Move all RegionTree functions inline
This will allow turning this class into a template.
2026-09-18 17:25:42 +02:00
Sönke Holz 2766a55379 Kernel: Directly pass PageDirectory to ThreadRegisters::set_*_state()
This solves an include cycle that would otherwise be caused by the next
commit:

Thread.h -> ThreadRegisters.h -> AddressSpace.h -> RegionTree.h
-> Random.h -> DeprecatedWaitQueue.h -> Thread.h

(a -> b means a includes b.)
2026-09-18 17:25:42 +02:00
Sönke Holz 30d5f2c1fc Kernel/Memory: Allow subclassing VirtualRange
This will be used for GPU virtual address ranges.

Use an explicit Self template parameter instead of just using
`VirtualRangeBase` as argument/return type to make different
subclasses intentionally incompatible with each other.
This will e.g. not allow comparing CPU virtual address ranges with GPU
virtual address ranges.

Don't put expand_to_page_boundaries() in the new base class since
this function assumes a CPU page size of 4K. Additionally, since this
is a static member function, deducing this would not work and we would
have to use CRTP for this function (but we could still use deducing
this for the other ones).
2026-09-18 17:25:42 +02:00
Sönke Holz 25538bf0f0 Kernel/Memory: Move some VirtualRange functions inline
This will allow turning this class into a templated base class.
Don't move expand_to_page_boundaries() inline since it will only be
implemented by one subclass. Additionally, this function uses
page_round_up() from MemoryManager.h. Including this header in
VirtualRange.h would result in a circular include.
2026-09-18 17:25:42 +02:00
Sönke Holz 3c4fe04b2b Kernel/Memory: Allow subclassing VirtualAddress
This will be used for GPU virtual addresses.

Use an explicit Self template parameter instead of just using
`VirtualAddressBase` as argument/return type to make different
subclasses intentionally incompatible with each other.
This will e.g. not allow comparing CPU virtual addresses with GPU
virtual addresses.

Don't put is_page_aligned() and page_base() in the new base class since
those functions assume a CPU page size of 4K.
2026-09-18 17:25:42 +02:00
Sönke Holz c2542ef35d Kernel/Memory: Implement spaceship operator for VirtualAddress
This will make the code a tiny bit shorter once we use deducing this
here in the next commit.
2026-09-18 17:25:42 +02:00
Sönke Holz 6a04d4a37b Kernel/aarch64: Flush the D-cache before reading back RPi mailbox data
Since we currently can't use MM to allocate a DMA buffer for the RPi
mailbox (as it needs to be below 1G), we can't map it as Non-cacheable,
and instead need to rely on manual cache maintenance operations.
We previously forgot to flush the cache again before reading back data,
which is required on ARM systems, as explained in the comment.
(See also https://events.static.linuxfound.org/sites/events/files/slides/slides_17.pdf
and the DMA examples at https://support.arm.com/documentation/ddi0487/mc/-Part-K-Appendixes/-Appendix-K11-Barrier-Litmus-Tests/-K11-5-Cache-and-TLB-maintenance-instructions-and-barriers/-K11-5-1-Data-cache-maintenance-instructions.)

This appears to have fixed the "Failed to get the RPi CPU temperature"
messages that occur every so often.

In the future, we should instead make MM somehow be able to return
DMA buffers below a given address threshold for legacy bus masters, such
as the mailbox peripheral in Raspberry Pis. MM should also somehow try
to make sure that some low memory stays available for legacy DMA
peripherals and otherwise potentially fall back to bounce pages.
2026-09-18 17:23:32 +02:00
Sönke Holz f414ac22bd Kernel/aarch64: Remove Asm::flush_data_cache()
We can replace the only user of this function with the generic
Processor::flush_data_cache() function.
2026-09-18 17:23:32 +02:00
Sönke Holz e94c7fb5e1 Meta: Check for wast2json instead of wat2wasm
We use wast2json since 27905af9ec.
2026-09-17 08:53:54 -04:00
Sönke Holz da8d8f61f4 Meta: Correctly check if WebAssembly spec tests were generated
Since 27905af9ec we use wast2json, which writes the modules to
$SPEC_TEST.$INDEX.wasm. Before, we manually wrote them to
$SPEC_TEST_$INDEX.wasm.
2026-09-17 08:53:54 -04:00
Sönke Holz e5a7173492 Documentation: Update list of required and supported RISC-V extensions
We started conditionally using Svpbmt in a2f75c5f5e, Zicbom in
f0af457011, and Zkr in 048ba5b4d0.
2026-08-18 09:25:44 -04:00
Sönke Holz 688bf2d7f7 Kernel: Correctly calculate number of bytes to read/write from partition
`offset` is in bytes, not blocks.

Previously, if `BlockBasedFileSystem::read_block()` attempted to read at
a byte offset that is equal to the block count, `nread` would be 0, so
it wouldn't read any data. This led to a crash because
`BlockBasedFileSystem::read_block()` asserts that the returned byte
count is equal to the number of bytes it requested.
The same bug also applies to the `write()` function.

If `read()` or `write()` was called with an offset that is larger than
the block count, the first parameter to the `min()` call would underflow
to a large value, leading it to always use the second argument.
2026-08-18 11:39:21 +02:00
Sönke Holz afe859b2b6 Kernel: Extract a total_block_count variable in StorageDevicePartition
No behavior change.
2026-08-18 11:39:21 +02:00
Sönke Holz 7c50847a92 DHCPClient: Set Host Name option
This makes bare metal serenity systems reachable by their hostname
on my local network, which uses a FRITZ!Box as the router, DNS server,
and DHCP server. It appears to use this DHCP option to add DNS records
for "$hostname" and "$hostname.fritz.box".
2026-08-16 16:27:59 -04:00
Sönke Holz 3d41262ab2 Kernel/Net: Support the GEM ethernet adapter in the RP1
This means we now have ethernet support on the Raspberry Pi 5!
The generic Cadence Gigabit Ethernet MAC (GEM) driver only supports the
IP revision built into the RP1 for now, which is 1p09 according to the
datasheet.

Since the RP1 datasheet doesn't provide any detailed documentation about
this IP block, I referenced the AMD Zynq UltraScale+ docs,
as those devices also use the Cadence GEM (but a different version).
2026-08-16 16:57:03 +02:00
Sönke Holz 20295abc11 AK: Allow constructing MACAdress from an Array 2026-08-16 16:57:03 +02:00
Sönke Holz 006de308b5 AK+DynamicLoader: Move optimizer_fence() into AK
This will allow us to use this function in other places.
2026-08-16 16:57:03 +02:00
Sönke Holz 1a3eb40582 AK: Put fence functions in the global namespace
In some places, we already didn't use an "AK::" prefix, most likely due
to ADL. Instead of having to rely on ADL, let's just make this explicit.
2026-08-16 16:57:03 +02:00
Sönke Holz 1320a0512a AK: Move fence functions to AK/Fences.h 2026-08-16 16:57:03 +02:00
Sönke Holz 8444f82579 Kernel/Net: Allow dynamically registering network adapters 2026-08-16 16:57:03 +02:00
Sönke Holz f270c6ffef Kernel/Net: Port NetworkTask to the new WaitQueue
Without this commit, latency in the RP1 GEM Ethernet driver is very
high, most likely because we only ever dequeued packets when we hit the
500 ms timeout.

The new (properly synchronized) WaitQueue implementation appears to fix
these problems.
2026-08-16 16:57:03 +02:00
Sönke Holz a0823fb2f5 Kernel: Don't panic on WaitQueue self-wakeups caused by deferred calls
WaitQueue::notify_one() can also be called from code triggered by
deferred calls, like timers. Deferred calls are executed in
exit_trap() after clearing m_in_irq, so this would previously cause this
VERIFY to trip.

This will make us not crash in the next commit if the NetworkTask
timeout deferred call is called during an interrupt context.
2026-08-16 16:57:03 +02:00
Sönke Holz 3df8595941 Kernel/Net: Don't use else after continue in NetworkTask 2026-08-16 16:57:03 +02:00
Sönke Holz 423924b746 Kernel: Add a WaitQueue::wait_until() overload that doesn't need a lock
Unlike condition variables, our WaitQueue implementation works correctly
without requiring a lock. Users of this overload just need to be sure
that the `should_wake` callback is done in an atomic way.
See https://read.seas.harvard.edu/cs1610/2026/doc/wait-queues/
(the site we used as an implementation reference) for a good explanation
why this is the case, especially the "Synchronization" section.

This allows us to remove a dummy spinlock from the WaitQueue in the
E1000 driver.
2026-08-13 20:47:26 +02:00
Sönke Holz 93af8693d6 Kernel/aarch64: Flush the TLB before enabling the MMU in pre_init
The EFIPrekernel does already do so on AArch64, but we forgot to do it
here.
2026-08-07 17:59:53 +02:00
Sönke Holz f18b0bdb10 Kernel/aarch64: Remove an outdated note from pre_init
Global variables can be directly used in pre_init since d7f65d06d6.
2026-08-07 17:59:53 +02:00
Sönke Holz e4b1afa7d6 Kernel/aarch64: Bootstrap the MMU in pre_init similar to RISC-V
The old code had two bugs.
The first bug was caused by us jumping into high memory inside of a C++
function (pre_init). Since the compiler (rightfully so) assumes that
all global variables stay at the same address, it decided to load the
address of g_boot_info (which we pass to init) before we enable the MMU.
This caused the boot_info info argument to point to physical memory.

Normally, this should cause a crash when we try to access this argument
in the kernel itself, since unmap_identity_map() unmaps the
identity map, causing all accesses to low memory to fail.
However, unmap_identity_map() is also broken, since it assumes that all
physical memory is below 0x3f000000 (likely a leftover from when we
only supported the Rasberry Pi 3). This causes it to not unmap the
identity mapping if physical memory is above that address, like on QEMU.

We can easily fix both of these problems if we bootstrap the MMU like
we do on RISC-V. Instead of identity mapping the entire kernel range,
only identity map a single "bootstrap" page that contains the code to
enable the MMU and afterwards jump into virtual memory.
This means that we don't jump into high virtual memory in the middle of
a C++ function, so the compiler can't incorrectly load the g_boot_info
address before the MMU is enabled. Additionally, we only have to unmap
a single page, which is significantly easier than having to unmap some
arbitrary range of physical memory.

This fixes booting on AArch64 systems which have physical memory below
0x3f000000, like the Pi 5.
This regressed in d7f65d06d6.
2026-08-07 17:59:53 +02:00
Sönke Holz e6ae1993ea Kernel: Simplify pre_init self-relocation a bit
Now that all declarations have hidden visibility, we don't need to use
inline asm to avoid GOT references here anymore.
2026-08-05 15:39:22 +02:00
Sönke Holz 681d709a8f Kernel/riscv64: Avoid using the la pseudo-instruction
In PIC mode, `la` is an alias for the `lga` (load global address)
pseudo-instruction, which generates a GOT load.
Since GOT loads aren't necessary in the kernel, use `lla` (load local
address) instead.
2026-08-05 15:39:22 +02:00
Sönke Holz d7f65d06d6 Kernel: Give all declarations hidden visibility
This causes GCC and Clang to generate relative loads when accessing
global variables instead of using the global offset table (GOT).
This saves one load for every global variable access.
We unfortunately have to do this by injecting a header into every
source file, since "-fvisibility=hidden" doesn't affect `extern`
declarations.

This additionally means that accessing global variables doesn't
depend on relocations anymore, so pre_init code no longer needs to
access variables through `adjust_by_mapping_base()`.
Next to this, some other small tweaks are required in pre_init because
global variables now have the "correct" addresses while we are still
identity mapped.

Being able to simplify pre_init like this was also the original
motivation for this patch. Clang trunk started optimizing
`adjust_by_mapping_base()` on AArch64 such that it avoids using the GOT
when we attempt to get the address of the global variable in high
memory. As a consequence, we now directly get the address in low memory
on Clang trunk, causing us to redundantly subtract the physical to link
time address offset and end up with an incorrect address.
With this patch, we no longer need to rely on the compiler not doing
such optimizations anymore.

The .got section still exists on non-x86 but only contains 2-3 entries:
- the start of the .dynamic section (I'm not sure why),
- the __stack_chk_guard (only actually used on RISC-V GCC),
- __clz_tab (only on RISC-V GCC).
Additionally, there are some other GOT entries caused by the RISC-V `la`
pseudo-instruction, which will be removed in the next commit.
It's a bit unfortunate that RISC-V GCC still uses the GOT to access the
stack protector (__stack_chk_guard), but that's not under our control.

RISC-V GCC and AArch64 GCC also still contain a .got.plt section, but
none of the other toolchain+architecture combinations.
2026-08-05 15:39:22 +02:00
Sönke Holz 78bf57e147 Kernel/aarch64: Don't align the pre_init kernel mapping to 2 MiB
This doesn't seem to be necessary.
2026-08-05 15:39:22 +02:00
Sönke Holz 550fba9345 Kernel/Net: Re-add custom E1000 destructor
I forgot to move the E1000E destructor into the E1000 driver in
e22c1f2df8. This should prevent UAFs when the E1000 driver is destroyed
(because initialization failed) after the MDIO handling task was already
spawned.
2026-07-30 16:04:11 +02:00
Sönke Holz 1334dce8a7 Kernel: Store InodeWatcher inode member as LockWeakPtr
This prevents use-after-frees when the watcher tries to access the
inode after it has been freed.

Before fe5ca6ca27, the inode was correctly stored as a WeakPtr.
For some reason that commit changed it to a raw reference instead.
(This was before 11eee67b85, so before the old WeakPtr was renamed to
LockWeakPtr. Inode derives from LockWeakable, so we unfortunately have
to use LockWeakPtr here.)

We have to add a new WatchDescription member to store the
InodeIdentifier for the inode so that we can still remove the
inode_to_watches entry for inodes that have already been freed.
2026-07-22 09:49:52 +02:00
Sönke Holz 9ca56bccc6 Kernel: Remove an unnecessary const_cast from InodeWatcher 2026-07-22 09:49:52 +02:00
Sönke Holz cd42ed4d84 Kernel: Support Message Signaled Interrupts in the Intel HDA driver 2026-07-21 20:35:19 +02:00
Sönke Holz c2bf8b685b Kernel: Explicitly enable memory space accesses in the Intel HDA driver
We previously relied on the firmware doing this for us.
2026-07-21 20:35:19 +02:00
Sönke Holz 311afe42f7 Kernel/Net: Support the I211 in the E1000 driver 2026-07-21 20:34:09 +02:00
Sönke Holz 49ed4f797e Kernel/Net: Only enable interrupts after configuring the handler
We otherwise can lose interrupts that occurred between setting the
interrupt mask bits and registering the interrupt handler and therefore
enabling its interrupt.
2026-07-21 20:34:09 +02:00
Sönke Holz df4b787e22 Kernel/Net: Remove an unnecessary interrupt cause read in E1000
This was added in 97664fad60 without a reason. Reading the interrupt
cause here shouldn't have any benefit. It only means that we can
potentially acknowledge an interrupt without actually handling it.
2026-07-21 20:34:09 +02:00
Sönke Holz d84865ccef Kernel/Net: Explicitly enable memory space accesses in the E1000 driver
We previously relied on the firmware doing this for us.
2026-07-21 20:34:09 +02:00
Sönke Holz 3880258993 Kernel/Net: Don't rely on ADL to call PCI::enable_bus_mastering() 2026-07-21 20:34:09 +02:00
Sönke Holz 1c7d9a36b9 Kernel/Net: Use a Rx and Tx buffer size of 2048 in the E1000 driver
We don't support jumbo frames, so the MTU is 1500. This means a buffer
size of 2048 is enough.

The motivation for this change is that the I211 requires using a
different register field for buffer sizes above 2048.
2026-07-21 20:34:09 +02:00
Sönke Holz 85c24bae35 Kernel/Net: Handle non-page aligned Rx and Tx buffer sizes in E1000
The underlying memory regions are currently contiguous, so we
alternatively could just use the regions' physical page 0 address and
add buffer_size * i to it.
This and the old approach will however work with non-contiguous regions
(under the constraint that PAGE_SIZE % buffer_size == 0),
if we decided to use scatter-gather transfers here in the future.
2026-07-21 20:34:09 +02:00
Sönke Holz a8a3b013b8 Kernel/PCI: Don't enable the MSI capability immediately
Unlike MSI-X, MSI vectors can't always be masked (it's an optional
feature that we don't even support), so we shouldn't enable it
immediately after reserving interrupt numbers.

This function will already be called by `Device::enable_interrupt()`
which in turn will be called by `PCI::IRQHandler::enable()`.
For MSI-X, this function unmasks the vector.
2026-07-21 20:34:09 +02:00
Sönke Holz e22c1f2df8 Kernel/Net: Integrate the E1000E driver into the E1000 driver
This removes quite a bit of duplicate code.
The only real remaining difference between the E1000 driver and its
subclassed E1000E driver is that the E1000E driver supports MDIO
access.

Keeping track of hardware differences in a m_hardware_features member
seems better than adding new subclasses.
2026-07-19 18:10:12 +02:00
Sönke Holz 1b5b1971ae Kernel/Net: Remove list of unsupported E1000E device IDs
I don't think it makes sense to have a long (and outdated) list of
device IDs that we don't support at the moment.
2026-07-19 18:10:12 +02:00
Sönke Holz 61a6debf18 Kernel/Net: Don't set CTRL.SLU twice in the E1000E driver
I missed in 84d1758de3 that setup_link() already sets the SLU bit.
It seems like unconditionally setting it is fine:

"Software must set the Set Link Up bit in the Device Control register
 (CTRL.SLU) before the MAC recognizes the link indication from the PHY
 and can consider the link to be up."
(82574 datasheet, 3.2.3.1.1)

This doesn't seem to suggest that we should only set it after the PHY
says that the link is up.
2026-07-19 18:10:12 +02:00
Sönke Holz 917b3102dd Kernel/Net: Read the E1000 MAC address from RAL0/RAH0
The datasheet(s) say these receive address filter registers are
preloaded with the MAC address of the controller.
This means we don't need to access the EEPROM (or NVM on newer
controllers).
2026-07-19 18:10:12 +02:00
Sönke Holz 75a8fe59b0 Toolchain: Update Jakt to latest commit
This fixes building the Jakt toolchain after c717b91897 added a
subdirectory in AK: AK/Math.
Previously, the "build jakt support libs" step failed because Jakt's
DirectoryIterator didn't treat symlinks to directories as directories.
2026-07-18 20:33:18 +02:00
Sönke Holz fc792d3386 Kernel/Net: Support MSIs in the E1000 driver
This can be tested using the "e1000e" QEMU device. The "e1000" device
doesn't have the MSI capability.
2026-07-18 12:27:34 +02:00
Sönke Holz 8f01756c34 Kernel/PCI: Allow requesting MSI but not MSI-X 2026-07-18 12:27:34 +02:00
Sönke Holz b56eed7e39 Kernel/Net: Make E1000 interrupt handler derive from PCI::IRQHandler
This will allow us to support MSIs.
2026-07-18 12:27:34 +02:00
Sönke Holz f81ec38b6f Kernel/Net: Use a separate class for the E1000 interrupt handler
This is the "intended" way to use the IRQHandler class.
This will allow us to support MSIs, since that requires calling the
`reserve_irqs()` method from the PCI::Device class.
The (PCI::)IRQHandler constructor needs the interrupt number, so we
can't call its constructor until we know the interrupt number, for which
we need a class deriving from PCI::Device.
2026-07-18 12:27:34 +02:00
Sönke Holz 1a5cf40f75 Kernel/x86: Properly determine the responsible controller for interrupts
Instead of only taking the lower bound of interrupt numbers into
account, we should also check that the interrupt number is below the
GSI end of the interrupt controller.

Previously, this incorrect check caused us to have all interrupts be
associated with the first IOAPIC, if the first IOAPIC is responsible
for the lower interrupt numbers.
2026-07-12 13:14:12 +02:00
Sönke Holz 2f1add56f4 Kernel/x86: Always treat interrupt numbers as GSIs in the IOAPIC class
ACPI global system interrupts (GSIs) are a global interrupt number
namespace that is mapped to interrupt controller-relative interrupt
numbers. To do so, we need to subtract gsi_base() from them.
We previously didn't do so in some places in the IOAPIC driver.
2026-07-12 13:14:12 +02:00
Sönke Holz 1fddd44a4b Kernel/x86: Remove unused IRQController::get_irr() function
This unused function is only implemented by the PIC.
2026-07-12 13:14:12 +02:00
Sönke Holz 7d71b67a54 Kernel/x86: Make get_isr() a PIC-specific member function
This function is only implemented by the PIC to return the value of its
ISR register. Since the previous commit, the only user of this function
(PICSpuriousInterruptHandler) refers to it directly using the PIC class,
so we don't need to implement it in the general IRQController class
anymore (even then we could have casted the IRQController to a PIC).
2026-07-12 13:14:12 +02:00
Sönke Holz 259c9b87a9 Kernel/x86: Explicitly pass the PIC to its spurious interrupt handler
Previously, this class incorrectly had its m_responsible_irq_controller
temporarily set to the I/O APIC if the PICs were disabled and the
spurious interrupt handler only was registered to catch any stray
spurious interrupts that may still be caused by the PICs on buggy x86
systems.

Additionally, we can now remove one overload of the
get_responsible_irq_controller() function since we removed the only
user of it.
2026-07-12 13:14:12 +02:00
Sönke Holz 3a70417ff0 Kernel/x86: Rename {=> PIC}SpuriousInterruptHandler
This class is now only used by the PIC.

Spurious interrupt vectors that can maybe actually not be spurious
are only a thing on x86 due to legacy reasons, so we don't need this
class on non-x86.
Both AArch64's and RISC-V's interrupt controller do also have a way
to communicate that there is no interrupt pending (anymore), but we
don't need a special class to handle this for these architectures,
so remove FIXMEs mentioning that SpuriousInterruptHandler should also
be used for them.
2026-07-12 13:14:12 +02:00
Sönke Holz d2eb593961 Kernel/x86: Add an APIC-specific spurious interrupt handler
The old SpuriousInterruptHandler only works with PICs.
It assumes that it always has a parent IRQController, which isn't the
case for APICs (APICs aren't represented by an IRQController).
This didn't cause a crash because get_responsible_irq_controller()'s
logic of determining the correct IRQController is broken at the moment
and always returns the first I/O APIC. This bug will be fixed by a
future commit.

Additionally, SpuriousInterruptHandler always tries to use
IRQController::get_isr() in its handle_interrupt() function, which
only the PIC class implements.
2026-07-12 13:14:12 +02:00
Sönke Holz 920062e64e Kernel: Move kprintf to the arch-independent KERNEL_SOURCES definition
All architectures now use this file.
2026-07-12 13:14:12 +02:00
Sönke Holz eeee1387c3 Kernel/x86: Tweak an outdated FIXME
We do support retrieving PCIe host controllers from the devicetree
on AArch64 and RISC-V now.

The microvm devicetree doesn't seem to be intended to be used by the OS,
only for EDK II. We seem to be supposed to use an AML interpreter to
call the _CBA method.
2026-07-12 13:03:08 +02:00
Sönke Holz 5625fddc59 Kernel/PCI: Don't use Region::physical_page() to print the ECAM address
Since 827322c139, MMIO regions aren't backed by physical page classes
anymore, so this caused a null RefPtr to be dereferenced.
2026-07-12 13:03:08 +02:00
Sönke Holz fb23f3c902 Kernel/MM: Only reserve SMBIOS memory regions if they are non-null
These boot info members are set to null if the prekernel didn't find
SMBIOS tables for us.
SMBIOS tables will most likely never be at physical address zero.
2026-07-11 12:18:03 +02:00
Sönke Holz 570c9f1833 EFIPrekernel: Insert missing SMBIOS configuration table null check
The 32-bit SMBIOS case was missing a null check. This caused KUBSAN
to trigger if neither a 64-bit SMBIOS nor a 32-bit SMBIOS configuration
table was present.
2026-07-11 12:18:03 +02:00