diff --git a/kernel/spinlock/spinlock.c b/kernel/spinlock/spinlock.c index 97307db..23521a8 100644 --- a/kernel/spinlock/spinlock.c +++ b/kernel/spinlock/spinlock.c @@ -12,12 +12,14 @@ void spinlock_init(SpinLock *sl) { uint64_t spinlock_irqsave(void) { uint64_t flags; - asm volatile("pushfq; cli; popq %0" : "=r"(flags)); + asm volatile("pushfq; cli; popq %0" : "=r"(flags) :: "memory"); return flags; } void spinlock_irqrestore(uint64_t flags) { - asm volatile("pushq %0; popfq" :: "r"(flags)); + if (flags & (1<<9)) { + asm volatile("sti" ::: "memory"); + } } void spinlock_acquire(SpinLock *sl) {