Skip to contentSkip to conversation

random: Include <linux/percpu.h> and resolve circular include dependency

PATCH Applied Uros Bizjak 7 participants 32 messages Sep 5, 2024 – Sep 9, 2024

Subsystems (24)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover random: Include <linux/percpu.h> and resolve circular include dependency

There were several attempts to resolve circular include dependency after the addition of percpu.h: 1c9df907da83 ("random: fix circular include dependency on arm64 after addition of percpu.h"), c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h") and finally d9f29deb7fe8 ("prandom: Remove unused include") that completely removes inclusion of <linux/percpu.h>.

Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but with the commit entry remark:

--quote--
A further cleanup step would be to remove this from <linux/random.h> entirely, and make people who use the prandom infrastructure include just the new header file. That's a bit of a churn patch, but grepping for "prandom_" and "next_pseudo_random32" "struct rnd_state" should catch most users.

But it turns out that that nice cleanup step is fairly painful, because a _lot_ of code currently seems to depend on the implicit include of <linux/random.h>, which can currently come in a lot of ways, including such fairly core headfers as <linux/net.h>.

So the "nice cleanup" part may or may never happen. --/quote--

__percpu tag is currently defined in include/linux/compiler_types.h, so there is no direct need for the inclusion of <linux/percpu.h>. However, in [1] we would like to repurpose __percpu tag as a named address space qualifier, where __percpu macro uses defines from <linux/percpu.h>.

This patch series is the "nice cleanup" part, and allows us to finally include <linux/percpu.h> in prandom.h.

The whole series was tested by compiling the kernel for x86_64 allconfig and some popular architectures, namely arm64 defconfig, powerpc defconfig and loongarch defconfig.

[1] https://lore.kernel.org/lkml/[email protected]/

Cc Dave Hansen <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Miquel Raynal <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Vignesh Raghavendra <[email protected]>
Cc Eric Biggers <[email protected]>
Cc "Theodore Y. Ts'o" <[email protected]>
Cc Jaegeuk Kim <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc John Fastabend <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Eduard Zingerman <[email protected]>
Cc Song Liu <[email protected]>
Cc Yonghong Song <[email protected]>
Cc KP Singh <[email protected]>
Cc Stanislav Fomichev <[email protected]>
Cc Hao Luo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Brendan Higgins <[email protected]>
Cc David Gow <[email protected]>
Cc Rae Moar <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Rasmus Villemoes <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Jamal Hadi Salim <[email protected]>
Cc Cong Wang <[email protected]>
Cc Uros Bizjak <[email protected]>
Cc Kent Overstreet <[email protected]>

Uros Bizjak (18):
x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h> drm/i915/selftests: Include <linux/prandom.h> instead of
<linux/random.h>
drm/lib: Include <linux/prandom.h> instead of <linux/random.h>
media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
fscrypt: Include <linux/prandom.h> instead of <linux/random.h>
scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>
bpf: Include <linux/prandom.h> instead of <linux/random.h> lib/interval_tree_test.c: Include <linux/prandom.h> instead of
<linux/random.h>
kunit: string-stream-test: Include <linux/prandom.h> instead of
<linux/random.h>
random32: Include <linux/prandom.h> instead of <linux/random.h> lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h> bpf/tests: Include <linux/prandom.h> instead of <linux/random.h> lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h> lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
netem: Include <linux/prandom.h> in sch_netem.c
random: Do not include <linux/prandom.h>
prandom: Include <linux/percpu.h>

 arch/x86/mm/kaslr.c                              | 2 +-
 drivers/gpu/drm/i915/selftests/i915_gem.c        | 2 +-
 drivers/gpu/drm/i915/selftests/i915_random.h     | 2 +-
 drivers/gpu/drm/i915/selftests/scatterlist.c     | 2 +-
 drivers/gpu/drm/lib/drm_random.h                 | 2 +-
 drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 +
 drivers/mtd/tests/oobtest.c                      | 2 +-
 drivers/mtd/tests/pagetest.c                     | 2 +-
 drivers/mtd/tests/subpagetest.c                  | 2 +-
 fs/crypto/keyring.c                              | 2 +-
 include/linux/prandom.h                          | 1 +
 include/linux/random.h                           | 7 -------
 include/scsi/libfcoe.h                           | 2 +-
 kernel/bpf/core.c                                | 2 +-
 lib/interval_tree_test.c                         | 2 +-
 lib/kunit/string-stream-test.c                   | 1 +
 lib/random32.c                                   | 2 +-
 lib/rbtree_test.c                                | 2 +-
 lib/test_bpf.c                                   | 2 +-
 lib/test_parman.c                                | 2 +-
 lib/test_scanf.c                                 | 2 +-
 net/sched/sch_netem.c                            | 1 +
 22 files changed, 21 insertions(+), 24 deletions(-)
Signature · 1 line
2.46.0
#1 lore raw

PATCH 1/18 x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Dave Hansen <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/mm/kaslr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/kaslr.c +1 -1
index 230f1dee4f09..e17e6e27b7ec 100644
@@ -22,7 +22,7 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/memblock.h>
 #include <linux/pgtable.h>
 
Signature · 1 line
2.46.0
#2 lore raw

PATCH 2/18 drm/i915/selftests: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/selftests/i915_gem.c    | 2 +-
 drivers/gpu/drm/i915/selftests/i915_random.h | 2 +-
 drivers/gpu/drm/i915/selftests/scatterlist.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/selftests/i915_gem.c +1 -1
index 61da4ed9d521..0727492576be 100644
@@ -4,7 +4,7 @@
  * Copyright © 2018 Intel Corporation
  */
 
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "gem/i915_gem_internal.h"
 #include "gem/i915_gem_pm.h"
drivers/gpu/drm/i915/selftests/i915_random.h +1 -1
index 05364eca20f7..70330a2e80f2 100644
@@ -26,7 +26,7 @@
 #define __I915_SELFTESTS_RANDOM_H__
 
 #include <linux/math64.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "../i915_selftest.h"
 
drivers/gpu/drm/i915/selftests/scatterlist.c +1 -1
index 805c4bfb85fe..7e59591bbed6 100644
@@ -22,7 +22,7 @@
  */
 
 #include <linux/prime_numbers.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "i915_selftest.h"
 #include "i915_utils.h"
Signature · 1 line
2.46.0
maintainer Acked-by on v1 2/18
#3 lore raw

Re: [PATCH 02/18] drm/i915/selftests: Include <linux/prandom.h> instead of <linux/random.h>

Quoted 12 lines · Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>

LGTM,

for merging via whichever tree suits you best.

Quoted 45 lines
---
 drivers/gpu/drm/i915/selftests/i915_gem.c    | 2 +-
 drivers/gpu/drm/i915/selftests/i915_random.h | 2 +-
 drivers/gpu/drm/i915/selftests/scatterlist.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/selftests/i915_gem.c +1 -1
index 61da4ed9d521..0727492576be 100644
@@ -4,7 +4,7 @@
  * Copyright © 2018 Intel Corporation
  */
 
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "gem/i915_gem_internal.h"
 #include "gem/i915_gem_pm.h"
drivers/gpu/drm/i915/selftests/i915_random.h +1 -1
index 05364eca20f7..70330a2e80f2 100644
@@ -26,7 +26,7 @@
 #define __I915_SELFTESTS_RANDOM_H__
 
 #include <linux/math64.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "../i915_selftest.h"
 
drivers/gpu/drm/i915/selftests/scatterlist.c +1 -1
index 805c4bfb85fe..7e59591bbed6 100644
@@ -22,7 +22,7 @@
  */
 
 #include <linux/prime_numbers.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "i915_selftest.h"
 #include "i915_utils.h"
Signature · 1 line
Jani Nikula, Intel
#4 lore raw

PATCH 3/18 drm/lib: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/lib/drm_random.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/lib/drm_random.h +1 -1
index 5543bf0474bc..9f827260a89d 100644
@@ -6,7 +6,7 @@
  * be transposed to lib/ at the earliest convenience.
  */
 
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #define DRM_RND_STATE_INITIALIZER(seed__) ({				\
 	struct rnd_state state__;					\
Signature · 1 line
2.46.0
#5 lore raw

PATCH 4/18 media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header.

Cc Hans Verkuil <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
---
 drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/test-drivers/vivid/vivid-vid-cap.c +1 -0
index 69620e0a35a0..184460eb356e 100644
@@ -10,6 +10,7 @@
 #include <linux/sched.h>
 #include <linux/vmalloc.h>
 #include <linux/videodev2.h>
+#include <linux/prandom.h>
 #include <linux/v4l2-dv-timings.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-event.h>
Signature · 1 line
2.46.0
#6 lore raw

PATCH 5/18 mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Miquel Raynal <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Vignesh Raghavendra <[email protected]>
---
 drivers/mtd/tests/oobtest.c     | 2 +-
 drivers/mtd/tests/pagetest.c    | 2 +-
 drivers/mtd/tests/subpagetest.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/tests/oobtest.c +1 -1
index 13fed398937e..e1ee68f8b8f8 100644
@@ -17,7 +17,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "mtd_test.h"
 
drivers/mtd/tests/pagetest.c +1 -1
index 8eb40b6e6dfa..6878700d2fc0 100644
@@ -17,7 +17,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "mtd_test.h"
 
drivers/mtd/tests/subpagetest.c +1 -1
index 05250a080139..f34bbf033c4d 100644
@@ -15,7 +15,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 
 #include "mtd_test.h"
 
Signature · 1 line
2.46.0
maintainer Applied
#7 lore raw

