All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/10] archs/random: fallback to best raw ktime when no cycle counter
@ 2022-04-12 17:27 ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

Hi folks,

The RNG uses a function called random_get_entropy() basically anytime
that it needs to timestamp an event. For example, an interrupt comes in,
and we mix a random_get_entropy() into the entropy pool somehow.
Somebody mashes their keyboard or moves their mouse around? We mix a
random_get_entropy() into the entropy pool. It's one of the main
varieties of input.

Unfortunately, it's always 0 on a few platforms. The RNG has accumulated
various hacks to deal with this, but in general it's not great. Surely
we can do better than 0. In fact, *anything* that's not the same exact
value all the time would be better than 0. Even a counter that
increments once per hour would be better than 0! I think you get the
idea.

On most platforms, random_get_entropy() is aliased to get_cycles(),
which makes sense for platforms where get_cycles() is defined. RDTSC,
for example, has all the characteristics we care about for this
function: it's fast to acquire (i.e. acceptable in an irq handler),
pretty high precision, available, forms a 2-monotone distribution, etc.
But for platforms without that, what is the next best thing?

Sometimes the next best thing is architecture-defined. For example,
really old MIPS has the CP0 random register, which isn't a cycle
counter, but is at least something. However, some platforms don't even
have an architecture-defined fallback.

Fortunately, the timekeeping subsystem has already solved this problem
of trying to determine what the least bad clock is on constrained
systems, falling back to jiffies in the worst case. By exporting the raw
clock, we can get a decent fallback function for when there's no cycle
counter or architecture-specific function.

This series makes the RNG more useful on: m68k, RISC-V, MIPS, ARM32,
NIOS II, SPARC32, Xtensa, and Usermode Linux. Previously these platforms
would, in certain circumstances, but out of luck with regards to having
any type of event timestamping source in the RNG.

Finally, note that this series isn't about "jitter entropy" or other
ways of initializing the RNG. That's a different topic for a different
thread. Please don't let this discussion veer off into that. Here, I'm
just trying to find a good fallback counter/timer for platforms without
get_cycles(), a question with limited scope.

If this (or a future revision) looks good to you all and receives the
requisite acks, my plan was to take these through the random.git tree
for 5.19, so that I can then build on top of it. Alternatively, maybe
Thomas wants to take it through his timekeeping tree? Or something else.
If anybody has strong preferences, please pipe up.

Thanks,
Jason

Changes v2->v3:
- Name the fallback function random_get_entropy_fallback(), so that it
  can be changed out as needed.
- Include header with prototype in timekeeping.c to avoid compiler
  warning.
- Export fallback function symbol.

Changes v1->v2:
- Use ktime_read_raw_clock() instead of sched_clock(), per Thomas'
  suggestion.
- Drop arm64 change.
- Cleanup header inclusion ordering problem.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: David S. Miller <davem@davemloft.net>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: sparclinux@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: x86@kernel.org
Cc: linux-xtensa@linux-xtensa.org

Jason A. Donenfeld (10):
  timekeeping: add raw clock fallback for random_get_entropy()
  m68k: use fallback for random_get_entropy() instead of zero
  riscv: use fallback for random_get_entropy() instead of zero
  mips: use fallback for random_get_entropy() instead of zero
  arm: use fallback for random_get_entropy() instead of zero
  nios2: use fallback for random_get_entropy() instead of zero
  x86: use fallback for random_get_entropy() instead of zero
  um: use fallback for random_get_entropy() instead of zero
  sparc: use fallback for random_get_entropy() instead of zero
  xtensa: use fallback for random_get_entropy() instead of zero

 arch/arm/include/asm/timex.h      |  1 +
 arch/m68k/include/asm/timex.h     |  2 +-
 arch/mips/include/asm/timex.h     |  2 +-
 arch/nios2/include/asm/timex.h    |  2 ++
 arch/riscv/include/asm/timex.h    |  2 +-
 arch/sparc/include/asm/timex_32.h |  4 +---
 arch/um/include/asm/timex.h       |  9 ++-------
 arch/x86/include/asm/tsc.h        | 10 ++++++++++
 arch/xtensa/include/asm/timex.h   |  6 ++----
 include/linux/timex.h             |  8 ++++++++
 kernel/time/timekeeping.c         | 10 ++++++++++
 11 files changed, 39 insertions(+), 17 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH v3 00/10] archs/random: fallback to best raw ktime when no cycle counter
@ 2022-04-12 17:27 ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

Hi folks,

The RNG uses a function called random_get_entropy() basically anytime
that it needs to timestamp an event. For example, an interrupt comes in,
and we mix a random_get_entropy() into the entropy pool somehow.
Somebody mashes their keyboard or moves their mouse around? We mix a
random_get_entropy() into the entropy pool. It's one of the main
varieties of input.

Unfortunately, it's always 0 on a few platforms. The RNG has accumulated
various hacks to deal with this, but in general it's not great. Surely
we can do better than 0. In fact, *anything* that's not the same exact
value all the time would be better than 0. Even a counter that
increments once per hour would be better than 0! I think you get the
idea.

On most platforms, random_get_entropy() is aliased to get_cycles(),
which makes sense for platforms where get_cycles() is defined. RDTSC,
for example, has all the characteristics we care about for this
function: it's fast to acquire (i.e. acceptable in an irq handler),
pretty high precision, available, forms a 2-monotone distribution, etc.
But for platforms without that, what is the next best thing?

Sometimes the next best thing is architecture-defined. For example,
really old MIPS has the CP0 random register, which isn't a cycle
counter, but is at least something. However, some platforms don't even
have an architecture-defined fallback.

Fortunately, the timekeeping subsystem has already solved this problem
of trying to determine what the least bad clock is on constrained
systems, falling back to jiffies in the worst case. By exporting the raw
clock, we can get a decent fallback function for when there's no cycle
counter or architecture-specific function.

This series makes the RNG more useful on: m68k, RISC-V, MIPS, ARM32,
NIOS II, SPARC32, Xtensa, and Usermode Linux. Previously these platforms
would, in certain circumstances, but out of luck with regards to having
any type of event timestamping source in the RNG.

