diff --git a/jitterentropy-rh-s390x.patch b/jitterentropy-rh-s390x.patch new file mode 100644 index 0000000..6f37417 --- /dev/null +++ b/jitterentropy-rh-s390x.patch @@ -0,0 +1,55 @@ +diff -up jitterentropy-base-user.h.orig jitterentropy-base-user.h +--- jitterentropy-base-user.h ++++ jitterentropy-base-user.h +@@ -129,13 +129,46 @@ static inline void jent_get_nstime(uint64_t *out) + + static inline void jent_get_nstime(uint64_t *out) + { +- uint64_t clk; ++ /* ++ * This is MVS+STCK code! Enable it with -S in the compiler. ++ * ++ * uint64_t clk; ++ * __asm__ volatile("stck %0" : "=m" (clk) : : "cc"); ++ * *out = (uint64_t)(clk); ++ */ ++ ++ /* ++ * This is GCC+STCKE code. STCKE command and data format: ++ * z/Architecture - Principles of Operation ++ * http://publibz.boulder.ibm.com/epubs/pdf/dz9zr007.pdf ++ * ++ * The current value of bits 0-103 of the TOD clock is stored in bytes ++ * 1-13 of the sixteen-byte output: ++ * ++ * bits 0-7: zeros (reserved for future extention) ++ * bits 8-111: TOD Clock value ++ * bits 112-127: Programmable Field ++ * ++ * Output bit 59 (TOD-Clock bit 51) effectively increments every ++ * microsecond. Bits 60 to 111 of STCKE output are fractions of ++ * a miscrosecond: bit 59 is 1.0us, bit 60 is .5us, bit 61 is .25us, ++ * bit 62 is .125us, bit 63 is 62.5ns, etc. ++ * ++ * Some of these bits can be implemented, some not. 64 bits of ++ * the TOD clock are implemented usually nowadays, these are ++ * bits 8-71 of the output. ++ * ++ * The stepping value of TOD-clock bit position 63, if implemented, ++ * is 2^-12 microseconds, or approximately 244 picoseconds. This value ++ * is called a clock unit. ++ */ ++ ++ uint8_t clk[16]; + +- /* this is MVS code! enable with -S in the compiler */ +- /*__asm__ volatile("stck %0" : "=m" (clk) : : "cc"); */ +- /* this is gcc */ + asm volatile("stcke %0" : "=Q" (clk) : : "cc"); +- *out = (uint64_t)(clk); ++ ++ /* s390x is big-endian, so just perfom a byte-by-byte copy */ ++ *out = *(uint64_t *)(clk + 1); + } + + #elif defined(__powerpc) diff --git a/jitterentropy.spec b/jitterentropy.spec index 9a171dc..f67ad3a 100644 --- a/jitterentropy.spec +++ b/jitterentropy.spec @@ -1,6 +1,6 @@ Name: jitterentropy Version: 3.4.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Library implementing the jitter entropy source License: BSD or GPLv2 @@ -12,6 +12,7 @@ BuildRequires: make # Disable Upstream Makefiles debuginfo strip on install Patch0: jitterentropy-rh-makefile.patch +Patch1: jitterentropy-rh-s390x.patch %description Library implementing the CPU jitter entropy source @@ -45,6 +46,9 @@ mkdir -p %{buildroot}/usr/include/ %{_mandir}/man3/* %changelog +* Tue Dec 27 2022 Vladis Dronov - 3.4.1-2 +- Fix a stack corruption on s390x + * Tue Sep 06 2022 Vladis Dronov - 3.4.1-1 - Update to the upstream v3.4.1 @ 4544e113