summaryrefslogtreecommitdiff
path: root/Kernel/Arch
AgeCommit message (Collapse)Author
2021-08-11Kernel: Disambiguate instruction size for mov in read_gs_ptrGunnar Beutner
Previously we allowed using immediate values here which is ambiguous as to which specific mov instruction the compiler should choose.
2021-08-10Kernel/SMP: Change critical sections to not disable interruptsAndreas Kling
Leave interrupts enabled so that we can still process IRQs. Critical sections should only prevent preemption by another thread. Co-authored-by: Tom <tomut@yahoo.com>
2021-08-10Kernel/SMP: Make entering/leaving critical sections multi-processor safeAndreas Kling
By making these functions static we close a window where we could get preempted after calling Processor::current() and move to another processor. Co-authored-by: Tom <tomut@yahoo.com>
2021-08-09Kernel/SMP: Don't process SMP messages in non-SMP modeAndreas Kling
Processing SMP messages outside of non-SMP mode is a waste of time, and now that we don't rely on the side effects of calling the message processing function, let's stop calling it entirely. :^)
2021-08-09Kernel/SMP: Process the deferred call queue in exit_trap()Andreas Kling
We were previously relying on a side effect of the critical section in smp_process_pending_messages(): when exiting that section, it would process any pending deferred calls. Instead of relying on that, make the deferred invocations explicit by calling deferred_call_execute_pending() in exit_trap(). This ensures that deferred calls get processed before entering the scheduler at the end of exit_trap(). Since thread unblocking happens via deferred calls, the threads don't have to wait until the next scheduling opportunity when they could be ready *now*. :^) This was the main reason Tom's SMP branch ran slowly in non-SMP mode.
2021-08-09Kernel/SMP: Don't process SMP messages in exit_trap() in non-SMP modeAndreas Kling
2021-08-09Kernel/SMP: Don't enable interrupts in Processor::exit_trapAndreas Kling
Enter a critical section in Processor::exit_trap so that processing SMP messages doesn't enable interrupts upon leaving. We need to delay this until the end where we call into the Scheduler if exiting the trap results in being outside of a critical section and irq handler. Co-authored-by: Tom <tomut@yahoo.com>
2021-08-09Kernel/SMP: Mark s_smp_enabled READONLY_AFTER_INITAndreas Kling
We can't enter/leave SMP mode once the kernel is up and running.
2021-08-09Kernel/SMP: Make SMP message queueing work correctlyAndreas Kling
- Use the receiver's per-CPU entry in the message, instead of the sender's. (Using the sender's entry wasn't safe for broadcast messages since the same entry ended up on multiple message queues.) - Retry the CAS until it *succeeds* instead of *fails*. This closes a race window, and also ensures a correct return value. The return value is used by the caller to decide whether to broadcast an IPI. This was the main reason smp=on was so slow. We had CPUs busy-waiting until someone else triggered an IPI and moved things along. - Add a CPU pause hint to the spin loop. :^)
2021-08-09Kernel/SMP: Fix ProcessorMessage deallocation bugAndreas Kling
Due to a boolean mistake in smp_return_to_pool(), we didn't retry pushing the message onto the freelist after a failed attempt. This caused the message pool to eventually become completely empty after enough contentious access attempts. This patch also adds a pause hint to the CPU in the failed attempt code path.
2021-08-09Kernel: Rename Processor::smp_queue_message() => smp_enqueue_message()Andreas Kling
2021-08-09Kernel: Add Processor::pause() and use it to give the CPU a restAndreas Kling
On x86, the "pause" instruction is a "spin loop hint".
2021-08-06Kernel: Rename Process::space() => Process::address_space()Andreas Kling
We commonly talk about "a process's address space" so let's nudge the code towards matching how we talk about it. :^)
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-08-06Kernel: Rename Kernel/VM/ to Kernel/Memory/Andreas Kling
This directory isn't just about virtual memory, it's about all kinds of memory management.
2021-08-06Kernel: Store coredump metadata properties as KStringsAndreas Kling
This patch also replaces the HashMap previously used to store coredump properties with a plain AK::Array.
2021-08-01Kernel: Remove ThreadTracer.h include from Process.h / Thread.hBrian Gianforcaro
This isn't needed for Process / Thread as they only reference it by pointer and it's already part of Kernel/Forward.h. So just include it where the implementation needs to call it.
2021-08-01Kernel: Remove unused header includesBrian Gianforcaro
2021-07-27Kernel: Fix CPU initialization for SMPGunnar Beutner
This was broken by the KASLR changes.
2021-07-27Kernel: Remove a handful of unused member functions in ProcessorAndreas Kling
2021-07-27Kernel: Introduce ProcessorSpecific<T> for per-CPU data structuresAndreas Kling
To add a new per-CPU data structure, add an ID for it to the ProcessorSpecificDataID enum. Then call ProcessorSpecific<T>::initialize() when you are ready to construct the per-CPU data structure on the current CPU. It can then be accessed via ProcessorSpecific<T>::get(). This patch replaces the existing hard-coded mechanisms for Scheduler and MemoryManager per-CPU data structure.
2021-07-27Kernel: Support loading the kernel at almost arbitrary virtual addressesGunnar Beutner
This enables further work on implementing KASLR by adding relocation support to the pre-kernel and updating the kernel to be less dependent on specific virtual memory layouts.
2021-07-26Kernel: Remove invalid '#' format modifier for printing a faulting addrAli Mohammad Pur
This was mistakenly added in 306d898ee56c0d277d865dd4e3afba3d95eab9aa.
2021-07-26Kernel: Show the unmapped-after-init symbol being accessedAli Mohammad Pur
This makes it a lot easier to figure out what unmapped function is being accessed, and a lot easier to reason about _why_ it is being accessed.
2021-07-26Kernel: PANIC() instead of manually halting the processor in abort()Ali Mohammad Pur
2021-07-25Kernel+LibSystem: Add a 4th syscall argumentAndreas Kling
Let's allow passing 4 function arguments to a syscall. The 4th argument goes into ESI or RSI.
2021-07-23Kernel: Add missing .globl definitionsGunnar Beutner
This ensures that we can properly take the address of these symbols in other code.
2021-07-23Kernel: Make some of the assembly code position-independent on x86_64Gunnar Beutner
2021-07-22Kernel: Fix the variable declaration for some linker script symbolsGunnar Beutner
Despite what the declaration would have us believe these are not "u8*". If they were we wouldn't have to use the & operator to get the address of them and then cast them to "u8*"/FlatPtr afterwards.
2021-07-22Everywhere: Prefix hexadecimal numbers with 0xGunnar Beutner
Depending on the values it might be difficult to figure out whether a value is decimal or hexadecimal. So let's make this more obvious. Also this allows copying and pasting those numbers into GNOME calculator and probably also other apps which auto-detect the base.
2021-07-20Kernel: Mark read only RegisterState function parameters as constBrian Gianforcaro
2021-07-20Kernel: No lock validate_user_stack variant, switch to Space as argumentBrian Gianforcaro
The entire process is not needed, just require the user to pass in the Space. Also provide no_lock variant to use when you already have the VM/Space lock acquired, to avoid unnecessary recursive spinlock acquisitions.
2021-07-19Kernel: Remove obsolete codeGunnar Beutner
2021-07-19Kernel: Push ARCH specific ifdef's down into RegisterState functionsBrian Gianforcaro
The non CPU specific code of the kernel shouldn't need to deal with architecture specific registers, and should instead deal with an abstract view of the machine. This allows us to remove a variety of architecture specific ifdefs and helps keep the code slightly more portable. We do this by exposing the abstract representation of instruction pointer, stack pointer, base pointer, return register, etc on the RegisterState struct.
2021-07-18Everywhere: Make tracking cpu usage independent from system ticksTom
This switches tracking CPU usage to more accurately measure time in user and kernel land using either the TSC or another time source. This will also come in handy when implementing a tickless kernel mode.
2021-07-18Kernel: Introduce basic pre-kernel environmentGunnar Beutner
This implements a simple bootloader that is capable of loading ELF64 kernel images. It does this by using QEMU/GRUB to load the kernel image from disk and pass it to our bootloader as a Multiboot module. The bootloader then parses the ELF image and sets it up appropriately. The kernel's entry point is a C++ function with architecture-native code. Co-authored-by: Liav A <liavalb@gmail.com>
2021-07-18Kernel: Add support for kernel addresses other than 3-4GBGunnar Beutner
2021-07-18Kernel: Fix {read,write}_gs_ptr() for 64-bit addressesGunnar Beutner
2021-07-17Kernel: Replace "folder" => "directory" everywhereAndreas Kling
Folders are a GUI concept. File systems have directories.
2021-07-17Kernel: Make PAGE_MASK architecture independentHediadyoin1
2021-07-16Kernel: Make resizing the page tables for the kernel image easierGunnar Beutner
By using the KERNEL_PD_OFFSET constant we can avoid some of the hard-coded values in the boot code.
2021-07-16Kernel: Move end_of_kernel_image after the .ksyms sectionGunnar Beutner
Without this we won't be able to detect whether .ksyms overlaps the end of the page table we set up for the kernel image.
2021-07-16Kernel: Support specifying a 64-bit KERNEL_BASE addressGunnar Beutner
The kernel doesn't currently boot when using an address other than 0xc0000000 because the page tables aren't set up properly for that but this at least lets us build the kernel.
2021-07-16Kernel: Avoid unnecessary jump in the boot codeGunnar Beutner
The 32-bit boot code jumps to 0xc0000000 + entry address once page tables are set up. This is unnecessary for 64-bit mode because we'll do another far jump just moments later.
2021-07-16Kernel: Avoid hard-coding kernel virtual baseGunnar Beutner
2021-07-14Kernel: Detect and display CPUID Hyper-V dataJean-Baptiste Boric
2021-07-14Kernel: Detect and display CPUID hypervisor signatureJean-Baptiste Boric
2021-07-14Kernel: Add support for hypervisor CPUID featureJean-Baptiste Boric
2021-07-14Kernel: Don't mix AT&T and Intel ASM syntax in `boot.S`Daniel Bertalan
The rest of the file is in AT&T syntax, so for the time being, I'll switch these instructions to AT&T too to make Clang shut up.
2021-07-14AK: Generalize ByteReaderHendiadyoin1
Also use it instead of CPU.h's possibly_unaligned_data interface