Finally, note that this series isn't about "jitter entropy" or other
ways of initializing the RNG. That's a different topic for a different
thread. Please don't let this discussion veer off into that. Here, I'm
just trying to find a good fallback counter/timer for platforms without
get_cycles(), a question with limited scope.

If this (or a future revision) looks good to you all and receives the
requisite acks, my plan was to take these through the random.git tree
for 5.19, so that I can then build on top of it. Alternatively, maybe
Thomas wants to take it through his timekeeping tree? Or something else.
If anybody has strong preferences, please pipe up.

Thanks,
Jason

Changes v2->v3:
- Name the fallback function random_get_entropy_fallback(), so that it
  can be changed out as needed.
- Include header with prototype in timekeeping.c to avoid compiler
  warning.
- Export fallback function symbol.

Changes v1->v2:
- Use ktime_read_raw_clock() instead of sched_clock(), per Thomas'
  suggestion.
- Drop arm64 change.
- Cleanup header inclusion ordering problem.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: David S. Miller <davem@davemloft.net>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: sparclinux@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: x86@kernel.org
Cc: linux-xtensa@linux-xtensa.org

Jason A. Donenfeld (10):
  timekeeping: add raw clock fallback for random_get_entropy()
  m68k: use fallback for random_get_entropy() instead of zero
  riscv: use fallback for random_get_entropy() instead of zero
  mips: use fallback for random_get_entropy() instead of zero
  arm: use fallback for random_get_entropy() instead of zero
  nios2: use fallback for random_get_entropy() instead of zero
  x86: use fallback for random_get_entropy() instead of zero
  um: use fallback for random_get_entropy() instead of zero
  sparc: use fallback for random_get_entropy() instead of zero
  xtensa: use fallback for random_get_entropy() instead of zero

 arch/arm/include/asm/timex.h      |  1 +
 arch/m68k/include/asm/timex.h     |  2 +-
 arch/mips/include/asm/timex.h     |  2 +-
 arch/nios2/include/asm/timex.h    |  2 ++
 arch/riscv/include/asm/timex.h    |  2 +-
 arch/sparc/include/asm/timex_32.h |  4 +---
 arch/um/include/asm/timex.h       |  9 ++-------
 arch/x86/include/asm/tsc.h        | 10 ++++++++++
 arch/xtensa/include/asm/timex.h   |  6 ++----
 include/linux/timex.h             |  8 ++++++++
 kernel/time/timekeeping.c         | 10 ++++++++++
 11 files changed, 39 insertions(+), 17 deletions(-)

-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH v3 00/10] archs/random: fallback to best raw ktime when no cycle counter
@ 2022-04-12 17:27 ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

Hi folks,

The RNG uses a function called random_get_entropy() basically anytime
that it needs to timestamp an event. For example, an interrupt comes in,
and we mix a random_get_entropy() into the entropy pool somehow.
Somebody mashes their keyboard or moves their mouse around? We mix a
random_get_entropy() into the entropy pool. It's one of the main
varieties of input.

Unfortunately, it's always 0 on a few platforms. The RNG has accumulated
various hacks to deal with this, but in general it's not great. Surely
we can do better than 0. In fact, *anything* that's not the same exact
value all the time would be better than 0. Even a counter that
increments once per hour would be better than 0! I think you get the
idea.

On most platforms, random_get_entropy() is aliased to get_cycles(),
which makes sense for platforms where get_cycles() is defined. RDTSC,
for example, has all the characteristics we care about for this
function: it's fast to acquire (i.e. acceptable in an irq handler),
pretty high precision, available, forms a 2-monotone distribution, etc.
But for platforms without that, what is the next best thing?

Sometimes the next best thing is architecture-defined. For example,
really old MIPS has the CP0 random register, which isn't a cycle
counter, but is at least something. However, some platforms don't even
have an architecture-defined fallback.

Fortunately, the timekeeping subsystem has already solved this problem
of trying to determine what the least bad clock is on constrained
systems, falling back to jiffies in the worst case. By exporting the raw
clock, we can get a decent fallback function for when there's no cycle
counter or architecture-specific function.

This series makes the RNG more useful on: m68k, RISC-V, MIPS, ARM32,
NIOS II, SPARC32, Xtensa, and Usermode Linux. Previously these platforms
would, in certain circumstances, but out of luck with regards to having
any type of event timestamping source in the RNG.

Finally, note that this series isn't about "jitter entropy" or other
ways of initializing the RNG. That's a different topic for a different
thread. Please don't let this discussion veer off into that. Here, I'm
just trying to find a good fallback counter/timer for platforms without
get_cycles(), a question with limited scope.

If this (or a future revision) looks good to you all and receives the
requisite acks, my plan was to take these through the random.git tree
for 5.19, so that I can then build on top of it. Alternatively, maybe
Thomas wants to take it through his timekeeping tree? Or something else.
If anybody has strong preferences, please pipe up.

Thanks,
Jason

Changes v2->v3:
- Name the fallback function random_get_entropy_fallback(), so that it
  can be changed out as needed.
- Include header with prototype in timekeeping.c to avoid compiler
  warning.
- Export fallback function symbol.

Changes v1->v2:
- Use ktime_read_raw_clock() instead of sched_clock(), per Thomas'
  suggestion.
- Drop arm64 change.
- Cleanup header inclusion ordering problem.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: David S. Miller <davem@davemloft.net>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: sparclinux@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: x86@kernel.org
Cc: linux-xtensa@linux-xtensa.org

Jason A. Donenfeld (10):
  timekeeping: add raw clock fallback for random_get_entropy()
  m68k: use fallback for random_get_entropy() instead of zero
  riscv: use fallback for random_get_entropy() instead of zero
  mips: use fallback for random_get_entropy() instead of zero
  arm: use fallback for random_get_entropy() instead of zero
  nios2: use fallback for random_get_entropy() instead of zero
  x86: use fallback for random_get_entropy() instead of zero
  um: use fallback for random_get_entropy() instead of zero
  sparc: use fallback for random_get_entropy() instead of zero
  xtensa: use fallback for random_get_entropy() instead of zero

 arch/arm/include/asm/timex.h      |  1 +
 arch/m68k/include/asm/timex.h     |  2 +-
 arch/mips/include/asm/timex.h     |  2 +-
 arch/nios2/include/asm/timex.h    |  2 ++
 arch/riscv/include/asm/timex.h    |  2 +-
 arch/sparc/include/asm/timex_32.h |  4 +---
 arch/um/include/asm/timex.h       |  9 ++-------
 arch/x86/include/asm/tsc.h        | 10 ++++++++++
 arch/xtensa/include/asm/timex.h   |  6 ++----
 include/linux/timex.h             |  8 ++++++++
 kernel/time/timekeeping.c         | 10 ++++++++++
 11 files changed, 39 insertions(+), 17 deletions(-)

