Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178377424
D59954.1796620131.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
D59954.1796620131.diff
View Options
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd.h
@@ -54,4 +54,18 @@
#define simd_stat_init() do {} while (0)
#define simd_stat_fini() do {} while (0)
+/*
+ * Hand-written assembly routines write their results through pointers that
+ * the compiler never sees, so KMSAN cannot tell that the destination has been
+ * initialized and would report a false positive on the first read of it.
+ * Wrappers around such routines use this to mark the output buffer initialized.
+ *
+ * This is only needed for separately assembled .S code. Inline asm should
+ * instead describe its destination with an "=m" output operand, which the
+ * compiler turns into an unpoison call automatically.
+ */
+#include <sys/msan.h>
+#define kmsan_unpoison_memory(ptr, size) \
+ kmsan_mark((ptr), (size), KMSAN_STATE_INITED)
+
#endif
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/simd.h b/sys/contrib/openzfs/include/os/linux/spl/sys/simd.h
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/simd.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/simd.h
@@ -27,5 +27,6 @@
#include <sys/isa_defs.h>
#include <linux/simd.h>
+#include <linux/kmsan-checks.h>
#endif /* _SPL_SYS_SIMD_H */
diff --git a/sys/contrib/openzfs/lib/libspl/include/sys/simd.h b/sys/contrib/openzfs/lib/libspl/include/sys/simd.h
--- a/sys/contrib/openzfs/lib/libspl/include/sys/simd.h
+++ b/sys/contrib/openzfs/lib/libspl/include/sys/simd.h
@@ -622,6 +622,8 @@
#endif
+#define kmsan_unpoison_memory(p, c) do {} while (0)
+
extern void simd_stat_init(void);
extern void simd_stat_fini(void);
diff --git a/sys/contrib/openzfs/module/icp/algs/blake3/blake3_impl.c b/sys/contrib/openzfs/module/icp/algs/blake3/blake3_impl.c
--- a/sys/contrib/openzfs/module/icp/algs/blake3/blake3_impl.c
+++ b/sys/contrib/openzfs/module/icp/algs/blake3/blake3_impl.c
@@ -48,6 +48,7 @@
zfs_blake3_compress_in_place_sse2(cv, block, block_len, counter,
flags);
kfpu_end();
+ kmsan_unpoison_memory(cv, 8 * sizeof (*cv));
}
static void blake3_compress_xof_sse2(const uint32_t cv[8],
@@ -57,6 +58,7 @@
zfs_blake3_compress_xof_sse2(cv, block, block_len, counter, flags,
out);
kfpu_end();
+ kmsan_unpoison_memory(out, 64);
}
static void blake3_hash_many_sse2(const uint8_t * const *inputs,
@@ -67,6 +69,7 @@
zfs_blake3_hash_many_sse2(inputs, num_inputs, blocks, key, counter,
increment_counter, flags, flags_start, flags_end, out);
kfpu_end();
+ kmsan_unpoison_memory(out, num_inputs * BLAKE3_OUT_LEN);
}
static boolean_t blake3_is_sse2_supported(void)
@@ -112,6 +115,7 @@
zfs_blake3_compress_in_place_sse41(cv, block, block_len, counter,
flags);
kfpu_end();
+ kmsan_unpoison_memory(cv, 8 * sizeof (*cv));
}
static void blake3_compress_xof_sse41(const uint32_t cv[8],
@@ -121,6 +125,7 @@
zfs_blake3_compress_xof_sse41(cv, block, block_len, counter, flags,
out);
kfpu_end();
+ kmsan_unpoison_memory(out, 64);
}
static void blake3_hash_many_sse41(const uint8_t * const *inputs,
@@ -131,6 +136,7 @@
zfs_blake3_hash_many_sse41(inputs, num_inputs, blocks, key, counter,
increment_counter, flags, flags_start, flags_end, out);
kfpu_end();
+ kmsan_unpoison_memory(out, num_inputs * BLAKE3_OUT_LEN);
}
static boolean_t blake3_is_sse41_supported(void)
@@ -168,6 +174,7 @@
zfs_blake3_hash_many_avx2(inputs, num_inputs, blocks, key, counter,
increment_counter, flags, flags_start, flags_end, out);
kfpu_end();
+ kmsan_unpoison_memory(out, num_inputs * BLAKE3_OUT_LEN);
}
static boolean_t blake3_is_avx2_supported(void)
@@ -208,6 +215,7 @@
zfs_blake3_compress_in_place_avx512(cv, block, block_len, counter,
flags);
kfpu_end();
+ kmsan_unpoison_memory(cv, 8 * sizeof (*cv));
}
static void blake3_compress_xof_avx512(const uint32_t cv[8],
@@ -217,6 +225,7 @@
zfs_blake3_compress_xof_avx512(cv, block, block_len, counter, flags,
out);
kfpu_end();
+ kmsan_unpoison_memory(out, 64);
}
static void blake3_hash_many_avx512(const uint8_t * const *inputs,
@@ -227,6 +236,7 @@
zfs_blake3_hash_many_avx512(inputs, num_inputs, blocks, key, counter,
increment_counter, flags, flags_start, flags_end, out);
kfpu_end();
+ kmsan_unpoison_memory(out, num_inputs * BLAKE3_OUT_LEN);
}
static boolean_t blake3_is_avx512_supported(void)
diff --git a/sys/contrib/openzfs/module/icp/algs/sha2/sha256_impl.c b/sys/contrib/openzfs/module/icp/algs/sha2/sha256_impl.c
--- a/sys/contrib/openzfs/module/icp/algs/sha2/sha256_impl.c
+++ b/sys/contrib/openzfs/module/icp/algs/sha2/sha256_impl.c
@@ -26,6 +26,7 @@
extern void ASMABI E(uint32_t s[8], const void *, size_t); \
static inline void N(uint32_t s[8], const void *d, size_t b) { \
kfpu_begin(); E(s, d, b); kfpu_end(); \
+ kmsan_unpoison_memory(s, 8 * sizeof (*s)); \
}
#if defined(__x86_64) || defined(__aarch64__) || defined(__arm__) || \
@@ -47,6 +48,7 @@
tf_sha256_transform_x64(uint32_t s[8], const void *d, size_t b)
{
zfs_sha256_transform_x64(s, d, b);
+ kmsan_unpoison_memory(s, 8 * sizeof (*s));
}
const sha256_ops_t sha256_x64_impl = {
diff --git a/sys/contrib/openzfs/module/icp/algs/sha2/sha512_impl.c b/sys/contrib/openzfs/module/icp/algs/sha2/sha512_impl.c
--- a/sys/contrib/openzfs/module/icp/algs/sha2/sha512_impl.c
+++ b/sys/contrib/openzfs/module/icp/algs/sha2/sha512_impl.c
@@ -27,6 +27,7 @@
extern void ASMABI E(uint64_t s[8], const void *, size_t); \
static inline void N(uint64_t s[8], const void *d, size_t b) { \
kfpu_begin(); E(s, d, b); kfpu_end(); \
+ kmsan_unpoison_memory(s, 8 * sizeof (*s)); \
}
#if defined(__x86_64) || defined(__aarch64__) || defined(__arm__) || \
@@ -48,6 +49,7 @@
tf_sha512_transform_x64(uint64_t s[8], const void *d, size_t b)
{
zfs_sha512_transform_x64(s, d, b);
+ kmsan_unpoison_memory(s, 8 * sizeof (*s));
}
const sha512_ops_t sha512_x64_impl = {
.is_supported = sha2_is_supported,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 7, 5:08 AM (18 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42272735
Default Alt Text
D59954.1796620131.diff (5 KB)
Attached To
Mode
D59954: zfs: avoid false KMSAN reports for functions in .S files.
Attached
Detach File
Event Timeline