diff --git a/hw/opentitan/ot_kmac.c b/hw/opentitan/ot_kmac.c index 817a03938a14..013dcc1f49bb 100644 --- a/hw/opentitan/ot_kmac.c +++ b/hw/opentitan/ot_kmac.c @@ -75,12 +75,12 @@ REG32(CFG_SHADOWED, 0x14u) FIELD(CFG_SHADOWED, ENTROPY_FAST_PROCESS, 19u, 1u) FIELD(CFG_SHADOWED, MSG_MASK, 20u, 1u) FIELD(CFG_SHADOWED, ENTROPY_READY, 24u, 1u) - FIELD(CFG_SHADOWED, ERR_PROCESSED, 25u, 1u) FIELD(CFG_SHADOWED, EN_UNSUPPORTED_MODESTRENGTH, 26u, 1u) REG32(CMD, 0x18u) FIELD(CMD, CMD, 0u, 6u) FIELD(CMD, ENTROPY_REQ, 8u, 1u) FIELD(CMD, HASH_CNT_CLR, 9u, 1u) + FIELD(CMD, ERR_PROCESSED, 10u, 1u) REG32(STATUS, 0x1cu) FIELD(STATUS, SHA3_IDLE, 0u, 1u) FIELD(STATUS, SHA3_ABSORB, 1u, 1u) @@ -97,57 +97,53 @@ REG32(ENTROPY_REFRESH_HASH_CNT, 0x24u) FIELD(ENTROPY_REFRESH_HASH_CNT, HASH_CNT, 0u, 10u) REG32(ENTROPY_REFRESH_THRESHOLD_SHADOWED, 0x28u) FIELD(ENTROPY_REFRESH_THRESHOLD_SHADOWED, THRESHOLD, 0u, 10u) -REG32(ENTROPY_SEED_0, 0x2cu) -REG32(ENTROPY_SEED_1, 0x30u) -REG32(ENTROPY_SEED_2, 0x34u) -REG32(ENTROPY_SEED_3, 0x38u) -REG32(ENTROPY_SEED_4, 0x3cu) -REG32(KEY_SHARE0_0, 0x40u) -REG32(KEY_SHARE0_1, 0x44u) -REG32(KEY_SHARE0_2, 0x48u) -REG32(KEY_SHARE0_3, 0x4cu) -REG32(KEY_SHARE0_4, 0x50u) -REG32(KEY_SHARE0_5, 0x54u) -REG32(KEY_SHARE0_6, 0x58u) -REG32(KEY_SHARE0_7, 0x5cu) -REG32(KEY_SHARE0_8, 0x60u) -REG32(KEY_SHARE0_9, 0x64u) -REG32(KEY_SHARE0_10, 0x68u) -REG32(KEY_SHARE0_11, 0x6cu) -REG32(KEY_SHARE0_12, 0x70u) -REG32(KEY_SHARE0_13, 0x74u) -REG32(KEY_SHARE0_14, 0x78u) -REG32(KEY_SHARE0_15, 0x7cu) -REG32(KEY_SHARE1_0, 0x80u) -REG32(KEY_SHARE1_1, 0x84u) -REG32(KEY_SHARE1_2, 0x88u) -REG32(KEY_SHARE1_3, 0x8cu) -REG32(KEY_SHARE1_4, 0x90u) -REG32(KEY_SHARE1_5, 0x94u) -REG32(KEY_SHARE1_6, 0x98u) -REG32(KEY_SHARE1_7, 0x9cu) -REG32(KEY_SHARE1_8, 0xa0u) -REG32(KEY_SHARE1_9, 0xa4u) -REG32(KEY_SHARE1_10, 0xa8u) -REG32(KEY_SHARE1_11, 0xacu) -REG32(KEY_SHARE1_12, 0xb0u) -REG32(KEY_SHARE1_13, 0xb4u) -REG32(KEY_SHARE1_14, 0xb8u) -REG32(KEY_SHARE1_15, 0xbcu) -REG32(KEY_LEN, 0xc0u) +REG32(ENTROPY_SEED, 0x2cu) +REG32(KEY_SHARE0_0, 0x30u) +REG32(KEY_SHARE0_1, 0x34u) +REG32(KEY_SHARE0_2, 0x38u) +REG32(KEY_SHARE0_3, 0x3cu) +REG32(KEY_SHARE0_4, 0x40u) +REG32(KEY_SHARE0_5, 0x44u) +REG32(KEY_SHARE0_6, 0x48u) +REG32(KEY_SHARE0_7, 0x4cu) +REG32(KEY_SHARE0_8, 0x50u) +REG32(KEY_SHARE0_9, 0x54u) +REG32(KEY_SHARE0_10, 0x58u) +REG32(KEY_SHARE0_11, 0x5cu) +REG32(KEY_SHARE0_12, 0x60u) +REG32(KEY_SHARE0_13, 0x64u) +REG32(KEY_SHARE0_14, 0x68u) +REG32(KEY_SHARE0_15, 0x6cu) +REG32(KEY_SHARE1_0, 0x70u) +REG32(KEY_SHARE1_1, 0x74u) +REG32(KEY_SHARE1_2, 0x78u) +REG32(KEY_SHARE1_3, 0x7cu) +REG32(KEY_SHARE1_4, 0x80u) +REG32(KEY_SHARE1_5, 0x84u) +REG32(KEY_SHARE1_6, 0x88u) +REG32(KEY_SHARE1_7, 0x8cu) +REG32(KEY_SHARE1_8, 0x90u) +REG32(KEY_SHARE1_9, 0x94u) +REG32(KEY_SHARE1_10, 0x98u) +REG32(KEY_SHARE1_11, 0x9cu) +REG32(KEY_SHARE1_12, 0xa0u) +REG32(KEY_SHARE1_13, 0xa4u) +REG32(KEY_SHARE1_14, 0xa8u) +REG32(KEY_SHARE1_15, 0xacu) +REG32(KEY_LEN, 0xb0u) FIELD(KEY_LEN, LEN, 0u, 3u) -REG32(PREFIX_0, 0xc4u) -REG32(PREFIX_1, 0xc8u) -REG32(PREFIX_2, 0xccu) -REG32(PREFIX_3, 0xd0u) -REG32(PREFIX_4, 0xd4u) -REG32(PREFIX_5, 0xd8u) -REG32(PREFIX_6, 0xdcu) -REG32(PREFIX_7, 0xe0u) -REG32(PREFIX_8, 0xe4u) -REG32(PREFIX_9, 0xe8u) -REG32(PREFIX_10, 0xecu) -REG32(ERR_CODE, 0xf0u) +REG32(PREFIX_0, 0xb4u) +REG32(PREFIX_1, 0xb8u) +REG32(PREFIX_2, 0xbcu) +REG32(PREFIX_3, 0xc0u) +REG32(PREFIX_4, 0xc4u) +REG32(PREFIX_5, 0xc8u) +REG32(PREFIX_6, 0xccu) +REG32(PREFIX_7, 0xd0u) +REG32(PREFIX_8, 0xd4u) +REG32(PREFIX_9, 0xd8u) +REG32(PREFIX_10, 0xdcu) +REG32(ERR_CODE, 0xe0u) FIELD(ERR_CODE, INFO, 0u, 24u) FIELD(ERR_CODE, CODE, 24u, 8u) /* clang-format on */ @@ -162,7 +158,7 @@ REG32(ERR_CODE, 0xf0u) R_CFG_SHADOWED_STATE_ENDIANNESS_MASK | R_CFG_SHADOWED_SIDELOAD_MASK | \ R_CFG_SHADOWED_ENTROPY_MODE_MASK | \ R_CFG_SHADOWED_ENTROPY_FAST_PROCESS_MASK | R_CFG_SHADOWED_MSG_MASK_MASK | \ - R_CFG_SHADOWED_ENTROPY_READY_MASK | R_CFG_SHADOWED_ERR_PROCESSED_MASK | \ + R_CFG_SHADOWED_ENTROPY_READY_MASK | \ R_CFG_SHADOWED_EN_UNSUPPORTED_MODESTRENGTH_MASK) enum { @@ -254,11 +250,7 @@ static const char *REG_NAMES[REGS_COUNT] = { REG_NAME_ENTRY(ENTROPY_PERIOD), REG_NAME_ENTRY(ENTROPY_REFRESH_HASH_CNT), REG_NAME_ENTRY(ENTROPY_REFRESH_THRESHOLD_SHADOWED), - REG_NAME_ENTRY(ENTROPY_SEED_0), - REG_NAME_ENTRY(ENTROPY_SEED_1), - REG_NAME_ENTRY(ENTROPY_SEED_2), - REG_NAME_ENTRY(ENTROPY_SEED_3), - REG_NAME_ENTRY(ENTROPY_SEED_4), + REG_NAME_ENTRY(ENTROPY_SEED), REG_NAME_ENTRY(KEY_SHARE0_0), REG_NAME_ENTRY(KEY_SHARE0_1), REG_NAME_ENTRY(KEY_SHARE0_2), @@ -1094,11 +1086,7 @@ static uint64_t ot_kmac_regs_read(void *opaque, hwaddr addr, unsigned size) break; case R_INTR_TEST: case R_ALERT_TEST: - case R_ENTROPY_SEED_0: - case R_ENTROPY_SEED_1: - case R_ENTROPY_SEED_2: - case R_ENTROPY_SEED_3: - case R_ENTROPY_SEED_4: + case R_ENTROPY_SEED: case R_KEY_SHARE0_0: case R_KEY_SHARE0_1: case R_KEY_SHARE0_2: @@ -1212,6 +1200,12 @@ static void ot_kmac_regs_write(void *opaque, hwaddr addr, uint64_t value, qemu_log_mask(LOG_UNIMP, "%s: CMD.HASH_CNT_CLR is not supported\n", __func__); } + + if (val32 & R_CMD_ERR_PROCESSED_MASK) { + /* TODO: implement entropy */ + s->regs[R_STATUS] &= ~R_STATUS_ALERT_RECOV_CTRL_UPDATE_ERR_MASK; + ot_kmac_update_alert(s); + } break; } case R_ENTROPY_PERIOD: @@ -1240,11 +1234,7 @@ static void ot_kmac_regs_write(void *opaque, hwaddr addr, uint64_t value, break; } break; - case R_ENTROPY_SEED_0: - case R_ENTROPY_SEED_1: - case R_ENTROPY_SEED_2: - case R_ENTROPY_SEED_3: - case R_ENTROPY_SEED_4: + case R_ENTROPY_SEED: /* TODO: implement entropy */ qemu_log_mask(LOG_UNIMP, "%s: R_ENTROPY_SEED_* is not supported\n", __func__);