-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

The addition of random_get_entropy_fallback() provides access to
whichever time source has the highest frequency, which is useful for
gathering entropy on platforms without available cycle counters. It's
not necessarily as good as being able to quickly access a cycle counter
that the CPU has, but it's still something, even when it falls back to
being jiffies-based.

In the event that a given arch does not define get_cycles(), falling
back to the get_cycles() default implementation that returns 0 is really
not the best we can do. Instead, at least calling
random_get_entropy_fallback() would be preferable, because that always
needs to return _something_, even falling back to jiffies eventually.
It's not as though random_get_entropy_fallback() is super high precision
or guaranteed to be entropic, but basically anything that's not zero all
the time is better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 include/linux/timex.h     |  8 ++++++++
 kernel/time/timekeeping.c | 10 ++++++++++
 2 files changed, 18 insertions(+)

diff --git a/include/linux/timex.h b/include/linux/timex.h
index 5745c90c8800..fbbe34226044 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -62,6 +62,8 @@
 #include <linux/types.h>
 #include <linux/param.h>
 
+extern unsigned long random_get_entropy_fallback(void);
+
 #include <asm/timex.h>
 
 #ifndef random_get_entropy
@@ -74,8 +76,14 @@
  *
  * By default we use get_cycles() for this purpose, but individual
  * architectures may override this in their asm/timex.h header file.
+ * If a given arch does not have get_cycles(), then we fallback to
+ * using random_get_entropy_fallback().
  */
+#ifdef get_cycles
 #define random_get_entropy()	((unsigned long)get_cycles())
+#else
+#define random_get_entropy()	random_get_entropy_fallback()
+#endif
 #endif
 
 /*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index dcdcb85121e4..7372d60c7c65 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -17,6 +17,7 @@
 #include <linux/clocksource.h>
 #include <linux/jiffies.h>
 #include <linux/time.h>
+#include <linux/timex.h>
 #include <linux/tick.h>
 #include <linux/stop_machine.h>
 #include <linux/pvclock_gtod.h>
@@ -2380,6 +2381,15 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc)
 	return 0;
 }
 
+/**
+ * random_get_entropy_fallback - Returns the raw clock source value,
+ * used by random.c for platforms with no valid random_get_entropy().
+ */
+unsigned long random_get_entropy_fallback(void)
+{
+	return tk_clock_read(&tk_core.timekeeper.tkr_mono);
+}
+EXPORT_SYMBOL(random_get_entropy_fallback);
 
 /**
  * do_adjtimex() - Accessor function to NTP __do_adjtimex function
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

The addition of random_get_entropy_fallback() provides access to
whichever time source has the highest frequency, which is useful for
gathering entropy on platforms without available cycle counters. It's
not necessarily as good as being able to quickly access a cycle counter
that the CPU has, but it's still something, even when it falls back to
being jiffies-based.

In the event that a given arch does not define get_cycles(), falling
back to the get_cycles() default implementation that returns 0 is really
not the best we can do. Instead, at least calling
random_get_entropy_fallback() would be preferable, because that always
needs to return _something_, even falling back to jiffies eventually.
It's not as though random_get_entropy_fallback() is super high precision
or guaranteed to be entropic, but basically anything that's not zero all
the time is better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 include/linux/timex.h     |  8 ++++++++
 kernel/time/timekeeping.c | 10 ++++++++++
 2 files changed, 18 insertions(+)

diff --git a/include/linux/timex.h b/include/linux/timex.h
index 5745c90c8800..fbbe34226044 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -62,6 +62,8 @@
 #include <linux/types.h>
 #include <linux/param.h>
 
+extern unsigned long random_get_entropy_fallback(void);
+
 #include <asm/timex.h>
 
 #ifndef random_get_entropy
@@ -74,8 +76,14 @@
  *
  * By default we use get_cycles() for this purpose, but individual
  * architectures may override this in their asm/timex.h header file.
+ * If a given arch does not have get_cycles(), then we fallback to
+ * using random_get_entropy_fallback().
  */
+#ifdef get_cycles
 #define random_get_entropy()	((unsigned long)get_cycles())
+#else
+#define random_get_entropy()	random_get_entropy_fallback()
+#endif
 #endif
 
 /*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index dcdcb85121e4..7372d60c7c65 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -17,6 +17,7 @@
 #include <linux/clocksource.h>
 #include <linux/jiffies.h>
 #include <linux/time.h>
+#include <linux/timex.h>
 #include <linux/tick.h>
 #include <linux/stop_machine.h>
 #include <linux/pvclock_gtod.h>
@@ -2380,6 +2381,15 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc)
 	return 0;
 }
 
+/**
+ * random_get_entropy_fallback - Returns the raw clock source value,
+ * used by random.c for platforms with no valid random_get_entropy().
+ */
+unsigned long random_get_entropy_fallback(void)
+{
+	return tk_clock_read(&tk_core.timekeeper.tkr_mono);
+}
+EXPORT_SYMBOL(random_get_entropy_fallback);
 
 /**
  * do_adjtimex() - Accessor function to NTP __do_adjtimex function
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

The addition of random_get_entropy_fallback() provides access to
whichever time source has the highest frequency, which is useful for
gathering entropy on platforms without available cycle counters. It's
not necessarily as good as being able to quickly access a cycle counter
that the CPU has, but it's still something, even when it falls back to
being jiffies-based.

In the event that a given arch does not define get_cycles(), falling
back to the get_cycles() default implementation that returns 0 is really
not the best we can do. Instead, at least calling
random_get_entropy_fallback() would be preferable, because that always
needs to return _something_, even falling back to jiffies eventually.
It's not as though random_get_entropy_fallback() is super high precision
or guaranteed to be entropic, but basically anything that's not zero all
the time is better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 include/linux/timex.h     |  8 ++++++++
 kernel/time/timekeeping.c | 10 ++++++++++
 2 files changed, 18 insertions(+)

diff --git a/include/linux/timex.h b/include/linux/timex.h
index 5745c90c8800..fbbe34226044 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -62,6 +62,8 @@
 #include <linux/types.h>
 #include <linux/param.h>
 
+extern unsigned long random_get_entropy_fallback(void);
+
 #include <asm/timex.h>
 
 #ifndef random_get_entropy
@@ -74,8 +76,14 @@
  *
  * By default we use get_cycles() for this purpose, but individual
  * architectures may override this in their asm/timex.h header file.
+ * If a given arch does not have get_cycles(), then we fallback to
+ * using random_get_entropy_fallback().
  */
