diff options
author | David S. Miller <davem@davemloft.net> | 2006-01-31 21:34:51 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-03-20 04:11:29 -0500 |
commit | 86b818687d4894063ecd1190e54717a0cce8c009 (patch) | |
tree | d2951295358502c88f7fe0c02517d729cff4eb9a /include/asm-sparc64 | |
parent | 9954863975910a1b9372b7d5006a6cba43bdd288 (diff) |
[SPARC64]: Fix race in LOAD_PER_CPU_BASE()
Since we use %g5 itself as a temporary, it can get clobbered
if we take an interrupt mid-stream and thus cause end up with
the final %g5 value too early as a result of rtrap processing.
Set %g5 at the very end, atomically, to avoid this problem.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-sparc64')
-rw-r--r-- | include/asm-sparc64/cpudata.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/include/asm-sparc64/cpudata.h b/include/asm-sparc64/cpudata.h index 16d628913837..f83768883e98 100644 --- a/include/asm-sparc64/cpudata.h +++ b/include/asm-sparc64/cpudata.h | |||
@@ -101,20 +101,25 @@ extern void setup_tba(void); | |||
101 | ldx [%g1 + %g6], %g6; | 101 | ldx [%g1 + %g6], %g6; |
102 | 102 | ||
103 | /* Given the current thread info pointer in %g6, load the per-cpu | 103 | /* Given the current thread info pointer in %g6, load the per-cpu |
104 | * area base of the current processor into %g5. REG1 and REG2 are | 104 | * area base of the current processor into %g5. REG1, REG2, and REG3 are |
105 | * clobbered. | 105 | * clobbered. |
106 | * | ||
107 | * You absolutely cannot use %g5 as a temporary in this code. The | ||
108 | * reason is that traps can happen during execution, and return from | ||
109 | * trap will load the fully resolved %g5 per-cpu base. This can corrupt | ||
110 | * the calculations done by the macro mid-stream. | ||
106 | */ | 111 | */ |
107 | #ifdef CONFIG_SMP | 112 | #ifdef CONFIG_SMP |
108 | #define LOAD_PER_CPU_BASE(REG1, REG2) \ | 113 | #define LOAD_PER_CPU_BASE(REG1, REG2, REG3) \ |
109 | ldub [%g6 + TI_CPU], REG1; \ | 114 | ldub [%g6 + TI_CPU], REG1; \ |
110 | sethi %hi(__per_cpu_shift), %g5; \ | 115 | sethi %hi(__per_cpu_shift), REG3; \ |
111 | sethi %hi(__per_cpu_base), REG2; \ | 116 | sethi %hi(__per_cpu_base), REG2; \ |
112 | ldx [%g5 + %lo(__per_cpu_shift)], %g5; \ | 117 | ldx [REG3 + %lo(__per_cpu_shift)], REG3; \ |
113 | ldx [REG2 + %lo(__per_cpu_base)], REG2; \ | 118 | ldx [REG2 + %lo(__per_cpu_base)], REG2; \ |
114 | sllx REG1, %g5, %g5; \ | 119 | sllx REG1, REG3, REG3; \ |
115 | add %g5, REG2, %g5; | 120 | add REG3, REG2, %g5; |
116 | #else | 121 | #else |
117 | #define LOAD_PER_CPU_BASE(REG1, REG2) | 122 | #define LOAD_PER_CPU_BASE(REG1, REG2, REG3) |
118 | #endif | 123 | #endif |
119 | 124 | ||
120 | #endif /* _SPARC64_CPUDATA_H */ | 125 | #endif /* _SPARC64_CPUDATA_H */ |