diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-08-29 19:31:22 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-30 13:20:34 +0200 |
commit | 779cf49f38e237191e9403b8e2ab463a14080bed (patch) | |
tree | 683fa4ff9259c7c1264de41171c51bc089fbd507 /Kernel/Arch | |
parent | f0b3aa033134b788a28fe8cf8ff6028d0e7941e8 (diff) | |
download | serenity-779cf49f38e237191e9403b8e2ab463a14080bed.zip |
Kernel: Fix Clang not initializing `s_bsp_processor` correctly
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.
Diffstat (limited to 'Kernel/Arch')
-rw-r--r-- | Kernel/Arch/x86/Processor.h | 6 | ||||
-rw-r--r-- | Kernel/Arch/x86/common/Processor.cpp | 1 |
2 files changed, 4 insertions, 3 deletions
diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h index 52d1e1c478..1b601b9c58 100644 --- a/Kernel/Arch/x86/Processor.h +++ b/Kernel/Arch/x86/Processor.h @@ -119,8 +119,8 @@ class Processor { u32 m_gdt_length; u32 m_cpu; - FlatPtr m_in_irq {}; - volatile u32 m_in_critical {}; + FlatPtr m_in_irq; + volatile u32 m_in_critical; static Atomic<u32> s_idle_cpu_mask; TSS m_tss; @@ -137,7 +137,7 @@ class Processor { bool m_invoke_scheduler_async; bool m_scheduler_initialized; - bool m_in_scheduler { true }; + bool m_in_scheduler; Atomic<bool> m_halt_requested; DeferredCallEntry* m_pending_deferred_calls; // in reverse order diff --git a/Kernel/Arch/x86/common/Processor.cpp b/Kernel/Arch/x86/common/Processor.cpp index 1b8de25d1b..11affd1bed 100644 --- a/Kernel/Arch/x86/common/Processor.cpp +++ b/Kernel/Arch/x86/common/Processor.cpp @@ -305,6 +305,7 @@ UNMAP_AFTER_INIT void Processor::early_initialize(u32 cpu) m_invoke_scheduler_async = false; m_scheduler_initialized = false; + m_in_scheduler = true; m_message_queue = nullptr; m_idle_thread = nullptr; |