+#ifdef get_cycles
 #define random_get_entropy()	((unsigned long)get_cycles())
+#else
+#define random_get_entropy()	random_get_entropy_fallback()
+#endif
 #endif
 
 /*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index dcdcb85121e4..7372d60c7c65 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -17,6 +17,7 @@
 #include <linux/clocksource.h>
 #include <linux/jiffies.h>
 #include <linux/time.h>
+#include <linux/timex.h>
 #include <linux/tick.h>
 #include <linux/stop_machine.h>
 #include <linux/pvclock_gtod.h>
@@ -2380,6 +2381,15 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc)
 	return 0;
 }
 
+/**
+ * random_get_entropy_fallback - Returns the raw clock source value,
+ * used by random.c for platforms with no valid random_get_entropy().
+ */
+unsigned long random_get_entropy_fallback(void)
+{
+	return tk_clock_read(&tk_core.timekeeper.tkr_mono);
+}
+EXPORT_SYMBOL(random_get_entropy_fallback);
 
 /**
  * do_adjtimex() - Accessor function to NTP __do_adjtimex function
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/m68k/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/timex.h b/arch/m68k/include/asm/timex.h
index 6a21d9358280..f4a7a340f4ca 100644
--- a/arch/m68k/include/asm/timex.h
+++ b/arch/m68k/include/asm/timex.h
@@ -35,7 +35,7 @@ static inline unsigned long random_get_entropy(void)
 {
 	if (mach_random_get_entropy)
 		return mach_random_get_entropy();
-	return 0;
+	return random_get_entropy_fallback();
 }
 #define random_get_entropy	random_get_entropy
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/m68k/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/timex.h b/arch/m68k/include/asm/timex.h
index 6a21d9358280..f4a7a340f4ca 100644
--- a/arch/m68k/include/asm/timex.h
+++ b/arch/m68k/include/asm/timex.h
@@ -35,7 +35,7 @@ static inline unsigned long random_get_entropy(void)
 {
 	if (mach_random_get_entropy)
 		return mach_random_get_entropy();
-	return 0;
+	return random_get_entropy_fallback();
 }
 #define random_get_entropy	random_get_entropy
 
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/m68k/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/timex.h b/arch/m68k/include/asm/timex.h
index 6a21d9358280..f4a7a340f4ca 100644
--- a/arch/m68k/include/asm/timex.h
+++ b/arch/m68k/include/asm/timex.h
@@ -35,7 +35,7 @@ static inline unsigned long random_get_entropy(void)
 {
 	if (mach_random_get_entropy)
 		return mach_random_get_entropy();
-	return 0;
+	return random_get_entropy_fallback();
 }
 #define random_get_entropy	random_get_entropy
 
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 03/10] riscv: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/riscv/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/timex.h b/arch/riscv/include/asm/timex.h
index 507cae273bc6..d6a7428f6248 100644
--- a/arch/riscv/include/asm/timex.h
+++ b/arch/riscv/include/asm/timex.h
@@ -41,7 +41,7 @@ static inline u32 get_cycles_hi(void)
 static inline unsigned long random_get_entropy(void)
 {
 	if (unlikely(clint_time_val == NULL))
-		return 0;
+		return random_get_entropy_fallback();
 	return get_cycles();
 }
 #define random_get_entropy()	random_get_entropy()
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 03/10] riscv: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/riscv/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/timex.h b/arch/riscv/include/asm/timex.h
index 507cae273bc6..d6a7428f6248 100644
--- a/arch/riscv/include/asm/timex.h
+++ b/arch/riscv/include/asm/timex.h
@@ -41,7 +41,7 @@ static inline u32 get_cycles_hi(void)
 static inline unsigned long random_get_entropy(void)
 {
 	if (unlikely(clint_time_val == NULL))
-		return 0;
+		return random_get_entropy_fallback();
 	return get_cycles();
 }
 #define random_get_entropy()	random_get_entropy()
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 03/10] riscv: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/riscv/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/timex.h b/arch/riscv/include/asm/timex.h
index 507cae273bc6..d6a7428f6248 100644
--- a/arch/riscv/include/asm/timex.h
+++ b/arch/riscv/include/asm/timex.h
@@ -41,7 +41,7 @@ static inline u32 get_cycles_hi(void)
 static inline unsigned long random_get_entropy(void)
 {
 	if (unlikely(clint_time_val == NULL))
-		return 0;
+		return random_get_entropy_fallback();
 	return get_cycles();
 }
 #define random_get_entropy()	random_get_entropy()
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 04/10] mips: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/mips/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/timex.h b/arch/mips/include/asm/timex.h
index b05bb70a2e46..abc60a6395e3 100644
--- a/arch/mips/include/asm/timex.h
+++ b/arch/mips/include/asm/timex.h
@@ -94,7 +94,7 @@ static inline unsigned long random_get_entropy(void)
 	else if (likely(imp != PRID_IMP_R6000 && imp != PRID_IMP_R6000A))
 		return read_c0_random();
 	else
-		return 0;	/* no usable register */
+		return random_get_entropy_fallback();	/* no usable register */
 }
 #define random_get_entropy random_get_entropy
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 04/10] mips: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/mips/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/timex.h b/arch/mips/include/asm/timex.h
index b05bb70a2e46..abc60a6395e3 100644
--- a/arch/mips/include/asm/timex.h
+++ b/arch/mips/include/asm/timex.h
@@ -94,7 +94,7 @@ static inline unsigned long random_get_entropy(void)
 	else if (likely(imp != PRID_IMP_R6000 && imp != PRID_IMP_R6000A))
 		return read_c0_random();
 	else
