]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Define an empty __msan_unpoison() without Z_MEMORY_SANITIZER
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 6 Jul 2023 11:49:58 +0000 (13:49 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 16 Jul 2023 10:41:50 +0000 (12:41 +0200)
Currently all the usages of __msan_unpoison() have to be guarded by
"#ifdef Z_MEMORY_SANITIZER". Simplify things by defining an empty
__msan_unpoison() when the code is compiled without MSan.

arch/arm/chunkset_neon.c
arch/s390/dfltcc_detail.h
arch/x86/chunkset_avx2.c
arch/x86/chunkset_ssse3.c
zbuild.h

index 1890c91356ee4be85e7650cc5867bab5bba02de1..7891eabd2a7584d906465a1c9f9a6e11a93cac30 100644 (file)
@@ -68,10 +68,8 @@ static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t
     lut_rem_pair lut_rem = perm_idx_lut[dist - 3];
     *chunk_rem = lut_rem.remval;
 
-#ifdef Z_MEMORY_SANITIZER
     /* See note in chunkset_ssse3.c for why this is ok */
     __msan_unpoison(buf + dist, 16 - dist);
-#endif
 
     /* This version of table is only available on aarch64 */
 #if defined(_M_ARM64) || defined(__aarch64__)
index 354c2f5550fe7d2048a98e5c4b7058e6aed70860..362d94c337fd83e0f5ce9c531afa9bf25b2491ab 100644 (file)
@@ -166,9 +166,7 @@ static inline dfltcc_cc dfltcc(int fn, void *param,
                                unsigned char **op1, size_t *len1,
                                z_const unsigned char **op2, size_t *len2, void *hist) {
     unsigned char *t2 = op1 ? *op1 : NULL;
-#ifdef Z_MEMORY_SANITIZER
     unsigned char *orig_t2 = t2;
-#endif
     size_t t3 = len1 ? *len1 : 0;
     z_const unsigned char *t4 = op2 ? *op2 : NULL;
     size_t t5 = len2 ? *len2 : 0;
@@ -203,7 +201,6 @@ static inline dfltcc_cc dfltcc(int fn, void *param,
                      : "cc", "memory");
     t2 = r2; t3 = r3; t4 = r4; t5 = r5;
 
-#ifdef Z_MEMORY_SANITIZER
     switch (fn & DFLTCC_FN_MASK) {
     case DFLTCC_QAF:
         __msan_unpoison(param, DFLTCC_SIZEOF_QAF);
@@ -220,7 +217,6 @@ static inline dfltcc_cc dfltcc(int fn, void *param,
         __msan_unpoison(orig_t2, t2 - orig_t2);
         break;
     }
-#endif
 
     if (op1)
         *op1 = t2;
index f309878b351ec5bec6b49c1cd1ec18b98c1b15c5..70620b91542ecabc0a839575d8106b7f66e519c6 100644 (file)
@@ -84,10 +84,8 @@ static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t
      * GPRs to begin with the 256 bit load is _probably_ just as inexpensive */
     *chunk_rem = lut_rem.remval;
 
-#ifdef Z_MEMORY_SANITIZER
     /* See note in chunkset_ssse3.c for why this is ok */
     __msan_unpoison(buf + dist, 32 - dist);
-#endif
 
     if (dist < 16) {
         /* This simpler case still requires us to shuffle in 128 bit lanes, so we must apply a static offset after
index 0bd6263859cb42c4aee69ea977b8706f70099df1..c06d1b37bd7e973736d52c0aa41c8edeecb8c9bc 100644 (file)
@@ -68,14 +68,12 @@ static inline void storechunk(uint8_t *out, chunk_t *chunk) {
 static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t dist) {
     lut_rem_pair lut_rem = perm_idx_lut[dist - 3];
     __m128i perm_vec, ret_vec;
-#ifdef Z_MEMORY_SANITIZER
     /* Important to note:
      * This is _not_ to subvert the memory sanitizer but to instead unpoison some
      * bytes we willingly and purposefully load uninitialized that we swizzle over
      * in a vector register, anyway.  If what we assume is wrong about what is used,
      * the memory sanitizer will still usefully flag it */
     __msan_unpoison(buf + dist, 16 - dist);
-#endif
     ret_vec = _mm_loadu_si128((__m128i*)buf);
     *chunk_rem = lut_rem.remval;
 
index 525a34d8d8452200aec74af90a7b5623fc8f09f5..d9559591b4cd071ab171e077967194b6ee204b81 100644 (file)
--- a/zbuild.h
+++ b/zbuild.h
 #  endif
 #endif
 
+#ifndef Z_MEMORY_SANITIZER
+#  define __msan_unpoison(a, size) do { Z_UNUSED(a); Z_UNUSED(size); } while (0)
+#endif
+
 #endif