Compare commits

..

No commits in common. "c9-beta" and "a10s" have entirely different histories.

12 changed files with 288 additions and 130 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/jitterentropy-library-3.6.0.tar.gz
/jitterentropy-library-*.tar.gz

View File

@ -1 +0,0 @@
fc2ca7a94bef565a9dee5c3d8a66ff74560e0c31 SOURCES/jitterentropy-library-3.6.0.tar.gz

View File

@ -1,126 +0,0 @@
%global libjit_soversion 3
Name: jitterentropy
Version: 3.6.0
Release: 1%{?dist}
Summary: Library implementing the jitter entropy source
License: BSD-3-Clause OR GPL-2.0-only
URL: https://github.com/smuellerDD/jitterentropy-library
Source0: %{url}/archive/v%{version}/%{name}-library-%{version}.tar.gz
BuildRequires: gcc
BuildRequires: make
# Disable Upstream Makefiles debuginfo strip on install
Patch0: jitterentropy-rh-makefile.patch
%description
Library implementing the CPU jitter entropy source
%package devel
Summary: Development headers for jitterentropy library
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
Development headers and libraries for jitterentropy
%prep
%autosetup -p0 -n %{name}-library-%{version}
%build
%set_build_flags
%make_build
%install
mkdir -p %{buildroot}/usr/include/
%make_install PREFIX=/usr LIBDIR=%{_lib}
%files
%doc README.md CHANGES.md
%license LICENSE LICENSE.bsd LICENSE.gplv2
%{_libdir}/libjitterentropy.so.%{libjit_soversion}*
%files devel
%{_includedir}/*
%{_libdir}/libjitterentropy.so
%{_mandir}/man3/*
%changelog
* Fri Oct 25 2024 Vladis Dronov <vdronov@redhat.com> - 3.6.0-1
- Update to the upstream v3.6.0 @ 11829386 (RHEL-64947)
* Wed Feb 07 2024 Vladis Dronov <vdronov@redhat.com> - 3.5.0-1
- Update to the upstream v3.5.0 @ b178ef6b (RHEL-30957)
- Use proper SPDX license identifiers
* Tue Dec 27 2022 Vladis Dronov <vdronov@redhat.com> - 3.4.1-2
- Update to the upstream v3.4.1 @ 7bf9f85d (bz 2140043)
- Fix a stack corruption on s390x
* Tue Oct 04 2022 Vladis Dronov <vdronov@redhat.com> - 3.4.1-1
- Update to the upstream v3.4.1 @ 4544e113 (bz 2124596)
* Tue Apr 26 2022 Vladis Dronov <vdronov@redhat.com> - 3.4.0-1
- Update to the upstream v3.4.0 @ 2e5019cf (bz 2075978)
* Tue Nov 23 2021 Vladis Dronov <vdronov@redhat.com> - 3.3.1-2
- Update to the upstream v3.3.1 @ 887c9871 (bz 2015560)
- Fix a security issue found by a covscan in jitterentropy library
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 3.0.2-3.git.409828cf
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Tue Jul 13 2021 Vladis Dronov <vdronov@redhat.com> - 3.0.2-2.git.409828cf
- Update to the latest upstream commits upto 409828cf (bz 1973157)
- Add clock_gettime() software time source
- Add a code for choosing between software and hardware time sources
https://github.com/smuellerDD/jitterentropy-library/pull/57
https://bugzilla.redhat.com/show_bug.cgi?id=1974132
* Tue Jul 06 2021 Vladis Dronov <vdronov@redhat.com> - 3.0.2.git.d18d5863-1
- Update to the upstream v3.0.2 + tip of origin/master
with fixes for an important issue:
https://github.com/nhorman/rng-tools/pull/123
https://github.com/smuellerDD/jitterentropy-library/issues/37
- Add important upstream fixes for the one CPU case (bz 1974132)
* Fri Jun 18 2021 Vladis Dronov <vdronov@redhat.com> - 3.0.2-1
- Update to the upstream v3.0.2 (bz 1973157)
- Remove ldconfig_scriptlets
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.2.0-5
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Sep 26 2019 Neil Horman <nhorman@redhat.com> - 2.2.0-1
- Update to latest upstream
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Sep 21 2018 Neil Horman <nhorman@tuxdriver.com> - 2.1.2-3
- Drop static library
- Fix up naming
- Add gcc buildrequires
- Fix files glob
* Thu Sep 13 2018 Neil Horman <nhorman@tuxdriver.com> - 2.1.2-2
- Fixed license
- Fixed up some macro usage in spec file
- Documented patches
- Modified makefile to use $(INSTALL) macro
* Thu Sep 06 2018 Neil Horman <nhorman@tuxdriver.com> - 2.1.2-1
- Initial import

51
jitterentropy-api.patch Normal file
View File

@ -0,0 +1,51 @@
diff --git jitterentropy.h jitterentropy.h
--- jitterentropy.h
+++ jitterentropy.h
@@ -158,6 +158,24 @@ extern "C" {
#define JENT_PTHREAD
#endif
+/* an ugly hack to revert an api change --> */
+#define JENT_PTHREAD
+#ifdef JENT_CONF_ENABLE_INTERNAL_TIMER
+#ifdef JENT_PTHREAD
+#include <pthread.h>
+struct jent_notime_ctx {
+ pthread_attr_t notime_pthread_attr; /* pthreads library */
+ pthread_t notime_thread_id; /* pthreads thread ID */
+};
+#else
+#include <threads.h>
+struct jent_notime_ctx {
+ thrd_t notime_thread_id; /* thread ID */
+};
+#endif
+#endif
+/* <-- an ugly hack to revert an api change */
+
/* Forward declaration of opaque value */
struct rand_data;
diff --git src/jitterentropy-timer.c src/jitterentropy-timer.c
--- src/jitterentropy-timer.c
+++ src/jitterentropy-timer.c
@@ -24,19 +24,6 @@
/* Timer-less entropy source */
#ifdef JENT_CONF_ENABLE_INTERNAL_TIMER
-#ifdef JENT_PTHREAD
-#include <pthread.h>
-struct jent_notime_ctx {
- pthread_attr_t notime_pthread_attr; /* pthreads library */
- pthread_t notime_thread_id; /* pthreads thread ID */
-};
-#else
-#include <threads.h>
-struct jent_notime_ctx {
- thrd_t notime_thread_id; /* thread ID */
-};
-#endif
-
/***************************************************************************
* Thread handler
***************************************************************************/

