Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package zlib for openSUSE:Factory checked in 
at 2022-09-02 21:55:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/zlib (Old)
 and      /work/SRC/openSUSE:Factory/.zlib.new.2083 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "zlib"

Fri Sep  2 21:55:58 2022 rev:83 rq:1000401 version:1.2.12

Changes:
--------
--- /work/SRC/openSUSE:Factory/zlib/zlib.changes        2022-04-01 
21:34:57.262256019 +0200
+++ /work/SRC/openSUSE:Factory/.zlib.new.2083/zlib.changes      2022-09-02 
21:56:04.288228022 +0200
@@ -1,0 +2,40 @@
+Tue Aug 23 16:22:59 UTC 2022 - Danilo Spinella <danilo.spine...@suse.com>
+
+- Update to 1.2.12:
+  * A lot of bug fixes
+  * Improve speed of crc32 functions
+  * Use ARM crc32 instructions if the ARM architecture has them
+  For the complete changes, see ChangeLog
+- Fixes CVE-2022-37434,  heap-based buffer over-read or buffer overflow in
+  inflate.c via a large gzip header extra field
+  (CVE-2022-37434, bsc#1202175)
+- Added patches:
+  * zlib-1.2.11-covscan-issues-rhel9.patch
+  * zlib-1.2.11-covscan-issues.patch
+  * zlib-1.2.12-s390-vectorize-crc32.patch
+  * zlib-1.2.12-optimized-crc32-power8.patch
+  * zlib-1.2.12-IBM-Z-hw-accelerated-deflate-s390x.patch
+  * zlib-1.2.12-fix-configure.patch
+  * zlib-1.2.12-correct-inputs-provided-to-crc-func.patch
+  * zlib-1.2.12-fix-CVE-2022-37434.patch
+  * zlib-1.2.5-minizip-fixuncrypt.patch
+- Removed patches:
+  * bsc1197459.patch (upstreamed)
+  * zlib-power8-fate325307.patch
+    (replaced by zlib-1.2.12-optimized-crc32-power8.patch)
+  * bsc1174736-DFLTCC_LEVEL_MASK-set-to-0x1ff.patch
+    (replaced by zlib-1.2.12-IBM-Z-hw-accelrated-deflate-s390x.patch)
+  * 410.patch
+    (replaced by zlib-1.2.12-IBM-Z-hw-accelrated-deflate-s390x.patch)
+- Refreshed patches:
+  * zlib-format.patch
+  * zlib-no-version-check.patch
+- Disable profiling since it breaks tests
+- Update zlib-rpmlintrc
+
+-------------------------------------------------------------------
+Sat Jul  2 10:00:46 UTC 2022 - Marcus Meissner <meiss...@suse.com>
+
+- switch to https urls
+
+-------------------------------------------------------------------

Old:
----
  410.patch
  bsc1174736-DFLTCC_LEVEL_MASK-set-to-0x1ff.patch
  bsc1197459.patch
  zlib-1.2.11.tar.gz
  zlib-1.2.11.tar.gz.asc
  zlib-power8-fate325307.patch

New:
----
  zlib-1.2.11-covscan-issues-rhel9.patch
  zlib-1.2.11-covscan-issues.patch
  zlib-1.2.12-IBM-Z-hw-accelerated-deflate-s390x.patch
  zlib-1.2.12-correct-inputs-provided-to-crc-func.patch
  zlib-1.2.12-fix-CVE-2022-37434.patch
  zlib-1.2.12-fix-configure.patch
  zlib-1.2.12-optimized-crc32-power8.patch
  zlib-1.2.12-s390-vectorize-crc32.patch
  zlib-1.2.12.tar.gz
  zlib-1.2.12.tar.gz.asc
  zlib-1.2.5-minizip-fixuncrypt.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ zlib.spec ++++++
--- /var/tmp/diff_new_pack.efpb4k/_old  2022-09-02 21:56:05.600231197 +0200
+++ /var/tmp/diff_new_pack.efpb4k/_new  2022-09-02 21:56:05.600231197 +0200
@@ -17,35 +17,39 @@
 
 
 Name:           zlib
-Version:        1.2.11
+Version:        1.2.12
 Release:        0
 Summary:        Library implementing the DEFLATE compression algorithm
 License:        Zlib
-URL:            http://www.zlib.net/
-Source0:        http://zlib.net/zlib-%{version}.tar.gz
-Source1:        http://zlib.net/zlib-%{version}.tar.gz.asc
+URL:            https://www.zlib.net/
+Source0:        https://zlib.net/zlib-%{version}.tar.gz
+Source1:        https://zlib.net/zlib-%{version}.tar.gz.asc
 Source2:        %{name}.keyring
 Source4:        LICENSE
 Source5:        baselibs.conf
 Source6:        zlib-rpmlintrc
-#PATCH-FIX-SUSE: fate#314093, sent upstream by IBM
-Patch0:         zlib-1.2.11-optimized-s390.patch
 #PATCH-FIX-SUSE: compiler check of varguments passed to gzprintf
 Patch1:         zlib-format.patch
 #PATCH-FIX-UPSTREAM do not store negative values in uInt
 Patch2:         0001-Do-not-try-to-store-negative-values-in-unsigned-int.patch
-#PATCH-FIX-UPSTREAM https://github.com/madler/zlib/pull/335
-Patch3:         zlib-power8-fate325307.patch
 #PATCH-FIX-SUSE do not check exact version match as the lib can be updated
 #               we should simply rely on soname versioning to protect us
-Patch5:         zlib-no-version-check.patch
-Patch6:         bsc1174736-DFLTCC_LEVEL_MASK-set-to-0x1ff.patch
+Patch3:         zlib-no-version-check.patch
+#PATCH-FIX-UPSTREAM https://github.com/madler/zlib/commit/ec3df00224d4
+Patch4:         zlib-1.2.12-correct-inputs-provided-to-crc-func.patch
+#PATCH-FIX-UPSTREAM 
https://github.com/madler/zlib/commit/1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d
+Patch5:         zlib-1.2.12-fix-CVE-2022-37434.patch
 #PATCH-FIX-UPSTREAM https://github.com/madler/zlib/pull/229
-Patch10:        minizip-dont-install-crypt-header.patch
-#PATCH-FIX-UPSTREAM 
https://github.com/madler/zlib/commit/5c44459c3b28a9bd3283aaceab7c615f8020c531
-Patch11:        bsc1197459.patch
-#PATCH-FIX-UPSTREAM https://github.com/madler/zlib/pull/410
-Patch101:       410.patch
+Patch6:         minizip-dont-install-crypt-header.patch
+# The following patches are taken from 
https://github.com/iii-i/zlib/commits/crc32vx-v3
+Patch7:         zlib-1.2.5-minizip-fixuncrypt.patch
+Patch8:         zlib-1.2.11-optimized-s390.patch
+Patch9:         zlib-1.2.12-IBM-Z-hw-accelerated-deflate-s390x.patch
+Patch10:        zlib-1.2.11-covscan-issues.patch
+Patch11:        zlib-1.2.11-covscan-issues-rhel9.patch
+Patch12:        zlib-1.2.12-optimized-crc32-power8.patch
+Patch13:        zlib-1.2.12-fix-configure.patch
+Patch14:        zlib-1.2.12-s390-vectorize-crc32.patch
 BuildRequires:  autoconf
 BuildRequires:  automake
 BuildRequires:  libtool
@@ -130,15 +134,20 @@
 
 %prep
 %setup -q
-%patch0
 %patch1
 %patch2 -p1
 %patch3 -p1
+%patch4 -p1
 %patch5 -p1
 %patch6 -p1
+%patch7 -p1
+%patch8
+%patch9 -p1
 %patch10 -p1
 %patch11 -p1
-%patch101 -p1
+%patch12 -p1
+%patch13 -p1
+%patch14 -p1
 cp %{SOURCE4} .
 
 %build
@@ -155,14 +164,16 @@
 %endif
     %{nil}
 
-%if %{do_profiling}
-  make %{?_smp_mflags} CFLAGS="%{optflags} %{cflags_profile_generate}"
-  make check %{?_smp_mflags}
-  make %{?_smp_mflags} clean
-  make %{?_smp_mflags} CFLAGS="%{optflags} %{cflags_profile_feedback}"
-%else
+# Profiling flags breaks tests, as of 1.2.12
+# In particular, gzseek does not work as intended
+#%if %{do_profiling}
+#  #make %{?_smp_mflags} CFLAGS="%{optflags} %{cflags_profile_generate}"
+#  make check %{?_smp_mflags}
+#  #make %{?_smp_mflags} clean
+#  #make %{?_smp_mflags} CFLAGS="%{optflags} %{cflags_profile_feedback}"
+#%else
   make %{?_smp_mflags}
-%endif
+#%endif
 
 # And build minizip
 cd contrib/minizip

++++++ zlib-1.2.11-covscan-issues-rhel9.patch ++++++
>From a7d3c3076dc316f1408f56af86a72a17fcfdf5dd Mon Sep 17 00:00:00 2001
From: Ilya Leoshkevich <i...@linux.ibm.com>
Date: Wed, 27 Apr 2022 14:37:54 +0200
Subject: [PATCH] zlib-1.2.11-covscan-issues-rhel9.patch

---
 contrib/minizip/mztools.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c
index 96891c2e0..1197928a7 100644
--- a/contrib/minizip/mztools.c
+++ b/contrib/minizip/mztools.c
@@ -286,6 +286,14 @@ uLong* bytesRecovered;
     }
   } else {
     err = Z_STREAM_ERROR;
+    if(fpZip != NULL)
+      fclose(fpZip);
+
+    if(fpOut != NULL)
+      fclose(fpOut);
+
+    if(fpOutCD != NULL)
+      fclose(fpOutCD);
   }
   return err;
 }

