mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
Kernel: Convert Processor::in_irq() to static current_in_irq()
This closes the race window between Processor::current() and a context switch happening before in_irq().
This commit is contained in:
parent
3e3f760808
commit
d60635cb9d
14 changed files with 37 additions and 39 deletions
|
@ -120,7 +120,7 @@ class Processor {
|
|||
u32 m_gdt_length;
|
||||
|
||||
u32 m_cpu;
|
||||
u32 m_in_irq;
|
||||
FlatPtr m_in_irq {};
|
||||
volatile u32 m_in_critical {};
|
||||
static Atomic<u32> s_idle_cpu_mask;
|
||||
|
||||
|
@ -329,9 +329,9 @@ public:
|
|||
return Processor::id() == 0;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u32& in_irq()
|
||||
ALWAYS_INLINE static FlatPtr current_in_irq()
|
||||
{
|
||||
return m_in_irq;
|
||||
return read_gs_ptr(__builtin_offsetof(Processor, m_in_irq));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static void restore_in_critical(u32 critical)
|
||||
|
|
|
@ -288,7 +288,7 @@ void page_fault_handler(TrapFrame* trap)
|
|||
|
||||
bool faulted_in_kernel = !(regs.cs & 3);
|
||||
|
||||
if (faulted_in_kernel && Processor::current().in_irq()) {
|
||||
if (faulted_in_kernel && Processor::current_in_irq()) {
|
||||
// If we're faulting in an IRQ handler, first check if we failed
|
||||
// due to safe_memcpy, safe_strnlen, or safe_memset. If we did,
|
||||
// gracefully continue immediately. Because we're in an IRQ handler
|
||||
|
|
|
@ -180,7 +180,7 @@ FlatPtr Processor::init_context(Thread& thread, bool leave_crit)
|
|||
|
||||
void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
|
||||
{
|
||||
VERIFY(!in_irq());
|
||||
VERIFY(!m_in_irq);
|
||||
VERIFY(m_in_critical == 1);
|
||||
VERIFY(is_kernel_mode());
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ FlatPtr Processor::init_context(Thread& thread, bool leave_crit)
|
|||
|
||||
void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
|
||||
{
|
||||
VERIFY(!in_irq());
|
||||
VERIFY(!m_in_irq);
|
||||
VERIFY(m_in_critical == 1);
|
||||
VERIFY(is_kernel_mode());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue