summaryrefslogtreecommitdiff
path: root/Kernel/Arch/x86
AgeCommit message (Collapse)Author
2022-09-20Kernel: Move x86-specific HID code to the Arch/x86 directoryLiav A
The i8042 controller with its attached devices, the PS2 keyboard and mouse, rely on x86-specific IO instructions to work. Therefore, move them to the Arch/x86 directory to make it easier to omit the handling code of these devices.
2022-09-20Kernel: Don't compile ISA IDE controller code in non-x86 buildsLiav A
The ISA IDE controller code makes sense to be compiled in a x86 build as it relies on access to the x86 IO space. For other architectures, we can just omit the code as there's no way we can use that code again. To ensure we can omit the code easily, we move it to the Arch/x86 directory.
2022-09-20Kernel: Move VMWare backdoor communication code to the x86 directoryLiav A
The VMWare backdoor handling code involves many x86-specific instructions and therefore should be in the Arch/x86 directory. This ensures we can easily omit the code in compile-time for non-x86 builds.
2022-09-20Kernel: Move PCI initialization x86-specific code to the arch directoryLiav A
It seems more correct to let each platform to define its own sequence of initialization of the PCI bus, so let's remove the #if flags and just put the entire Initializer.cpp file in the appropriate code directory.
2022-09-20Kernel: Move PCSpeaker code to the x86-specific architecture directoryLiav A
The PCSpeaker code is specific to x86 platforms, thus it makes sense to put in the Arch/x86 subdirectory.
2022-09-20Kernel/PCI: Move IO based HostBridge code to x86 arch-specific directoryLiav A
The simple PCI::HostBridge class implements access to the PCI configuration space by using x86 IO instructions. Therefore, it should be put in the Arch/x86/PCI directory so it can be easily omitted for non-x86 builds.
2022-09-20Kernel: Abstract platform-specific serial port access from kprintfLiav A
kprintf should not really care about the hardware-specific details of each UART or serial port out there, so instead of using x86 specific instructions, let's ensure that we will compile only the relevant code for debug output for a targeted-specific platform.
2022-09-20Kernel/x86: Move RTC and CMOS code to x86 arch-specific subdirectoryLiav A
The RTC and CMOS are currently only supported for x86 platforms and use specific x86 instructions to produce only certain x86 plaform operations and results, therefore, we move them to the Arch/x86 specific directory.
2022-09-20Kernel: Move IO delay code to x86 architecture subdirectoryLiav A
Many code patterns and hardware procedures rely on reliable delay in the microseconds granularity, and since they are using such delays which are valid cases, but should not rely on x86 specific code, we allow to determine in compile time the proper platform-specific code to use to invoke such delays.
2022-09-20Kernel: Abstracts x86 reboot and shutdown specific methodsLiav A
We move QEMU and VirtualBox shutdown sequences to a separate file, as well as moving the i8042 reboot code sequence too to another file. This allows us to abstract specific methods from the power state node code of the SysFS filesystem, to allow other architectures to put their methods there too in the future.
2022-09-20Kernel: Move QEMU shutdown code to the x86 subdirectoryLiav A
QEMU VM shutdown code is really x86 specific, so let's ensure we only use it when compiling a Kernel for x86 machines.
2022-09-16Kernel: Send SIGBUS to threads that use after valid Inode mmaped rangeLiav A
According to Dr. POSIX, we should allow to call mmap on inodes even on ranges that currently don't map to any actual data. Trying to read or write to those ranges should result in SIGBUS being sent to the thread that did violating memory access.
2022-08-26Kernel: Move Spinlock functions back to arch independent Locking folderTimon Kruiper
Now that the Spinlock code is not dependent on architectural specific code anymore, we can move it back to the Locking folder. This also means that the Spinlock implemenation is now used for the aarch64 kernel.
2022-08-26Kernel: Use InterruptsState in Spinlock codeTimon Kruiper
This commit updates the lock function from Spinlock and RecursiveSpinlock to return the InterruptsState of the processor, instead of the processor flags. The unlock functions would only look at the interrupt flag of the processor flags, so we now use the InterruptsState enum to clarify the intent, and such that we can use the same Spinlock code for the aarch64 build. To not break the build, all the call sites are updated aswell.
2022-08-24Kernel: Wrap process address spaces in SpinlockProtectedAndreas Kling
This forces anyone who wants to look into and/or manipulate an address space to lock it. And this replaces the previous, more flimsy, manual spinlock use. Note that pointers *into* the address space are not safe to use after you unlock the space. We've got many issues like this, and we'll have to track those down as wlel.
2022-08-22Kernel/x86: Protect the CR3->PD map with a spinlockAndreas Kling
This can be accessed from multiple CPUs at the same time, so relying on the interrupt flag is clearly insufficient.
2022-08-22Kernel: Stop taking MM lock while using regular quickmapsAndreas Kling
You're still required to disable interrupts though, as the mappings are per-CPU. This exposed the fact that our CR3 lookup map is insufficiently protected (but we'll address that in a separate commit.)
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-08-20AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernelAndreas Kling
Instead of having two separate implementations of AK::RefCounted, one for userspace and one for kernelspace, there is now RefCounted and AtomicRefCounted.
2022-08-19Kernel: Add 8-byte atomics for i686 GCCIdan Horowitz
Unlike Clang, GCC does not support 8-byte atomics on i686 with the -mno-80387 flag set, so until that is fixed, implement a minimal set of atomics that are currently required.
2022-08-19Kernel/x86: Re-enable interrupts ASAP when handling page faultsAndreas Kling
As soon as we've saved CR2 (the faulting address), we can re-enable interrupt processing. This should make the kernel more responsive under heavy fault loads.
2022-08-18Kernel/x86: Don't re-enable interrupts too soon when unlocking spinlocksAndreas Kling
To ensure that we stay on the same CPU that acquired the spinlock until we're completely unlocked, we now leave the critical section *before* re-enabling interrupts.
2022-08-18Kernel/x86: Disable interrupts when leaving critical sectionsAndreas Kling
This fixes an issue where we could get preempted after acquiring the current Processor pointer, but before calling methods on it. I strongly suspect this was the cause of "Processor::current() == this" assertion failures.
2022-08-18Kernel/x86: Move Processor::{leave,clear}_critical() out of lineAndreas Kling
I don't think this code needs to be ALWAYS_INLINE, and moving it out of line will make backtraces nicer.
2022-07-14Kernel+Userland: Remove supervisor pages conceptLiav A
There's no real value in separating physical pages to supervisor and user types, so let's remove the concept and just let everyone to use "user" physical pages which can be allocated from any PhysicalRegion we want to use. Later on, we will remove the "user" prefix as this prefix is not needed anymore.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12Everywhere: Explicitly specify the size in StringView constructorssin-ack
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
2022-07-08Kernel: Do not disable userland access to the RDTSC instructionTim Schumacher
Access to RDTSC is occasionally restricted to give malware one less option to accurately time attacks (side-channels, etc.). However, QEMU requires access to the timestamp counter for the exact same reason (which is accurately timing its CPU ticks), so lets just enable it for now.
2022-06-22Kernel: Eliminate possible KASLR leak by disabling CR4.FSGSBASEIdan Horowitz
The RDGSBASE userspace instruction allows programs to read the contents of the gs segment register which contains a kernel pointer to the base of the current Processor struct. Since we don't use this instruction in Serenity at the moment, we can simply disable it for now to ensure we don't break KASLR. Support can later be restored once proper swapping of the contents of gs is done on userspace/kernel boundaries.
2022-06-17Kernel/Interrupts: Add missing include for IRQController header fileLiav A
This is necessary for the next commit in the patch, otherwise this can't be compiled. It seems like this was a hidden issue that is discovered now only by changing includes in a mass-scale.
2022-06-02Kernel: Move IRQController and InterruptManagement to Arch directoryTimon Kruiper
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-02Kernel: Rename idt_init() to initialize_interrupts()Timon Kruiper
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-02Kernel: Implement InterruptDisabler using generic Processor functionsTimon Kruiper
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-02Kernel: Separate NonMaskableInterruptDisabler into its own fileTimon Kruiper
This is for the upcoming change to make InterruptDisabler class work for the aarch64 build.
2022-06-02Kernel: Add interrupt related functions to Processor classTimon Kruiper
This adds {enable, disable}_interrupts() and are_interrupts_enabled() to the Processor class, and also implements them for x86(_64) and aarch64.
2022-06-02Kernel: Add GenericInterruptHandler.cpp to aarch64 buildTimon Kruiper
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-05-30Kernel: Do not include AK/Platform.h in mcontext headersSeekingBlues
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-30Kernel: Expose cache size for Intel CPUsLucas CHOLLET
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-29Kernel: Expose size of L1 data/instruction, L2, and L3 CPU caches :^)Linus Groh
These are added as properties of the "caches" object to each processor, if available.
2022-05-15Kernel: Implement AVX `XSAVE` supportJesse Buhagiar
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-03Kernel: Move Arch/x86/Spinlock.h and add stubs for aarch64Timon Kruiper
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-03Kernel: Move Kernel/Arch/x86/SafeMem.h to Kernel/Arch/SafeMem.hTimon Kruiper
The file does not contain any specific architectural code, thus it can be moved to the Kernel/Arch directory.
2022-04-26Kernel: Strip null terminators from all CPUID strings, not just brandLinus Groh
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-08Kernel: Query OS-enabled CPUID features again at the end of cpu_setup()Linus Groh
For OSPKE this is a no-op as we don't enable PKU yet, but the state of the OSXSAVE flag might have changed if we enabled XSAVE.
2022-04-08Kernel: Rename OSPKU CPUID feature flag to OSPKELinus Groh
Unlike "XSAVE enabled by OS" being indicated by the OSXSAVE flag, in this case it's "PKU enabled by OS" being indicated by the OSPKE flag.
2022-04-03Kernel: Convert ProcessorInfo::build_brand_string() to StringBuilderLinus Groh
2022-04-03Kernel: Remove EBX, ECX, and EDX values from hypervisor dmesgln()Linus Groh
2022-04-03Kernel: Move hypervisor vendor ID string to ProcessorInfoLinus Groh
This will make it possible to expose it in /proc/cpuinfo. :^)
2022-04-03Kernel: Make ProcessorInfo::build_foo_string() privateLinus Groh
2022-04-03Kernel: Move feature string building to ProcessorInfoLinus Groh
Other than a dmesgln(), ProcessorInfo is the only user of this function and is already responsible for building other CPUID-related strings.