++++++ zlib-1.2.11-covscan-issues.patch ++++++
>From e4c0c07385f80e260f1f1aa2a80c41c62754b9d4 Mon Sep 17 00:00:00 2001
From: Ilya Leoshkevich <i...@linux.ibm.com>
Date: Wed, 27 Apr 2022 14:37:39 +0200
Subject: [PATCH] zlib-1.2.11-covscan-issues.patch

---
 deflate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/deflate.c b/deflate.c
index ac0b865a4..49f056a00 100644
--- a/deflate.c
+++ b/deflate.c
@@ -1062,7 +1062,7 @@ int ZEXPORT deflate (strm, flush)
      */
     if (strm->avail_in != 0 || s->lookahead != 0 ||
         (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
-        block_state bstate;
+        block_state bstate = 0;
 
         bstate = DEFLATE_HOOK(strm, flush, &bstate) ? bstate :
                  s->level == 0 ? deflate_stored(s, flush) :

++++++ zlib-1.2.12-IBM-Z-hw-accelerated-deflate-s390x.patch ++++++
++++ 1910 lines (skipped)

++++++ zlib-1.2.12-correct-inputs-provided-to-crc-func.patch ++++++
>From ec3df00224d4b396e2ac6586ab5d25f673caa4c2 Mon Sep 17 00:00:00 2001
From: Mark Adler <mad...@alumni.caltech.edu>
Date: Wed, 30 Mar 2022 11:14:53 -0700
Subject: [PATCH] Correct incorrect inputs provided to the CRC functions.

The previous releases of zlib were not sensitive to incorrect CRC
inputs with bits set above the low 32. This commit restores that
behavior, so that applications with such bugs will continue to
operate as before.
---
 crc32.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/crc32.c b/crc32.c
index a1bdce5c2..451887bc7 100644
--- a/crc32.c
+++ b/crc32.c
@@ -630,7 +630,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
 #endif /* DYNAMIC_CRC_TABLE */
 
     /* Pre-condition the CRC */
-    crc ^= 0xffffffff;
+    crc = (~crc) & 0xffffffff;
 
     /* Compute the CRC up to a word boundary. */
     while (len && ((z_size_t)buf & 7) != 0) {
@@ -749,7 +749,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
 #endif /* DYNAMIC_CRC_TABLE */
 
     /* Pre-condition the CRC */
-    crc ^= 0xffffffff;
+    crc = (~crc) & 0xffffffff;
 
 #ifdef W
 
@@ -1077,7 +1077,7 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
 #ifdef DYNAMIC_CRC_TABLE
     once(&made, make_crc_table);
 #endif /* DYNAMIC_CRC_TABLE */
-    return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
+    return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff);
 }
 
 /* ========================================================================= */
@@ -1112,5 +1112,5 @@ uLong crc32_combine_op(crc1, crc2, op)
     uLong crc2;
     uLong op;
 {
-    return multmodp(op, crc1) ^ crc2;
+    return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
 }

++++++ zlib-1.2.12-fix-CVE-2022-37434.patch ++++++
--- zlib-1.2.12/inflate.c.old   2022-08-09 10:30:18.831225181 +0000
+++ zlib-1.2.12/inflate.c       2022-08-09 10:29:33.251225181 +0000
@@ -792,8 +792,9 @@ int flush;
                 if (copy > have) copy = have;
                 if (copy) {
                     if (state->head != Z_NULL &&
-                        state->head->extra != Z_NULL) {
-                        len = state->head->extra_len - state->length;
+                        state->head->extra != Z_NULL &&
+                        (len = state->head->extra_len - state->length) <
+                               state->head->extra_max) {
                         zmemcpy(state->head->extra + len, next,
                                 len + copy > state->head->extra_max ?
                                 state->head->extra_max - len : copy);

++++++ zlib-1.2.12-fix-configure.patch ++++++
>From 6378872888c85c02f340126712684e0f603f5e76 Mon Sep 17 00:00:00 2001
From: Ilya Leoshkevich <i...@linux.ibm.com>
Date: Wed, 27 Apr 2022 14:38:23 +0200
Subject: [PATCH] zlib-1.2.12-fix-configure.patch

---
 configure | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configure b/configure
index cff6207ec..dd01b5c0e 100755
--- a/configure
+++ b/configure
@@ -185,7 +185,10 @@ if test -z "$CC"; then
   else
     cc=${CROSS_PREFIX}cc
   fi
+else
+  cc=${CC}
 fi
+
 cflags=${CFLAGS-"-O3"}
 # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
 case "$cc" in

++++++ zlib-1.2.12-optimized-crc32-power8.patch ++++++
++++ 2708 lines (skipped)

++++++ zlib-1.2.12-s390-vectorize-crc32.patch ++++++
>From 957bc67cfb4e01403c01fe6243850383183a7c19 Mon Sep 17 00:00:00 2001
From: Ilya Leoshkevich <i...@linux.ibm.com>
Date: Thu, 19 Mar 2020 11:52:03 +0100
Subject: [PATCH] s390x: vectorize crc32

Use vector extensions when compiling for s390x and binutils knows
about them. At runtime, check whether kernel supports vector
extensions (it has to be not just the CPU, but also the kernel) and
choose between the regular and the vectorized implementations.
---
 Makefile.in                     |   9 ++
 configure                       |  28 +++++
 contrib/gcc/zifunc.h            |  21 +++-
 contrib/s390/crc32-vx.c         | 195 ++++++++++++++++++++++++++++++++
 contrib/s390/crc32_z_resolver.c |  41 +++++++
 crc32.c                         |  11 +-
 6 files changed, 301 insertions(+), 4 deletions(-)
 create mode 100644 contrib/s390/crc32-vx.c
 create mode 100644 contrib/s390/crc32_z_resolver.c

diff --git a/Makefile.in b/Makefile.in
index 2e78f3844..04c2f5d53 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -29,6 +29,7 @@ LDFLAGS=
 TEST_LDFLAGS=-L. libz.a
 LDSHARED=$(CC)
 CPP=$(CC) -E
+VGFMAFLAG=
 
 STATICLIB=libz.a
 SHAREDLIB=libz.so
@@ -179,6 +180,9 @@ crc32.o: $(SRCDIR)crc32.c
 crc32_z_power8.o: $(SRCDIR)contrib/power/crc32_z_power8.c
        $(CC) $(CFLAGS) -mcpu=power8 $(ZINC) -c -o $@ 
$(SRCDIR)contrib/power/crc32_z_power8.c
 
+crc32-vx.o: $(SRCDIR)contrib/s390/crc32-vx.c
+       $(CC) $(CFLAGS) $(VGFMAFLAG) $(ZINC) -c -o $@ 
$(SRCDIR)contrib/s390/crc32-vx.c
+
 deflate.o: $(SRCDIR)deflate.c
        $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c
 
@@ -229,6 +233,11 @@ crc32.lo: $(SRCDIR)crc32.c
        $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/crc32.o $(SRCDIR)crc32.c
        -@mv objs/crc32.o $@
 
+crc32-vx.lo: $(SRCDIR)contrib/s390/crc32-vx.c
+       -@mkdir objs 2>/dev/null || test -d objs
+       $(CC) $(SFLAGS) $(VGFMAFLAG) $(ZINC) -DPIC -c -o objs/crc32-vx.o 
$(SRCDIR)contrib/s390/crc32-vx.c
+       -@mv objs/crc32-vx.o $@
+
 crc32_z_power8.lo: $(SRCDIR)contrib/power/crc32_z_power8.c
        -@mkdir objs 2>/dev/null || test -d objs
        $(CC) $(SFLAGS) -mcpu=power8 $(ZINC) -DPIC -c -o objs/crc32_z_power8.o 
$(SRCDIR)contrib/power/crc32_z_power8.c
diff --git a/configure b/configure
index dd01b5c0e..acf94a599 100755
--- a/configure
+++ b/configure
@@ -929,6 +929,32 @@ else
   echo "Checking for Power optimizations support... No." | tee -a configure.log
 fi
 
+# check if we are compiling for s390 and binutils support vector extensions
+VGFMAFLAG=-march=z13
+cat > $test.c <<EOF
+#ifndef __s390__
+#error
+#endif
+EOF
+if try $CC -c $CFLAGS $VGFMAFLAG $test.c; then
+  CFLAGS="$CFLAGS -DHAVE_S390X_VX"
+  SFLAGS="$SFLAGS -DHAVE_S390X_VX"
+  OBJC="$OBJC crc32-vx.o"
+  PIC_OBJC="$PIC_OBJC crc32-vx.lo"
+  echo "Checking for s390 vector extensions... Yes." | tee -a configure.log
+
+  for flag in -mzarch -fzvector; do
+    if try $CC -c $CFLAGS $VGFMAFLAG $flag $test.c; then
+      VGFMAFLAG="$VGFMAFLAG $flag"
+      echo "Checking for $flag... Yes." | tee -a configure.log
+    else
+      echo "Checking for $flag... No." | tee -a configure.log
+    fi
+  done
+else
+  echo "Checking for s390 vector extensions... No." | tee -a configure.log
+fi
+
 # show the results in the log
 echo >> configure.log
 echo ALL = $ALL >> configure.log
@@ -960,6 +986,7 @@ echo mandir = $mandir >> configure.log
 echo prefix = $prefix >> configure.log
 echo sharedlibdir = $sharedlibdir >> configure.log
 echo uname = $uname >> configure.log
+echo VGFMAFLAG = $VGFMAFLAG >> configure.log
 
 # udpate Makefile with the configure results
 sed < ${SRCDIR}Makefile.in "
@@ -969,6 +996,7 @@ sed < ${SRCDIR}Makefile.in "
 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
 /^LDSHARED *=/s#=.*#=$LDSHARED#
 /^CPP *=/s#=.*#=$CPP#
+/^VGFMAFLAG *=/s#=.*#=$VGFMAFLAG#
 /^STATICLIB *=/s#=.*#=$STATICLIB#
 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
diff --git a/contrib/gcc/zifunc.h b/contrib/gcc/zifunc.h
index daf4fe442..b62379ed8 100644
--- a/contrib/gcc/zifunc.h
+++ b/contrib/gcc/zifunc.h
@@ -8,9 +8,28 @@
 
 /* Helpers for arch optimizations */
 
+#if defined(__clang__)
+#if __has_feature(coverage_sanitizer)
+#define Z_IFUNC_NO_SANCOV __attribute__((no_sanitize("coverage")))
+#else /* __has_feature(coverage_sanitizer) */
+#define Z_IFUNC_NO_SANCOV
+#endif /* __has_feature(coverage_sanitizer) */
+#else /* __clang__ */
+#define Z_IFUNC_NO_SANCOV
+#endif /* __clang__ */
+
+#ifdef __s390__
+#define Z_IFUNC_PARAMS unsigned long hwcap
+#define Z_IFUNC_ATTRS Z_IFUNC_NO_SANCOV
+#else /* __s390__ */
+#define Z_IFUNC_PARAMS void
+#define Z_IFUNC_ATTRS
+#endif /* __s390__ */
+
 #define Z_IFUNC(fname) \
     typeof(fname) fname __attribute__ ((ifunc (#fname "_resolver"))); \
-    local typeof(fname) *fname##_resolver(void)
+    Z_IFUNC_ATTRS \
+    local typeof(fname) *fname##_resolver(Z_IFUNC_PARAMS)
 /* This is a helper macro to declare a resolver for an indirect function
  * (ifunc). Let's say you have function
  *
diff --git a/contrib/s390/crc32-vx.c b/contrib/s390/crc32-vx.c
new file mode 100644
index 000000000..fa5387c11
--- /dev/null
+++ b/contrib/s390/crc32-vx.c
@@ -0,0 +1,195 @@
+/*
+ * Hardware-accelerated CRC-32 variants for Linux on z Systems
+ *
+ * Use the z/Architecture Vector Extension Facility to accelerate the
+ * computing of bitreflected CRC-32 checksums.
+ *
+ * This CRC-32 implementation algorithm is bitreflected and processes
+ * the least-significant bit first (Little-Endian).
+ *
+ * This code was originally written by Hendrik Brueckner
+ * <brueck...@linux.vnet.ibm.com> for use in the Linux kernel and has been
+ * relicensed under the zlib license.
+ */
+
+#include "../../zutil.h"
+
+#include <stdint.h>
+#include <vecintrin.h>
+
+typedef unsigned char uv16qi __attribute__((vector_size(16)));
+typedef unsigned int uv4si __attribute__((vector_size(16)));
+typedef unsigned long long uv2di __attribute__((vector_size(16)));
+
+uint32_t crc32_le_vgfm_16(uint32_t crc, const unsigned char *buf, size_t len) {
+    /*
+     * The CRC-32 constant block contains reduction constants to fold and
+     * process particular chunks of the input data stream in parallel.
+     *
+     * For the CRC-32 variants, the constants are precomputed according to
+     * these definitions:
+     *
+     *      R1 = [(x4*128+32 mod P'(x) << 32)]' << 1
+     *      R2 = [(x4*128-32 mod P'(x) << 32)]' << 1
+     *      R3 = [(x128+32 mod P'(x) << 32)]'   << 1
+     *      R4 = [(x128-32 mod P'(x) << 32)]'   << 1
+     *      R5 = [(x64 mod P'(x) << 32)]'       << 1
+     *      R6 = [(x32 mod P'(x) << 32)]'       << 1
+     *
+     *      The bitreflected Barret reduction constant, u', is defined as
+     *      the bit reversal of floor(x**64 / P(x)).
+     *
+     *      where P(x) is the polynomial in the normal domain and the P'(x) is 
the
+     *      polynomial in the reversed (bitreflected) domain.
+     *
+     * CRC-32 (IEEE 802.3 Ethernet, ...) polynomials:
+     *
+     *      P(x)  = 0x04C11DB7
+     *      P'(x) = 0xEDB88320
+     */
+    const uv16qi perm_le2be = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 
1, 0};  /* BE->LE mask */
+    const uv2di r2r1 = {0x1C6E41596, 0x154442BD4};                             
        /* R2, R1 */
+    const uv2di r4r3 = {0x0CCAA009E, 0x1751997D0};                             
        /* R4, R3 */
+    const uv2di r5 = {0, 0x163CD6124};                                         
        /* R5 */
+    const uv2di ru_poly = {0, 0x1F7011641};                                    
        /* u' */
+    const uv2di crc_poly = {0, 0x1DB710641};                                   
        /* P'(x) << 1 */
+
+    /*
+     * Load the initial CRC value.
+     *
+     * The CRC value is loaded into the rightmost word of the
+     * vector register and is later XORed with the LSB portion
+     * of the loaded input data.
+     */
+    uv2di v0 = {0, 0};
+    v0 = (uv2di)vec_insert(crc, (uv4si)v0, 3);
+
+    /* Load a 64-byte data chunk and XOR with CRC */
+    uv2di v1 = vec_perm(((uv2di *)buf)[0], ((uv2di *)buf)[0], perm_le2be);
+    uv2di v2 = vec_perm(((uv2di *)buf)[1], ((uv2di *)buf)[1], perm_le2be);
+    uv2di v3 = vec_perm(((uv2di *)buf)[2], ((uv2di *)buf)[2], perm_le2be);
+    uv2di v4 = vec_perm(((uv2di *)buf)[3], ((uv2di *)buf)[3], perm_le2be);
+
+    v1 ^= v0;
+    buf += 64;
+    len -= 64;
+
+    while (len >= 64) {
+        /* Load the next 64-byte data chunk */
+        uv16qi part1 = vec_perm(((uv16qi *)buf)[0], ((uv16qi *)buf)[0], 
perm_le2be);
+        uv16qi part2 = vec_perm(((uv16qi *)buf)[1], ((uv16qi *)buf)[1], 
perm_le2be);
+        uv16qi part3 = vec_perm(((uv16qi *)buf)[2], ((uv16qi *)buf)[2], 
perm_le2be);
+        uv16qi part4 = vec_perm(((uv16qi *)buf)[3], ((uv16qi *)buf)[3], 
perm_le2be);
+
+        /*
+         * Perform a GF(2) multiplication of the doublewords in V1 with
+         * the R1 and R2 reduction constants in V0.  The intermediate result
+         * is then folded (accumulated) with the next data chunk in PART1 and
+         * stored in V1. Repeat this step for the register contents
+         * in V2, V3, and V4 respectively.
+         */
+        v1 = (uv2di)vec_gfmsum_accum_128(r2r1, v1, part1);
+        v2 = (uv2di)vec_gfmsum_accum_128(r2r1, v2, part2);
+        v3 = (uv2di)vec_gfmsum_accum_128(r2r1, v3, part3);
+        v4 = (uv2di)vec_gfmsum_accum_128(r2r1, v4, part4);
+
+        buf += 64;
+        len -= 64;
+    }
+
+    /*
+     * Fold V1 to V4 into a single 128-bit value in V1.  Multiply V1 with R3
+     * and R4 and accumulating the next 128-bit chunk until a single 128-bit
+     * value remains.
+     */
+    v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v2);
+    v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v3);
+    v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v4);
+
+    while (len >= 16) {
+        /* Load next data chunk */
+        v2 = vec_perm(*(uv2di *)buf, *(uv2di *)buf, perm_le2be);
+
+        /* Fold next data chunk */
+        v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v2);
+
+        buf += 16;
+        len -= 16;
+    }
+
+    /*
+     * Set up a vector register for byte shifts.  The shift value must
+     * be loaded in bits 1-4 in byte element 7 of a vector register.
+     * Shift by 8 bytes: 0x40
+     * Shift by 4 bytes: 0x20
+     */
+    uv16qi v9 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    v9 = vec_insert((unsigned char)0x40, v9, 7);
+
+    /*
+     * Prepare V0 for the next GF(2) multiplication: shift V0 by 8 bytes
+     * to move R4 into the rightmost doubleword and set the leftmost
+     * doubleword to 0x1.
+     */
+    v0 = vec_srb(r4r3, (uv2di)v9);
+    v0[0] = 1;
+
+    /*
+     * Compute GF(2) product of V1 and V0.  The rightmost doubleword
+     * of V1 is multiplied with R4.  The leftmost doubleword of V1 is
+     * multiplied by 0x1 and is then XORed with rightmost product.
+     * Implicitly, the intermediate leftmost product becomes padded
+     */
+    v1 = (uv2di)vec_gfmsum_128(v0, v1);
+
+    /*
+     * Now do the final 32-bit fold by multiplying the rightmost word
+     * in V1 with R5 and XOR the result with the remaining bits in V1.
+     *
+     * To achieve this by a single VGFMAG, right shift V1 by a word
+     * and store the result in V2 which is then accumulated.  Use the
+     * vector unpack instruction to load the rightmost half of the
+     * doubleword into the rightmost doubleword element of V1; the other
+     * half is loaded in the leftmost doubleword.
+     * The vector register with CONST_R5 contains the R5 constant in the
+     * rightmost doubleword and the leftmost doubleword is zero to ignore
+     * the leftmost product of V1.
+     */
+    v9 = vec_insert((unsigned char)0x20, v9, 7);
+    v2 = vec_srb(v1, (uv2di)v9);
+    v1 = vec_unpackl((uv4si)v1);  /* Split rightmost doubleword */
+    v1 = (uv2di)vec_gfmsum_accum_128(r5, v1, (uv16qi)v2);
+
+    /*
+     * Apply a Barret reduction to compute the final 32-bit CRC value.
+     *
+     * The input values to the Barret reduction are the degree-63 polynomial
+     * in V1 (R(x)), degree-32 generator polynomial, and the reduction
+     * constant u.  The Barret reduction result is the CRC value of R(x) mod
+     * P(x).
+     *
+     * The Barret reduction algorithm is defined as:
+     *
+     *    1. T1(x) = floor( R(x) / x^32 ) GF2MUL u
+     *    2. T2(x) = floor( T1(x) / x^32 ) GF2MUL P(x)
+     *    3. C(x)  = R(x) XOR T2(x) mod x^32
+     *
+     *  Note: The leftmost doubleword of vector register containing
+     *  CONST_RU_POLY is zero and, thus, the intermediate GF(2) product
+     *  is zero and does not contribute to the final result.
+     */
+
+    /* T1(x) = floor( R(x) / x^32 ) GF2MUL u */
+    v2 = vec_unpackl((uv4si)v1);
+    v2 = (uv2di)vec_gfmsum_128(ru_poly, v2);
+
+    /*
+     * Compute the GF(2) product of the CRC polynomial with T1(x) in
+     * V2 and XOR the intermediate result, T2(x), with the value in V1.
+     * The final result is stored in word element 2 of V2.
+     */
+    v2 = vec_unpackl((uv4si)v2);
+    v2 = (uv2di)vec_gfmsum_accum_128(crc_poly, v2, (uv16qi)v1);
+
+    return ((uv4si)v2)[2];
+}
diff --git a/contrib/s390/crc32_z_resolver.c b/contrib/s390/crc32_z_resolver.c
new file mode 100644
index 000000000..9749cab40
--- /dev/null
+++ b/contrib/s390/crc32_z_resolver.c
@@ -0,0 +1,41 @@
+#include <sys/auxv.h>
+#include "../gcc/zifunc.h"
+
+#define VX_MIN_LEN 64
+#define VX_ALIGNMENT 16L
+#define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
+
+unsigned int crc32_le_vgfm_16(unsigned int crc, const unsigned char FAR *buf, 
z_size_t len);
+
+local unsigned long s390_crc32_vx(unsigned long crc, const unsigned char FAR 
*buf, z_size_t len)
+{
+    uintptr_t prealign, aligned, remaining;
+
+    if (buf == Z_NULL) return 0UL;
+
+    if (len < VX_MIN_LEN + VX_ALIGN_MASK)
+        return crc32_z_default(crc, buf, len);
+
+    if ((uintptr_t)buf & VX_ALIGN_MASK) {
+        prealign = VX_ALIGNMENT - ((uintptr_t)buf & VX_ALIGN_MASK);
+        len -= prealign;
+        crc = crc32_z_default(crc, buf, prealign);
+        buf += prealign;
+    }
+    aligned = len & ~VX_ALIGN_MASK;
+    remaining = len & VX_ALIGN_MASK;
+
+    crc = crc32_le_vgfm_16(crc ^ 0xffffffff, buf, (size_t)aligned) ^ 
0xffffffff;
+
+    if (remaining)
+        crc = crc32_z_default(crc, buf + aligned, remaining);
+
+    return crc;
+}
+
+Z_IFUNC(crc32_z)
+{
+    if (hwcap & HWCAP_S390_VX)
+        return s390_crc32_vx;
+    return crc32_z_default;
+}
diff --git a/crc32.c b/crc32.c
index ae7b7e792..c2122615b 100644
--- a/crc32.c
+++ b/crc32.c
@@ -736,12 +736,12 @@ local z_word_t crc_word_big(data)
 #endif
 
 /* ========================================================================= */
-#ifdef Z_POWER_OPT
+#if defined(Z_POWER_OPT) || defined(HAVE_S390X_VX)
 /* Rename function so resolver can use its symbol. The default version will be
  * returned by the resolver if the host has no support for an optimized 
version.
  */
 #define crc32_z crc32_z_default
-#endif /* Z_POWER_OPT */
+#endif /* defined(Z_POWER_OPT) || defined(HAVE_S390X_VX) */
 
 unsigned long ZEXPORT crc32_z(crc, buf, len)
     unsigned long crc;
@@ -1064,10 +1064,15 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
     return crc ^ 0xffffffff;
 }
 
