summaryrefslogtreecommitdiff
path: root/Kernel/Arch
AgeCommit message (Collapse)Author
2021-05-28Kernel: Allow building the kernel with -O0Gunnar Beutner
Unfortunately the kernel doesn't run with -O0 but at least it can be successfully built with this change.
2021-05-21Kernel/CPU: Fix awkward printing early on bootLiav A
This usage of the word "installing" seemed for me for a long time as a wrong thing, so let's make it better now.
2021-05-20Kernel: Use the Function class for smp_broadcast()/smp_unicast()Gunnar Beutner
This avoids allocations for smp_broadcast() and smp_unicast() by using the Function class.
2021-05-20Kernel: Use the Function class for deferred_call_queue()Gunnar Beutner
This avoids allocations for deferred_call_queue().
2021-05-20Kernel: Remove s_processor_lock by making s_processors statically sizedBrian Gianforcaro
Currently in SMP mode we hard code support for up to only 8 processors. There is no reason for this to be a dynamic allocation that needs to be guarded by a spinlock. Instead use a Array<T* with inline storage of 8, allowing each processor to initialize it self in place, avoiding all the need for locks.
2021-05-19Kernel: Generate page fault events from the kernel profilerBrian Gianforcaro
Hook the kernel page fault handler and capture page fault events when the fault has a current thread attached in TLS. We capture the eip and ebp so we can unwind the stack and locate which pieces of code are generating the most page faults. Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-16Kernel/Graphics + SystemServer: Support text mode properlyLiav A
As we removed the support of VBE modesetting that was done by GRUB early on boot, we need to determine if we can modeset the resolution with our drivers, and if not, we should enable text mode and ensure that SystemServer knows about it too. Also, SystemServer should first check if there's a framebuffer device node, which is an indication that text mode was not even if it was requested. Then, if it doesn't find it, it should check what boot_mode argument the user specified (in case it's self-test). This way if we try to use bochs-display device (which is not VGA compatible) and request a text mode, it will not honor the request and will continue with graphical mode. Also try to print critical messages with mininum memory allocations possible. In LibVT, We make the implementation flexible for kernel-specific methods that are implemented in ConsoleImpl class.
2021-05-16Kernel: Expand the kernel memory slot from 16 MiB to 32 MiBLiav A
Like in 8cd5477e54a19d5476e9a31d0677e58c9a4ce12d, we need to expand the kernel slot again to be able to boot again.
2021-05-16Kernel: Drop support of GRUB VBE modesettingLiav A
We used GRUB to modeset the resolution for a long time, but for good reasons I see no point with keeping it supported in our kernel. We support bochs-display device on QEMU (both the VGA compatible and non-VGA compatible variants), so for QEMU we can still boot the system in graphical mode even without GRUB help. Also, we now have a native driver for Intel graphics and although it doesn't support most Intel graphics cards out there yet, it's a good starting point to support more cards. If a user wants to boot on bare-metal in graphical mode, all he needs to do is to add the removed flag back again, as the kernel still supports pre-set framebuffers.
2021-05-16AK+Kernel+LibELF: Remove the need for `IteratorDecision::Continue`Nicholas Baron
By constraining two implementations, the compiler will select the best fitting one. All this will require is duplicating the implementation and simplifying for the `void` case. This constraining also informs both the caller and compiler by passing the callback parameter types as part of the constraint (e.g.: `IterationFunction<int>`). Some `for_each` functions in LibELF only take functions which return `void`. This is a minimal correctness check, as it removes one way for a function to incompletely do something. There seems to be a possible idiom where inside a lambda, a `return;` is the same as `continue;` in a for-loop.
2021-05-15Kernel: Don't crash in page_fault_handler if current_thread is nullBrian Gianforcaro
If we are attempting to emit debugging information about an unhandleable page fault, don't crash trying to kill threads or dump processes if the current_thread isn't set in TLS. Attempt to keep proceeding in order to dump as much useful information as possible. Related: #6948
2021-05-05Kernel: Add Processor::is_bootstrap_processor() function, and use it. (#6871)Brian Gianforcaro
The variety of checks for Processor::id() == 0 could use some assistance in the readability department. This change adds a new function to represent this check, and replaces the comparison everywhere it's used.
2021-05-04Kernel: Store whether a thread is the idle thread in Thread directlyTom
This solves a problem where checking whether a thread is an idle thread may require iterating all processors if it is not the idle thread of the current processor.
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-29Kernel: Enable building the kernel with -fltoGunnar Beutner
GCC with -flto is more aggressive when it comes to inlining and discarding functions which is why we must mark some of the functions as NEVER_INLINE (because they contain asm labels which would be duplicated in the object files if the compiler decides to inline the function elsewhere) and __attribute__((used)) for others so that GCC doesn't discard them.
2021-04-25Everywhere: Remove empty line after function body opening curly braceLinus Groh
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-18Kernel: Add ptrace commands for reading/writing the debug registersFalseHonesty
This adds PT_PEEKDEBUG and PT_POKEDEBUG to allow for reading/writing the debug registers, and updates the Kernel's debug handler to read the new information from the debug status register.
2021-04-18Kernel: Add debug register handlingFalseHonesty
This patch adds functions to read/write from the debug registers, and implements storing/loading them across context switches.
2021-04-18Kernel+LibC: Clean up how assertions work in the kernel and LibCGunnar Beutner
This also brings LibC's abort() function closer to the spec.
2021-04-18Everywhere: Fix a bunch of typosLinus Groh
2021-04-06Kernel/PCI + CPU: Allow to access unaligned dataLiav A
2021-04-04Kernel+CrashReporter: Add metadata about page faults to crash reportsAndreas Kling
Crash reports for page faults now tell you what kind of memory access failed and where. :^)
2021-03-21Kernel::x86_64: Re-copy boot.S and add longmode inHendiadyoin1
Now we should have the posibility to run in longmode, after enabling it in the gdt
2021-03-21Kernel: Make IDT Entries their one structHendiadyoin1
This is to make them a bit more transparent, and with a bit of Compiler magic we get the 64-bit implementation in the same package
2021-03-21Kernel::CPU: Move headers into common directoryHendiadyoin1
Alot of code is shared between i386/i686/x86 and x86_64 and a lot probably will be used for compatability modes. So we start by moving the headers into one Directory. We will probalby be able to move some cpp files aswell.
2021-03-21Kernel: Add TSS64 and Desciptor for 64-bitHendiadyoin1
2021-03-08Everywhere: Remove unnecessary whitespace at the end of some lines.Emanuele Torre
2021-03-08Kernel: Manually reset the XCR0 registerLuke
According to the Intel manual: "After reset, all bits (except bit 0) in XCR0 are cleared to zero; XCR0[0] is set to 1." Sadly we can't trust this, for example VirtualBox starts with bits 0-4 set, so let's do it ourselves. Fixes #5653
2021-03-07Kernel: Fix unaligned read inside map_ebda()Jean-Baptiste Boric
2021-03-04Kernel: Make the kernel compile & link for x86_64Andreas Kling
It's now possible to build the whole kernel with an x86_64 toolchain. There's no bootstrap code so it doesn't work yet (obviously.)
2021-03-03Kernel: Make InstructionFetch PageFault flags match up (#5608)Nick Johnson
Previously, the instruction fetch flag of the page fault handler did not have the currect binary representation, and would always return false. This aligns these flags.
2021-03-02Kernel: Enable AVX flags if supported by cpuAshleigh Newman-Jones
This enables AVX and its dependency CR4.OSXSAVE when both are available on the cpu.
2021-02-28Kernel: Fix KUBSAN warnings due to unaligned APIC variablesTom
2021-02-28Kernel: Fix GenericInterruptHandler problems with virtual functionsTom
Because registering and unregistering interrupt handlers triggers calls to virtual functions, we can't do this in the constructor and destructor. Fixes #5539
2021-02-25Kernel: Don't disable interrupts while dealing with a process crashAndreas Kling
This was necessary in the past when crash handling would modify various global things, but all that stuff is long gone so we can simplify crashes by leaving the interrupt flag alone.
2021-02-25Kernel: Move SMAP disabler RAII helper to its own fileAndreas Kling
Added this in a new directory called Kernel/Arch/x86/ where stuff that applies to both i386 and x86_64 can live.
2021-02-25Kernel: Take some baby steps towards x86_64Andreas Kling
Make more of the kernel compile in 64-bit mode, and make some things pointer-size-agnostic (by using FlatPtr.) There's a lot of work to do here before the kernel will even compile.
2021-02-25Kernel: Tighten some typing in Arch/i386/CPU.hAndreas Kling
Use more appropriate types for some things.
2021-02-25Kernel: Remove unused Processor::set_thread_specific()Andreas Kling
2021-02-25Kernel: Remove some unused cruft in Arch/i386/CPU.hAndreas Kling
2021-02-24Kernel: Fix some number typos in Arch/i386/boot.SAndreas Kling
2021-02-23Kernel: Expand the kernel memory slot from 8 MiB to 16 MiBAndreas Kling
We were only 448 KiB away from filling up the old slot size we reserve for the kernel above the 3 GiB mark. This expands the slot to 16 MiB, which allows us to continue booting the kernel until somebody takes the time to improve our loader.
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-23Kernel: Copy the kernel command line to a good location at bootAndreas Kling
When building the kernel with -O2, we somehow ended up with the kernel command line outside of the lower 8MB of physical memory. Since we don't map that area in our initial page table setup, we would triple fault when trying to parse the command line. This patch sidesteps the issue by copying the (first 4KB of) the kernel command line to a buffer in a known safe location at boot.
2021-02-21Kernel: Populate ELF::AuxilaryValue::Platform from Processor object.Brian Gianforcaro
Move this to the processor object so it can easily be implemented when Serenity is compiled for a different architecture.
2021-02-21Kernel: Make UNMAP_AFTER_INIT imply NEVER_INLINE as wellAndreas Kling
We want to make sure these functions actually do get unmapped. If they were inlined somewhere, the inlined version(s) would remain mapped. Thanks to "thislooksfun" for the suggestion! :^)
2021-02-20Kernel: Slap a handful more things with UNMAP_AFTER_INITAndreas Kling
2021-02-19Kernel: Slap UNMAP_AFTER_INIT on a bunch more functionsAndreas Kling
We're now able to unmap 100 KiB of kernel text after init. :^)
2021-02-19Kernel: Slap UNMAP_AFTER_INIT on a whole bunch of functionsAndreas Kling
There's no real system here, I just added it to various functions that I don't believe we ever want to call after initialization has finished. With these changes, we're able to unmap 60 KiB of kernel text after init. :^)