-		return 0;	/* no usable register */
+		return random_get_entropy_fallback();	/* no usable register */
 }
 #define random_get_entropy random_get_entropy
 
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 04/10] mips: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/mips/include/asm/timex.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/timex.h b/arch/mips/include/asm/timex.h
index b05bb70a2e46..abc60a6395e3 100644
--- a/arch/mips/include/asm/timex.h
+++ b/arch/mips/include/asm/timex.h
@@ -94,7 +94,7 @@ static inline unsigned long random_get_entropy(void)
 	else if (likely(imp != PRID_IMP_R6000 && imp != PRID_IMP_R6000A))
 		return read_c0_random();
 	else
-		return 0;	/* no usable register */
+		return random_get_entropy_fallback();	/* no usable register */
 }
 #define random_get_entropy random_get_entropy
 
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 05/10] arm: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/arm/include/asm/timex.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 7c3b3671d6c2..6d1337c169cd 100644
--- a/arch/arm/include/asm/timex.h
+++ b/arch/arm/include/asm/timex.h
@@ -11,5 +11,6 @@
 
 typedef unsigned long cycles_t;
 #define get_cycles()	({ cycles_t c; read_current_timer(&c) ? 0 : c; })
+#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
 
 #endif
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 05/10] arm: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/arm/include/asm/timex.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 7c3b3671d6c2..6d1337c169cd 100644
--- a/arch/arm/include/asm/timex.h
+++ b/arch/arm/include/asm/timex.h
@@ -11,5 +11,6 @@
 
 typedef unsigned long cycles_t;
 #define get_cycles()	({ cycles_t c; read_current_timer(&c) ? 0 : c; })
+#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
 
 #endif
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 05/10] arm: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/arm/include/asm/timex.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 7c3b3671d6c2..6d1337c169cd 100644
--- a/arch/arm/include/asm/timex.h
+++ b/arch/arm/include/asm/timex.h
@@ -11,5 +11,6 @@
 
 typedef unsigned long cycles_t;
 #define get_cycles()	({ cycles_t c; read_current_timer(&c) ? 0 : c; })
+#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
 
 #endif
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 06/10] nios2: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/nios2/include/asm/timex.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/nios2/include/asm/timex.h b/arch/nios2/include/asm/timex.h
index a769f871b28d..d9a3f426cdda 100644
--- a/arch/nios2/include/asm/timex.h
+++ b/arch/nios2/include/asm/timex.h
@@ -9,4 +9,6 @@ typedef unsigned long cycles_t;
 
 extern cycles_t get_cycles(void);
 
+#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
+
 #endif
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 06/10] nios2: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/nios2/include/asm/timex.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/nios2/include/asm/timex.h b/arch/nios2/include/asm/timex.h
index a769f871b28d..d9a3f426cdda 100644
--- a/arch/nios2/include/asm/timex.h
+++ b/arch/nios2/include/asm/timex.h
@@ -9,4 +9,6 @@ typedef unsigned long cycles_t;
 
 extern cycles_t get_cycles(void);
 
+#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
+
 #endif
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 06/10] nios2: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/nios2/include/asm/timex.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/nios2/include/asm/timex.h b/arch/nios2/include/asm/timex.h
index a769f871b28d..d9a3f426cdda 100644
--- a/arch/nios2/include/asm/timex.h
+++ b/arch/nios2/include/asm/timex.h
@@ -9,4 +9,6 @@ typedef unsigned long cycles_t;
 
 extern cycles_t get_cycles(void);
 
+#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
+
 #endif
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 07/10] x86: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

If CONFIG_X86_TSC=n, then it's possible that we're running on a 486 with
no RDTSC, so we only need the fallback code for that case.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: x86@kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/x86/include/asm/tsc.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
index 01a300a9700b..194dc1e3f77c 100644
--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -28,6 +28,16 @@ static inline cycles_t get_cycles(void)
 	return rdtsc();
 }
 
+static inline unsigned long random_get_entropy(void)
+{
+#ifndef CONFIG_X86_TSC
+	if (!boot_cpu_has(X86_FEATURE_TSC))
+		return random_get_entropy_fallback();
+#endif
+	return rdtsc();
+}
+#define random_get_entropy random_get_entropy
+
 extern struct system_counterval_t convert_art_to_tsc(u64 art);
 extern struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 07/10] x86: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

If CONFIG_X86_TSC=n, then it's possible that we're running on a 486 with
no RDTSC, so we only need the fallback code for that case.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: x86@kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/x86/include/asm/tsc.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
index 01a300a9700b..194dc1e3f77c 100644
--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -28,6 +28,16 @@ static inline cycles_t get_cycles(void)
 	return rdtsc();
 }
 
+static inline unsigned long random_get_entropy(void)
+{
+#ifndef CONFIG_X86_TSC
+	if (!boot_cpu_has(X86_FEATURE_TSC))
+		return random_get_entropy_fallback();
+#endif
+	return rdtsc();
+}
+#define random_get_entropy random_get_entropy
+
 extern struct system_counterval_t convert_art_to_tsc(u64 art);
 extern struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns);
 
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 07/10] x86: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

If CONFIG_X86_TSC=n, then it's possible that we're running on a 486 with
no RDTSC, so we only need the fallback code for that case.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: x86@kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/x86/include/asm/tsc.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
index 01a300a9700b..194dc1e3f77c 100644
--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -28,6 +28,16 @@ static inline cycles_t get_cycles(void)
 	return rdtsc();
 }
 
+static inline unsigned long random_get_entropy(void)
+{
+#ifndef CONFIG_X86_TSC
+	if (!boot_cpu_has(X86_FEATURE_TSC))
+		return random_get_entropy_fallback();
+#endif
+	return rdtsc();
+}
+#define random_get_entropy random_get_entropy
+
 extern struct system_counterval_t convert_art_to_tsc(u64 art);
 extern struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns);
 
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 08/10] um: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/um/include/asm/timex.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/um/include/asm/timex.h b/arch/um/include/asm/timex.h
index e392a9a5bc9b..9f27176adb26 100644
--- a/arch/um/include/asm/timex.h
+++ b/arch/um/include/asm/timex.h
@@ -2,13 +2,8 @@
 #ifndef __UM_TIMEX_H
 #define __UM_TIMEX_H
 
