Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Fix KASAN on aarch64: the bus_space_* functions are macr...



details:   https://anonhg.NetBSD.org/src/rev/aa82628595cb
branches:  trunk
changeset: 454577:aa82628595cb
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Sep 22 10:35:12 2019 +0000

description:
Fix KASAN on aarch64: the bus_space_* functions are macros, so we can't
redefine them. Introduce __HAVE_KASAN_INSTR_BUS, which indicates whether
to instrument the bus functions. Defined on amd64 only.

diffstat:

 sys/arch/amd64/include/types.h |  5 ++++-
 sys/kern/subr_asan.c           |  8 ++++++--
 sys/sys/bus_proto.h            |  6 +++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diffs (82 lines):

diff -r c4eff98dbdb3 -r aa82628595cb sys/arch/amd64/include/types.h
--- a/sys/arch/amd64/include/types.h    Sun Sep 22 09:54:56 2019 +0000
+++ b/sys/arch/amd64/include/types.h    Sun Sep 22 10:35:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.60 2019/04/06 03:06:24 thorpej Exp $       */
+/*     $NetBSD: types.h,v 1.61 2019/09/22 10:35:12 maxv Exp $  */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -103,6 +103,9 @@
 
 #include "opt_xen.h"
 #include "opt_kasan.h"
+#ifdef KASAN
+#define __HAVE_KASAN_INSTR_BUS
+#endif
 #if defined(__x86_64__) && !defined(XENPV)
 #if !defined(KASAN)
 #define        __HAVE_PCPU_AREA 1
diff -r c4eff98dbdb3 -r aa82628595cb sys/kern/subr_asan.c
--- a/sys/kern/subr_asan.c      Sun Sep 22 09:54:56 2019 +0000
+++ b/sys/kern/subr_asan.c      Sun Sep 22 10:35:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_asan.c,v 1.13 2019/09/07 10:24:01 maxv Exp $      */
+/*     $NetBSD: subr_asan.c,v 1.14 2019/09/22 10:35:12 maxv Exp $      */
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_asan.c,v 1.13 2019/09/07 10:24:01 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_asan.c,v 1.14 2019/09/22 10:35:12 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -781,6 +781,8 @@
 
 /* -------------------------------------------------------------------------- */
 
+#ifdef __HAVE_KASAN_INSTR_BUS
+
 #include <sys/bus.h>
 
 #undef bus_space_read_multi_1
@@ -926,6 +928,8 @@
 ASAN_BUS_WRITE_FUNC(4, 32)
 ASAN_BUS_WRITE_FUNC(8, 64)
 
+#endif /* __HAVE_KASAN_INSTR_BUS */
+
 /* -------------------------------------------------------------------------- */
 
 void __asan_register_globals(struct __asan_global *, size_t);
diff -r c4eff98dbdb3 -r aa82628595cb sys/sys/bus_proto.h
--- a/sys/sys/bus_proto.h       Sun Sep 22 09:54:56 2019 +0000
+++ b/sys/sys/bus_proto.h       Sun Sep 22 10:35:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_proto.h,v 1.8 2019/09/07 10:24:01 maxv Exp $       */
+/*     $NetBSD: bus_proto.h,v 1.9 2019/09/22 10:35:12 maxv Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2001, 2007 The NetBSD Foundation, Inc.
@@ -132,7 +132,7 @@
 uint64_t bus_space_read_stream_8(bus_space_tag_t, bus_space_handle_t,
                                 bus_size_t);
 
-#ifdef KASAN
+#if defined(KASAN) && defined(__HAVE_KASAN_INSTR_BUS)
 #define BUS_SPACE_READ_MEM_PROTOS(bytes, bits)                                 \
 void kasan_bus_space_read_multi_##bytes(bus_space_tag_t, bus_space_handle_t,   \
     bus_size_t, uint##bits##_t *, bus_size_t);                                 \
@@ -195,7 +195,7 @@
 void   bus_space_write_stream_8(bus_space_tag_t, bus_space_handle_t,
                                 bus_size_t, uint64_t);
 
-#ifdef KASAN
+#if defined(KASAN) && defined(__HAVE_KASAN_INSTR_BUS)
 #define BUS_SPACE_WRITE_MEM_PROTOS(bytes, bits)                                        \
 void kasan_bus_space_write_multi_##bytes(bus_space_tag_t, bus_space_handle_t,  \
     bus_size_t, const uint##bits##_t *, bus_size_t);                           \



Home | Main Index | Thread Index | Old Index