-#ifdef Z_POWER_OPT
+#if defined(Z_POWER_OPT) || defined(HAVE_S390X_VX)
 #undef crc32_z
+#ifdef Z_POWER_OPT
 #include "contrib/power/crc32_z_resolver.c"
 #endif /* Z_POWER_OPT */
+#ifdef HAVE_S390X_VX
+#include "contrib/s390/crc32_z_resolver.c"
+#endif /* HAVE_S390X_VX */
+#endif /* defined(Z_POWER_OPT) || defined(HAVE_S390X_VX) */
 
 #endif
 

++++++ zlib-1.2.11.tar.gz -> zlib-1.2.12.tar.gz ++++++
++++ 23250 lines of diff (skipped)

++++++ zlib-1.2.5-minizip-fixuncrypt.patch ++++++
>From 9352e84c149d02ec0df78e19dad55b7f83185622 Mon Sep 17 00:00:00 2001
From: Ilya Leoshkevich <i...@linux.ibm.com>
Date: Wed, 27 Apr 2022 14:36:43 +0200
Subject: [PATCH] zlib-1.2.5-minizip-fixuncrypt.patch

---
 contrib/minizip/unzip.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
index 5e12e4747..aa1a92d17 100644
--- a/contrib/minizip/unzip.c
+++ b/contrib/minizip/unzip.c
@@ -68,10 +68,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef NOUNCRYPT
-        #define NOUNCRYPT
-#endif
-
 #include "zlib.h"
 #include "unzip.h"
 