-typedef unsigned long cycles_t;
-
-static inline cycles_t get_cycles (void)
-{
-	return 0;
-}
-
 #define CLOCK_TICK_RATE (HZ)
 
+#include <asm-generic/timex.h>
+
 #endif
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 08/10] um: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/um/include/asm/timex.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/um/include/asm/timex.h b/arch/um/include/asm/timex.h
index e392a9a5bc9b..9f27176adb26 100644
--- a/arch/um/include/asm/timex.h
+++ b/arch/um/include/asm/timex.h
@@ -2,13 +2,8 @@
 #ifndef __UM_TIMEX_H
 #define __UM_TIMEX_H
 
-typedef unsigned long cycles_t;
-
-static inline cycles_t get_cycles (void)
-{
-	return 0;
-}
-
 #define CLOCK_TICK_RATE (HZ)
 
+#include <asm-generic/timex.h>
+
 #endif
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 08/10] um: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/um/include/asm/timex.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/um/include/asm/timex.h b/arch/um/include/asm/timex.h
index e392a9a5bc9b..9f27176adb26 100644
--- a/arch/um/include/asm/timex.h
+++ b/arch/um/include/asm/timex.h
@@ -2,13 +2,8 @@
 #ifndef __UM_TIMEX_H
 #define __UM_TIMEX_H
 
-typedef unsigned long cycles_t;
-
-static inline cycles_t get_cycles (void)
-{
-	return 0;
-}
-
 #define CLOCK_TICK_RATE (HZ)
 
+#include <asm-generic/timex.h>
+
 #endif
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 09/10] sparc: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/sparc/include/asm/timex_32.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sparc/include/asm/timex_32.h b/arch/sparc/include/asm/timex_32.h
index 542915b46209..f86326a6f89e 100644
--- a/arch/sparc/include/asm/timex_32.h
+++ b/arch/sparc/include/asm/timex_32.h
@@ -9,8 +9,6 @@
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
 
-/* XXX Maybe do something better at some point... -DaveM */
-typedef unsigned long cycles_t;
-#define get_cycles()	(0)
+#include <asm-generic/timex.h>
 
 #endif
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 09/10] sparc: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/sparc/include/asm/timex_32.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sparc/include/asm/timex_32.h b/arch/sparc/include/asm/timex_32.h
index 542915b46209..f86326a6f89e 100644
--- a/arch/sparc/include/asm/timex_32.h
+++ b/arch/sparc/include/asm/timex_32.h
@@ -9,8 +9,6 @@
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
 
-/* XXX Maybe do something better at some point... -DaveM */
-typedef unsigned long cycles_t;
-#define get_cycles()	(0)
+#include <asm-generic/timex.h>
 
 #endif
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 09/10] sparc: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/sparc/include/asm/timex_32.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sparc/include/asm/timex_32.h b/arch/sparc/include/asm/timex_32.h
index 542915b46209..f86326a6f89e 100644
--- a/arch/sparc/include/asm/timex_32.h
+++ b/arch/sparc/include/asm/timex_32.h
@@ -9,8 +9,6 @@
 
 #define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
 
-/* XXX Maybe do something better at some point... -DaveM */
-typedef unsigned long cycles_t;
-#define get_cycles()	(0)
+#include <asm-generic/timex.h>
 
 #endif
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 10/10] xtensa: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27 ` Jason A. Donenfeld
  (?)
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/xtensa/include/asm/timex.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/include/asm/timex.h b/arch/xtensa/include/asm/timex.h
index 233ec75e60c6..3f2462f2d027 100644
--- a/arch/xtensa/include/asm/timex.h
+++ b/arch/xtensa/include/asm/timex.h
@@ -29,10 +29,6 @@
 
 extern unsigned long ccount_freq;
 
-typedef unsigned long long cycles_t;
-
-#define get_cycles()	(0)
-
 void local_timer_setup(unsigned cpu);
 
 /*
@@ -59,4 +55,6 @@ static inline void set_linux_timer (unsigned long ccompare)
 	xtensa_set_sr(ccompare, SREG_CCOMPARE + LINUX_TIMER);
 }
 
+#include <asm-generic/timex.h>
+
 #endif	/* _XTENSA_TIMEX_H */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 10/10] xtensa: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/xtensa/include/asm/timex.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/include/asm/timex.h b/arch/xtensa/include/asm/timex.h
index 233ec75e60c6..3f2462f2d027 100644
--- a/arch/xtensa/include/asm/timex.h
+++ b/arch/xtensa/include/asm/timex.h
@@ -29,10 +29,6 @@
 
 extern unsigned long ccount_freq;
 
-typedef unsigned long long cycles_t;
-
-#define get_cycles()	(0)
-
 void local_timer_setup(unsigned cpu);
 
 /*
@@ -59,4 +55,6 @@ static inline void set_linux_timer (unsigned long ccompare)
 	xtensa_set_sr(ccompare, SREG_CCOMPARE + LINUX_TIMER);
 }
 
+#include <asm-generic/timex.h>
+
 #endif	/* _XTENSA_TIMEX_H */
-- 
2.35.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 10/10] xtensa: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 17:27   ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 17:27 UTC (permalink / raw)
  To: linux-kernel, linux-crypto, tglx, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

In the event that random_get_entropy() can't access a cycle counter or
similar, falling back to returning 0 is really not the best we can do.
Instead, at least calling random_get_entropy_fallback() would be
preferable, because that always needs to return _something_, even
falling back to jiffies eventually. It's not as though
random_get_entropy_fallback() is super high precision or guaranteed to
be entropic, but basically anything that's not zero all the time is
better than returning zero all the time.

This is accomplished by just including the asm-generic code like on
other architectures, which means we can get rid of the empty stub
function here.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/xtensa/include/asm/timex.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/include/asm/timex.h b/arch/xtensa/include/asm/timex.h
index 233ec75e60c6..3f2462f2d027 100644
--- a/arch/xtensa/include/asm/timex.h
+++ b/arch/xtensa/include/asm/timex.h
@@ -29,10 +29,6 @@
 
 extern unsigned long ccount_freq;
 
-typedef unsigned long long cycles_t;
-
-#define get_cycles()	(0)
-
 void local_timer_setup(unsigned cpu);
 
 /*
@@ -59,4 +55,6 @@ static inline void set_linux_timer (unsigned long ccompare)
 	xtensa_set_sr(ccompare, SREG_CCOMPARE + LINUX_TIMER);
 }
 
+#include <asm-generic/timex.h>
+
 #endif	/* _XTENSA_TIMEX_H */
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero
  2022-04-12 17:27   ` Jason A. Donenfeld
  (?)
  (?)
