git: ffcb2897471b - stable/13 - kasan: provide bus peek/poke definitions

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Wed, 02 Nov 2022 17:03:06 UTC
The branch stable/13 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=ffcb2897471b8971c62dedbde0caaca9396fb618

commit ffcb2897471b8971c62dedbde0caaca9396fb618
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-09-26 19:24:21 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-11-02 17:02:24 +0000

    kasan: provide bus peek/poke definitions
    
    Reviewed by:    andrew, markj
    Sponsored by:   Juniper Networks, Inc.
    Sponsored by:   Klara, Inc.
    
    (cherry picked from commit 818cae0ff7527f39ef5efe1180de3e6461fff93c)
---
 sys/kern/subr_asan.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c
index cf7c27c9c418..70f7e11ef8f6 100644
--- a/sys/kern/subr_asan.c
+++ b/sys/kern/subr_asan.c
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_asan.c,v 1.26 2020/09/10 14:10:46 maxv Exp $");
 #include <sys/sysctl.h>
 
 #include <machine/asan.h>
+#include <machine/bus.h>
 
 /* ASAN constants. Part of the compiler ABI. */
 #define KASAN_SHADOW_MASK		(KASAN_SHADOW_SCALE - 1)
@@ -930,6 +931,32 @@ ASAN_BUS_SET_FUNC(region, 4, uint32_t)
 ASAN_BUS_SET_FUNC(multi_stream, 4, uint32_t)
 ASAN_BUS_SET_FUNC(region_stream, 4, uint32_t)
 
+#define	ASAN_BUS_PEEK_FUNC(width, type)					\
+	int kasan_bus_space_peek_##width(bus_space_tag_t tag,		\
+	    bus_space_handle_t hnd, bus_size_t offset, type *valuep)	\
+	{								\
+		return (bus_space_peek_##width(tag, hnd, offset,	\
+		    valuep));						\
+	}
+
+ASAN_BUS_PEEK_FUNC(1, uint8_t)
+ASAN_BUS_PEEK_FUNC(2, uint16_t)
+ASAN_BUS_PEEK_FUNC(4, uint32_t)
+ASAN_BUS_PEEK_FUNC(8, uint64_t)
+
+#define	ASAN_BUS_POKE_FUNC(width, type)					\
+	int kasan_bus_space_poke_##width(bus_space_tag_t tag,		\
+	    bus_space_handle_t hnd, bus_size_t offset, type value)	\
+	{								\
+		return (bus_space_poke_##width(tag, hnd, offset,	\
+		    value));						\
+	}
+
+ASAN_BUS_POKE_FUNC(1, uint8_t)
+ASAN_BUS_POKE_FUNC(2, uint16_t)
+ASAN_BUS_POKE_FUNC(4, uint32_t)
+ASAN_BUS_POKE_FUNC(8, uint64_t)
+
 /* -------------------------------------------------------------------------- */
 
 void __asan_register_globals(struct __asan_global *, size_t);