Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Instrument ufetch/ustore in kMSan, these were the last r...
details: https://anonhg.NetBSD.org/src/rev/78c642706b30
branches: trunk
changeset: 461087:78c642706b30
user: maxv <maxv%NetBSD.org@localhost>
date: Fri Nov 15 12:18:46 2019 +0000
description:
Instrument ufetch/ustore in kMSan, these were the last remaining functions.
diffstat:
sys/kern/subr_msan.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++-
sys/sys/systm.h | 39 ++++++++++-
2 files changed, 225 insertions(+), 3 deletions(-)
diffs (277 lines):
diff -r 0276d190ba64 -r 78c642706b30 sys/kern/subr_msan.c
--- a/sys/kern/subr_msan.c Fri Nov 15 09:50:01 2019 +0000
+++ b/sys/kern/subr_msan.c Fri Nov 15 12:18:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_msan.c,v 1.1 2019/11/14 16:23:52 maxv Exp $ */
+/* $NetBSD: subr_msan.c,v 1.2 2019/11/15 12:18:46 maxv Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#define KMSAN_NO_INST
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_msan.c,v 1.1 2019/11/14 16:23:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_msan.c,v 1.2 2019/11/15 12:18:46 maxv Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -870,6 +870,191 @@
/* -------------------------------------------------------------------------- */
+#undef _ucas_32
+#undef _ucas_32_mp
+#undef _ucas_64
+#undef _ucas_64_mp
+#undef _ufetch_8
+#undef _ufetch_16
+#undef _ufetch_32
+#undef _ufetch_64
+#undef _ustore_8
+#undef _ustore_16
+#undef _ustore_32
+#undef _ustore_64
+
+int _ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
+int kmsan__ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
+int
+kmsan__ucas_32(volatile uint32_t *uaddr, uint32_t old, uint32_t new,
+ uint32_t *ret)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(old) +
+ sizeof(new) + sizeof(ret), "ucas_32");
+ _ret = _ucas_32(uaddr, old, new, ret);
+ if (_ret == 0)
+ kmsan_shadow_fill(ret, KMSAN_STATE_INITED, sizeof(*ret));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+
+#ifdef __HAVE_UCAS_MP
+int _ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
+int kmsan__ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
+int
+kmsan__ucas_32_mp(volatile uint32_t *uaddr, uint32_t old, uint32_t new,
+ uint32_t *ret)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(old) +
+ sizeof(new) + sizeof(ret), "ucas_32_mp");
+ _ret = _ucas_32_mp(uaddr, old, new, ret);
+ if (_ret == 0)
+ kmsan_shadow_fill(ret, KMSAN_STATE_INITED, sizeof(*ret));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+#endif
+
+#ifdef _LP64
+int _ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
+int kmsan__ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
+int
+kmsan__ucas_64(volatile uint64_t *uaddr, uint64_t old, uint64_t new,
+ uint64_t *ret)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(old) +
+ sizeof(new) + sizeof(ret), "ucas_64");
+ _ret = _ucas_64(uaddr, old, new, ret);
+ if (_ret == 0)
+ kmsan_shadow_fill(ret, KMSAN_STATE_INITED, sizeof(*ret));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+
+#ifdef __HAVE_UCAS_MP
+int _ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
+int kmsan__ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
+int
+kmsan__ucas_64_mp(volatile uint64_t *uaddr, uint64_t old, uint64_t new,
+ uint64_t *ret)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(old) +
+ sizeof(new) + sizeof(ret), "ucas_64_mp");
+ _ret = _ucas_64_mp(uaddr, old, new, ret);
+ if (_ret == 0)
+ kmsan_shadow_fill(ret, KMSAN_STATE_INITED, sizeof(*ret));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+#endif
+#endif
+
+int _ufetch_8(const uint8_t *, uint8_t *);
+int kmsan__ufetch_8(const uint8_t *, uint8_t *);
+int
+kmsan__ufetch_8(const uint8_t *uaddr, uint8_t *valp)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(valp), "ufetch_8");
+ _ret = _ufetch_8(uaddr, valp);
+ if (_ret == 0)
+ kmsan_shadow_fill(valp, KMSAN_STATE_INITED, sizeof(*valp));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+
+int _ufetch_16(const uint16_t *, uint16_t *);
+int kmsan__ufetch_16(const uint16_t *, uint16_t *);
+int
+kmsan__ufetch_16(const uint16_t *uaddr, uint16_t *valp)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(valp), "ufetch_16");
+ _ret = _ufetch_16(uaddr, valp);
+ if (_ret == 0)
+ kmsan_shadow_fill(valp, KMSAN_STATE_INITED, sizeof(*valp));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+
+int _ufetch_32(const uint32_t *, uint32_t *);
+int kmsan__ufetch_32(const uint32_t *, uint32_t *);
+int
+kmsan__ufetch_32(const uint32_t *uaddr, uint32_t *valp)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(valp), "ufetch_32");
+ _ret = _ufetch_32(uaddr, valp);
+ if (_ret == 0)
+ kmsan_shadow_fill(valp, KMSAN_STATE_INITED, sizeof(*valp));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+
+#ifdef _LP64
+int _ufetch_64(const uint64_t *, uint64_t *);
+int kmsan__ufetch_64(const uint64_t *, uint64_t *);
+int
+kmsan__ufetch_64(const uint64_t *uaddr, uint64_t *valp)
+{
+ int _ret;
+ kmsan_check_arg(sizeof(uaddr) + sizeof(valp), "ufetch_64");
+ _ret = _ufetch_64(uaddr, valp);
+ if (_ret == 0)
+ kmsan_shadow_fill(valp, KMSAN_STATE_INITED, sizeof(*valp));
+ kmsan_init_ret(sizeof(int));
+ return _ret;
+}
+#endif
+
+int _ustore_8(uint8_t *, uint8_t);
+int kmsan__ustore_8(uint8_t *, uint8_t);
+int
+kmsan__ustore_8(uint8_t *uaddr, uint8_t val)
+{
+ kmsan_check_arg(sizeof(uaddr) + sizeof(val), "ustore_8");
+ kmsan_init_ret(sizeof(int));
+ return _ustore_8(uaddr, val);
+}
+
+int _ustore_16(uint16_t *, uint16_t);
+int kmsan__ustore_16(uint16_t *, uint16_t);
+int
+kmsan__ustore_16(uint16_t *uaddr, uint16_t val)
+{
+ kmsan_check_arg(sizeof(uaddr) + sizeof(val), "ustore_16");
+ kmsan_init_ret(sizeof(int));
+ return _ustore_16(uaddr, val);
+}
+
+int _ustore_32(uint32_t *, uint32_t);
+int kmsan__ustore_32(uint32_t *, uint32_t);
+int
+kmsan__ustore_32(uint32_t *uaddr, uint32_t val)
+{
+ kmsan_check_arg(sizeof(uaddr) + sizeof(val), "ustore_32");
+ kmsan_init_ret(sizeof(int));
+ return _ustore_32(uaddr, val);
+}
+
+#ifdef _LP64
+int _ustore_64(uint64_t *, uint64_t);
+int kmsan__ustore_64(uint64_t *, uint64_t);
+int
+kmsan__ustore_64(uint64_t *uaddr, uint64_t val)
+{
+ kmsan_check_arg(sizeof(uaddr) + sizeof(val), "ustore_64");
+ kmsan_init_ret(sizeof(int));
+ return _ustore_64(uaddr, val);
+}
+#endif
+
+/* -------------------------------------------------------------------------- */
+
#undef atomic_add_32
#undef atomic_add_int
#undef atomic_add_long
diff -r 0276d190ba64 -r 78c642706b30 sys/sys/systm.h
--- a/sys/sys/systm.h Fri Nov 15 09:50:01 2019 +0000
+++ b/sys/sys/systm.h Fri Nov 15 12:18:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systm.h,v 1.290 2019/11/15 08:11:36 maxv Exp $ */
+/* $NetBSD: systm.h,v 1.291 2019/11/15 12:18:46 maxv Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@@ -46,6 +46,7 @@
#include "opt_kasan.h"
#include "opt_kcsan.h"
#include "opt_kleak.h"
+#include "opt_kmsan.h"
#include "opt_wsdisplay_compat.h"
#endif
#if !defined(_KERNEL) && !defined(_STANDALONE)
@@ -397,6 +398,21 @@
#define _ucas_32_mp kasan__ucas_32_mp
#define _ucas_64 kasan__ucas_64
#define _ucas_64_mp kasan__ucas_64_mp
+#elif defined(KMSAN)
+int kmsan__ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
+#ifdef __HAVE_UCAS_MP
+int kmsan__ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
+#endif /* __HAVE_UCAS_MP */
+#ifdef _LP64
+int kmsan__ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
+#ifdef __HAVE_UCAS_MP
+int kmsan__ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
+#endif /* __HAVE_UCAS_MP */
+#endif /* _LP64 */
+#define _ucas_32 kmsan__ucas_32
+#define _ucas_32_mp kmsan__ucas_32_mp
+#define _ucas_64 kmsan__ucas_64
+#define _ucas_64_mp kmsan__ucas_64_mp
#else
int _ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
#ifdef __HAVE_UCAS_MP
@@ -431,6 +447,27 @@
#define _ufetch_16 kasan__ufetch_16
#define _ufetch_32 kasan__ufetch_32
#define _ufetch_64 kasan__ufetch_64
+#elif defined(KMSAN)
+int kmsan__ufetch_8(const uint8_t *, uint8_t *);
+int kmsan__ufetch_16(const uint16_t *, uint16_t *);
+int kmsan__ufetch_32(const uint32_t *, uint32_t *);
+#ifdef _LP64
+int kmsan__ufetch_64(const uint64_t *, uint64_t *);
+#endif
+int kmsan__ustore_8(uint8_t *, uint8_t);
+int kmsan__ustore_16(uint16_t *, uint16_t);
+int kmsan__ustore_32(uint32_t *, uint32_t);
+#ifdef _LP64
+int kmsan__ustore_64(uint64_t *, uint64_t);
+#endif
+#define _ufetch_8 kmsan__ufetch_8
+#define _ufetch_16 kmsan__ufetch_16
+#define _ufetch_32 kmsan__ufetch_32
+#define _ufetch_64 kmsan__ufetch_64
+#define _ustore_8 kmsan__ustore_8
+#define _ustore_16 kmsan__ustore_16
+#define _ustore_32 kmsan__ustore_32
+#define _ustore_64 kmsan__ustore_64
#else
int _ufetch_8(const uint8_t *, uint8_t *);
int _ufetch_16(const uint16_t *, uint16_t *);
Home |
Main Index |
Thread Index |
Old Index