All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] random: do not take pool spinlock at boot
@ 2022-02-12  0:28 Jason A. Donenfeld
  2022-02-12  5:04 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jason A. Donenfeld @ 2022-02-12  0:28 UTC (permalink / raw)
  To: linux, linux-kernel; +Cc: Jason A. Donenfeld

Since rand_initialize() is run while interrupts are still off and
nothing else is running, we don't need to repeatedly take and release
the pool spinlock, especially in the RDSEED loop.

Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
Dominik - I'm still a bit unclear about early boot semantics that you
seem to know well. Is this patch correct?

 drivers/char/random.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index d4b692c9de68..8088348190e6 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -966,10 +966,10 @@ int __init rand_initialize(void)
 			rv = random_get_entropy();
 			arch_init = false;
 		}
-		mix_pool_bytes(&rv, sizeof(rv));
+		_mix_pool_bytes(&rv, sizeof(rv));
 	}
-	mix_pool_bytes(&now, sizeof(now));
-	mix_pool_bytes(utsname(), sizeof(*(utsname())));
+	_mix_pool_bytes(&now, sizeof(now));
+	_mix_pool_bytes(utsname(), sizeof(*(utsname())));
 
 	extract_entropy(base_crng.key, sizeof(base_crng.key));
 	++base_crng.generation;
-- 
2.35.0


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

* Re: [PATCH] random: do not take pool spinlock at boot
  2022-02-12  0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
@ 2022-02-12  5:04 ` kernel test robot
  2022-02-12  5:35 ` kernel test robot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-12  5:04 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3196 bytes --]

Hi "Jason,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20220211]
[cannot apply to char-misc/char-misc-testing linux/master linus/master v5.17-rc3 v5.17-rc2 v5.17-rc1 v5.17-rc3]
[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]