@ 2022-04-12 19:26     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 43+ messages in thread
From: Geert Uytterhoeven @ 2022-04-12 19:26 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: Linux Kernel Mailing List, Linux Crypto Mailing List,
	Thomas Gleixner, Arnd Bergmann, Theodore Ts'o,
	Dominik Brodowski, Russell King, Catalin Marinas, Will Deacon,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, Linux ARM, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, linux-riscv, sparclinux,
	linux-um, the arch/x86 maintainers,
	open list:TENSILICA XTENSA PORT (xtensa)

On Tue, Apr 12, 2022 at 7:29 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> In the event that random_get_entropy() can't access a cycle counter or
> similar, falling back to returning 0 is really not the best we can do.
> Instead, at least calling random_get_entropy_fallback() would be
> preferable, because that always needs to return _something_, even
> falling back to jiffies eventually. It's not as though
> random_get_entropy_fallback() is super high precision or guaranteed to
> be entropic, but basically anything that's not zero all the time is
> better than returning zero all the time.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 19:26     ` Geert Uytterhoeven
  0 siblings, 0 replies; 43+ messages in thread
From: Geert Uytterhoeven @ 2022-04-12 19:26 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: Linux Kernel Mailing List, Linux Crypto Mailing List,
	Thomas Gleixner, Arnd Bergmann, Theodore Ts'o,
	Dominik Brodowski, Russell King, Catalin Marinas, Will Deacon,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, Linux ARM, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, linux-riscv, sparclinux,
	linux-um, the arch/x86 maintainers,
	open list:TENSILICA XTENSA PORT (xtensa)

On Tue, Apr 12, 2022 at 7:29 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> In the event that random_get_entropy() can't access a cycle counter or
> similar, falling back to returning 0 is really not the best we can do.
> Instead, at least calling random_get_entropy_fallback() would be
> preferable, because that always needs to return _something_, even
> falling back to jiffies eventually. It's not as though
> random_get_entropy_fallback() is super high precision or guaranteed to
> be entropic, but basically anything that's not zero all the time is
> better than returning zero all the time.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 19:26     ` Geert Uytterhoeven
  0 siblings, 0 replies; 43+ messages in thread
From: Geert Uytterhoeven @ 2022-04-12 19:26 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: Linux Kernel Mailing List, Linux Crypto Mailing List,
	Thomas Gleixner, Arnd Bergmann, Theodore Ts'o,
	Dominik Brodowski, Russell King, Catalin Marinas, Will Deacon,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, Linux ARM, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, linux-riscv, sparclinux,
	linux-um, the arch/x86 maintainers,
	open list:TENSILICA XTENSA PORT (xtensa)

On Tue, Apr 12, 2022 at 7:29 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> In the event that random_get_entropy() can't access a cycle counter or
> similar, falling back to returning 0 is really not the best we can do.
> Instead, at least calling random_get_entropy_fallback() would be
> preferable, because that always needs to return _something_, even
> falling back to jiffies eventually. It's not as though
> random_get_entropy_fallback() is super high precision or guaranteed to
> be entropic, but basically anything that's not zero all the time is
> better than returning zero all the time.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero
@ 2022-04-12 19:26     ` Geert Uytterhoeven
  0 siblings, 0 replies; 43+ messages in thread
From: Geert Uytterhoeven @ 2022-04-12 19:26 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: Linux Kernel Mailing List, Linux Crypto Mailing List,
	Thomas Gleixner, Arnd Bergmann, Jason A. Donenfeld,
	Theodore Ts'o, Dominik Brodowski, Russell King,
	Catalin Marinas, Will Deacon, Thomas Bogendoerfer, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, David S . Miller, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H . Peter Anvin, Chris Zankel, Max Filippov,
	John Stultz, Stephen Boyd, Dinh Nguyen, Linux ARM, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, linux-riscv, sparclinux,
	linux-um, the arch/x86 maintainers,
	open list:TENSILICA XTENSA PORT (xtensa)

On Tue, Apr 12, 2022 at 7:29 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> In the event that random_get_entropy() can't access a cycle counter or
> similar, falling back to returning 0 is really not the best we can do.
> Instead, at least calling random_get_entropy_fallback() would be
> preferable, because that always needs to return _something_, even
> falling back to jiffies eventually. It's not as though
> random_get_entropy_fallback() is super high precision or guaranteed to
> be entropic, but basically anything that's not zero all the time is
> better than returning zero all the time.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
  2022-04-12 17:27   ` Jason A. Donenfeld
  (?)
@ 2022-04-12 20:57     ` Thomas Gleixner
  -1 siblings, 0 replies; 43+ messages in thread
From: Thomas Gleixner @ 2022-04-12 20:57 UTC (permalink / raw)
  To: Jason A. Donenfeld, linux-kernel, linux-crypto, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

On Tue, Apr 12 2022 at 19:27, Jason A. Donenfeld wrote:
> +/**
> + * random_get_entropy_fallback - Returns the raw clock source value,
> + * used by random.c for platforms with no valid random_get_entropy().
> + */
> +unsigned long random_get_entropy_fallback(void)
> +{
> +	return tk_clock_read(&tk_core.timekeeper.tkr_mono);
> +}
> +EXPORT_SYMBOL(random_get_entropy_fallback);

EXPORT_SYMBOL_GPL() please.

Thanks,

        tglx

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
@ 2022-04-12 20:57     ` Thomas Gleixner
  0 siblings, 0 replies; 43+ messages in thread
From: Thomas Gleixner @ 2022-04-12 20:57 UTC (permalink / raw)
  To: Jason A. Donenfeld, linux-kernel, linux-crypto, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

