Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[MIPS] IP28: added cache barrier to assembly routines

IP28 needs special treatment to avoid speculative accesses. gcc
takes care for .c code, but for assembly code we need to do it
manually.

This is taken from Peter Fuersts IP28 patches.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Thomas Bogendoerfer and committed by
Ralf Baechle
930bff88 2064ba23

+24
+10
arch/mips/lib/memcpy.S
··· 199 199 */ 200 200 #define rem t8 201 201 202 + R10KCBARRIER(0(ra)) 202 203 /* 203 204 * The "issue break"s below are very approximate. 204 205 * Issue delays for dcache fills will perturb the schedule, as will ··· 232 231 PREF( 1, 3*32(dst) ) 233 232 .align 4 234 233 1: 234 + R10KCBARRIER(0(ra)) 235 235 EXC( LOAD t0, UNIT(0)(src), l_exc) 236 236 EXC( LOAD t1, UNIT(1)(src), l_exc_copy) 237 237 EXC( LOAD t2, UNIT(2)(src), l_exc_copy) ··· 274 272 EXC( LOAD t3, UNIT(3)(src), l_exc_copy) 275 273 SUB len, len, 4*NBYTES 276 274 ADD src, src, 4*NBYTES 275 + R10KCBARRIER(0(ra)) 277 276 EXC( STORE t0, UNIT(0)(dst), s_exc_p4u) 278 277 EXC( STORE t1, UNIT(1)(dst), s_exc_p3u) 279 278 EXC( STORE t2, UNIT(2)(dst), s_exc_p2u) ··· 290 287 beq rem, len, copy_bytes 291 288 nop 292 289 1: 290 + R10KCBARRIER(0(ra)) 293 291 EXC( LOAD t0, 0(src), l_exc) 294 292 ADD src, src, NBYTES 295 293 SUB len, len, NBYTES ··· 338 334 EXC( LDREST t3, REST(0)(src), l_exc_copy) 339 335 SUB t2, t2, t1 # t2 = number of bytes copied 340 336 xor match, t0, t1 337 + R10KCBARRIER(0(ra)) 341 338 EXC( STFIRST t3, FIRST(0)(dst), s_exc) 342 339 beq len, t2, done 343 340 SUB len, len, t2 ··· 359 354 * It's OK to load FIRST(N+1) before REST(N) because the two addresses 360 355 * are to the same unit (unless src is aligned, but it's not). 361 356 */ 357 + R10KCBARRIER(0(ra)) 362 358 EXC( LDFIRST t0, FIRST(0)(src), l_exc) 363 359 EXC( LDFIRST t1, FIRST(1)(src), l_exc_copy) 364 360 SUB len, len, 4*NBYTES ··· 390 384 beq rem, len, copy_bytes 391 385 nop 392 386 1: 387 + R10KCBARRIER(0(ra)) 393 388 EXC( LDFIRST t0, FIRST(0)(src), l_exc) 394 389 EXC( LDREST t0, REST(0)(src), l_exc_copy) 395 390 ADD src, src, NBYTES ··· 406 399 nop 407 400 copy_bytes: 408 401 /* 0 < len < NBYTES */ 402 + R10KCBARRIER(0(ra)) 409 403 #define COPY_BYTE(N) \ 410 404 EXC( lb t0, N(src), l_exc); \ 411 405 SUB len, len, 1; \ ··· 536 528 ADD a1, a2 # src = src + len 537 529 538 530 r_end_bytes: 531 + R10KCBARRIER(0(ra)) 539 532 lb t0, -1(a1) 540 533 SUB a2, a2, 0x1 541 534 sb t0, -1(a0) ··· 551 542 move a2, zero 552 543 553 544 r_end_bytes_up: 545 + R10KCBARRIER(0(ra)) 554 546 lb t0, (a1) 555 547 SUB a2, a2, 0x1 556 548 sb t0, (a0)
+5
arch/mips/lib/memset.S
··· 86 86 .set at 87 87 #endif 88 88 89 + R10KCBARRIER(0(ra)) 89 90 #ifdef __MIPSEB__ 90 91 EX(LONG_S_L, a1, (a0), first_fixup) /* make word/dword aligned */ 91 92 #endif ··· 104 103 PTR_ADDU t1, a0 /* end address */ 105 104 .set reorder 106 105 1: PTR_ADDIU a0, 64 106 + R10KCBARRIER(0(ra)) 107 107 f_fill64 a0, -64, a1, fwd_fixup 108 108 bne t1, a0, 1b 109 109 .set noreorder 110 110 111 111 memset_partial: 112 + R10KCBARRIER(0(ra)) 112 113 PTR_LA t1, 2f /* where to start */ 113 114 #if LONGSIZE == 4 114 115 PTR_SUBU t1, t0 ··· 132 129 133 130 beqz a2, 1f 134 131 PTR_ADDU a0, a2 /* What's left */ 132 + R10KCBARRIER(0(ra)) 135 133 #ifdef __MIPSEB__ 136 134 EX(LONG_S_R, a1, -1(a0), last_fixup) 137 135 #endif ··· 147 143 PTR_ADDU t1, a0, a2 148 144 149 145 1: PTR_ADDIU a0, 1 /* fill bytewise */ 146 + R10KCBARRIER(0(ra)) 150 147 bne t1, a0, 1b 151 148 sb a1, -1(a0) 152 149
+1
arch/mips/lib/strncpy_user.S
··· 38 38 .set noreorder 39 39 1: EX(lbu, t0, (v1), fault) 40 40 PTR_ADDIU v1, 1 41 + R10KCBARRIER(0(ra)) 41 42 beqz t0, 2f 42 43 sb t0, (a0) 43 44 PTR_ADDIU v0, 1
+8
include/asm-mips/asm.h
··· 398 398 399 399 #define SSNOP sll zero, zero, 1 400 400 401 + #ifdef CONFIG_SGI_IP28 402 + /* Inhibit speculative stores to volatile (e.g.DMA) or invalid addresses. */ 403 + #include <asm/cacheops.h> 404 + #define R10KCBARRIER(addr) cache Cache_Barrier, addr; 405 + #else 406 + #define R10KCBARRIER(addr) 407 + #endif 408 + 401 409 #endif /* __ASM_ASM_H */