++++++ zlib-format.patch ++++++
--- /var/tmp/diff_new_pack.efpb4k/_old  2022-09-02 21:56:05.984232126 +0200
+++ /var/tmp/diff_new_pack.efpb4k/_new  2022-09-02 21:56:05.988232136 +0200
@@ -5,7 +5,7 @@
 ===================================================================
 --- zlib.h.orig
 +++ zlib.h
-@@ -1464,7 +1464,11 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((vo
+@@ -1465,7 +1465,11 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((vo
     is returned, and the error state is set to Z_STREAM_ERROR.
  */
  
@@ -16,6 +16,6 @@
 +#endif
 +;
  /*
-      Converts, formats, and writes the arguments to the compressed file under
-    control of the format string, as in fprintf.  gzprintf returns the number 
of
+      Convert, format, compress, and write the arguments (...) to file under
+    control of the string format, as in fprintf.  gzprintf returns the number 
of
 

++++++ zlib-no-version-check.patch ++++++
--- /var/tmp/diff_new_pack.efpb4k/_old  2022-09-02 21:56:06.000232165 +0200
+++ /var/tmp/diff_new_pack.efpb4k/_new  2022-09-02 21:56:06.004232174 +0200
@@ -1,7 +1,7 @@
-Index: zlib-1.2.11/infback.c
+Index: zlib-1.2.12/infback.c
 ===================================================================
---- zlib-1.2.11.orig/infback.c
-+++ zlib-1.2.11/infback.c
+--- zlib-1.2.12.orig/infback.c
++++ zlib-1.2.12/infback.c
 @@ -34,9 +34,6 @@ int stream_size;
  {
      struct inflate_state FAR *state;
@@ -12,11 +12,11 @@
      if (strm == Z_NULL || window == Z_NULL ||
          windowBits < 8 || windowBits > 15)
          return Z_STREAM_ERROR;
-Index: zlib-1.2.11/inflate.c
+Index: zlib-1.2.12/inflate.c
 ===================================================================
---- zlib-1.2.11.orig/inflate.c
-+++ zlib-1.2.11/inflate.c
-@@ -219,9 +219,6 @@ int stream_size;
+--- zlib-1.2.12.orig/inflate.c
++++ zlib-1.2.12/inflate.c
+@@ -202,9 +202,6 @@ int stream_size;
      int ret;
      struct inflate_state FAR *state;
  
@@ -26,21 +26,16 @@
      if (strm == Z_NULL) return Z_STREAM_ERROR;
      strm->msg = Z_NULL;                 /* in case we return an error */
      if (strm->zalloc == (alloc_func)0) {
-Index: zlib-1.2.11/deflate.c
+Index: zlib-1.2.12/deflate.c
 ===================================================================
---- zlib-1.2.11.orig/deflate.c
-+++ zlib-1.2.11/deflate.c
-@@ -263,17 +263,12 @@ int ZEXPORT deflateInit2_(strm, level, m
+--- zlib-1.2.12.orig/deflate.c
++++ zlib-1.2.12/deflate.c
+@@ -253,12 +253,7 @@ int ZEXPORT deflateInit2_(strm, level, m
  {
      deflate_state *s;
      int wrap = 1;
 -    static const char my_version[] = ZLIB_VERSION;
  
-     ushf *overlay;
-     /* We overlay pending_buf and d_buf+l_buf. This works since the average
-      * output size for (length,distance) codes is <= 24 bits.
-      */
- 
 -    if (version == Z_NULL || version[0] != my_version[0] ||
 -        stream_size != sizeof(z_stream)) {
 -        return Z_VERSION_ERROR;

++++++ zlib-rpmlintrc ++++++
--- /var/tmp/diff_new_pack.efpb4k/_old  2022-09-02 21:56:06.024232223 +0200
+++ /var/tmp/diff_new_pack.efpb4k/_new  2022-09-02 21:56:06.028232233 +0200
@@ -1,5 +1,3 @@
-# zlib-devel require libz1 - zlib produces libz, not libzlib
-addFilter("zlib-devel.*: W: no-dependency-on zlib*/zlib-libs/libzlib")
 # used only if build --with profiling
 addFilter("zlib.src.*: W: make-check-outside-check-section time make check")
 

Reply via email to