aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadav Amit <namit@vmware.com>2017-11-24 22:29:06 -0500
committerThomas Gleixner <tglx@linutronix.de>2017-11-25 07:28:43 -0500
commit0c3292ca8025c5aef44dc389ac3a6bf4a325e0be (patch)
tree1291f883a1b0905beba720250956ba29fbe036e0
parent12a78d43de767eaf8fb272facb7a7b6f2dc6a9df (diff)
x86/tlb: Refactor CR4 setting and shadow write
Refactor the write to CR4 and its shadow value. This is done in preparation for the addition of an assertion to check that IRQs are disabled during CR4 update. No functional change. Signed-off-by: Nadav Amit <namit@vmware.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: nadav.amit@gmail.com Cc: Andy Lutomirski <luto@kernel.org> Cc: linux-edac@vger.kernel.org Link: https://lkml.kernel.org/r/20171125032907.2241-2-namit@vmware.com
-rw-r--r--arch/x86/include/asm/tlbflush.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index 509046cfa5ce..e736f7f0ba92 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -173,17 +173,20 @@ static inline void cr4_init_shadow(void)
173 this_cpu_write(cpu_tlbstate.cr4, __read_cr4()); 173 this_cpu_write(cpu_tlbstate.cr4, __read_cr4());
174} 174}
175 175
176static inline void __cr4_set(unsigned long cr4)
177{
178 this_cpu_write(cpu_tlbstate.cr4, cr4);
179 __write_cr4(cr4);
180}
181
176/* Set in this cpu's CR4. */ 182/* Set in this cpu's CR4. */
177static inline void cr4_set_bits(unsigned long mask) 183static inline void cr4_set_bits(unsigned long mask)
178{ 184{
179 unsigned long cr4; 185 unsigned long cr4;
180 186
181 cr4 = this_cpu_read(cpu_tlbstate.cr4); 187 cr4 = this_cpu_read(cpu_tlbstate.cr4);
182 if ((cr4 | mask) != cr4) { 188 if ((cr4 | mask) != cr4)
183 cr4 |= mask; 189 __cr4_set(cr4 | mask);
184 this_cpu_write(cpu_tlbstate.cr4, cr4);
185 __write_cr4(cr4);
186 }
187} 190}
188 191
189/* Clear in this cpu's CR4. */ 192/* Clear in this cpu's CR4. */
@@ -192,11 +195,8 @@ static inline void cr4_clear_bits(unsigned long mask)
192 unsigned long cr4; 195 unsigned long cr4;
193 196
194 cr4 = this_cpu_read(cpu_tlbstate.cr4); 197 cr4 = this_cpu_read(cpu_tlbstate.cr4);
195 if ((cr4 & ~mask) != cr4) { 198 if ((cr4 & ~mask) != cr4)
196 cr4 &= ~mask; 199 __cr4_set(cr4 & ~mask);
197 this_cpu_write(cpu_tlbstate.cr4, cr4);
198 __write_cr4(cr4);
199 }
200} 200}
201 201
202static inline void cr4_toggle_bits(unsigned long mask) 202static inline void cr4_toggle_bits(unsigned long mask)
@@ -204,9 +204,7 @@ static inline void cr4_toggle_bits(unsigned long mask)
204 unsigned long cr4; 204 unsigned long cr4;
205 205
206 cr4 = this_cpu_read(cpu_tlbstate.cr4); 206 cr4 = this_cpu_read(cpu_tlbstate.cr4);
207 cr4 ^= mask; 207 __cr4_set(cr4 ^ mask);
208 this_cpu_write(cpu_tlbstate.cr4, cr4);
209 __write_cr4(cr4);
210} 208}
211 209
212/* Read the CR4 shadow. */ 210/* Read the CR4 shadow. */