View File

@ -0,0 +1,49 @@
diff --git jitterentropy-base-user.h jitterentropy-base-user.h
--- jitterentropy-base-user.h
+++ jitterentropy-base-user.h
@@ -196,42 +196,14 @@ static inline void jent_get_nstime(uint64_t *out)
*out = *(uint64_t *)(clk + 1);
}
-#elif defined(__powerpc)
-/*
- * Uncomment this for newer PPC CPUs
- * Newer PPC CPUs do not support mftbu/mftb
- * these instructions were obsoleted and replaced by
- * mfspr. special processor registers 268 and 269 are the
- * ones we want.
- */
- /* #define POWER_PC_USE_NEW_INSTRUCTIONS */
-
-/* taken from http://www.ecrypt.eu.org/ebats/cpucycles.html */
+#elif defined(__powerpc__)
static inline void jent_get_nstime(uint64_t *out)
{
- unsigned long high;
- unsigned long low;
- unsigned long newhigh;
- uint64_t result;
-#ifdef POWER_PC_USE_NEW_INSTRUCTIONS /* Newer PPC CPUs do not support mftbu/mftb */
- __asm__ __volatile__(
- "Lcpucycles:mfspr %0, 269;mfspr %1, 268;mfspr %2, 269;cmpw %0,%2;bne Lcpucycles"
- : "=r" (high), "=r" (low), "=r" (newhigh)
- );
-#else
- __asm__ __volatile__(
- "Lcpucycles:mftbu %0;mftb %1;mftbu %2;cmpw %0,%2;bne Lcpucycles"
- : "=r" (high), "=r" (low), "=r" (newhigh)
- );
-#endif
- result = high;
- result <<= 32;
- result |= low;
- *out = result;
+ *out = (uint64_t)__builtin_ppc_get_timebase();
}
-#else /* (__x86_64__) || (__i386__) || (__aarch64__) || (__s390x__) || (__powerpc) */
+#else /* (__x86_64__) || (__i386__) || (__aarch64__) || (__s390x__) || (__powerpc__) */
static inline void jent_get_nstime(uint64_t *out)
{

View File

@ -5,8 +5,8 @@ diff -up Makefile.orig Makefile
#Hardening
ENABLE_STACK_PROTECTOR ?= 1
CFLAGS ?= -fwrapv --param ssp-buffer-size=4 -fvisibility=hidden -fPIE -Wcast-align -Wmissing-field-initializers -Wshadow -Wswitch-enum
-CFLAGS +=-Wextra -Wall -pedantic -fPIC -O0 -fwrapv -Wconversion
+CFLAGS +=-Wp,-U_FORTIFY_SOURCE -Wextra -Wall -pedantic -fPIC -O0 -fwrapv -Wconversion
-CFLAGS +=-Wextra -Wall -pedantic -fPIC -O0 -fwrapv -Wconversion -std=c11
+CFLAGS +=-Wp,-U_FORTIFY_SOURCE -Wextra -Wall -pedantic -fPIC -O0 -fwrapv -Wconversion -std=c11
LDFLAGS +=-Wl,-z,relro,-z,now -lpthread
# Enable internal timer support

View File

@ -0,0 +1,82 @@
From 9671e0f658ef70bdadf18a060870f76eeb3f5f90 Mon Sep 17 00:00:00 2001
From: Eduard Abdullin <eabdullin@cloudlinux.com>
Date: Wed, 27 May 2026 11:48:00 +0500
Subject: [PATCH] Backport upstream commit 59dc5997: native riscv64 timer
The jitterentropy library v3.7.0 fails to build on riscv64 with -std=c11
because none of the architecture-specific branches in
jitterentropy-base-user.h match __riscv. Compilation falls through to
the generic clock_gettime() path, which glibc hides behind
_POSIX_C_SOURCE >= 199309L in C11 mode:
jitterentropy-base-user.h: In function 'jent_get_nstime':
jitterentropy-base-user.h:235:13: error: implicit declaration of
function 'clock_gettime' [-Wimplicit-function-declaration]
jitterentropy-base-user.h:235:27: error: 'CLOCK_REALTIME' undeclared
Upstream resolved this on 2026-04-25 in commit 59dc5997 ('refactor
architecture specific code'), which adds a native riscv branch using
the rdtime CSR via the rdtime pseudo-instruction. That commit is a
large refactor (17 files, +1544/-1499 lines) and has not yet appeared
in any tagged release; the next upstream release (3.7.1) will carry it.
Backport the riscv branch only, simplified for RV64. The timer
implementation is verbatim from upstream arch/jitterentropy-arch-timer.h;
only the structural wrapper differs (arch dispatch fused with the
function body, as in v3.7.0). RV32 (rdtimeh/rdtime retry pair) is
intentionally omitted because AlmaLinux only targets RV64 (riscv64).
Using the native time CSR rather than clock_gettime() also preserves
the entropy quality of the library: clock_gettime(CLOCK_REALTIME) is
subject to NTP steering and lacks the cycle-level resolution required
by the jitter entropy source on which all other architectures already
rely (rdtsc on x86, cntvct_el0 on aarch64, stcke on s390x, mftb on
ppc64le).
Drop this patch when jitterentropy is rebased to >= 3.7.1.
---
jitterentropy-base-user.h | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git jitterentropy-base-user.h jitterentropy-base-user.h
index 0cfc526..77e3b38 100644
--- jitterentropy-base-user.h
+++ jitterentropy-base-user.h
@@ -203,7 +203,33 @@ static inline void jent_get_nstime(uint64_t *out)
*out = (uint64_t)__builtin_ppc_get_timebase();
}
-#else /* (__x86_64__) || (__i386__) || (__aarch64__) || (__s390x__) || (__powerpc__) */
+#elif defined(__riscv)
+/*
+ * Backport of upstream commit 59dc5997 ("refactor architecture specific
+ * code", 2026-04-25) -- riscv branch only, simplified for RV64. To be
+ * obsoleted by jitterentropy >= 3.7.1, which carries the same logic in
+ * arch/jitterentropy-arch-timer.h (with full RV32 support).
+ *
+ * The "time" CSR is the platform timer and is reliably accessible from
+ * user mode on Linux (the kernel enables [s|m]counteren.TM). The "cycle"
+ * CSR has higher resolution but is not always user-readable. Override
+ * RISCV_NSTIME_INSN to switch sources, e.g. to "rdcycle".
+ *
+ * AlmaLinux only targets RV64 (riscv64); RV32 support is intentionally
+ * not backported (it would require a rdtimeh/rdtime retry pair).
+ */
+# ifndef RISCV_NSTIME_INSN
+# define RISCV_NSTIME_INSN "rdtime"
+# endif
+
+static inline void jent_get_nstime(uint64_t *out)
+{
+ uint64_t ctr_val;
+ __asm__ __volatile__(RISCV_NSTIME_INSN " %0" : "=r" (ctr_val));
+ *out = ctr_val;
+}
+
+#else /* (__x86_64__) || (__i386__) || (__aarch64__) || (__s390x__) || (__powerpc__) || (__riscv) */
static inline void jent_get_nstime(uint64_t *out)
{
--
2.51.0

86
jitterentropy.spec Normal file
View File

@ -0,0 +1,86 @@
%global libjit_soversion 3
Name: jitterentropy
Version: 3.7.0
Release: 1%{?dist}.alma.1
Summary: Library implementing the jitter entropy source
License: BSD-3-Clause OR GPL-2.0-only
URL: https://github.com/smuellerDD/jitterentropy-library
Source0: %{url}/archive/v%{version}/%{name}-library-%{version}.tar.gz
BuildRequires: gcc
BuildRequires: make
# Disable Upstream Makefiles debuginfo strip on install
Patch0: jitterentropy-rh-makefile.patch
# Gcc with -std=c11 defines __powerpc__ only
Patch1: jitterentropy-powerpc.patch
# Restore previous jitterentropy public api
Patch2: jitterentropy-api.patch
# AlmaLinux Patch
Patch1000: jitterentropy-riscv64.patch
%description
Library implementing the CPU jitter entropy source
%package devel
Summary: Development headers for jitterentropy library
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
Development headers and libraries for jitterentropy
%prep
%autosetup -p0 -n %{name}-library-%{version}
%build
%set_build_flags
%make_build
%install
mkdir -p %{buildroot}%{_includedir}
%make_install PREFIX=%{_prefix} LIBDIR=%{_lib}
%files
%doc README.md CHANGES.md
%license LICENSE LICENSE.bsd LICENSE.gplv2
%{_libdir}/libjitterentropy.so.%{libjit_soversion}*
%files devel
%{_includedir}/*
%{_libdir}/libjitterentropy.so
%{_mandir}/man3/*
%changelog
* Wed May 27 2026 Eduard Abdullin <eabdullin@almalinux.org> - 3.7.0-1.alma.1
- Backport patch for riscv64 architecture support
* Wed May 20 2026 Vladislav Dronov <vdronov@redhat.com> - 3.7.0-1
- Update to the upstream v3.7.0 @ e783cf1c (RHEL-176348)
- Fix PowerPC architecture detection code
- Simplify jent_get_nstime() for PowerPC
- Restore previous jitterentropy public api
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 3.6.0-2
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Fri Oct 25 2024 Vladis Dronov <vdronov@redhat.com> - 3.6.0-1
- Update to the upstream v3.6.0 @ 11829386 (RHEL-64946)
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 3.5.0-4
- Bump release for June 2024 mass rebuild
* Fri May 31 2024 Vladis Dronov <vdronov@redhat.com> - 3.5.0-3
- Update to the upstream v3.5.0 @ 48b2ffc1 (RHEL-30639)
* Mon Apr 01 2024 Vladis Dronov <vdronov@redhat.com> - 3.5.0-2
- Rebuild the package for RHEL-10
* Wed Feb 07 2024 Vladis Dronov <vdronov@redhat.com> - 3.5.0-1
- Update to the upstream v3.5.0 @ b178ef6b (RHEL-30639)
- Use proper SPDX license identifiers
* Fri Jan 26 2024 Vladis Dronov <vdronov@redhat.com> - 3.4.1-7
- Initial import from Fedora 40

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (jitterentropy-library-3.7.0.tar.gz) = 86efb4a0348a8426be9ce3742a9744f91f2bd201046463e3b5d530232735ae13f76fdc79105f683b97cfd211e9132a24f032dde817f83799e5776f472c182fc9

2
tests/README Normal file
View File

@ -0,0 +1,2 @@
jitterentropy library does not really have tests.
it is tested as a part of rng-tools tests.

4
tests/nulltest.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
echo JITTER-LIB nulltest is PASS
exit 0

10
tests/tests.yml Normal file
View File

@ -0,0 +1,10 @@
---
- hosts: localhost
roles:
- role: standard-test-basic
tags:
- classic
tests:
- nulltest:
dir: .
run: nulltest.sh