smuellerDD / lrng

Linux Random Number Generator
http://www.chronox.de/lrng
68 stars 11 forks source link

Trouble building using lrng-50-6.4 #32

Closed BruceMc-wg closed 1 year ago

BruceMc-wg commented 1 year ago

Hello Stephan,

Thank you for guidance on the procedure to apply patches for my 4.14.140 kernel.

I am having trouble building my kernel sources. My build process cross-compiles for a few different architectures using different architectures toolchains built from the same sources. I build for x84-64 bit, ppc-32 bit, ppc-64 bit, and arm-64 bit.

I first tried building for arm-64 and I ran into trouble building the lrng_es_mgr.c source file. The error I received is linux/drivers/char/lrng/lrng_es_mgr.c:14:28: fatal error: asm/archrandom.h: No such file or directory

Looking at this I found, at least in my kernel version. asm/archrandom.h is only present for some architectures. I did a search of my linux source tree and this is what I found $ find linux/ -not -type d | grep archrandom linux/arch/x86/include/asm/archrandom.h linux/arch/s390/include/asm/archrandom.h linux/arch/powerpc/include/asm/archrandom.h $ So apparently archrandom is only available for a limited set of architectures.

Realizing there was likely no quick solution for building for arm-64, I tried building for x86-64. I got past the asm/archrandom.h problem but ran into a different issue, again in the lrng_es_mgr.c source file. I'm seeing this problem. CC drivers/char/lrng/lrng_es_mgr.o /builds/appliances/utm-fips140-3/linux/drivers/char/lrng/lrng_es_mgr.c: In function 'lrng_rand_initialize_early': /builds/appliances/utm-fips140-3/linux/drivers/char/lrng/lrng_es_mgr.c:396:8: error: implicit declaration of function 'arch_get_random_seed_long_early' [-Werror=implicit-function-declaration] if (!arch_get_random_seed_long_early(&(seed.data[i])) && ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /builds/appliances/utm-fips140-3/linux/drivers/char/lrng/lrng_es_mgr.c:397:8: error: implicit declaration of function 'arch_get_random_long_early' [-Werror=implicit-function-declaration] !arch_get_random_long_early(&seed.data[i])) ^~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors make[7]: *** [/builds/appliances/utm-fips140-3/linux/scripts/Makefile.build:327: drivers/char/lrng/lrng_es_mgr.o] Error 1

Looking at my patch files I applied I see the functions being complained about, arch_get_random_long_early and arch_get_random_seed_long_early were patched into lrng_es_mgr.c from the patch I used backports/v50-4.14.320/v50-03-revert-arch_get_random_long.patch

I noticed that the lrng_es_mgr.c file in the top level directory of the lnrg git repo, the function where these functions are called, void __init lrng_rand_initialize_early(void) uses similarly named functions and looks a bit different.

Is it the patch files are out of date? I've attached the lrng_es_mgr.c file I have now.

What is my path forward?

Bruce lrng_es_mgr.c.txt

smuellerDD commented 1 year ago

Am Mittwoch, 26. Juli 2023, 05:25:39 CEST schrieb Bruce McPeek:

Hi Bruce,

Hello Stephan,

Thank you for guidance on the procedure to apply patches for my 4.14.140 kernel.

I am having trouble building my kernel sources. My build process cross-compiles for a few different architectures using different architectures toolchains built from the same sources. I build for x84-64 bit, ppc-32 bit, ppc-64 bit, and arm-64 bit.

I first tried building for arm-64 and I ran into trouble building the lrng_es_mgr.c source file. The error I received is linux/drivers/char/lrng/lrng_es_mgr.c:14:28: fatal error: asm/archrandom.h: No such file or directory

Interesting, asm/archrandom.h exists only for the implementing arches. But otherwise the defines are taken from random.h. Thanks for the hint. Please simply remove the archrandom.h include.

Looking at this I found, at least in my kernel version. asm/archrandom.h is only present for some architectures. I did a search of my linux source tree and this is what I found $ find linux/ -not -type d | grep archrandom linux/arch/x86/include/asm/archrandom.h linux/arch/s390/include/asm/archrandom.h linux/arch/powerpc/include/asm/archrandom.h $ So apparently archrandom is only available for a limited set of architectures.

Realizing there was likely no quick solution for building for arm-64, I tried building for x86-64. I got past the asm/archrandom.h problem but ran into a different issue, again in the lrng_es_mgr.c source file. I'm seeing this problem. CC drivers/char/lrng/lrng_es_mgr.o /builds/appliances/utm-fips140-3/linux/drivers/char/lrng/lrng_es_mgr.c: In function 'lrng_rand_initialize_early': /builds/appliances/utm-fips140-3/linux/drivers/char/lrng/lrng_es_mgr.c:396 :8: error: implicit declaration of function 'arch_get_random_seed_long_early' [-Werror=implicit-function-declaration] if (!arch_get_random_seed_long_early(&(seed.data[i])) && ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /builds/appliances/utm-fips140-3/linux/drivers/char/lrng/lrng_es_mgr.c:397: 8: error: implicit declaration of function 'arch_get_random_long_early' [-Werror=implicit-function-declaration] !arch_get_random_long_early(&seed.data[i])) ^~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors make[7]: *** [/builds/appliances/utm-fips140-3/linux/scripts/Makefile.build:327: drivers/char/lrng/lrng_es_mgr.o] Error 1

Which kernel version are you using? In Linux kernel 4.14.302 this function does exist.

If it does not exist, you can safely change the function call to remove the _early suffix - both functions are identical from a caller's perspective.

Looking at my patch files I applied I see the functions being complained about, arch_get_random_long_early and arch_get_random_seed_long_early were patched into lrng_es_mgr.c from the patch I used backports/v50-4.14.320/v50-03-revert-arch_get_random_long.patch

I noticed that the lrng_es_mgr.c file in the top level directory of the lnrg git repo, the function where these functions are called, void __init lrng_rand_initialize_early(void) uses similarly named functions and looks a bit different.

Is it the patch files are out of date? I've attached the lrng_es_mgr.c file I have now.

The latest 4.14 kernel does have the function. Note, I am always performing a full test on all kernel patches I release and compilation works fine.

What is my path forward?

Bruce lrng_es_mgr.c.txt

Ciao Stephan