1 /* $NetBSD: msan.h,v 1.2 2020/09/09 16:29:59 maxv Exp $ */
4 * Copyright (c) 2019-2020 Maxime Villard, m00nbsd.net
7 * This code is part of the KMSAN subsystem of the NetBSD kernel.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/_bus_dma.h>
36 #include <sys/types.h>
38 #define KMSAN_STATE_UNINIT 0xFF
39 #define KMSAN_STATE_INITED 0x00
41 #define KMSAN_TYPE_STACK 0
42 #define KMSAN_TYPE_KMEM 1
43 #define KMSAN_TYPE_MALLOC 2
44 #define KMSAN_TYPE_UMA 3
45 #define KMSAN_TYPE_MAX 3
47 #define KMSAN_RET_ADDR (uintptr_t)__builtin_return_address(0)
54 void kmsan_init(void);
56 void kmsan_shadow_map(vm_offset_t, size_t);
58 void kmsan_thread_alloc(struct thread *);
59 void kmsan_thread_free(struct thread *);
61 void kmsan_bus_dmamap_sync(struct memdesc *, bus_dmasync_op_t);
63 void kmsan_orig(const void *, size_t, int, uintptr_t);
64 void kmsan_mark(const void *, size_t, uint8_t);
65 void kmsan_mark_bio(const struct bio *, uint8_t);
66 void kmsan_mark_mbuf(const struct mbuf *, uint8_t);
68 void kmsan_check(const void *, size_t, const char *);
69 void kmsan_check_bio(const struct bio *, const char *);
70 void kmsan_check_ccb(const union ccb *, const char *);
71 void kmsan_check_mbuf(const struct mbuf *, const char *);
75 #define kmsan_shadow_map(a, s)
76 #define kmsan_thread_alloc(td)
77 #define kmsan_thread_free(l)
78 #define kmsan_dma_sync(m, a, s, o)
79 #define kmsan_dma_load(m, b, s, o)
80 #define kmsan_orig(p, l, c, a)
81 #define kmsan_mark(p, l, c)
82 #define kmsan_mark_bio(b, c)
83 #define kmsan_mark_mbuf(m, c)
84 #define kmsan_check(b, s, d)
85 #define kmsan_check_bio(b, d)
86 #define kmsan_check_ccb(c, d)
87 #define kmsan_check_mbuf(m, d)
88 #define kmsan_bus_dmamap_sync(d, op)
91 #endif /* !_SYS_MSAN_H_ */