tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

suspicious code in ioapic locking

The apic handling routines embedded in the macros in vector.S come from i82093reg.h, and operate on struct pic (sys/x86/include/pic.h). The __cpu_simple_lock_t in the struct pic is now a byte, so the code is wrong. This doesn't seem to break anything, probably due to structure padding. The following patch corrects the ioapic code. Another approach would be to rearrange the register usage so that the simple lock routines could be called directly, but this would be more involved. In the patch below, I used %bl because %rbx is blown away in the macros anyway.

Let me know if you think I should commit this.


Index: sys/arch/amd64/include/i82093reg.h
RCS file: /cvsroot/src/sys/arch/amd64/include/i82093reg.h,v
retrieving revision 1.3
diff -u -u -r1.3 i82093reg.h
--- sys/arch/amd64/include/i82093reg.h  11 May 2003 15:46:57 -0000      1.3
+++ sys/arch/amd64/include/i82093reg.h  23 Apr 2008 04:58:48 -0000
@@ -14,14 +14,13 @@
 #define ioapic_asm_lock(num) \
-       movl    $1,%esi                                         ;\
+       movb    $1,%bl                                  ;       \
 77:                                                            \
-       xchgl   %esi,PIC_LOCK(%rdi)                             ;\
-       testl   %esi,%esi                                       ;\
+        cmpxchgb %bl,PIC_LOCK(%rdi)                    ;       \
        jne     77b
 #define ioapic_asm_unlock(num) \
-       movl    $0,PIC_LOCK(%rdi)
+       movb    $0,PIC_LOCK(%rdi)

Home | Main Index | Thread Index | Old Index