From b439c6e9b1029531199594ff545ef2ac0e6b154b Mon Sep 17 00:00:00 2001 From: Alex Jones Date: Tue, 10 Dec 2024 11:54:13 +0000 Subject: [PATCH] [ot] hw/opentitan: Small HMAC updates Reports `IDLE` in the status register if no command is currently being processed (i.e. no START/CONTINUE/PROCESS/STOP in progress). Allows the new KEY_SWAP, DIGEST_SIZE and KEY_LENGTH fields of the config registers to be written to by stopping them from being masked out. Signed-off-by: Alex Jones --- hw/opentitan/ot_hmac.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/opentitan/ot_hmac.c b/hw/opentitan/ot_hmac.c index 65f07aa81826f..0008a36dff310 100644 --- a/hw/opentitan/ot_hmac.c +++ b/hw/opentitan/ot_hmac.c @@ -486,6 +486,9 @@ static uint64_t ot_hmac_regs_read(void *opaque, hwaddr addr, unsigned size) val32 |= R_STATUS_FIFO_FULL_MASK; } } + if (!(s->regs->cmd)) { + val32 |= R_STATUS_HMAC_IDLE_MASK; + } } break; case R_ERR_CODE: val32 = s->regs->err_code; @@ -610,8 +613,10 @@ static void ot_hmac_regs_write(void *opaque, hwaddr addr, uint64_t value, } s->regs->cfg = - val32 & (R_CFG_HMAC_EN_MASK | R_CFG_SHA_EN_MASK | - R_CFG_ENDIAN_SWAP_MASK | R_CFG_DIGEST_SWAP_MASK); + val32 & + (R_CFG_HMAC_EN_MASK | R_CFG_SHA_EN_MASK | R_CFG_ENDIAN_SWAP_MASK | + R_CFG_DIGEST_SWAP_MASK | R_CFG_KEY_SWAP_MASK | + R_CFG_DIGEST_SIZE_MASK | R_CFG_KEY_LENGTH_MASK); /* clear digest when SHA is disabled */ if (!(s->regs->cfg & R_CFG_SHA_EN_MASK)) {