Re: [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>

Quoted 8 lines · Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Miquel Raynal <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Vignesh Raghavendra <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

#8 lore raw

Re: [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>

Quoted 5 lines · Miquel Raynal
Quoted 3 lines · Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Quoted 7 lines
Quoted 5 lines
Cc Miquel Raynal <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Vignesh Raghavendra <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel, is it possible to just ACK the patch for now? The series touches many parts of the kernel, so I guess it is best to harvest Acked-by:s in this stage of development and commit all the patches some time after the merge window. This will avoid merge conflicts with the series.

Thanks,
Uros.

maintainer
#9 lore raw

Re: [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>

Hi Uros,

[email protected] wrote on Fri, 6 Sep 2024 17:58:39 +0200:

Quoted 12 lines · Miquel Raynal
Quoted 11 lines · Uros Bizjak
Quoted 8 lines

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Miquel Raynal <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Vignesh Raghavendra <[email protected]>
Quoted 7 lines
Quoted 1 line

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel, is it possible to just ACK the patch for now? The series touches many parts of the kernel, so I guess it is best to harvest Acked-by:s in this stage of development and commit all the patches some time after the merge window. This will avoid merge conflicts with the series.

Changing an include with a more specific include didn't look like a dangerous change, but I'm fine dropping the patch. Please mention it next time, because I didn't see it.

Thanks,
Miquèl

#10 lore raw

PATCH 6/18 fscrypt: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Eric Biggers <[email protected]>
Cc "Theodore Y. Ts'o" <[email protected]>
Cc Jaegeuk Kim <[email protected]>

Cc. [email protected]

---
 fs/crypto/keyring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/crypto/keyring.c +1 -1
index 6681a71625f0..e2c10b3b960b 100644
@@ -21,7 +21,7 @@
 #include <asm/unaligned.h>
 #include <crypto/skcipher.h>
 #include <linux/key-type.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/seq_file.h>
 
 #include "fscrypt_private.h"
Signature · 1 line
2.46.0
maintainer
#11 lore raw

Re: [PATCH 06/18] fscrypt: Include <linux/prandom.h> instead of <linux/random.h>

Quoted 17 lines · Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Eric Biggers <[email protected]>
Cc "Theodore Y. Ts'o" <[email protected]>
Cc Jaegeuk Kim <[email protected]>

Cc. [email protected]

---
 fs/crypto/keyring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/crypto/keyring.c +0 -0
index 6681a71625f0..e2c10b3b960b 100644

fs/crypto/keyring.c line 26

Quoted 7 lines
fs/crypto/keyring.c +1 -1
@@ -21,7 +21,7 @@
 #include <asm/unaligned.h>
 #include <crypto/skcipher.h>
 #include <linux/key-type.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/seq_file.h>
 

1. linux-fscrypt wasn't actually Cc'ed on this patch, due to the typo of "Cc." instead of "Cc:".

2. Currently <linux/random.h> includes <linux/prandom.h>, so the issue described in the commit message does not exist. I assume this in changing in a later patch that was not sent to me. The commit message should be rephrased to clarify that this change is needed because of header refactoring, as otherwise it sounds like a bug fix.

3. The proposed change does not make sense, because fs/crypto/keyring.c does not use any "pseudo-random functions". It does use get_random_once(), which is defined in <linux/once.h>. Currently <linux/random.h> includes <linux/prandom.h> which includes <linux/once.h>. If the inclusion of prandom.h by random.h is going away, then perhaps random.h should include once.h directly so that get_random_once() continues to work? If not, then this file should include once.h. Either way it should not include prandom.h.

- Eric

#12 lore raw

Re: [PATCH 06/18] fscrypt: Include <linux/prandom.h> instead of <linux/random.h>

Quoted 14 lines · Eric Biggers
Quoted 12 lines · Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Eric Biggers <[email protected]>
Cc "Theodore Y. Ts'o" <[email protected]>
Cc Jaegeuk Kim <[email protected]>

Cc. [email protected]

---
 fs/crypto/keyring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

fs/crypto/keyring.c line 26

Quoted 12 lines
fs/crypto/keyring.c +1 -1
index 6681a71625f0..e2c10b3b960b 100644
@@ -21,7 +21,7 @@
 #include <asm/unaligned.h>
 #include <crypto/skcipher.h>
 #include <linux/key-type.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/seq_file.h>
 

1. linux-fscrypt wasn't actually Cc'ed on this patch, due to the typo of "Cc." instead of "Cc:".

Uh, thanks for noticing.

Quoted 5 lines

2. Currently <linux/random.h> includes <linux/prandom.h>, so the issue described in the commit message does not exist. I assume this in changing in a later patch that was not sent to me. The commit message should be rephrased to clarify that this change is needed because of header refactoring, as otherwise it sounds like a bug fix.

Yes, the goal of the patch series is to allow inclusion of <linux/percpu.h> in linux/prandom.h. The major roadblock to achieve this is the inclusion of <linux/prandom.h> in linux/random.h, since this creates circular dependency which doesn't allow the inclusion of <linux/percpu.h>. Please note that this legacy include is removed in patch 17. I will mention this in the 0000 commit.

I will also mention header refactoring in individual commits.

OTOH, I think that while particular maintainers are CC'd only on their individual patches, it is better to send the whole series to all mentioned mailing lists. Will do that in v2.

Quoted 7 lines

3. The proposed change does not make sense, because fs/crypto/keyring.c does not use any "pseudo-random functions". It does use get_random_once(), which is defined in <linux/once.h>. Currently <linux/random.h> includes <linux/prandom.h> which includes <linux/once.h>. If the inclusion of prandom.h by random.h is going away, then perhaps random.h should include once.h directly so that get_random_once() continues to work? If not, then this file should include once.h. Either way it should not include prandom.h.

Due to the tricky nature of the whole series I tried to make individual patches as mechanical as possible, IOW, change the inclusion of <linux/random.h> to <linux/prandom.h>.

Looking at fs/crypto/keyring.c, it should still include <linux/random.h> but should also include <linux/once.h>. The latter was just accidentally included via <linux/random.h>/<linux/prandom.h> path which is going away.

Will fix in v2.

Thanks,
Uros.

#13 lore raw

PATCH 7/18 scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Hannes Reinecke <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
---
 include/scsi/libfcoe.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/scsi/libfcoe.h +1 -1
index 3c5899290aed..6616348e59b9 100644
@@ -15,7 +15,7 @@
 #include <linux/skbuff.h>
 #include <linux/workqueue.h>
 #include <linux/local_lock.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <scsi/fc/fc_fcoe.h>
 #include <scsi/libfc.h>
 #include <scsi/fcoe_sysfs.h>
Signature · 1 line
2.46.0
#14 lore raw

PATCH 8/18 bpf: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc John Fastabend <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Eduard Zingerman <[email protected]>
Cc Song Liu <[email protected]>
Cc Yonghong Song <[email protected]>
Cc KP Singh <[email protected]>
Cc Stanislav Fomichev <[email protected]>
Cc Hao Luo <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 kernel/bpf/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/core.c +1 -1
index 7ee62e38faf0..3f0d1eb7f5b0 100644
@@ -21,7 +21,7 @@
 #include <linux/filter.h>
 #include <linux/skbuff.h>
 #include <linux/vmalloc.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/bpf.h>
 #include <linux/btf.h>
 #include <linux/objtool.h>
Signature · 1 line
2.46.0
#15 lore raw

PATCH 9/18 lib/interval_tree_test.c: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

---
 lib/interval_tree_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/interval_tree_test.c +1 -1
index f37f4d44faa9..837064b83a6c 100644
@@ -2,7 +2,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/interval_tree.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/slab.h>
 #include <asm/timex.h>
 
Signature · 1 line
2.46.0
#16 lore raw

PATCH 10/18 kunit: string-stream-test: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

---
 lib/kunit/string-stream-test.c | 1 +
 1 file changed, 1 insertion(+)
lib/kunit/string-stream-test.c +1 -0
index 7511442ea98f..7734e33156f9 100644
@@ -9,6 +9,7 @@
 #include <kunit/static_stub.h>
 #include <kunit/test.h>
 #include <linux/ktime.h>
+#include <linux/prandom.h>
 #include <linux/slab.h>
 #include <linux/timekeeping.h>
 
Signature · 1 line
2.46.0
#17 lore raw

PATCH 11/18 random32: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Andrew Morton <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 lib/random32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/random32.c +1 -1
index 32060b852668..31fc2ca68856 100644
@@ -36,7 +36,7 @@
 #include <linux/percpu.h>
 #include <linux/export.h>
 #include <linux/jiffies.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/sched.h>
 #include <linux/bitops.h>
 #include <linux/slab.h>
Signature · 1 line
2.46.0
#18 lore raw

PATCH 12/18 lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

---
 lib/rbtree_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rbtree_test.c +1 -1
index 41ae3c7570d3..8655a76d29a1 100644
@@ -2,7 +2,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/rbtree_augmented.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/slab.h>
 #include <asm/timex.h>
 
Signature · 1 line
2.46.0
#19 lore raw

PATCH 13/18 bpf/tests: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Andrew Morton <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Eduard Zingerman <[email protected]>
Cc Song Liu <[email protected]>
Cc Yonghong Song <[email protected]>
Cc John Fastabend <[email protected]>
Cc KP Singh <[email protected]>
Cc Stanislav Fomichev <[email protected]>
Cc Hao Luo <[email protected]>
Cc Jiri Olsa <[email protected]>
---
 lib/test_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_bpf.c +1 -1
index ca4b0eea81a2..eb4a1915e4d2 100644
@@ -14,7 +14,7 @@
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/if_vlan.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/highmem.h>
 #include <linux/sched.h>
 
Signature · 1 line
2.46.0
#20 lore raw

PATCH 14/18 lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

---
 lib/test_parman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_parman.c +1 -1
index 35e32243693c..f9b97426a337 100644
@@ -39,7 +39,7 @@
 #include <linux/slab.h>
 #include <linux/bitops.h>
 #include <linux/err.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/parman.h>
 
 #define TEST_PARMAN_PRIO_SHIFT 7 /* defines number of prios for testing */
Signature · 1 line
2.46.0
#21 lore raw

PATCH 15/18 lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header instead of <linux/random.h>.

Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Rasmus Villemoes <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Andrew Morton <[email protected]>
---
 lib/test_scanf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_scanf.c +1 -1
index 7257b1768545..44f8508c9d88 100644
@@ -11,7 +11,7 @@
 #include <linux/module.h>
 #include <linux/overflow.h>
 #include <linux/printk.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 
Signature · 1 line
2.46.0
#23 lore raw

PATCH 16/18 netem: Include <linux/prandom.h> in sch_netem.c

In reply to Uros Bizjak

Usage of pseudo-random functions requires inclusion of <linux/prandom.h> header.

Cc Stephen Hemminger <[email protected]>
Cc Jamal Hadi Salim <[email protected]>
Cc Cong Wang <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 net/sched/sch_netem.c | 1 +
 1 file changed, 1 insertion(+)
net/sched/sch_netem.c +1 -0
index 0f8d581438c3..2d919f590772 100644
@@ -17,6 +17,7 @@
 #include <linux/errno.h>
 #include <linux/skbuff.h>
 #include <linux/vmalloc.h>
+#include <linux/prandom.h>
 #include <linux/rtnetlink.h>
 #include <linux/reciprocal_div.h>
 #include <linux/rbtree.h>
Signature · 1 line
2.46.0
#24 lore raw

PATCH 17/18 random: Do not include <linux/prandom.h>

In reply to Uros Bizjak

Files that use prandom infrastructure are now converted to use <linux/prandom.h> header instead of <linux/random.h>, so remove inclusion of <linux/prandom.h> from random.h

This is the "nice cleanup" part, wished in c0842fbc1b18.

Fixes c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h")
Cc "Theodore Ts'o" <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Linus Torvalds <[email protected]>
---
 include/linux/random.h | 7 -------
 1 file changed, 7 deletions(-)
include/linux/random.h +0 -7
index b0a940af4fff..333cecfca93f 100644
@@ -145,13 +145,6 @@ declare_get_random_var_wait(u64, u32)
 declare_get_random_var_wait(long, unsigned long)
 #undef declare_get_random_var
 
-/*
- * This is designed to be standalone for just prandom
- * users, but for now we include it from <linux/random.h>
- * for legacy reasons.
- */
-#include <linux/prandom.h>
-
 #ifdef CONFIG_SMP
 int random_prepare_cpu(unsigned int cpu);
 int random_online_cpu(unsigned int cpu);
Signature · 1 line
2.46.0
#25 lore raw

Re: [PATCH 17/18] random: Do not include <linux/prandom.h>

kernel test robot noticed the following build errors:

Hi Uros,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-nonmm-unstable]
[also build test ERROR on mtd/mtd/next mtd/mtd/fixes linus/master v6.11-rc6 next-20240906] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-kaslr-Include-linux-prandom-h-instead-of-linux-random-h/20240905-202710
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link:    https://lore.kernel.org/r/20240905122020.872466-18-ubizjak%40gmail.com
patch subject: [PATCH 17/18] random: Do not include <linux/prandom.h>
config: arm-randconfig-002-20240906 (https://download.01.org/0day-ci/archive/20240906/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240906/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

>> crypto/testmgr.c:881:42: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     881 | static inline void init_rnd_state(struct rnd_state *rng)
         |                                          ^~~~~~~~~
   crypto/testmgr.c: In function 'init_rnd_state':
>> crypto/testmgr.c:883:9: error: implicit declaration of function 'prandom_seed_state' [-Wimplicit-function-declaration]
     883 |         prandom_seed_state(rng, get_random_u64());
         |         ^~~~~~~~~~~~~~~~~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:886:36: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     886 | static inline u8 prandom_u8(struct rnd_state *rng)
         |                                    ^~~~~~~~~
   crypto/testmgr.c: In function 'prandom_u8':
>> crypto/testmgr.c:888:16: error: implicit declaration of function 'prandom_u32_state' [-Wimplicit-function-declaration]
     888 |         return prandom_u32_state(rng);
         |                ^~~~~~~~~~~~~~~~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:891:44: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                            ^~~~~~~~~
   crypto/testmgr.c:900:40: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                        ^~~~~~~~~
   crypto/testmgr.c: In function 'prandom_bool':
>> crypto/testmgr.c:902:34: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     902 |         return prandom_u32_below(rng, 2);
         |                                  ^~~
         |                                  |
         |                                  struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:905:48: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
         |                                                ^~~~~~~~~
   crypto/testmgr.c: In function 'prandom_u32_inclusive':
   crypto/testmgr.c:908:42: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     908 |         return floor + prandom_u32_below(rng, ceil - floor + 1);
         |                                          ^~~
         |                                          |
         |                                          struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:912:51: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     912 | static unsigned int generate_random_length(struct rnd_state *rng,
         |                                                   ^~~~~~~~~
   crypto/testmgr.c: In function 'generate_random_length':
   crypto/testmgr.c:915:46: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     915 |         unsigned int len = prandom_u32_below(rng, max_len + 1);
         |                                              ^~~
         |                                              |
         |                                              struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:917:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     917 |         switch (prandom_u32_below(rng, 4)) {
         |                                   ^~~
         |                                   |
         |                                   struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:930:38: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     930 |         if (len && prandom_u32_below(rng, 4) == 0)
         |                                      ^~~
         |                                      |
         |                                      struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:936:36: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
         |                                    ^~~~~~~~~
   crypto/testmgr.c: In function 'flip_random_bit':
   crypto/testmgr.c:940:36: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     940 |         bitpos = prandom_u32_below(rng, size * 8);
         |                                    ^~~
         |                                    |
         |                                    struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:945:37: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     945 | static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
         |                                     ^~~~~~~~~
   crypto/testmgr.c: In function 'flip_random_byte':
   crypto/testmgr.c:947:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     947 |         buf[prandom_u32_below(rng, size)] ^= 0xff;
         |                               ^~~
         |                               |
         |                               struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:951:34: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
         |                                  ^~~~~~~~~
   crypto/testmgr.c: In function 'mutate_buffer':
   crypto/testmgr.c:957:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     957 |         if (prandom_u32_below(rng, 4) == 0) {
         |                               ^~~
         |                               |
         |                               struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   In file included from include/linux/kernel.h:28,
                    from include/linux/cpumask.h:11,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/spinlock.h:63,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from include/linux/crypto.h:15,
                    from include/crypto/aead.h:13,
                    from crypto/testmgr.c:19:
   crypto/testmgr.c:958:66: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     958 |                 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
         |                                                                  ^~~
         |                                                                  |
         |                                                                  struct rnd_state *
   include/linux/minmax.h:93:23: note: in definition of macro '__cmp_once_unique'
      93 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
         |                       ^
   include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
     213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
         |                           ^~~~~~~~~~
   crypto/testmgr.c:958:29: note: in expansion of macro 'min_t'
     958 |                 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
         |                             ^~~~~
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:961:41: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
     961 |                         flip_random_bit(rng, buf, size);
         |                                         ^~~
         |                                         |
         |                                         struct rnd_state *
   crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
         |                             ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:965:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     965 |         if (prandom_u32_below(rng, 4) == 0) {
         |                               ^~~
         |                               |
         |                               struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:966:66: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     966 |                 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
         |                                                                  ^~~
         |                                                                  |
         |                                                                  struct rnd_state *
   include/linux/minmax.h:93:23: note: in definition of macro '__cmp_once_unique'
      93 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
         |                       ^
   include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
     213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
         |                           ^~~~~~~~~~
   crypto/testmgr.c:966:29: note: in expansion of macro 'min_t'
     966 |                 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
         |                             ^~~~~
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:968:42: error: passing argument 1 of 'flip_random_byte' from incompatible pointer type [-Wincompatible-pointer-types]
     968 |                         flip_random_byte(rng, buf, size);
         |                                          ^~~
         |                                          |
         |                                          struct rnd_state *
   crypto/testmgr.c:945:48: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     945 | static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
         |                              ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:973:42: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
     973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
         |                                          ^~~~~~~~~
   crypto/testmgr.c: In function 'generate_random_bytes':
   crypto/testmgr.c:982:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     982 |         switch (prandom_u32_below(rng, 8)) { /* Choose a generation strategy */
         |                                   ^~~
         |                                   |
         |                                   struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:986:43: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
     986 |                 switch (prandom_u32_below(rng, 4)) {
         |                                           ^~~
         |                                           |
         |                                           struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:994:40: error: passing argument 1 of 'prandom_u8' from incompatible pointer type [-Wincompatible-pointer-types]
     994 |                         b = prandom_u8(rng);
         |                                        ^~~
         |                                        |
         |                                        struct rnd_state *
   crypto/testmgr.c:886:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     886 | static inline u8 prandom_u8(struct rnd_state *rng)
         |                             ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:998:31: error: passing argument 1 of 'mutate_buffer' from incompatible pointer type [-Wincompatible-pointer-types]
     998 |                 mutate_buffer(rng, buf, count);
         |                               ^~~
         |                               |
         |                               struct rnd_state *
   crypto/testmgr.c:951:45: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
         |                           ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1002:40: error: passing argument 1 of 'prandom_u8' from incompatible pointer type [-Wincompatible-pointer-types]
    1002 |                 increment = prandom_u8(rng);
         |                                        ^~~
         |                                        |
         |                                        struct rnd_state *
   crypto/testmgr.c:886:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     886 | static inline u8 prandom_u8(struct rnd_state *rng)
         |                             ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1003:32: error: passing argument 1 of 'prandom_u8' from incompatible pointer type [-Wincompatible-pointer-types]
    1003 |                 b = prandom_u8(rng);
         |                                ^~~
         |                                |
         |                                struct rnd_state *
   crypto/testmgr.c:886:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     886 | static inline u8 prandom_u8(struct rnd_state *rng)
         |                             ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1006:31: error: passing argument 1 of 'mutate_buffer' from incompatible pointer type [-Wincompatible-pointer-types]
    1006 |                 mutate_buffer(rng, buf, count);
         |                               ^~~
         |                               |
         |                               struct rnd_state *
   crypto/testmgr.c:951:45: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
         |                           ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1010:17: error: implicit declaration of function 'prandom_bytes_state' [-Wimplicit-function-declaration]
    1010 |                 prandom_bytes_state(rng, buf, count);
         |                 ^~~~~~~~~~~~~~~~~~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:1014:51: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
    1014 | static char *generate_random_sgl_divisions(struct rnd_state *rng,
         |                                                   ^~~~~~~~~
   crypto/testmgr.c: In function 'generate_random_sgl_divisions':
>> crypto/testmgr.c:1026:64: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1026 |                 if (div == &divs[max_divs - 1] || prandom_bool(rng))
         |                                                                ^~~
         |                                                                |
         |                                                                struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1028:44: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1028 |                 else if (prandom_u32_below(rng, 4) == 0)
         |                                            ^~~
         |                                            |
         |                                            struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1031:58: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
    1031 |                         this_len = prandom_u32_inclusive(rng, 1, remaining);
         |                                                          ^~~
         |                                                          |
         |                                                          struct rnd_state *
   crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
         |                                         ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1034:39: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1034 |                 if (prandom_u32_below(rng, 4) == 0)
         |                                       ^~~
         |                                       |
         |                                       struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1035:61: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
    1035 |                         div->offset = prandom_u32_inclusive(rng,
         |                                                             ^~~
         |                                                             |
         |                                                             struct rnd_state *
   crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
         |                                         ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1038:39: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1038 |                 else if (prandom_bool(rng))
         |                                       ^~~
         |                                       |
         |                                       struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1039:57: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1039 |                         div->offset = prandom_u32_below(rng, 32);
         |                                                         ^~~
         |                                                         |
         |                                                         struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1041:57: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1041 |                         div->offset = prandom_u32_below(rng, PAGE_SIZE);
         |                                                         ^~~
         |                                                         |
         |                                                         struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1042:39: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1042 |                 if (prandom_u32_below(rng, 8) == 0)
         |                                       ^~~
         |                                       |
         |                                       struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1047:51: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1047 |                         switch (prandom_u32_below(rng, 4)) {
         |                                                   ^~~
         |                                                   |
         |                                                   struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1059:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1059 |                     prandom_bool(rng))
         |                                  ^~~
         |                                  |
         |                                  struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:1094:51: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
    1094 | static void generate_random_testvec_config(struct rnd_state *rng,
         |                                                   ^~~~~~~~~
   crypto/testmgr.c: In function 'generate_random_testvec_config':
   crypto/testmgr.c:1107:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1107 |         switch (prandom_u32_below(rng, 4)) {
         |                                   ^~~
         |                                   |
         |                                   struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1122:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1122 |         if (prandom_bool(rng)) {
         |                          ^~~
         |                          |
         |                          struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1127:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1127 |         switch (prandom_u32_below(rng, 4)) {
         |                                   ^~~
         |                                   |
         |                                   struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1143:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1143 |                 if (prandom_bool(rng)) {
         |                                  ^~~
         |                                  |
         |                                  struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1147:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1147 |                 if (prandom_bool(rng)) {
         |                                  ^~~
         |                                  |
         |                                  struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1154:43: error: passing argument 1 of 'generate_random_sgl_divisions' from incompatible pointer type [-Wincompatible-pointer-types]
    1154 |         p = generate_random_sgl_divisions(rng, cfg->src_divs,
         |                                           ^~~
         |                                           |
         |                                           struct rnd_state *
   crypto/testmgr.c:1014:62: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
    1014 | static char *generate_random_sgl_divisions(struct rnd_state *rng,
         |                                            ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1161:63: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1161 |         if (cfg->inplace_mode == OUT_OF_PLACE && prandom_bool(rng)) {
         |                                                               ^~~
         |                                                               |
         |                                                               struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1163:51: error: passing argument 1 of 'generate_random_sgl_divisions' from incompatible pointer type [-Wincompatible-pointer-types]
    1163 |                 p = generate_random_sgl_divisions(rng, cfg->dst_divs,
         |                                                   ^~~
         |                                                   |
         |                                                   struct rnd_state *
   crypto/testmgr.c:1014:62: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
    1014 | static char *generate_random_sgl_divisions(struct rnd_state *rng,
         |                                            ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1170:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1170 |         if (prandom_bool(rng)) {
         |                          ^~~
         |                          |
         |                          struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1171:56: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
    1171 |                 cfg->iv_offset = prandom_u32_inclusive(rng, 1,
         |                                                        ^~~
         |                                                        |
         |                                                        struct rnd_state *
   crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
         |                                         ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1176:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    1176 |         if (prandom_bool(rng)) {
         |                          ^~~
         |                          |
         |                          struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1177:57: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
    1177 |                 cfg->key_offset = prandom_u32_inclusive(rng, 1,
         |                                                         ^~~
         |                                                         |
         |                                                         struct rnd_state *
   crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
         |                                         ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: In function 'test_hash_vec':
>> crypto/testmgr.c:1689:34: error: storage size of 'rng' isn't known
    1689 |                 struct rnd_state rng;
         |                                  ^~~
>> crypto/testmgr.c:1689:34: warning: unused variable 'rng' [-Wunused-variable]
   crypto/testmgr.c: At top level:
   crypto/testmgr.c:1714:49: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
    1714 | static void generate_random_hash_testvec(struct rnd_state *rng,
         |                                                 ^~~~~~~~~
   crypto/testmgr.c: In function 'generate_random_hash_testvec':
>> crypto/testmgr.c:1722:45: error: passing argument 1 of 'generate_random_length' from incompatible pointer type [-Wincompatible-pointer-types]
    1722 |         vec->psize = generate_random_length(rng, maxdatasize);
         |                                             ^~~
         |                                             |
         |                                             struct rnd_state *
   crypto/testmgr.c:912:62: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     912 | static unsigned int generate_random_length(struct rnd_state *rng,
         |                                            ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1723:31: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
    1723 |         generate_random_bytes(rng, (u8 *)vec->plaintext, vec->psize);
         |                               ^~~
         |                               |
         |                               struct rnd_state *
   crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
         |                                   ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1733:39: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    1733 |                 if (prandom_u32_below(rng, 4) == 0)
         |                                       ^~~
         |                                       |
         |                                       struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1734:60: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
    1734 |                         vec->ksize = prandom_u32_inclusive(rng, 1, maxkeysize);
         |                                                            ^~~
         |                                                            |
         |                                                            struct rnd_state *
   crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
         |                                         ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:1735:39: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
    1735 |                 generate_random_bytes(rng, (u8 *)vec->key, vec->ksize);
         |                                       ^~~
         |                                       |
         |                                       struct rnd_state *
   crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
         |                                   ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: In function 'test_hash_vs_generic_impl':
   crypto/testmgr.c:1769:26: error: storage size of 'rng' isn't known
    1769 |         struct rnd_state rng;
         |                          ^~~
   crypto/testmgr.c:1769:26: warning: unused variable 'rng' [-Wunused-variable]
   crypto/testmgr.c: In function 'test_aead_vec':
   crypto/testmgr.c:2259:34: error: storage size of 'rng' isn't known
    2259 |                 struct rnd_state rng;
         |                                  ^~~
   crypto/testmgr.c:2259:34: warning: unused variable 'rng' [-Wunused-variable]
   crypto/testmgr.c: At top level:
>> crypto/testmgr.c:2282:26: error: field 'rng' has incomplete type
    2282 |         struct rnd_state rng;
         |                          ^~~
   crypto/testmgr.c: In function 'mutate_aead_message':
   crypto/testmgr.c:2308:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    2308 |         if (prandom_bool(rng) && vec->alen > aad_tail_size) {
         |                          ^~~
         |                          |
         |                          struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2310:33: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
    2310 |                 flip_random_bit(rng, (u8 *)vec->assoc,
         |                                 ^~~
         |                                 |
         |                                 struct rnd_state *
   crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
         |                             ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2312:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    2312 |                 if (prandom_bool(rng))
         |                                  ^~~
         |                                  |
         |                                  struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2315:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    2315 |         if (prandom_bool(rng)) {
         |                          ^~~
         |                          |
         |                          struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2317:33: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
    2317 |                 flip_random_bit(rng, (u8 *)vec->ctext + vec->plen, authsize);
         |                                 ^~~
         |                                 |
         |                                 struct rnd_state *
   crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
         |                             ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2320:33: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
    2320 |                 flip_random_bit(rng, (u8 *)vec->ctext, vec->clen);
         |                                 ^~~
         |                                 |
         |                                 struct rnd_state *
   crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
         |                             ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: In function 'generate_aead_message':
   crypto/testmgr.c:2342:53: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    2342 |                                   prandom_u32_below(rng, 4) == 0);
         |                                                     ^~~
         |                                                     |
         |                                                     struct rnd_state *
   crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                     ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2345:31: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
    2345 |         generate_random_bytes(rng, (u8 *)vec->assoc, vec->alen);
         |                               ^~~
         |                               |
         |                               struct rnd_state *
   crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
         |                                   ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2350:41: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
    2350 |         if (inauthentic && prandom_bool(rng)) {
         |                                         ^~~
         |                                         |
         |                                         struct rnd_state *
   crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                 ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2352:39: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
    2352 |                 generate_random_bytes(rng, (u8 *)vec->ctext, vec->clen);
         |                                       ^~~
         |                                       |
         |                                       struct rnd_state *
   crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
         |                                   ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c:2364:47: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
    2364 |                         generate_random_bytes(rng, (u8 *)vec->ptext, vec->plen);
         |                                               ^~~
         |                                               |
         |                                               struct rnd_state *
   crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
     973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
         |                                   ~~~~~~~~~~~~~~~~~~^~~
   crypto/testmgr.c: In function 'generate_random_aead_testvec':
   crypto/testmgr.c:2415:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
    2415 |         if (prandom_u32_below(rng, 4) == 0)
         |                               ^~~
         |                               |
         |                               struct rnd_state *

crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)

vim +/prandom_seed_state +883 crypto/testmgr.c

f2bb770ae89641 Eric Biggers 2019-04-11   873  
f900fde2888360 Eric Biggers 2023-02-27   874  /*
f900fde2888360 Eric Biggers 2023-02-27   875   * The fuzz tests use prandom instead of the normal Linux RNG since they don't
f900fde2888360 Eric Biggers 2023-02-27   876   * need cryptographically secure random numbers.  This greatly improves the
f900fde2888360 Eric Biggers 2023-02-27   877   * performance of these tests, especially if they are run before the Linux RNG
f900fde2888360 Eric Biggers 2023-02-27   878   * has been initialized or if they are run on a lockdep-enabled kernel.
f900fde2888360 Eric Biggers 2023-02-27   879   */
f900fde2888360 Eric Biggers 2023-02-27   880  
f900fde2888360 Eric Biggers 2023-02-27  @881  static inline void init_rnd_state(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27   882  {
f900fde2888360 Eric Biggers 2023-02-27  @883  	prandom_seed_state(rng, get_random_u64());
f900fde2888360 Eric Biggers 2023-02-27   884  }
f900fde2888360 Eric Biggers 2023-02-27   885  
f900fde2888360 Eric Biggers 2023-02-27   886  static inline u8 prandom_u8(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27   887  {
f900fde2888360 Eric Biggers 2023-02-27  @888  	return prandom_u32_state(rng);
f900fde2888360 Eric Biggers 2023-02-27   889  }
f900fde2888360 Eric Biggers 2023-02-27   890  
f900fde2888360 Eric Biggers 2023-02-27  @891  static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
f900fde2888360 Eric Biggers 2023-02-27   892  {
f900fde2888360 Eric Biggers 2023-02-27   893  	/*
f900fde2888360 Eric Biggers 2023-02-27   894  	 * This is slightly biased for non-power-of-2 values of 'ceil', but this
f900fde2888360 Eric Biggers 2023-02-27   895  	 * isn't important here.
f900fde2888360 Eric Biggers 2023-02-27   896  	 */
f900fde2888360 Eric Biggers 2023-02-27   897  	return prandom_u32_state(rng) % ceil;
f900fde2888360 Eric Biggers 2023-02-27   898  }
f900fde2888360 Eric Biggers 2023-02-27   899  
f900fde2888360 Eric Biggers 2023-02-27   900  static inline bool prandom_bool(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27   901  {
f900fde2888360 Eric Biggers 2023-02-27  @902  	return prandom_u32_below(rng, 2);
f900fde2888360 Eric Biggers 2023-02-27   903  }
f900fde2888360 Eric Biggers 2023-02-27   904  
f900fde2888360 Eric Biggers 2023-02-27  @905  static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
f900fde2888360 Eric Biggers 2023-02-27   906  					u32 floor, u32 ceil)
f900fde2888360 Eric Biggers 2023-02-27   907  {
f900fde2888360 Eric Biggers 2023-02-27   908  	return floor + prandom_u32_below(rng, ceil - floor + 1);
f900fde2888360 Eric Biggers 2023-02-27   909  }
f900fde2888360 Eric Biggers 2023-02-27   910  
f2bb770ae89641 Eric Biggers 2019-04-11   911  /* Generate a random length in range [0, max_len], but prefer smaller values */
f900fde2888360 Eric Biggers 2023-02-27   912  static unsigned int generate_random_length(struct rnd_state *rng,
f900fde2888360 Eric Biggers 2023-02-27   913  					   unsigned int max_len)
f2bb770ae89641 Eric Biggers 2019-04-11   914  {
f900fde2888360 Eric Biggers 2023-02-27   915  	unsigned int len = prandom_u32_below(rng, max_len + 1);
f2bb770ae89641 Eric Biggers 2019-04-11   916  
f900fde2888360 Eric Biggers 2023-02-27   917  	switch (prandom_u32_below(rng, 4)) {
f2bb770ae89641 Eric Biggers 2019-04-11   918  	case 0:
101e99c23af946 Eric Biggers 2024-07-03   919  		len %= 64;
101e99c23af946 Eric Biggers 2024-07-03   920  		break;
f2bb770ae89641 Eric Biggers 2019-04-11   921  	case 1:
101e99c23af946 Eric Biggers 2024-07-03   922  		len %= 256;
101e99c23af946 Eric Biggers 2024-07-03   923  		break;
f2bb770ae89641 Eric Biggers 2019-04-11   924  	case 2:
101e99c23af946 Eric Biggers 2024-07-03   925  		len %= 1024;
101e99c23af946 Eric Biggers 2024-07-03   926  		break;
f2bb770ae89641 Eric Biggers 2019-04-11   927  	default:
101e99c23af946 Eric Biggers 2024-07-03   928  		break;
f2bb770ae89641 Eric Biggers 2019-04-11   929  	}
101e99c23af946 Eric Biggers 2024-07-03   930  	if (len && prandom_u32_below(rng, 4) == 0)
101e99c23af946 Eric Biggers 2024-07-03   931  		len = rounddown_pow_of_two(len);
101e99c23af946 Eric Biggers 2024-07-03   932  	return len;
f2bb770ae89641 Eric Biggers 2019-04-11   933  }
f2bb770ae89641 Eric Biggers 2019-04-11   934  
49763fc6b1af42 Eric Biggers 2019-12-01   935  /* Flip a random bit in the given nonempty data buffer */
f900fde2888360 Eric Biggers 2023-02-27   936  static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
49763fc6b1af42 Eric Biggers 2019-12-01   937  {
49763fc6b1af42 Eric Biggers 2019-12-01   938  	size_t bitpos;
49763fc6b1af42 Eric Biggers 2019-12-01   939  
f900fde2888360 Eric Biggers 2023-02-27   940  	bitpos = prandom_u32_below(rng, size * 8);
49763fc6b1af42 Eric Biggers 2019-12-01   941  	buf[bitpos / 8] ^= 1 << (bitpos % 8);
49763fc6b1af42 Eric Biggers 2019-12-01   942  }
49763fc6b1af42 Eric Biggers 2019-12-01   943  
49763fc6b1af42 Eric Biggers 2019-12-01   944  /* Flip a random byte in the given nonempty data buffer */
f900fde2888360 Eric Biggers 2023-02-27   945  static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
49763fc6b1af42 Eric Biggers 2019-12-01   946  {
f900fde2888360 Eric Biggers 2023-02-27   947  	buf[prandom_u32_below(rng, size)] ^= 0xff;
49763fc6b1af42 Eric Biggers 2019-12-01   948  }
49763fc6b1af42 Eric Biggers 2019-12-01   949  
49763fc6b1af42 Eric Biggers 2019-12-01   950  /* Sometimes make some random changes to the given nonempty data buffer */
f900fde2888360 Eric Biggers 2023-02-27   951  static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
f2bb770ae89641 Eric Biggers 2019-04-11   952  {
f2bb770ae89641 Eric Biggers 2019-04-11   953  	size_t num_flips;
f2bb770ae89641 Eric Biggers 2019-04-11   954  	size_t i;
f2bb770ae89641 Eric Biggers 2019-04-11   955  
f2bb770ae89641 Eric Biggers 2019-04-11   956  	/* Sometimes flip some bits */
f900fde2888360 Eric Biggers 2023-02-27   957  	if (prandom_u32_below(rng, 4) == 0) {
f900fde2888360 Eric Biggers 2023-02-27  @958  		num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
f900fde2888360 Eric Biggers 2023-02-27   959  				  size * 8);
49763fc6b1af42 Eric Biggers 2019-12-01   960  		for (i = 0; i < num_flips; i++)
f900fde2888360 Eric Biggers 2023-02-27  @961  			flip_random_bit(rng, buf, size);
f2bb770ae89641 Eric Biggers 2019-04-11   962  	}
f2bb770ae89641 Eric Biggers 2019-04-11   963  
f2bb770ae89641 Eric Biggers 2019-04-11   964  	/* Sometimes flip some bytes */
f900fde2888360 Eric Biggers 2023-02-27   965  	if (prandom_u32_below(rng, 4) == 0) {
f900fde2888360 Eric Biggers 2023-02-27  @966  		num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
f2bb770ae89641 Eric Biggers 2019-04-11   967  		for (i = 0; i < num_flips; i++)
f900fde2888360 Eric Biggers 2023-02-27  @968  			flip_random_byte(rng, buf, size);
f2bb770ae89641 Eric Biggers 2019-04-11   969  	}
f2bb770ae89641 Eric Biggers 2019-04-11   970  }
f2bb770ae89641 Eric Biggers 2019-04-11   971  
f2bb770ae89641 Eric Biggers 2019-04-11   972  /* Randomly generate 'count' bytes, but sometimes make them "interesting" */
f900fde2888360 Eric Biggers 2023-02-27   973  static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
f2bb770ae89641 Eric Biggers 2019-04-11   974  {
f2bb770ae89641 Eric Biggers 2019-04-11   975  	u8 b;
f2bb770ae89641 Eric Biggers 2019-04-11   976  	u8 increment;
f2bb770ae89641 Eric Biggers 2019-04-11   977  	size_t i;
f2bb770ae89641 Eric Biggers 2019-04-11   978  
f2bb770ae89641 Eric Biggers 2019-04-11   979  	if (count == 0)
f2bb770ae89641 Eric Biggers 2019-04-11   980  		return;
f2bb770ae89641 Eric Biggers 2019-04-11   981  
f900fde2888360 Eric Biggers 2023-02-27   982  	switch (prandom_u32_below(rng, 8)) { /* Choose a generation strategy */
f2bb770ae89641 Eric Biggers 2019-04-11   983  	case 0:
f2bb770ae89641 Eric Biggers 2019-04-11   984  	case 1:
f2bb770ae89641 Eric Biggers 2019-04-11   985  		/* All the same byte, plus optional mutations */
f900fde2888360 Eric Biggers 2023-02-27  @986  		switch (prandom_u32_below(rng, 4)) {
f2bb770ae89641 Eric Biggers 2019-04-11   987  		case 0:
f2bb770ae89641 Eric Biggers 2019-04-11   988  			b = 0x00;
f2bb770ae89641 Eric Biggers 2019-04-11   989  			break;
f2bb770ae89641 Eric Biggers 2019-04-11   990  		case 1:
f2bb770ae89641 Eric Biggers 2019-04-11   991  			b = 0xff;
f2bb770ae89641 Eric Biggers 2019-04-11   992  			break;
f2bb770ae89641 Eric Biggers 2019-04-11   993  		default:
f900fde2888360 Eric Biggers 2023-02-27  @994  			b = prandom_u8(rng);
f2bb770ae89641 Eric Biggers 2019-04-11   995  			break;
f2bb770ae89641 Eric Biggers 2019-04-11   996  		}
f2bb770ae89641 Eric Biggers 2019-04-11   997  		memset(buf, b, count);
f900fde2888360 Eric Biggers 2023-02-27  @998  		mutate_buffer(rng, buf, count);
f2bb770ae89641 Eric Biggers 2019-04-11   999  		break;
f2bb770ae89641 Eric Biggers 2019-04-11  1000  	case 2:
f2bb770ae89641 Eric Biggers 2019-04-11  1001  		/* Ascending or descending bytes, plus optional mutations */
f900fde2888360 Eric Biggers 2023-02-27  1002  		increment = prandom_u8(rng);
f900fde2888360 Eric Biggers 2023-02-27  1003  		b = prandom_u8(rng);
f2bb770ae89641 Eric Biggers 2019-04-11  1004  		for (i = 0; i < count; i++, b += increment)
f2bb770ae89641 Eric Biggers 2019-04-11  1005  			buf[i] = b;
f900fde2888360 Eric Biggers 2023-02-27 @1006  		mutate_buffer(rng, buf, count);
f2bb770ae89641 Eric Biggers 2019-04-11  1007  		break;
f2bb770ae89641 Eric Biggers 2019-04-11  1008  	default:
f2bb770ae89641 Eric Biggers 2019-04-11  1009  		/* Fully random bytes */
f900fde2888360 Eric Biggers 2023-02-27 @1010  		prandom_bytes_state(rng, buf, count);
f2bb770ae89641 Eric Biggers 2019-04-11  1011  	}
f2bb770ae89641 Eric Biggers 2019-04-11  1012  }
f2bb770ae89641 Eric Biggers 2019-04-11  1013  
f900fde2888360 Eric Biggers 2023-02-27  1014  static char *generate_random_sgl_divisions(struct rnd_state *rng,
f900fde2888360 Eric Biggers 2023-02-27  1015  					   struct test_sg_division *divs,
25f9dddb928aee Eric Biggers 2019-01-31  1016  					   size_t max_divs, char *p, char *end,
6570737c7fa047 Eric Biggers 2019-03-12  1017  					   bool gen_flushes, u32 req_flags)
25f9dddb928aee Eric Biggers 2019-01-31  1018  {
25f9dddb928aee Eric Biggers 2019-01-31  1019  	struct test_sg_division *div = divs;
25f9dddb928aee Eric Biggers 2019-01-31  1020  	unsigned int remaining = TEST_SG_TOTAL;
25f9dddb928aee Eric Biggers 2019-01-31  1021  
25f9dddb928aee Eric Biggers 2019-01-31  1022  	do {
25f9dddb928aee Eric Biggers 2019-01-31  1023  		unsigned int this_len;
6570737c7fa047 Eric Biggers 2019-03-12  1024  		const char *flushtype_str;
25f9dddb928aee Eric Biggers 2019-01-31  1025  
f900fde2888360 Eric Biggers 2023-02-27 @1026  		if (div == &divs[max_divs - 1] || prandom_bool(rng))
25f9dddb928aee Eric Biggers 2019-01-31  1027  			this_len = remaining;
101e99c23af946 Eric Biggers 2024-07-03 @1028  		else if (prandom_u32_below(rng, 4) == 0)
101e99c23af946 Eric Biggers 2024-07-03  1029  			this_len = (remaining + 1) / 2;
25f9dddb928aee Eric Biggers 2019-01-31  1030  		else
f900fde2888360 Eric Biggers 2023-02-27 @1031  			this_len = prandom_u32_inclusive(rng, 1, remaining);
25f9dddb928aee Eric Biggers 2019-01-31  1032  		div->proportion_of_total = this_len;
25f9dddb928aee Eric Biggers 2019-01-31  1033  
f900fde2888360 Eric Biggers 2023-02-27  1034  		if (prandom_u32_below(rng, 4) == 0)
f900fde2888360 Eric Biggers 2023-02-27  1035  			div->offset = prandom_u32_inclusive(rng,
f900fde2888360 Eric Biggers 2023-02-27  1036  							    PAGE_SIZE - 128,
f900fde2888360 Eric Biggers 2023-02-27  1037  							    PAGE_SIZE - 1);
f900fde2888360 Eric Biggers 2023-02-27  1038  		else if (prandom_bool(rng))
f900fde2888360 Eric Biggers 2023-02-27  1039  			div->offset = prandom_u32_below(rng, 32);
25f9dddb928aee Eric Biggers 2019-01-31  1040  		else
f900fde2888360 Eric Biggers 2023-02-27  1041  			div->offset = prandom_u32_below(rng, PAGE_SIZE);
f900fde2888360 Eric Biggers 2023-02-27  1042  		if (prandom_u32_below(rng, 8) == 0)
25f9dddb928aee Eric Biggers 2019-01-31  1043  			div->offset_relative_to_alignmask = true;
25f9dddb928aee Eric Biggers 2019-01-31  1044  
25f9dddb928aee Eric Biggers 2019-01-31  1045  		div->flush_type = FLUSH_TYPE_NONE;
25f9dddb928aee Eric Biggers 2019-01-31  1046  		if (gen_flushes) {
f900fde2888360 Eric Biggers 2023-02-27  1047  			switch (prandom_u32_below(rng, 4)) {
25f9dddb928aee Eric Biggers 2019-01-31  1048  			case 0:
25f9dddb928aee Eric Biggers 2019-01-31  1049  				div->flush_type = FLUSH_TYPE_REIMPORT;
25f9dddb928aee Eric Biggers 2019-01-31  1050  				break;
25f9dddb928aee Eric Biggers 2019-01-31  1051  			case 1:
25f9dddb928aee Eric Biggers 2019-01-31  1052  				div->flush_type = FLUSH_TYPE_FLUSH;
25f9dddb928aee Eric Biggers 2019-01-31  1053  				break;
25f9dddb928aee Eric Biggers 2019-01-31  1054  			}
25f9dddb928aee Eric Biggers 2019-01-31  1055  		}
25f9dddb928aee Eric Biggers 2019-01-31  1056  
6570737c7fa047 Eric Biggers 2019-03-12  1057  		if (div->flush_type != FLUSH_TYPE_NONE &&
6570737c7fa047 Eric Biggers 2019-03-12  1058  		    !(req_flags & CRYPTO_TFM_REQ_MAY_SLEEP) &&
f900fde2888360 Eric Biggers 2023-02-27  1059  		    prandom_bool(rng))
6570737c7fa047 Eric Biggers 2019-03-12  1060  			div->nosimd = true;
6570737c7fa047 Eric Biggers 2019-03-12  1061  
6570737c7fa047 Eric Biggers 2019-03-12  1062  		switch (div->flush_type) {
6570737c7fa047 Eric Biggers 2019-03-12  1063  		case FLUSH_TYPE_FLUSH:
6570737c7fa047 Eric Biggers 2019-03-12  1064  			if (div->nosimd)
6570737c7fa047 Eric Biggers 2019-03-12  1065  				flushtype_str = "<flush,nosimd>";
6570737c7fa047 Eric Biggers 2019-03-12  1066  			else
6570737c7fa047 Eric Biggers 2019-03-12  1067  				flushtype_str = "<flush>";
6570737c7fa047 Eric Biggers 2019-03-12  1068  			break;
6570737c7fa047 Eric Biggers 2019-03-12  1069  		case FLUSH_TYPE_REIMPORT:
6570737c7fa047 Eric Biggers 2019-03-12  1070  			if (div->nosimd)
6570737c7fa047 Eric Biggers 2019-03-12  1071  				flushtype_str = "<reimport,nosimd>";
6570737c7fa047 Eric Biggers 2019-03-12  1072  			else
6570737c7fa047 Eric Biggers 2019-03-12  1073  				flushtype_str = "<reimport>";
6570737c7fa047 Eric Biggers 2019-03-12  1074  			break;
6570737c7fa047 Eric Biggers 2019-03-12  1075  		default:
6570737c7fa047 Eric Biggers 2019-03-12  1076  			flushtype_str = "";
6570737c7fa047 Eric Biggers 2019-03-12  1077  			break;
6570737c7fa047 Eric Biggers 2019-03-12  1078  		}
6570737c7fa047 Eric Biggers 2019-03-12  1079  
25f9dddb928aee Eric Biggers 2019-01-31  1080  		BUILD_BUG_ON(TEST_SG_TOTAL != 10000); /* for "%u.%u%%" */
6570737c7fa047 Eric Biggers 2019-03-12  1081  		p += scnprintf(p, end - p, "%s%u.%u%%@%s+%u%s", flushtype_str,
25f9dddb928aee Eric Biggers 2019-01-31  1082  			       this_len / 100, this_len % 100,
25f9dddb928aee Eric Biggers 2019-01-31  1083  			       div->offset_relative_to_alignmask ?
25f9dddb928aee Eric Biggers 2019-01-31  1084  					"alignmask" : "",
25f9dddb928aee Eric Biggers 2019-01-31  1085  			       div->offset, this_len == remaining ? "" : ", ");
25f9dddb928aee Eric Biggers 2019-01-31  1086  		remaining -= this_len;
25f9dddb928aee Eric Biggers 2019-01-31  1087  		div++;
25f9dddb928aee Eric Biggers 2019-01-31  1088  	} while (remaining);
25f9dddb928aee Eric Biggers 2019-01-31  1089  
25f9dddb928aee Eric Biggers 2019-01-31  1090  	return p;
25f9dddb928aee Eric Biggers 2019-01-31  1091  }
25f9dddb928aee Eric Biggers 2019-01-31  1092  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#26 lore raw

Re: [PATCH 17/18] random: Do not include <linux/prandom.h>

In reply to Uros Bizjak
kernel test robot noticed the following build errors:

Hi Uros,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-nonmm-unstable]
[also build test ERROR on mtd/mtd/next mtd/mtd/fixes linus/master v6.11-rc6 next-20240906] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-kaslr-Include-linux-prandom-h-instead-of-linux-random-h/20240905-202710
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link:    https://lore.kernel.org/r/20240905122020.872466-18-ubizjak%40gmail.com
patch subject: [PATCH 17/18] random: Do not include <linux/prandom.h>
config: um-randconfig-002-20240906 (https://download.01.org/0day-ci/archive/20240906/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 05f5a91d00b02f4369f46d076411c700755ae041)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240906/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from crypto/testmgr.c:27:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:517:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     517 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from crypto/testmgr.c:27:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from crypto/testmgr.c:27:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from crypto/testmgr.c:27:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> crypto/testmgr.c:881:42: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     881 | static inline void init_rnd_state(struct rnd_state *rng)
         |                                          ^
>> crypto/testmgr.c:883:2: error: call to undeclared function 'prandom_seed_state'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     883 |         prandom_seed_state(rng, get_random_u64());
         |         ^
   crypto/testmgr.c:886:36: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     886 | static inline u8 prandom_u8(struct rnd_state *rng)
         |                                    ^
>> crypto/testmgr.c:888:9: error: call to undeclared function 'prandom_u32_state'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     888 |         return prandom_u32_state(rng);
         |                ^
   crypto/testmgr.c:891:44: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                            ^
   crypto/testmgr.c:897:9: error: call to undeclared function 'prandom_u32_state'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     897 |         return prandom_u32_state(rng) % ceil;
         |                ^
   crypto/testmgr.c:900:40: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     900 | static inline bool prandom_bool(struct rnd_state *rng)
         |                                        ^
>> crypto/testmgr.c:902:27: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     902 |         return prandom_u32_below(rng, 2);
         |                                  ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:905:48: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
         |                                                ^
   crypto/testmgr.c:908:35: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     908 |         return floor + prandom_u32_below(rng, ceil - floor + 1);
         |                                          ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:912:51: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     912 | static unsigned int generate_random_length(struct rnd_state *rng,
         |                                                   ^
   crypto/testmgr.c:915:39: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     915 |         unsigned int len = prandom_u32_below(rng, max_len + 1);
         |                                              ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:917:28: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     917 |         switch (prandom_u32_below(rng, 4)) {
         |                                   ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:930:31: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     930 |         if (len && prandom_u32_below(rng, 4) == 0)
         |                                      ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:936:36: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
         |                                    ^
   crypto/testmgr.c:940:29: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     940 |         bitpos = prandom_u32_below(rng, size * 8);
         |                                    ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:945:37: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     945 | static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
         |                                     ^
   crypto/testmgr.c:947:24: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     947 |         buf[prandom_u32_below(rng, size)] ^= 0xff;
         |                               ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:951:34: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
     951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
         |                                  ^
   crypto/testmgr.c:957:24: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     957 |         if (prandom_u32_below(rng, 4) == 0) {
         |                               ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:958:52: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     958 |                 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
         |                                                                  ^~~
   include/linux/minmax.h:213:49: note: expanded from macro 'min_t'
     213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
         |                                                 ^
   include/linux/minmax.h:96:30: note: expanded from macro '__cmp_once'
      96 |         __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
         |                                     ^
   include/linux/minmax.h:93:16: note: expanded from macro '__cmp_once_unique'
      93 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
         |                       ^
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:961:20: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     961 |                         flip_random_bit(rng, buf, size);
         |                                         ^~~
   crypto/testmgr.c:936:47: note: passing argument to parameter 'rng' here
     936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
         |                                               ^
   crypto/testmgr.c:965:24: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     965 |         if (prandom_u32_below(rng, 4) == 0) {
         |                               ^~~
   crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
     891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
         |                                                       ^
   crypto/testmgr.c:966:52: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
     966 |                 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
         |                                                                  ^~~
   include/linux/minmax.h:213:49: note: expanded from macro 'min_t'
     213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
         |                                                 ^
   include/linux/minmax.h:96:30: note: expanded from macro '__cmp_once'
      96 |         __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
         |                                     ^
   include/linux/minmax.h:93:16: note: expanded from macro '__cmp_once_unique'
      93 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })

vim +/prandom_seed_state +883 crypto/testmgr.c

f2bb770ae89641 Eric Biggers 2019-04-11  873  
f900fde2888360 Eric Biggers 2023-02-27  874  /*
f900fde2888360 Eric Biggers 2023-02-27  875   * The fuzz tests use prandom instead of the normal Linux RNG since they don't
f900fde2888360 Eric Biggers 2023-02-27  876   * need cryptographically secure random numbers.  This greatly improves the
f900fde2888360 Eric Biggers 2023-02-27  877   * performance of these tests, especially if they are run before the Linux RNG
f900fde2888360 Eric Biggers 2023-02-27  878   * has been initialized or if they are run on a lockdep-enabled kernel.
f900fde2888360 Eric Biggers 2023-02-27  879   */
f900fde2888360 Eric Biggers 2023-02-27  880  
f900fde2888360 Eric Biggers 2023-02-27 @881  static inline void init_rnd_state(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27  882  {
f900fde2888360 Eric Biggers 2023-02-27 @883  	prandom_seed_state(rng, get_random_u64());
f900fde2888360 Eric Biggers 2023-02-27  884  }
f900fde2888360 Eric Biggers 2023-02-27  885  
f900fde2888360 Eric Biggers 2023-02-27  886  static inline u8 prandom_u8(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27  887  {
f900fde2888360 Eric Biggers 2023-02-27 @888  	return prandom_u32_state(rng);
f900fde2888360 Eric Biggers 2023-02-27  889  }
f900fde2888360 Eric Biggers 2023-02-27  890  
f900fde2888360 Eric Biggers 2023-02-27 @891  static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
f900fde2888360 Eric Biggers 2023-02-27  892  {
f900fde2888360 Eric Biggers 2023-02-27  893  	/*
f900fde2888360 Eric Biggers 2023-02-27  894  	 * This is slightly biased for non-power-of-2 values of 'ceil', but this
f900fde2888360 Eric Biggers 2023-02-27  895  	 * isn't important here.
f900fde2888360 Eric Biggers 2023-02-27  896  	 */
f900fde2888360 Eric Biggers 2023-02-27  897  	return prandom_u32_state(rng) % ceil;
f900fde2888360 Eric Biggers 2023-02-27  898  }
f900fde2888360 Eric Biggers 2023-02-27  899  
f900fde2888360 Eric Biggers 2023-02-27  900  static inline bool prandom_bool(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27  901  {

f900fde2888360 Eric Biggers 2023-02-27 @902 return prandom_u32_below(rng, 2);
f900fde2888360 Eric Biggers 2023-02-27 903 }
f900fde2888360 Eric Biggers 2023-02-27 904

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#27 lore raw

Re: [PATCH 17/18] random: Do not include <linux/prandom.h>

Quoted 19 lines · kernel test robot

Hi Uros,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-nonmm-unstable]
[also build test ERROR on mtd/mtd/next mtd/mtd/fixes linus/master v6.11-rc6 next-20240906] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-kaslr-Include-linux-prandom-h-instead-of-linux-random-h/20240905-202710
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link:    https://lore.kernel.org/r/20240905122020.872466-18-ubizjak%40gmail.com
patch subject: [PATCH 17/18] random: Do not include <linux/prandom.h>
config: um-randconfig-002-20240906 (https://download.01.org/0day-ci/archive/20240906/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 05f5a91d00b02f4369f46d076411c700755ae041)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240906/[email protected]/reproduce)
Quoted 8 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from crypto/testmgr.c:27:

Ah, here we have a negative config flag, enabled for allyesconfig, so
- the source is disabled with allyesconfig.

#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
...
#endif

Patch is as simple as:

--cut here--

crypto/testmgr.c +0 -0
index f02cb075bd68..eeb7edd99a93 100644
@@ -23,7 +23,7 @@

#include <linux/fips.h>
#include <linux/module.h>
#include <linux/once.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
#include <linux/string.h>
--cut here--

Will add the patch to v2 series.

Thanks to the kernel test robot,
Uros.

#28 lore raw

PATCH 18/18 prandom: Include <linux/percpu.h>

In reply to Uros Bizjak

<linux/percpu.h> include was removed in d9f29deb7fe8 ("prandom:
Remove unused include") from prandom.h because this inclusion broke arm64 due to a circular dependency on include files. Previous patches resolved this issue.

__percpu tag is currently defined in include/linux/compiler_types.h, so there is no direct need for the inclusion of <linux/percpu.h>. However, in [1] we would like to repurpose __percpu tag as a named address space qualifier, where __percpu macro uses defines from <linux/percpu.h>.

This patch is basically a full revert of d9f29deb7fe8 ("prandom: Remove unused include").

[1] https://lore.kernel.org/lkml/[email protected]/

Cc "Theodore Ts'o" <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Kent Overstreet <[email protected]>
---
 include/linux/prandom.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/prandom.h +1 -0
index f7f1e5251c67..f2ed5b72b3d6 100644
@@ -10,6 +10,7 @@
 
 #include <linux/types.h>
 #include <linux/once.h>
+#include <linux/percpu.h>
 #include <linux/random.h>
 
 struct rnd_state {
Signature · 1 line
2.46.0
#29 lore raw
In reply to Uros Bizjak
Quoted 31 lines · Uros Bizjak

There were several attempts to resolve circular include dependency after the addition of percpu.h: 1c9df907da83 ("random: fix circular include dependency on arm64 after addition of percpu.h"), c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h") and finally d9f29deb7fe8 ("prandom: Remove unused include") that completely removes inclusion of <linux/percpu.h>.

Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but with the commit entry remark:

--quote--
A further cleanup step would be to remove this from <linux/random.h> entirely, and make people who use the prandom infrastructure include just the new header file. That's a bit of a churn patch, but grepping for "prandom_" and "next_pseudo_random32" "struct rnd_state" should catch most users.

But it turns out that that nice cleanup step is fairly painful, because a _lot_ of code currently seems to depend on the implicit include of <linux/random.h>, which can currently come in a lot of ways, including such fairly core headfers as <linux/net.h>.

So the "nice cleanup" part may or may never happen. --/quote--

__percpu tag is currently defined in include/linux/compiler_types.h, so there is no direct need for the inclusion of <linux/percpu.h>. However, in [1] we would like to repurpose __percpu tag as a named address space qualifier, where __percpu macro uses defines from <linux/percpu.h>.

Quoted 6 lines

This patch series is the "nice cleanup" part, and allows us to finally include <linux/percpu.h> in prandom.h.

The whole series was tested by compiling the kernel for x86_64 allconfig and some popular architectures, namely arm64 defconfig, powerpc defconfig and loongarch defconfig.

Obvious question(s) is(are):
1) have you seen the Ingo's gigantic patch series towards resolving issues with the headers?
2) if not, please look at the preliminary work and take something from there, I believe there are many useful changes already waiting for a couple of years to be applied.

Because I haven't found any references nor mentions of that in the cover letter here and explanation why it was not taking into consideration.

Quoted 1 line

[1] https://lore.kernel.org/lkml/[email protected]/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#30 lore raw
Quoted 47 lines · Andy Shevchenko
Quoted 31 lines · Uros Bizjak

There were several attempts to resolve circular include dependency after the addition of percpu.h: 1c9df907da83 ("random: fix circular include dependency on arm64 after addition of percpu.h"), c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h") and finally d9f29deb7fe8 ("prandom: Remove unused include") that completely removes inclusion of <linux/percpu.h>.

Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but with the commit entry remark:

--quote--
A further cleanup step would be to remove this from <linux/random.h> entirely, and make people who use the prandom infrastructure include just the new header file. That's a bit of a churn patch, but grepping for "prandom_" and "next_pseudo_random32" "struct rnd_state" should catch most users.

But it turns out that that nice cleanup step is fairly painful, because a _lot_ of code currently seems to depend on the implicit include of <linux/random.h>, which can currently come in a lot of ways, including such fairly core headfers as <linux/net.h>.

So the "nice cleanup" part may or may never happen. --/quote--

__percpu tag is currently defined in include/linux/compiler_types.h, so there is no direct need for the inclusion of <linux/percpu.h>. However, in [1] we would like to repurpose __percpu tag as a named address space qualifier, where __percpu macro uses defines from <linux/percpu.h>.

Quoted 6 lines

This patch series is the "nice cleanup" part, and allows us to finally include <linux/percpu.h> in prandom.h.

The whole series was tested by compiling the kernel for x86_64 allconfig and some popular architectures, namely arm64 defconfig, powerpc defconfig and loongarch defconfig.

Obvious question(s) is(are):
1) have you seen the Ingo's gigantic patch series towards resolving issues with the headers?
2) if not, please look at the preliminary work and take something from there, I believe there are many useful changes already waiting for a couple of years to be applied.

Quoted 2 lines

Because I haven't found any references nor mentions of that in the cover letter here and explanation why it was not taking into consideration.

I am aware of the series, but the patch takes only a small bite of it and specifically resolves the inclusion of <linux/prandom.h> from linux/random.h. The series fixes the missing inclusion of <linux/prandom.h> in files that use pseudo-random function and it was not meant to be a general header cleanup. The end goal is to allow us to include <linux/percpu.h> in linux/prandom.h - which uses __percpu tag without the correct include.

Thus, the patch series is only tangentially connected to Ingo's patch series.

Best regards,
Uros.

#31 lore raw
Quoted 52 lines · Uros Bizjak
Quoted 47 lines · Andy Shevchenko
Quoted 31 lines · Uros Bizjak

There were several attempts to resolve circular include dependency after the addition of percpu.h: 1c9df907da83 ("random: fix circular include dependency on arm64 after addition of percpu.h"), c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h") and finally d9f29deb7fe8 ("prandom: Remove unused include") that completely removes inclusion of <linux/percpu.h>.

Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but with the commit entry remark:

--quote--
A further cleanup step would be to remove this from <linux/random.h> entirely, and make people who use the prandom infrastructure include just the new header file. That's a bit of a churn patch, but grepping for "prandom_" and "next_pseudo_random32" "struct rnd_state" should catch most users.

But it turns out that that nice cleanup step is fairly painful, because a _lot_ of code currently seems to depend on the implicit include of <linux/random.h>, which can currently come in a lot of ways, including such fairly core headfers as <linux/net.h>.

So the "nice cleanup" part may or may never happen. --/quote--

__percpu tag is currently defined in include/linux/compiler_types.h, so there is no direct need for the inclusion of <linux/percpu.h>. However, in [1] we would like to repurpose __percpu tag as a named address space qualifier, where __percpu macro uses defines from <linux/percpu.h>.

Quoted 6 lines

This patch series is the "nice cleanup" part, and allows us to finally include <linux/percpu.h> in prandom.h.

The whole series was tested by compiling the kernel for x86_64 allconfig and some popular architectures, namely arm64 defconfig, powerpc defconfig and loongarch defconfig.

Obvious question(s) is(are):
1) have you seen the Ingo's gigantic patch series towards resolving issues with the headers?
2) if not, please look at the preliminary work and take something from there, I believe there are many useful changes already waiting for a couple of years to be applied.

Quoted 2 lines

Because I haven't found any references nor mentions of that in the cover letter here and explanation why it was not taking into consideration.

Quoted 7 lines

I am aware of the series, but the patch takes only a small bite of it and specifically resolves the inclusion of <linux/prandom.h> from linux/random.h. The series fixes the missing inclusion of <linux/prandom.h> in files that use pseudo-random function and it was not meant to be a general header cleanup. The end goal is to allow us to include <linux/percpu.h> in linux/prandom.h - which uses __percpu tag without the correct include.

Thank you for elaboration, it's all clear now.

Quoted 1 line

Thus, the patch series is only tangentially connected to Ingo's patch series.

Signature · 2 lines
With Best Regards,
Andy Shevchenko