Sun Dec 8 14:37:29 2019 UTC ()
Pull up following revision(s) (requested by jmcneill in ticket #513):

	sys/arch/aarch64/aarch64/kobj_machdep.c: revision 1.3

Flush insn / data caches after loading modules


(martin)
diff -r1.2 -r1.2.8.1 src/sys/arch/aarch64/aarch64/kobj_machdep.c

cvs diff -r1.2 -r1.2.8.1 src/sys/arch/aarch64/aarch64/kobj_machdep.c (expand / switch to unified diff)

--- src/sys/arch/aarch64/aarch64/kobj_machdep.c 2018/08/19 20:02:22 1.2
+++ src/sys/arch/aarch64/aarch64/kobj_machdep.c 2019/12/08 14:37:29 1.2.8.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kobj_machdep.c,v 1.2 2018/08/19 20:02:22 ryo Exp $ */ 1/* $NetBSD: kobj_machdep.c,v 1.2.8.1 2019/12/08 14:37:29 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2018 Ryo Shimizu <ryo@nerv.org> 4 * Copyright (c) 2018 Ryo Shimizu <ryo@nerv.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,39 +17,41 @@ @@ -17,39 +17,41 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.2 2018/08/19 20:02:22 ryo Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.2.8.1 2019/12/08 14:37:29 martin Exp $");
31 31
32#define ELFSIZE ARCH_ELFSIZE 32#define ELFSIZE ARCH_ELFSIZE
33 33
34#include "opt_ddb.h" 34#include "opt_ddb.h"
35 35
36#include <sys/param.h> 36#include <sys/param.h>
 37#include <sys/kernel.h>
37#include <sys/kobj.h> 38#include <sys/kobj.h>
38#include <sys/exec.h> 39#include <sys/exec.h>
39#include <sys/exec_elf.h> 40#include <sys/exec_elf.h>
40#include <sys/errno.h> 41#include <sys/errno.h>
41#include <sys/queue.h> 42#include <sys/queue.h>
42#include <sys/tree.h> 43#include <sys/tree.h>
 44#include <sys/xcall.h>
43 45
44#include <aarch64/cpufunc.h> 46#include <aarch64/cpufunc.h>
45 47
46/* #define KOBJ_MACHDEP_DEBUG */ 48/* #define KOBJ_MACHDEP_DEBUG */
47 49
48#ifdef KOBJ_MACHDEP_DEBUG 50#ifdef KOBJ_MACHDEP_DEBUG
49#ifdef DDB 51#ifdef DDB
50#include <aarch64/db_machdep.h> /* for strdisasm() */ 52#include <aarch64/db_machdep.h> /* for strdisasm() */
51#endif 53#endif
52 54
53struct rtypeinfo { 55struct rtypeinfo {
54 Elf_Word rtype; 56 Elf_Word rtype;
55 const char *name; 57 const char *name;
@@ -347,18 +349,36 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas @@ -347,18 +349,36 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
347 printf("%s: insn %s\n", __func__, disasmbuf); 349 printf("%s: insn %s\n", __func__, disasmbuf);
348 printf("%s: -> %08x %s\n", __func__, 350 printf("%s: -> %08x %s\n", __func__,
349 *insn, strdisasm((vaddr_t)insn)); 351 *insn, strdisasm((vaddr_t)insn));
350#endif 352#endif
351 printf("\n"); 353 printf("\n");
352#endif /* KOBJ_MACHDEP_DEBUG */ 354#endif /* KOBJ_MACHDEP_DEBUG */
353 355
354 done: 356 done:
355 if (error != 0) 357 if (error != 0)
356 return -1; 358 return -1;
357 return 0; 359 return 0;
358} 360}
359 361
 362static void
 363kobj_idcache_wbinv_all(void)
 364{
 365 cpu_idcache_wbinv_all();
 366}
 367
360int 368int
361kobj_machdep(kobj_t ko, void *base, size_t size, bool load) 369kobj_machdep(kobj_t ko, void *base, size_t size, bool load)
362{ 370{
 371 uint64_t where;
 372
 373 if (load) {
 374 if (cold) {
 375 kobj_idcache_wbinv_all();
 376 } else {
 377 where = xc_broadcast(0,
 378 (xcfunc_t)kobj_idcache_wbinv_all, NULL, NULL);
 379 xc_wait(where);
 380 }
 381 }
 382
363 return 0; 383 return 0;
364} 384}