url:    https://github.com/0day-ci/linux/commits/Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
base:    6d9bd4ad4ca08b1114e814c2c42383b8b13be631
config: um-x86_64_defconfig (https://download.01.org/0day-ci/archive/20220212/202202121223.7CKs3pQ3-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/cac377f6ab22a8bfe966643ebe19812e8187de3b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
        git checkout cac377f6ab22a8bfe966643ebe19812e8187de3b
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=um SUBARCH=x86_64 SHELL=/bin/bash drivers/char/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/char/random.c: In function 'rand_initialize':
   drivers/char/random.c:162:3: error: implicit declaration of function '_mix_pool_bytes'; did you mean 'mix_pool_bytes'? [-Werror=implicit-function-declaration]
     162 |   _mix_pool_bytes(&rv, sizeof(rv));
         |   ^~~~~~~~~~~~~~~
         |   mix_pool_bytes
   drivers/char/random.c: At top level:
>> drivers/char/random.c:822:13: warning: conflicting types for '_mix_pool_bytes'
     822 | static void _mix_pool_bytes(const void *in, size_t nbytes)
         |             ^~~~~~~~~~~~~~~
   drivers/char/random.c:822:13: error: static declaration of '_mix_pool_bytes' follows non-static declaration
   drivers/char/random.c:162:3: note: previous implicit declaration of '_mix_pool_bytes' was here
     162 |   _mix_pool_bytes(&rv, sizeof(rv));
         |   ^~~~~~~~~~~~~~~
   drivers/char/random.c:1109:6: warning: no previous prototype for 'add_hwgenerator_randomness' [-Wmissing-prototypes]
    1109 | void add_hwgenerator_randomness(const void *buffer, size_t count,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/_mix_pool_bytes +822 drivers/char/random.c

b980955236922ae Theodore Ts'o      2013-03-04  821  
b67959013391e48 Jason A. Donenfeld 2022-02-10 @822  static void _mix_pool_bytes(const void *in, size_t nbytes)
b67959013391e48 Jason A. Donenfeld 2022-02-10  823  {
b67959013391e48 Jason A. Donenfeld 2022-02-10  824  	blake2s_update(&input_pool.hash, in, nbytes);
^1da177e4c3f415 Linus Torvalds     2005-04-16  825  }
^1da177e4c3f415 Linus Torvalds     2005-04-16  826  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* Re: [PATCH] random: do not take pool spinlock at boot
  2022-02-12  0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
  2022-02-12  5:04 ` kernel test robot
@ 2022-02-12  5:35 ` kernel test robot
  2022-02-12 10:01   ` Jason A. Donenfeld
  2022-02-13  6:55 ` Dominik Brodowski
  2022-02-21  5:34 ` Eric Biggers
  3 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2022-02-12  5:35 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4290 bytes --]

Hi "Jason,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20220211]
[cannot apply to char-misc/char-misc-testing linux/master linus/master v5.17-rc3 v5.17-rc2 v5.17-rc1 v5.17-rc3]
[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]

url:    https://github.com/0day-ci/linux/commits/Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
base:    6d9bd4ad4ca08b1114e814c2c42383b8b13be631
config: um-x86_64_defconfig (https://download.01.org/0day-ci/archive/20220212/202202121318.QSBkUcwP-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/cac377f6ab22a8bfe966643ebe19812e8187de3b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
        git checkout cac377f6ab22a8bfe966643ebe19812e8187de3b
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=um SUBARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/char/random.c: In function 'rand_initialize':
>> drivers/char/random.c:162:3: error: implicit declaration of function '_mix_pool_bytes'; did you mean 'mix_pool_bytes'? [-Werror=implicit-function-declaration]
     162 |   _mix_pool_bytes(&rv, sizeof(rv));
         |   ^~~~~~~~~~~~~~~
         |   mix_pool_bytes
   drivers/char/random.c: At top level:
   drivers/char/random.c:822:13: warning: conflicting types for '_mix_pool_bytes'
     822 | static void _mix_pool_bytes(const void *in, size_t nbytes)
         |             ^~~~~~~~~~~~~~~
>> drivers/char/random.c:822:13: error: static declaration of '_mix_pool_bytes' follows non-static declaration
   drivers/char/random.c:162:3: note: previous implicit declaration of '_mix_pool_bytes' was here
     162 |   _mix_pool_bytes(&rv, sizeof(rv));
         |   ^~~~~~~~~~~~~~~
   drivers/char/random.c:1109:6: warning: no previous prototype for 'add_hwgenerator_randomness' [-Wmissing-prototypes]
    1109 | void add_hwgenerator_randomness(const void *buffer, size_t count,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +162 drivers/char/random.c

   138	
   139	/*
   140	 * Note that setup_arch() may call add_device_randomness()
   141	 * long before we get here. This allows seeding of the pools
   142	 * with some platform dependent data very early in the boot
   143	 * process. But it limits our options here. We must use
   144	 * statically allocated structures that already have all
   145	 * initializations complete at compile time. We should also
   146	 * take care not to overwrite the precious per platform data
   147	 * we were given.
   148	 */
   149	int __init rand_initialize(void)
   150	{
   151		size_t i;
   152		ktime_t now = ktime_get_real();
   153		bool arch_init = true;
   154		unsigned long rv;
   155	
   156		for (i = BLAKE2S_BLOCK_SIZE; i > 0; i -= sizeof(rv)) {
   157			if (!arch_get_random_seed_long_early(&rv) &&
   158			    !arch_get_random_long_early(&rv)) {
   159				rv = random_get_entropy();
   160				arch_init = false;
   161			}
 > 162			_mix_pool_bytes(&rv, sizeof(rv));
   163		}
   164		_mix_pool_bytes(&now, sizeof(now));
   165		_mix_pool_bytes(utsname(), sizeof(*(utsname())));
   166	
   167		extract_entropy(base_crng.key, sizeof(base_crng.key));
   168		++base_crng.generation;
   169	
   170		if (arch_init && trust_cpu && crng_init < 2) {
   171			crng_init = 2;
   172			pr_notice("crng init done (trusting CPU's manufacturer)\n");
   173		}
   174	
   175		if (ratelimit_disable) {
   176			urandom_warning.interval = 0;
   177			unseeded_warning.interval = 0;
   178		}
   179		return 0;
   180	}
   181	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

* Re: [PATCH] random: do not take pool spinlock at boot
  2022-02-12  5:35 ` kernel test robot
@ 2022-02-12 10:01   ` Jason A. Donenfeld
  2022-02-14  6:40     ` Chen, Rong A
  0 siblings, 1 reply; 7+ messages in thread
From: Jason A. Donenfeld @ 2022-02-12 10:01 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5056 bytes --]

Hey folks,

Just FYI, this applied to the wrong tree. It should have applied to
https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git

Regards,
Jason


On Sat, Feb 12, 2022, 06:35 kernel test robot <lkp@intel.com> wrote:

> Hi "Jason,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on next-20220211]
> [cannot apply to char-misc/char-misc-testing linux/master linus/master
> v5.17-rc3 v5.17-rc2 v5.17-rc1 v5.17-rc3]
> [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]
>
> url:
> https://github.com/0day-ci/linux/commits/Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
> base:    6d9bd4ad4ca08b1114e814c2c42383b8b13be631
> config: um-x86_64_defconfig (
> https://download.01.org/0day-ci/archive/20220212/202202121318.QSBkUcwP-lkp(a)intel.com/config
> )
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build):
>         #
> https://github.com/0day-ci/linux/commit/cac377f6ab22a8bfe966643ebe19812e8187de3b
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review
> Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
>         git checkout cac377f6ab22a8bfe966643ebe19812e8187de3b
>         # save the config file to linux build tree
>         mkdir build_dir
>         make W=1 O=build_dir ARCH=um SUBARCH=x86_64 SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
>    drivers/char/random.c: In function 'rand_initialize':
> >> drivers/char/random.c:162:3: error: implicit declaration of function
> '_mix_pool_bytes'; did you mean 'mix_pool_bytes'?
> [-Werror=implicit-function-declaration]
>      162 |   _mix_pool_bytes(&rv, sizeof(rv));
>          |   ^~~~~~~~~~~~~~~
>          |   mix_pool_bytes
>    drivers/char/random.c: At top level:
>    drivers/char/random.c:822:13: warning: conflicting types for
> '_mix_pool_bytes'
>      822 | static void _mix_pool_bytes(const void *in, size_t nbytes)
>          |             ^~~~~~~~~~~~~~~
> >> drivers/char/random.c:822:13: error: static declaration of
> '_mix_pool_bytes' follows non-static declaration
>    drivers/char/random.c:162:3: note: previous implicit declaration of
> '_mix_pool_bytes' was here
>      162 |   _mix_pool_bytes(&rv, sizeof(rv));
>          |   ^~~~~~~~~~~~~~~
>    drivers/char/random.c:1109:6: warning: no previous prototype for
> 'add_hwgenerator_randomness' [-Wmissing-prototypes]
>     1109 | void add_hwgenerator_randomness(const void *buffer, size_t
> count,
>          |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
>    cc1: some warnings being treated as errors
>
>
> vim +162 drivers/char/random.c
>
>    138
>    139  /*
>    140   * Note that setup_arch() may call add_device_randomness()
>    141   * long before we get here. This allows seeding of the pools
>    142   * with some platform dependent data very early in the boot
>    143   * process. But it limits our options here. We must use
>    144   * statically allocated structures that already have all
>    145   * initializations complete at compile time. We should also
>    146   * take care not to overwrite the precious per platform data
>    147   * we were given.
>    148   */
>    149  int __init rand_initialize(void)
>    150  {
>    151          size_t i;
>    152          ktime_t now = ktime_get_real();
>    153          bool arch_init = true;
>    154          unsigned long rv;
>    155
>    156          for (i = BLAKE2S_BLOCK_SIZE; i > 0; i -= sizeof(rv)) {
>    157                  if (!arch_get_random_seed_long_early(&rv) &&
>    158                      !arch_get_random_long_early(&rv)) {
>    159                          rv = random_get_entropy();
>    160                          arch_init = false;
>    161                  }
>  > 162                  _mix_pool_bytes(&rv, sizeof(rv));
>    163          }
>    164          _mix_pool_bytes(&now, sizeof(now));
>    165          _mix_pool_bytes(utsname(), sizeof(*(utsname())));
>    166
>    167          extract_entropy(base_crng.key, sizeof(base_crng.key));
>    168          ++base_crng.generation;
>    169
>    170          if (arch_init && trust_cpu && crng_init < 2) {
>    171                  crng_init = 2;
>    172                  pr_notice("crng init done (trusting CPU's
> manufacturer)\n");
>    173          }
>    174
>    175          if (ratelimit_disable) {
>    176                  urandom_warning.interval = 0;
>    177                  unseeded_warning.interval = 0;
>    178          }
>    179          return 0;
>    180  }
>    181
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
>

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 7081 bytes --]

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

