OSDN Git Service

i386: fix setCx86/getCx86 race in macros
authorWilly Tarreau <w@1wt.eu>
Sun, 10 Feb 2008 21:52:35 +0000 (22:52 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 10 Feb 2008 21:54:44 +0000 (22:54 +0100)
Because of the way the setCx86 macro is defined, a call to
setCx86(XXXX, getCx86(XXXX)) will produce the wrong output sequence.
This affects at least one place in arch/i386/kernel/setup.c :

/* Enable MMX extensions (App note 108) */
setCx86(CX86_CCR7, getCx86(CX86_CCR7)|1);

A correct solution consists in passing the value argument via a
temporary variable. 2.6 has a different fix using inline functions,
which produce equivalent code though.

Signed-off-by: Willy Tarreau <w@1wt.eu>
include/asm-i386/processor.h

index 81afef2..914c191 100644 (file)
@@ -234,8 +234,9 @@ static inline void clear_in_cr4 (unsigned long mask)
 #define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
 
 #define setCx86(reg, data) do { \
+       unsigned char _tmp_data = (data); \
        outb((reg), 0x22); \
-       outb((data), 0x23); \
+       outb(_tmp_data, 0x23); \
 } while (0)
 
 /*