summaryrefslogtreecommitdiff
path: root/Kernel/Arch
AgeCommit message (Collapse)Author
2021-09-04Kernel: Add x2APIC supportTom
This allows addressing all cores on more modern processors. For now, we still have a hardcoded limit of 64 due to s_processors being a static array.
2021-09-04Kernel: Allow specifying ecx with CPUIDTom
Some CPUID functions (e.g. 0xb) require input values in ecx.
2021-08-30Kernel: Fix Clang not initializing `s_bsp_processor` correctlyDaniel Bertalan
Initializing the variable this way fixes a kernel panic in Clang where the object was zero-initialized, so the `m_in_scheduler` contained the wrong value. GCC got it right, but we're better off making this change, as leaving uninitialized fields in constant-initialized objects can cause other weird situations like this. Also, initializing only a single field to a non-zero value isn't worth the cost of no longer fitting in `.bss`. Another two variables suffer from the same problem, even though their values are supposed to be zero. Removing these causes the `_GLOBAL_sub_I_` function to no longer be generated and the (not handled) `.init_array` section to be omitted.
2021-08-29Kernel: Rename Spinlock::is_owned_by_current_thread()Andreas Kling
...to is_owned_by_current_processor(). As Tom pointed out, this is much more accurate. :^)
2021-08-29Kernel: {Mutex,Spinlock}::own_lock() => is_locked_by_current_thread()Andreas Kling
Rename these API's to make it more clear what they are checking.
2021-08-29Kernel: Move "in-scheduler" flag from SchedulerData to ProcessorAndreas Kling
This avoids a race between getting the processor-specific SchedulerData and accessing it. (Switching to a different CPU in that window means that we're operating on the wrong SchedulerData.) Co-authored-by: Tom <tomut@yahoo.com>
2021-08-29Kernel: Add read_gs_value() and write_gs_value()Andreas Kling
Co-authored-by: Tom <tomut@yahoo.com>
2021-08-29Kernel: Make all ProcFS and SysFS files zero-sizedAndreas Kling
There is no value in exposing particular sizes for these files.
2021-08-29Kernel: Remove unused members in BIOSSysFSDirectoryAndreas Kling
2021-08-28Kernel: Omit all actual code from the kernel on aarch64 for nowNico Weber
2021-08-23Kernel: Make Processor::clean_fpu_state() staticAndreas Kling
This function returns the same identical FPU state for all CPU's, so there's no point requiring a Processor instance.
2021-08-23Kernel: Make Processor::platform_string() return StringViewAndreas Kling
2021-08-23Kernel: Consolidate I386/X86_64 implementations of do_init_context()Andreas Kling
We can use ThreadRegisters::set_flags() to avoid the #ifdef's here.
2021-08-23Kernel: Fix some trivial clang-tidy warnings in x86/common/Processor.cppAndreas Kling
2021-08-23Kernel: Rename Processor::id() => current_id()Andreas Kling
And let id() be the non-static version that gives you the ID of a Processor object.
2021-08-23Kernel: Convert Processor::in_irq() to static current_in_irq()Andreas Kling
This closes the race window between Processor::current() and a context switch happening before in_irq().
2021-08-22Kernel/SysFS: Don't expose SMBIOS blobs if can't find SMBIOS tablesLiav A
Don't assume that a platform machine will provide at least the 32 bit version of SMBIOS tables. If there's no SMBIOS tables, don't expose directory entries in the /sys/bios/ directory.
2021-08-22Kernel: Rename ScopedSpinlock => SpinlockLockerAndreas Kling
This matches MutexLocker, and doesn't sound like it's a lock itself.
2021-08-22Kernel: Rename SpinLock => SpinlockAndreas Kling
2021-08-19Kernel: Make Process::current() return a Process& instead of Process*Idan Horowitz
This has several benefits: 1) We no longer just blindly derefence a null pointer in various places 2) We will get nicer runtime error messages if the current process does turn out to be null in the call location 3) GCC no longer complains about possible nullptr dereferences when compiling without KUBSAN
2021-08-19Kernel: Consolidate a bunch of i386/x86_64 code pathsAndreas Kling
Add some arch-specific getters and setters that allow us to merge blocks that were previously specific to either ARCH(I386) or ARCH(X86_64).
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.