* Re: [PATCH] random: do not take pool spinlock at boot
  2022-02-12  0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
  2022-02-12  5:04 ` kernel test robot
  2022-02-12  5:35 ` kernel test robot
@ 2022-02-13  6:55 ` Dominik Brodowski
  2022-02-21  5:34 ` Eric Biggers
  3 siblings, 0 replies; 7+ messages in thread
From: Dominik Brodowski @ 2022-02-13  6:55 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux-kernel

Am Sat, Feb 12, 2022 at 01:28:59AM +0100 schrieb Jason A. Donenfeld:
> Since rand_initialize() is run while interrupts are still off and
> nothing else is running, we don't need to repeatedly take and release
> the pool spinlock, especially in the RDSEED loop.
> 
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
> Dominik - I'm still a bit unclear about early boot semantics that you
> seem to know well. Is this patch correct?

It seems to be.

	Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>

Thanks,
	Dominik

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

* Re: [PATCH] random: do not take pool spinlock at boot
  2022-02-12 10:01   ` Jason A. Donenfeld
@ 2022-02-14  6:40     ` Chen, Rong A
  0 siblings, 0 replies; 7+ messages in thread
From: Chen, Rong A @ 2022-02-14  6:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6856 bytes --]

Hi Jason,

Thanks for the explanation, we'll take a look.

