Skip to content

Commit 4b69ff8

Browse files
committed
[ot] hw/opentitan: ot_entropy_src: ignore generation identifier
The documented rules 1. ENTROPY_SRC may only be disabled if CSRNG is disabled. 3. Once disabled, CSRNG may only be re-enabled after ENTROPY_SRC has been disabled and re-enabled. no longer apply: remove the related checks. Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
1 parent cba42e2 commit 4b69ff8

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

hw/opentitan/ot_entropy_src.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ struct OtEntropySrcState {
396396
OtFifo32 final_fifo; /* output FIFO */
397397
hash_state sha3_state; /* libtomcrypt hash state */
398398
OtEntropySrcFsmState state;
399-
unsigned gennum;
400399
unsigned cond_word; /* count of words processed with SHA3 till hash */
401400
unsigned noise_count; /* count of consumed noise words since enabled */
402401
unsigned packet_count; /* count of output packets since enabled */
@@ -478,33 +477,21 @@ static int ot_entropy_src_get_generation(OtRandomSrcIf *dev)
478477
{
479478
OtEntropySrcState *s = OT_ENTROPY_SRC(dev);
480479

481-
return ot_entropy_src_is_module_enabled(s) ? (int)s->gennum : 0;
480+
return ot_entropy_src_is_module_enabled(s) ? -1 : 0;
482481
}
483482

484483
static int ot_entropy_src_get_random(OtRandomSrcIf *dev, int genid,
485484
uint64_t random[OT_RANDOM_SRC_DWORD_COUNT],
486485
bool *fips)
487486
{
488487
OtEntropySrcState *s = OT_ENTROPY_SRC(dev);
488+
(void)genid; /* accept any generation identifier */
489489

490490
if (!ot_entropy_src_is_module_enabled(s)) {
491491
qemu_log_mask(LOG_GUEST_ERROR, "%s: entropy_src is down\n", __func__);
492492
return -2;
493493
}
494494

495-
if (genid != (int)s->gennum) {
496-
qemu_log_mask(LOG_GUEST_ERROR,
497-
"%s: entropy_src gennum mismatch req:%d cur:%u\n",
498-
__func__, genid, s->gennum);
499-
/*
500-
* Continue anyway as it seems HW does not enforce what is documented.
501-
* Force the generation id so the warning message is only shown once.
502-
*/
503-
if (genid != 0) {
504-
s->gennum = (unsigned)genid;
505-
}
506-
}
507-
508495
bool fips_compliant;
509496

510497
switch (s->state) {
@@ -1354,8 +1341,6 @@ static void ot_entropy_src_regs_write(void *opaque, hwaddr addr, uint64_t val64,
13541341
break;
13551342
}
13561343
if ((old ^ s->regs[reg]) && ot_entropy_src_is_module_enabled(s)) {
1357-
s->gennum += 1;
1358-
trace_ot_entropy_src_update_generation(s->gennum);
13591344
if (ot_entropy_src_is_fips_enabled(s)) {
13601345
/* start up phase */
13611346
ot_entropy_src_change_state(s,
@@ -1364,7 +1349,6 @@ static void ot_entropy_src_regs_write(void *opaque, hwaddr addr, uint64_t val64,
13641349
/* boot phase */
13651350
ot_entropy_src_change_state(s, ENTROPY_SRC_BOOT_HT_RUNNING);
13661351
}
1367-
trace_ot_entropy_src_info("initial schedule");
13681352
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
13691353
timer_mod(s->scheduler,
13701354
(int64_t)(now +
@@ -1616,7 +1600,7 @@ static void ot_entropy_src_reset(DeviceState *dev)
16161600
ot_fifo32_reset(&s->observe_fifo);
16171601
ot_fifo32_reset(&s->swread_fifo);
16181602
ot_fifo32_reset(&s->final_fifo);
1619-
/* note: s->gennum should not be updated on reset */
1603+
16201604
s->cond_word = 0u;
16211605
s->noise_count = 0u;
16221606
s->packet_count = 0u;

hw/opentitan/trace-events

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ ot_entropy_src_push_bypass_entropy(unsigned slot) "final FIFO depth: %u"
180180
ot_entropy_src_reset(void) ""
181181
ot_entropy_src_show_buffer(const char *func, int line, const char *msg, const char *hexstr) "%s:%u %s: %s"
182182
ot_entropy_src_update_filler(bool iok, bool ook, bool pok, bool all) "in %u, out %u, proc %u -> %u"
183-
ot_entropy_src_update_generation(unsigned gennum) "%u"
184183

185184
# ot_flash.c
186185

0 commit comments

Comments
 (0)