From 0bbe2752c7ab310ce13318fdcf016ecc0099e56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Audun=20Kvamtr=C3=B8?= Date: Wed, 23 Oct 2024 17:41:59 +0200 Subject: [PATCH] crypto: cracen: Ensure that register reads/writes are flushed for PK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Add memory barrier wmb() and rmb() around writes and reads for pk module (IKG) for cracen. Signed-off-by: Frank Audun Kvamtrø --- .../silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subsys/nrf_security/src/drivers/cracen/silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c b/subsys/nrf_security/src/drivers/cracen/silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c index 4d6475bfe28b..9f7d381bcfa0 100644 --- a/subsys/nrf_security/src/drivers/cracen/silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c +++ b/subsys/nrf_security/src/drivers/cracen/silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c @@ -8,6 +8,7 @@ #include +#include #include "../hw/ba414/regs_addr.h" #include #include "../hw/ba414/pkhardware_ba414e.h" @@ -111,7 +112,9 @@ void sx_pk_wrreg(struct sx_regs *regs, uint32_t addr, uint32_t v) printk("sx_pk_wrreg(addr=0x%x, sum=0x%x, val=0x%x);\r\n", addr, (uint32_t)p, v); #endif + wmb(); /* comment for compliance */ *p = v; + rmb(); /* comment for compliance */ } uint32_t sx_pk_rdreg(struct sx_regs *regs, uint32_t addr) @@ -119,7 +122,9 @@ uint32_t sx_pk_rdreg(struct sx_regs *regs, uint32_t addr) volatile uint32_t *p = (uint32_t *)(regs->base + addr); uint32_t v; + wmb(); /* comment for compliance */ v = *p; + rmb(); /* comment for compliance */ #ifdef INSTRUMENT_MMIO_WITH_PRINTFS printk("sx_pk_rdreg(addr=0x%x, sum=0x%x);\r\n", addr, (uint32_t)p);