362362 * To allow fractional bits to be tracked, the entropy_count field is
363363 * denominated in units of 1/8th bits.
364364 *
365- * 2*(ENTROPY_SHIFT + poolbitshift) must <= 31, or the multiply in
365+ * 2*(POOL_ENTROPY_SHIFT + poolbitshift) must <= 31, or the multiply in
366366 * credit_entropy_bits() needs to be 64 bits wide.
367367 */
368- #define ENTROPY_SHIFT 3
369- #define ENTROPY_BITS () (input_pool.entropy_count >> ENTROPY_SHIFT )
368+ #define POOL_ENTROPY_SHIFT 3
369+ #define POOL_ENTROPY_BITS () (input_pool.entropy_count >> POOL_ENTROPY_SHIFT )
370370
371371/*
372372 * If the entropy count falls under this number of bits, then we
@@ -426,7 +426,7 @@ enum poolinfo {
426426 POOL_BYTES = POOL_WORDS * sizeof (u32 ),
427427 POOL_BITS = POOL_BYTES * 8 ,
428428 POOL_BITSHIFT = ilog2 (POOL_WORDS ) + 5 ,
429- POOL_FRACBITS = POOL_WORDS << (ENTROPY_SHIFT + 5 ),
429+ POOL_FRACBITS = POOL_WORDS << (POOL_ENTROPY_SHIFT + 5 ),
430430
431431 /* x^128 + x^104 + x^76 + x^51 +x^25 + x + 1 */
432432 POOL_TAP1 = 104 ,
@@ -650,7 +650,7 @@ static void process_random_ready_list(void)
650650static void credit_entropy_bits (int nbits )
651651{
652652 int entropy_count , entropy_bits , orig ;
653- int nfrac = nbits << ENTROPY_SHIFT ;
653+ int nfrac = nbits << POOL_ENTROPY_SHIFT ;
654654
655655 if (!nbits )
656656 return ;
@@ -683,7 +683,7 @@ static void credit_entropy_bits(int nbits)
683683 * turns no matter how large nbits is.
684684 */
685685 int pnfrac = nfrac ;
686- const int s = POOL_BITSHIFT + ENTROPY_SHIFT + 2 ;
686+ const int s = POOL_BITSHIFT + POOL_ENTROPY_SHIFT + 2 ;
687687 /* The +2 corresponds to the /4 in the denominator */
688688
689689 do {
@@ -704,9 +704,9 @@ static void credit_entropy_bits(int nbits)
704704 if (cmpxchg (& input_pool .entropy_count , orig , entropy_count ) != orig )
705705 goto retry ;
706706
707- trace_credit_entropy_bits (nbits , entropy_count >> ENTROPY_SHIFT , _RET_IP_ );
707+ trace_credit_entropy_bits (nbits , entropy_count >> POOL_ENTROPY_SHIFT , _RET_IP_ );
708708
709- entropy_bits = entropy_count >> ENTROPY_SHIFT ;
709+ entropy_bits = entropy_count >> POOL_ENTROPY_SHIFT ;
710710 if (crng_init < 2 && entropy_bits >= 128 )
711711 crng_reseed (& primary_crng , true);
712712}
@@ -1187,7 +1187,7 @@ void add_input_randomness(unsigned int type, unsigned int code,
11871187 last_value = value ;
11881188 add_timer_randomness (& input_timer_state ,
11891189 (type << 4 ) ^ code ^ (code >> 4 ) ^ value );
1190- trace_add_input_randomness (ENTROPY_BITS ());
1190+ trace_add_input_randomness (POOL_ENTROPY_BITS ());
11911191}
11921192EXPORT_SYMBOL_GPL (add_input_randomness );
11931193
@@ -1286,7 +1286,7 @@ void add_disk_randomness(struct gendisk *disk)
12861286 return ;
12871287 /* first major is 1, so we get >= 0x200 here */
12881288 add_timer_randomness (disk -> random , 0x100 + disk_devt (disk ));
1289- trace_add_disk_randomness (disk_devt (disk ), ENTROPY_BITS ());
1289+ trace_add_disk_randomness (disk_devt (disk ), POOL_ENTROPY_BITS ());
12901290}
12911291EXPORT_SYMBOL_GPL (add_disk_randomness );
12921292#endif
@@ -1313,7 +1313,7 @@ static size_t account(size_t nbytes, int min)
13131313 entropy_count = orig = READ_ONCE (input_pool .entropy_count );
13141314 ibytes = nbytes ;
13151315 /* never pull more than available */
1316- have_bytes = entropy_count >> (ENTROPY_SHIFT + 3 );
1316+ have_bytes = entropy_count >> (POOL_ENTROPY_SHIFT + 3 );
13171317
13181318 if (have_bytes < 0 )
13191319 have_bytes = 0 ;
@@ -1325,7 +1325,7 @@ static size_t account(size_t nbytes, int min)
13251325 pr_warn ("negative entropy count: count %d\n" , entropy_count );
13261326 entropy_count = 0 ;
13271327 }
1328- nfrac = ibytes << (ENTROPY_SHIFT + 3 );
1328+ nfrac = ibytes << (POOL_ENTROPY_SHIFT + 3 );
13291329 if ((size_t ) entropy_count > nfrac )
13301330 entropy_count -= nfrac ;
13311331 else
@@ -1335,7 +1335,7 @@ static size_t account(size_t nbytes, int min)
13351335 goto retry ;
13361336
13371337 trace_debit_entropy (8 * ibytes );
1338- if (ibytes && ENTROPY_BITS () < random_write_wakeup_bits ) {
1338+ if (ibytes && POOL_ENTROPY_BITS () < random_write_wakeup_bits ) {
13391339 wake_up_interruptible (& random_write_wait );
13401340 kill_fasync (& fasync , SIGIO , POLL_OUT );
13411341 }
@@ -1423,7 +1423,7 @@ static ssize_t _extract_entropy(void *buf, size_t nbytes)
14231423 */
14241424static ssize_t extract_entropy (void * buf , size_t nbytes , int min )
14251425{
1426- trace_extract_entropy (nbytes , ENTROPY_BITS (), _RET_IP_ );
1426+ trace_extract_entropy (nbytes , POOL_ENTROPY_BITS (), _RET_IP_ );
14271427 nbytes = account (nbytes , min );
14281428 return _extract_entropy (buf , nbytes );
14291429}
@@ -1749,9 +1749,9 @@ urandom_read_nowarn(struct file *file, char __user *buf, size_t nbytes,
17491749{
17501750 int ret ;
17511751
1752- nbytes = min_t (size_t , nbytes , INT_MAX >> (ENTROPY_SHIFT + 3 ));
1752+ nbytes = min_t (size_t , nbytes , INT_MAX >> (POOL_ENTROPY_SHIFT + 3 ));
17531753 ret = extract_crng_user (buf , nbytes );
1754- trace_urandom_read (8 * nbytes , 0 , ENTROPY_BITS ());
1754+ trace_urandom_read (8 * nbytes , 0 , POOL_ENTROPY_BITS ());
17551755 return ret ;
17561756}
17571757
@@ -1791,7 +1791,7 @@ random_poll(struct file *file, poll_table * wait)
17911791 mask = 0 ;
17921792 if (crng_ready ())
17931793 mask |= EPOLLIN | EPOLLRDNORM ;
1794- if (ENTROPY_BITS () < random_write_wakeup_bits )
1794+ if (POOL_ENTROPY_BITS () < random_write_wakeup_bits )
17951795 mask |= EPOLLOUT | EPOLLWRNORM ;
17961796 return mask ;
17971797}
@@ -1847,7 +1847,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
18471847 switch (cmd ) {
18481848 case RNDGETENTCNT :
18491849 /* inherently racy, no point locking */
1850- ent_count = ENTROPY_BITS ();
1850+ ent_count = POOL_ENTROPY_BITS ();
18511851 if (put_user (ent_count , p ))
18521852 return - EFAULT ;
18531853 return 0 ;
@@ -2005,7 +2005,7 @@ static int proc_do_entropy(struct ctl_table *table, int write,
20052005 struct ctl_table fake_table ;
20062006 int entropy_count ;
20072007
2008- entropy_count = * (int * )table -> data >> ENTROPY_SHIFT ;
2008+ entropy_count = * (int * )table -> data >> POOL_ENTROPY_SHIFT ;
20092009
20102010 fake_table .data = & entropy_count ;
20112011 fake_table .maxlen = sizeof (entropy_count );
@@ -2224,7 +2224,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
22242224 */
22252225 wait_event_interruptible (random_write_wait ,
22262226 !system_wq || kthread_should_stop () ||
2227- ENTROPY_BITS () <= random_write_wakeup_bits );
2227+ POOL_ENTROPY_BITS () <= random_write_wakeup_bits );
22282228 mix_pool_bytes (buffer , count );
22292229 credit_entropy_bits (entropy );
22302230}
0 commit comments