Sat Oct 8 08:19:22 2016 UTC ()
Sign extend VA for cache operations.

OK matt@


(skrll)
diff -r1.18 -r1.19 src/sys/arch/mips/mips/mips_fixup.c

cvs diff -r1.18 -r1.19 src/sys/arch/mips/mips/mips_fixup.c (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips_fixup.c 2016/08/18 19:25:34 1.18
+++ src/sys/arch/mips/mips/mips_fixup.c 2016/10/08 08:19:22 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mips_fixup.c,v 1.18 2016/08/18 19:25:34 skrll Exp $ */ 1/* $NetBSD: mips_fixup.c,v 1.19 2016/10/08 08:19:22 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry. 8 * by Matt Thomas of 3am Software Foundry.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: mips_fixup.c,v 1.18 2016/08/18 19:25:34 skrll Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: mips_fixup.c,v 1.19 2016/10/08 08:19:22 skrll Exp $");
34 34
35#include "opt_mips3_wired.h" 35#include "opt_mips3_wired.h"
36#include "opt_multiprocessor.h" 36#include "opt_multiprocessor.h"
37#include <sys/param.h> 37#include <sys/param.h>
38 38
39#include <uvm/uvm_extern.h> 39#include <uvm/uvm_extern.h>
40 40
41#include <mips/locore.h> 41#include <mips/locore.h>
42#include <mips/cache.h> 42#include <mips/cache.h>
43#include <mips/mips3_pte.h> 43#include <mips/mips3_pte.h>
44#include <mips/regnum.h> 44#include <mips/regnum.h>
45#include <mips/mips_opcode.h> 45#include <mips/mips_opcode.h>
46 46
@@ -147,27 +147,27 @@ mips_fixup_exceptions(mips_fixup_callbac @@ -147,27 +147,27 @@ mips_fixup_exceptions(mips_fixup_callbac
147 } 147 }
148 } else if (INSN_LOAD_P(insn)) { 148 } else if (INSN_LOAD_P(insn)) {
149 /* 149 /*
150 * If we are loading the register used in the LUI, 150 * If we are loading the register used in the LUI,
151 * then that LUI is meaningless now. 151 * then that LUI is meaningless now.
152 */ 152 */
153 size_t rt = (insn >> 16) & 31; 153 size_t rt = (insn >> 16) & 31;
154 if (lui_reg == rt) 154 if (lui_reg == rt)
155 lui_insn = 0; 155 lui_insn = 0;
156 } 156 }
157 } 157 }
158 158
159 if (fixed) 159 if (fixed)
160 mips_icache_sync_range((vaddr_t)start, 160 mips_icache_sync_range((intptr_t)start,
161 sizeof(start[0]) * (end - start)); 161 sizeof(start[0]) * (end - start));
162 162
163 return fixed; 163 return fixed;
164} 164}
165 165
166#ifdef MIPS3_PLUS 166#ifdef MIPS3_PLUS
167bool 167bool
168mips_fixup_zero_relative(int32_t load_addr, uint32_t new_insns[2], void *arg) 168mips_fixup_zero_relative(int32_t load_addr, uint32_t new_insns[2], void *arg)
169{ 169{
170 struct cpu_info * const ci = curcpu(); 170 struct cpu_info * const ci = curcpu();
171 struct pmap_tlb_info * const ti = ci->ci_tlb_info; 171 struct pmap_tlb_info * const ti = ci->ci_tlb_info;
172 172
173 KASSERT(MIPS_KSEG0_P(load_addr)); 173 KASSERT(MIPS_KSEG0_P(load_addr));
@@ -481,27 +481,27 @@ mips_fixup_stubs(uint32_t *start, uint32 @@ -481,27 +481,27 @@ mips_fixup_stubs(uint32_t *start, uint32
481 .jfi_stub = fixup_addr2offset(stubp), 481 .jfi_stub = fixup_addr2offset(stubp),
482 .jfi_real = fixup_addr2offset(real_addr), 482 .jfi_real = fixup_addr2offset(real_addr),
483 }; 483 };
484 484
485 fixup_mips_jump(insnp, &fixup); 485 fixup_mips_jump(insnp, &fixup);
486#ifdef DEBUG 486#ifdef DEBUG
487 fixups_done++; 487 fixups_done++;
488#endif 488#endif
489 } 489 }
490 490
491 if (sizeof(uint32_t [end - start]) > mips_cache_info.mci_picache_size) 491 if (sizeof(uint32_t [end - start]) > mips_cache_info.mci_picache_size)
492 mips_icache_sync_all(); 492 mips_icache_sync_all();
493 else 493 else
494 mips_icache_sync_range((vaddr_t)start, 494 mips_icache_sync_range((intptr_t)start,
495 sizeof(uint32_t [end - start])); 495 sizeof(uint32_t [end - start]));
496 496
497#ifdef DEBUG 497#ifdef DEBUG
498#if (MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 498#if (MIPS3 + MIPS4 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
499 if (CPUISMIPS3) 499 if (CPUISMIPS3)
500 cycles = mips3_cp0_count_read() - cycles; 500 cycles = mips3_cp0_count_read() - cycles;
501#endif 501#endif
502 printf("%s: %zu fixup%s done in %u cycles\n", __func__, 502 printf("%s: %zu fixup%s done in %u cycles\n", __func__,
503 fixups_done, fixups_done == 1 ? "" : "s", 503 fixups_done, fixups_done == 1 ? "" : "s",
504 cycles); 504 cycles);
505#endif 505#endif
506} 506}
507 507