@@ -1058,14 +1058,21 @@ health_test_apt(struct health_test *h, unsigned int event_entropy_shift,
return health_queue;
}
-static void health_test_reset(struct health_test *h)
+static void health_test_reset(struct health_test *h,
+ unsigned int event_entropy_shift)
{
/*
- * Don't dispatch until at least 1024 events have been
- * processed by the continuous health tests as required by
- * NIST SP800-90B for the startup tests.
+ * Let H = 2^-event_entropy_shift equal the estimated per-IRQ
+ * min-entropy. One APT will consume at most 128 / H samples
+ * until completion. Run the startup tests for the larger of
+ * 1024 events as required by NIST or four times the APT
+ * length. In either case, the combined probability of the
+ * resulting number of successive APTs to detect a degradation
+ * of H to H/2 will be >= 99.8%, for any supported value of
+ * event_entropy_shift.
*/
- h->warmup = 1024;
+ h->warmup = 4 * (128 << event_entropy_shift);
+ h->warmup = max_t(unsigned int, h->warmup, 1024);
health_apt_reset(h);
}
@@ -1092,7 +1099,7 @@ health_test_process(struct health_test *h, unsigned int event_entropy_shift,
* (or always been) a constant.
*/
if (h->warmup)
- health_test_reset(h);
+ health_test_reset(h, event_entropy_shift);
return health_discard;
}
@@ -1104,7 +1111,7 @@ health_test_process(struct health_test *h, unsigned int event_entropy_shift,
apt = health_test_apt(h, event_entropy_shift, sample_delta);
if (unlikely(h->warmup) && --h->warmup) {
if (apt == health_discard)
- health_test_reset(h);
+ health_test_reset(h, event_entropy_shift);
/*
* Don't allow the caller to dispatch until warmup
* has completed.
@@ -1883,7 +1890,7 @@ static inline void fast_pool_init_accounting(struct fast_pool *f)
return;
f->event_entropy_shift = min_irq_event_entropy_shift();
- health_test_reset(&f->health);
+ health_test_reset(&f->health, f->event_entropy_shift);
}
void add_interrupt_randomness(int irq, int irq_flags)