On Tue, Apr 12 2022 at 19:27, Jason A. Donenfeld wrote:
> +/**
> + * random_get_entropy_fallback - Returns the raw clock source value,
> + * used by random.c for platforms with no valid random_get_entropy().
> + */
> +unsigned long random_get_entropy_fallback(void)
> +{
> +	return tk_clock_read(&tk_core.timekeeper.tkr_mono);
> +}
> +EXPORT_SYMBOL(random_get_entropy_fallback);

EXPORT_SYMBOL_GPL() please.

Thanks,

        tglx

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
@ 2022-04-12 20:57     ` Thomas Gleixner
  0 siblings, 0 replies; 43+ messages in thread
From: Thomas Gleixner @ 2022-04-12 20:57 UTC (permalink / raw)
  To: Jason A. Donenfeld, linux-kernel, linux-crypto, arnd
  Cc: Jason A. Donenfeld, Theodore Ts'o, Dominik Brodowski,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	linux-mips, linux-riscv, sparclinux, linux-um, x86, linux-xtensa

On Tue, Apr 12 2022 at 19:27, Jason A. Donenfeld wrote:
> +/**
> + * random_get_entropy_fallback - Returns the raw clock source value,
> + * used by random.c for platforms with no valid random_get_entropy().
> + */
> +unsigned long random_get_entropy_fallback(void)
> +{
> +	return tk_clock_read(&tk_core.timekeeper.tkr_mono);
> +}
> +EXPORT_SYMBOL(random_get_entropy_fallback);

EXPORT_SYMBOL_GPL() please.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
  2022-04-12 20:57     ` Thomas Gleixner
  (?)
@ 2022-04-12 21:17       ` Jason A. Donenfeld
  -1 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 21:17 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Linux Crypto Mailing List, Arnd Bergmann,
	Theodore Ts'o, Dominik Brodowski, Russell King,
	Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, linux-riscv, sparclinux,
	linux-um, X86 ML, linux-xtensa

Hi Thomas,

On Tue, Apr 12, 2022 at 10:57 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Tue, Apr 12 2022 at 19:27, Jason A. Donenfeld wrote:
> > +/**
> > + * random_get_entropy_fallback - Returns the raw clock source value,
> > + * used by random.c for platforms with no valid random_get_entropy().
> > + */
> > +unsigned long random_get_entropy_fallback(void)
> > +{
> > +     return tk_clock_read(&tk_core.timekeeper.tkr_mono);
> > +}
> > +EXPORT_SYMBOL(random_get_entropy_fallback);
>
> EXPORT_SYMBOL_GPL() please.

Okay, will do.

Jason

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
@ 2022-04-12 21:17       ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 21:17 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Linux Crypto Mailing List, Arnd Bergmann,
	Theodore Ts'o, Dominik Brodowski, Russell King,
	Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, linux-riscv, sparclinux,
	linux-um, X86 ML, linux-xtensa

Hi Thomas,

On Tue, Apr 12, 2022 at 10:57 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Tue, Apr 12 2022 at 19:27, Jason A. Donenfeld wrote:
> > +/**
> > + * random_get_entropy_fallback - Returns the raw clock source value,
> > + * used by random.c for platforms with no valid random_get_entropy().
> > + */
> > +unsigned long random_get_entropy_fallback(void)
> > +{
> > +     return tk_clock_read(&tk_core.timekeeper.tkr_mono);
> > +}
> > +EXPORT_SYMBOL(random_get_entropy_fallback);
>
> EXPORT_SYMBOL_GPL() please.

Okay, will do.

Jason

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy()
@ 2022-04-12 21:17       ` Jason A. Donenfeld
  0 siblings, 0 replies; 43+ messages in thread
From: Jason A. Donenfeld @ 2022-04-12 21:17 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Linux Crypto Mailing List, Arnd Bergmann,
	Theodore Ts'o, Dominik Brodowski, Russell King,
	Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Thomas Bogendoerfer, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	David S . Miller, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Chris Zankel, Max Filippov, John Stultz,
	Stephen Boyd, Dinh Nguyen, linux-arm-kernel, linux-m68k,
	open list:BROADCOM NVRAM DRIVER, linux-riscv, sparclinux,
	linux-um, X86 ML, linux-xtensa

Hi Thomas,

On Tue, Apr 12, 2022 at 10:57 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Tue, Apr 12 2022 at 19:27, Jason A. Donenfeld wrote:
> > +/**
> > + * random_get_entropy_fallback - Returns the raw clock source value,
> > + * used by random.c for platforms with no valid random_get_entropy().
> > + */
> > +unsigned long random_get_entropy_fallback(void)
> > +{
> > +     return tk_clock_read(&tk_core.timekeeper.tkr_mono);
> > +}
> > +EXPORT_SYMBOL(random_get_entropy_fallback);
>
> EXPORT_SYMBOL_GPL() please.

Okay, will do.

Jason

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2022-04-12 23:20 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 17:27 [PATCH v3 00/10] archs/random: fallback to best raw ktime when no cycle counter Jason A. Donenfeld
2022-04-12 17:27 ` Jason A. Donenfeld
2022-04-12 17:27 ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 01/10] timekeeping: add raw clock fallback for random_get_entropy() Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 20:57   ` Thomas Gleixner
2022-04-12 20:57     ` Thomas Gleixner
2022-04-12 20:57     ` Thomas Gleixner
2022-04-12 21:17     ` Jason A. Donenfeld
2022-04-12 21:17       ` Jason A. Donenfeld
2022-04-12 21:17       ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 02/10] m68k: use fallback for random_get_entropy() instead of zero Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 19:26   ` Geert Uytterhoeven
2022-04-12 19:26     ` Geert Uytterhoeven
2022-04-12 19:26     ` Geert Uytterhoeven
2022-04-12 19:26     ` Geert Uytterhoeven
2022-04-12 17:27 ` [PATCH v3 03/10] riscv: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 04/10] mips: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 05/10] arm: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 06/10] nios2: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 07/10] x86: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 08/10] um: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 09/10] sparc: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27 ` [PATCH v3 10/10] xtensa: " Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld
2022-04-12 17:27   ` Jason A. Donenfeld

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.