spinlock only restore RFLAGS IF flag
This commit is contained in:
@ -12,12 +12,14 @@ void spinlock_init(SpinLock *sl) {
|
|||||||
|
|
||||||
uint64_t spinlock_irqsave(void) {
|
uint64_t spinlock_irqsave(void) {
|
||||||
uint64_t flags;
|
uint64_t flags;
|
||||||
asm volatile("pushfq; cli; popq %0" : "=r"(flags));
|
asm volatile("pushfq; cli; popq %0" : "=r"(flags) :: "memory");
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spinlock_irqrestore(uint64_t 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) {
|
void spinlock_acquire(SpinLock *sl) {
|
||||||
|
Reference in New Issue
Block a user