summaryrefslogtreecommitdiff
path: root/Kernel/Arch/x86
AgeCommit message (Collapse)Author
2021-11-06Kernel: Initialize regs.fs in Processor::init_contextAMACB
Commit f285241c replaced the line that sets regs.fs with a line that sets regs.gs, but not vice versa.
2021-10-21Kernel: Call try_set_coredump_property with StringView argumentsDaniel Bertalan
Storing assigning a string literal to a String object just to pass it to a function expecting a StringView is wasteful. Let's just not do that. For consistency's sake, this commit changes all of the other invocations to use StringView literals, too.
2021-10-16Kernel: Move ScopedCritical + SmapDisabler CPP files into x86 commonJames Mintram
2021-10-15Kernel: Move spinlock into ArchJames Mintram
Spinlocks are tied to the platform they are built for, this is why they have been moved into the Arch folder. They are still available via "Locking/Spinlock.h" An Aarch64 stub has been created
2021-10-15Kernel: Add cross platform RegisterState header and Aarch64 versionJames Mintram
A new RegisterState header includes the platform specific RegisterState header based on the platform being compiled. The Aarch64 RegisterState header contains stubs for Debug
2021-10-15Kernel: Split SmapDisabler so header is platform independentJames Mintram
A new header file has been created in the Arch/ folder while the implementation has been moved into a CPP living in the X86 folder.
2021-10-15Kernel: Split ScopedCritical so header is platform independentJames Mintram
A new header file has been created in the Arch/ folder while the implementation has been moved into a CPP living in the X86 folder.
2021-10-14Kernel: Add per platform Processor.h headersJames Mintram
The platform independent Processor.h file includes the shared processor code and includes the specific platform header file. All references to the Arch/x86/Processor.h file have been replaced with a reference to Arch/Processor.h.
2021-10-14Kernel: Move asserts inside platform #if clausesJames Mintram
2021-10-14Kernel: Replace includes with a forward declarationJames Mintram
2021-10-14Kernel: Remove unused includesJames Mintram
2021-10-14Kernel: Add header includes closer to their useJames Mintram
2021-10-07Kernel: Note if the page fault address is a destroyed smart pointerLuke Wilde
While I was working on LibWeb, I got a page fault at 0xe0e0e0e4. This indicates a destroyed RefPtr if compiled with SANITIZE_PTRS defined. However, the page fault handler didn't print out this indication. This makes the page fault handler print out a note if the faulting address looks like a recently destroyed RefPtr, OwnPtr, NonnullRefPtr, NonnullOwnPtr, ThreadSafeRefPtr or ThreadSafeNonnullRefPtr. It will only do this if SANITIZE_PTRS is defined, as smart pointers don't get scrubbed without it being defined.
2021-10-07Kernel: Add Processor::time_spent_idle()Idan Horowitz
2021-10-05Kernel: Validate x86_64 address canonicality before SafeMem operationsIdan Horowitz
This ensures we don't GP on x86_64 when a non-canonical address is fed to a safe_foo() operation.
2021-10-05Kernel: Detect and store the virtual address bit width during CPU initIdan Horowitz
2021-10-02Kernel: Access MemoryManager static functions staticallyBrian Gianforcaro
SonarCloud flagged this "Code Smell", where we are accessing these static methods as if they are instance methods. While it is technically possible, it is very confusing to read when you realize they are static functions.
2021-10-01Kernel: Move x86 IO instructions code into the x86 specific folderLiav A
2021-09-10Kernel: Replace inline assembly for turning on IA32_EFER.NXE with MSRIdan Horowitz
This fixes a triple fault that occurs when compiling serenity with the i686 clang toolchain. (The underlying issue is that the old inline assembly did not specify that it clobbered the eax/ecx/edx registers and as such the compiler assumed they were not changed and used their values across it) Co-authored-by: Brian Gianforcaro <bgianf@serenityos.org>
2021-09-07Kernel: Track when a thread is in the middle of crashingBrian Gianforcaro
There are certain checks that we should skip if the system is crashing. The system can avoid stack overflow during crash, or even triple faulting while while handling issues that can causes recursive panics or aborts.
2021-09-06Kernel: Rename ProcessPagingScope => ScopedAddressSpaceSwitcherAndreas Kling
2021-09-06Kernel: Improve API names for switching address spacesAndreas Kling
- enter_space => enter_address_space - enter_process_paging_scope => enter_process_address_space
2021-09-05Kernel: Switch static_asserts of a type size to AK::AssertSizeBrian Gianforcaro
This will provide better debug ability when the size comparison fails.
2021-09-05Kernel: Make copy_{from,to}_user() return KResult and use TRY()Andreas Kling
This makes EFAULT propagation flow much more naturally. :^)
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-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: 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. :^)