Best Regards,
Rong Chen

On 2/12/2022 6:01 PM, Jason A. Donenfeld wrote:
> Hey folks,
> 
> Just FYI, this applied to the wrong tree. It should have applied to 
> https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git 
> <https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git>
> 
> Regards,
> Jason
> 
> 
> On Sat, Feb 12, 2022, 06:35 kernel test robot <lkp@intel.com 
> <mailto:lkp@intel.com>> wrote:
> 
>     Hi "Jason,
> 
>     I love your patch! Yet something to improve:
> 
>     [auto build test ERROR on next-20220211]
>     [cannot apply to char-misc/char-misc-testing linux/master
>     linus/master v5.17-rc3 v5.17-rc2 v5.17-rc1 v5.17-rc3]
>     [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
>     <https://git-scm.com/docs/git-format-patch>]
> 
>     url:
>     https://github.com/0day-ci/linux/commits/Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
>     <https://github.com/0day-ci/linux/commits/Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131>
>     base:    6d9bd4ad4ca08b1114e814c2c42383b8b13be631
>     config: um-x86_64_defconfig
>     (https://download.01.org/0day-ci/archive/20220212/202202121318.QSBkUcwP-lkp(a)intel.com/config
>     <https://download.01.org/0day-ci/archive/20220212/202202121318.QSBkUcwP-lkp@intel.com/config>)
>     compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
>     reproduce (this is a W=1 build):
>              #
>     https://github.com/0day-ci/linux/commit/cac377f6ab22a8bfe966643ebe19812e8187de3b
>     <https://github.com/0day-ci/linux/commit/cac377f6ab22a8bfe966643ebe19812e8187de3b>
>              git remote add linux-review
>     https://github.com/0day-ci/linux <https://github.com/0day-ci/linux>
>              git fetch --no-tags linux-review
>     Jason-A-Donenfeld/random-do-not-take-pool-spinlock-at-boot/20220212-083131
>              git checkout cac377f6ab22a8bfe966643ebe19812e8187de3b
>              # save the config file to linux build tree
>              mkdir build_dir
>              make W=1 O=build_dir ARCH=um SUBARCH=x86_64 SHELL=/bin/bash
> 
>     If you fix the issue, kindly add following tag as appropriate
>     Reported-by: kernel test robot <lkp(a)intel.com <mailto:lkp@intel.com>>
> 
>     All errors (new ones prefixed by >>):
> 
>         drivers/char/random.c: In function 'rand_initialize':
>      >> drivers/char/random.c:162:3: error: implicit declaration of
>     function '_mix_pool_bytes'; did you mean 'mix_pool_bytes'?
>     [-Werror=implicit-function-declaration]
>           162 |   _mix_pool_bytes(&rv, sizeof(rv));
>               |   ^~~~~~~~~~~~~~~
>               |   mix_pool_bytes
>         drivers/char/random.c: At top level:
>         drivers/char/random.c:822:13: warning: conflicting types for
>     '_mix_pool_bytes'
>           822 | static void _mix_pool_bytes(const void *in, size_t nbytes)
>               |             ^~~~~~~~~~~~~~~
>      >> drivers/char/random.c:822:13: error: static declaration of
>     '_mix_pool_bytes' follows non-static declaration
>         drivers/char/random.c:162:3: note: previous implicit declaration
>     of '_mix_pool_bytes' was here
>           162 |   _mix_pool_bytes(&rv, sizeof(rv));
>               |   ^~~~~~~~~~~~~~~
>         drivers/char/random.c:1109:6: warning: no previous prototype for
>     'add_hwgenerator_randomness' [-Wmissing-prototypes]
>          1109 | void add_hwgenerator_randomness(const void *buffer,
>     size_t count,
>               |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
>         cc1: some warnings being treated as errors
> 
> 
>     vim +162 drivers/char/random.c
> 
>         138
>         139  /*
>         140   * Note that setup_arch() may call add_device_randomness()
>         141   * long before we get here. This allows seeding of the pools
>         142   * with some platform dependent data very early in the boot
>         143   * process. But it limits our options here. We must use
>         144   * statically allocated structures that already have all
>         145   * initializations complete at compile time. We should also
>         146   * take care not to overwrite the precious per platform data
>         147   * we were given.
>         148   */
>         149  int __init rand_initialize(void)
>         150  {
>         151          size_t i;
>         152          ktime_t now = ktime_get_real();
>         153          bool arch_init = true;
>         154          unsigned long rv;
>         155
>         156          for (i = BLAKE2S_BLOCK_SIZE; i > 0; i -= sizeof(rv)) {
>         157                  if (!arch_get_random_seed_long_early(&rv) &&
>         158                      !arch_get_random_long_early(&rv)) {
>         159                          rv = random_get_entropy();
>         160                          arch_init = false;
>         161                  }
>       > 162                  _mix_pool_bytes(&rv, sizeof(rv));
>         163          }
>         164          _mix_pool_bytes(&now, sizeof(now));
>         165          _mix_pool_bytes(utsname(), sizeof(*(utsname())));
>         166
>         167          extract_entropy(base_crng.key, sizeof(base_crng.key));
>         168          ++base_crng.generation;
>         169
>         170          if (arch_init && trust_cpu && crng_init < 2) {
>         171                  crng_init = 2;
>         172                  pr_notice("crng init done (trusting CPU's
>     manufacturer)\n");
>         173          }
>         174
>         175          if (ratelimit_disable) {
>         176                  urandom_warning.interval = 0;
>         177                  unseeded_warning.interval = 0;
>         178          }
>         179          return 0;
>         180  }
>         181
> 
>     ---
>     0-DAY CI Kernel Test Service, Intel Corporation
>     https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
>     <https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org>
> 
> 
> _______________________________________________
> kbuild-all mailing list -- kbuild-all(a)lists.01.org
> To unsubscribe send an email to kbuild-all-leave(a)lists.01.org
> 

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

* Re: [PATCH] random: do not take pool spinlock at boot
  2022-02-12  0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
                   ` (2 preceding siblings ...)
  2022-02-13  6:55 ` Dominik Brodowski
@ 2022-02-21  5:34 ` Eric Biggers
  3 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2022-02-21  5:34 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux, linux-kernel

On Sat, Feb 12, 2022 at 01:28:59AM +0100, Jason A. Donenfeld wrote:
> Since rand_initialize() is run while interrupts are still off and
> nothing else is running, we don't need to repeatedly take and release
> the pool spinlock, especially in the RDSEED loop.
> 
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
> Dominik - I'm still a bit unclear about early boot semantics that you
> seem to know well. Is this patch correct?
> 
>  drivers/char/random.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index d4b692c9de68..8088348190e6 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -966,10 +966,10 @@ int __init rand_initialize(void)
>  			rv = random_get_entropy();
>  			arch_init = false;
>  		}
> -		mix_pool_bytes(&rv, sizeof(rv));
> +		_mix_pool_bytes(&rv, sizeof(rv));
>  	}
> -	mix_pool_bytes(&now, sizeof(now));
> -	mix_pool_bytes(utsname(), sizeof(*(utsname())));
> +	_mix_pool_bytes(&now, sizeof(now));
> +	_mix_pool_bytes(utsname(), sizeof(*(utsname())));
>  
>  	extract_entropy(base_crng.key, sizeof(base_crng.key));
>  	++base_crng.generation;
> -- 
> 2.35.0

Reviewed-by: Eric Biggers <ebiggers@google.com>

- Eric

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

end of thread, other threads:[~2022-02-21  5:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-12  0:28 [PATCH] random: do not take pool spinlock at boot Jason A. Donenfeld
2022-02-12  5:04 ` kernel test robot
2022-02-12  5:35 ` kernel test robot
2022-02-12 10:01   ` Jason A. Donenfeld
2022-02-14  6:40     ` Chen, Rong A
2022-02-13  6:55 ` Dominik Brodowski
2022-02-21  5:34 ` Eric Biggers

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