From: Mostafa Saleh <smostafa@google.com>
To: Tao Tang <tangtao1634@phytium.com.cn>
Cc: "Eric Auger" <eric.auger@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
"Chen Baozi" <chenbaozi@phytium.com.cn>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Chao Liu" <chao.liu@processmission.com>,
"Jim MacArthur" <jim.macarthur@linaro.org>
Subject: Re: [RFC v5 04/28] hw/arm/smmuv3: Track SEC_SID in configs and events
Date: Tue, 1 Sep 2026 13:49:31 +0000 [thread overview]
Message-ID: <apbX6_O6T6zKvY22@google.com> (raw)
In-Reply-To: <20260813162410.2805113-4-tangtao1634@phytium.com.cn>
On Fri, Aug 14, 2026 at 12:24:09AM +0800, Tao Tang wrote:
> Pass the SEC_SID explicitly to smmuv3_decode_config() so configuration
> decoding can be tied to the correct register bank.
>
> Plumb the SEC_SID through tracepoints and queue helpers so diagnostics
> and event logs always show which security interface emitted the record.
> To support this, the SEC_SID is placed in SMMUEventInfo so the bank is
> identified as soon as an event record is built.
>
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> Reviewed-by: Eric Auger <eric.auger@redhat.com>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mostafa Saleh <smostafa@google.com>
Thanks,
Mostafa
> ---
> hw/arm/smmuv3-accel.c | 2 +-
> hw/arm/smmuv3-internal.h | 3 ++-
> hw/arm/smmuv3.c | 26 +++++++++++++++-----------
> hw/arm/trace-events | 2 +-
> include/hw/arm/smmuv3.h | 1 +
> 5 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c
> index fa079c8acea..2ce94786829 100644
> --- a/hw/arm/smmuv3-accel.c
> +++ b/hw/arm/smmuv3-accel.c
> @@ -509,7 +509,7 @@ static void smmuv3_accel_event_read(void *opaque)
> if (ret > 0) {
> return; /* EAGAIN/EINTR */
> }
> - smmuv3_propagate_event(s, (Evt *)&buf.vevent);
> + smmuv3_propagate_event(s, (Evt *)&buf.vevent, SMMU_SEC_SID_NS);
> }
>
> static void smmuv3_accel_free_veventq(SMMUv3AccelState *accel)
> diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
> index a88743ba9cd..202cd533636 100644
> --- a/hw/arm/smmuv3-internal.h
> +++ b/hw/arm/smmuv3-internal.h
> @@ -274,6 +274,7 @@ static inline const char *smmu_event_string(SMMUEventType type)
>
> /* Encode an event record */
> typedef struct SMMUEventInfo {
> + SMMUSecSID sec_sid;
> SMMUEventType type;
> uint32_t sid;
> bool recorded;
> @@ -365,7 +366,7 @@ typedef struct SMMUEventInfo {
> #define EVT_GET_SID(x) ((x)->word[1])
>
> void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *event);
> -void smmuv3_propagate_event(SMMUv3State *s, Evt *evt);
> +void smmuv3_propagate_event(SMMUv3State *s, Evt *evt, SMMUSecSID sec_sid);
> int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo *event);
>
> #define STE_SIZE 6
> diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
> index 51e970d710a..649050b9347 100644
> --- a/hw/arm/smmuv3.c
> +++ b/hw/arm/smmuv3.c
> @@ -149,9 +149,9 @@ static MemTxResult queue_write(SMMUQueue *q, Evt *evt_in)
> return MEMTX_OK;
> }
>
> -static MemTxResult smmuv3_write_eventq(SMMUv3State *s, Evt *evt)
> +static MemTxResult smmuv3_write_eventq(SMMUv3State *s, SMMUSecSID sec_sid,
> + Evt *evt)
> {
> - SMMUSecSID sec_sid = SMMU_SEC_SID_NS;
> SMMUv3RegBank *bank = smmuv3_bank(s, sec_sid);
> SMMUQueue *q = &bank->eventq;
> MemTxResult r;
> @@ -175,14 +175,14 @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s, Evt *evt)
> return MEMTX_OK;
> }
>
> -void smmuv3_propagate_event(SMMUv3State *s, Evt *evt)
> +void smmuv3_propagate_event(SMMUv3State *s, Evt *evt, SMMUSecSID sec_sid)
> {
> MemTxResult r;
>
> - trace_smmuv3_propagate_event(smmu_event_string(EVT_GET_TYPE(evt)),
> + trace_smmuv3_propagate_event(sec_sid, smmu_event_string(EVT_GET_TYPE(evt)),
> EVT_GET_SID(evt));
> QEMU_LOCK_GUARD(&s->mutex);
> - r = smmuv3_write_eventq(s, evt);
> + r = smmuv3_write_eventq(s, sec_sid, evt);
> if (r != MEMTX_OK) {
> smmuv3_trigger_irq(s, SMMU_IRQ_GERROR, R_GERROR_EVENTQ_ABT_ERR_MASK);
> }
> @@ -191,7 +191,7 @@ void smmuv3_propagate_event(SMMUv3State *s, Evt *evt)
> void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info)
> {
> Evt evt = {};
> - SMMUSecSID sec_sid = SMMU_SEC_SID_NS;
> + SMMUSecSID sec_sid = info->sec_sid;
>
> if (!smmuv3_eventq_enabled(s, sec_sid)) {
> return;
> @@ -271,7 +271,7 @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info)
> g_assert_not_reached();
> }
>
> - smmuv3_propagate_event(s, &evt);
> + smmuv3_propagate_event(s, &evt, sec_sid);
> info->recorded = true;
> }
>
> @@ -886,12 +886,13 @@ bad_cd:
> * @cfg: output translation configuration which is populated through
> * the different configuration decoding steps
> * @event: must be zero'ed by the caller
> + * @sec_sid: StreamID Security state
> *
> * return < 0 in case of config decoding error (@event is filled
> * accordingly). Return 0 otherwise.
> */
> static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg,
> - SMMUEventInfo *event)
> + SMMUEventInfo *event, SMMUSecSID sec_sid)
> {
> SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
> uint32_t sid = smmu_get_sid(sdev);
> @@ -958,7 +959,7 @@ static SMMUTransCfg *smmuv3_get_config(SMMUDevice *sdev, SMMUEventInfo *event)
> (sdev->cfg_cache_hits + sdev->cfg_cache_misses));
> cfg = g_new0(SMMUTransCfg, 1);
>
> - if (!smmuv3_decode_config(&sdev->iommu, cfg, event)) {
> + if (!smmuv3_decode_config(&sdev->iommu, cfg, event, SMMU_SEC_SID_NS)) {
> g_hash_table_insert(bc->configs, sdev, cfg);
> } else {
> g_free(cfg);
> @@ -1114,7 +1115,8 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
> SMMUv3RegBank *bank = smmuv3_bank(s, sec_sid);
> SMMUEventInfo event = {.type = SMMU_EVT_NONE,
> .sid = sid,
> - .inval_ste_allowed = false};
> + .inval_ste_allowed = false,
> + .sec_sid = sec_sid};
> SMMUTranslationStatus status;
> SMMUTransCfg *cfg = NULL;
> IOMMUTLBEntry entry = {
> @@ -1216,7 +1218,9 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
> uint64_t num_pages, int stage)
> {
> SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
> - SMMUEventInfo eventinfo = {.inval_ste_allowed = true};
> + SMMUSecSID sec_sid = SMMU_SEC_SID_NS;
> + SMMUEventInfo eventinfo = {.sec_sid = sec_sid,
> + .inval_ste_allowed = true};
> SMMUTransCfg *cfg = smmuv3_get_config(sdev, &eventinfo);
> IOMMUTLBEvent event;
> uint8_t granule;
> diff --git a/hw/arm/trace-events b/hw/arm/trace-events
> index 1b16f710fed..a166b79c8ef 100644
> --- a/hw/arm/trace-events
> +++ b/hw/arm/trace-events
> @@ -41,7 +41,7 @@ smmuv3_cmdq_opcode(const char *opcode) "<--- %s"
> smmuv3_cmdq_consume_out(uint32_t prod, uint32_t cons, uint8_t prod_wrap, uint8_t cons_wrap) "prod:%d, cons:%d, prod_wrap:%d, cons_wrap:%d "
> smmuv3_cmdq_consume_error(const char *cmd_name, uint8_t cmd_error) "Error on %s command execution: %d"
> smmuv3_write_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)"
> -smmuv3_propagate_event(const char *type, uint32_t sid) "%s sid=0x%x"
> +smmuv3_propagate_event(int sec_sid, const char *type, uint32_t sid) "sec_sid=%d %s sid=0x%x"
> smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "sid=0x%x features:0x%x, sid_split:0x%x"
> smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d"
> smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64
> diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
> index 45033d26a1b..8cd2edc3412 100644
> --- a/include/hw/arm/smmuv3.h
> +++ b/include/hw/arm/smmuv3.h
> @@ -115,6 +115,7 @@ OBJECT_DECLARE_TYPE(SMMUv3State, SMMUv3Class, ARM_SMMUV3)
>
> static inline SMMUv3RegBank *smmuv3_bank(SMMUv3State *s, SMMUSecSID sec_sid)
> {
> + g_assert(sec_sid < SMMU_SEC_SID_NUM);
> return &s->bank[sec_sid];
> }
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-09-01 13:50 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 16:15 [RFC v5 00/28] hw/arm/smmuv3: Support Secure state for SMMUv3 Tao Tang
2026-08-13 16:21 ` [RFC v5 23/28] hw/pci: Add sec-sid property to PCIDevice Tao Tang
2026-08-25 12:20 ` Jim MacArthur
2026-08-31 6:03 ` Eric Auger
2026-08-13 16:24 ` [RFC v5 01/28] hw/arm/smmuv3: Introduce secure registers Tao Tang
2026-08-18 14:21 ` Jim MacArthur
2026-08-13 16:24 ` [RFC v5 02/28] hw/arm/smmuv3: Introduce banked registers for SMMUv3 state Tao Tang
2026-08-21 9:52 ` Jim MacArthur
2026-08-21 16:03 ` Tao Tang
2026-08-13 16:24 ` [RFC v5 03/28] hw/arm/smmuv3: Thread SEC_SID through helper APIs Tao Tang
2026-08-21 10:09 ` Jim MacArthur
2026-09-01 13:48 ` Mostafa Saleh
2026-08-13 16:24 ` [RFC v5 04/28] hw/arm/smmuv3: Track SEC_SID in configs and events Tao Tang
2026-08-21 12:35 ` Jim MacArthur
2026-09-01 13:49 ` Mostafa Saleh [this message]
2026-08-13 16:24 ` [RFC v5 05/28] hw/arm/smmu-common: Add security-aware address space selector Tao Tang
2026-08-20 22:17 ` Pierrick Bouvier
2026-08-27 8:20 ` Eric Auger
2026-09-01 13:50 ` Mostafa Saleh
2026-08-13 16:24 ` [RFC v5 06/28] hw/arm/smmuv3: Plumb transaction attributes into config helpers Tao Tang
2026-08-20 22:19 ` Pierrick Bouvier
2026-08-27 9:07 ` Eric Auger
2026-09-01 13:58 ` Mostafa Saleh
2026-08-13 16:24 ` [RFC v5 07/28] hw/arm/smmuv3: Reject secure STEs with stage-2 enabled Tao Tang
2026-08-20 22:19 ` Pierrick Bouvier
2026-08-27 12:09 ` Eric Auger
2026-09-01 14:01 ` Mostafa Saleh
2026-08-13 16:24 ` [RFC v5 08/28] hw/arm/smmu-common: Key configuration cache on SMMUDevice and SEC_SID Tao Tang
2026-08-21 15:01 ` Jim MacArthur
2026-09-01 14:06 ` Mostafa Saleh
2026-08-13 16:24 ` [RFC v5 09/28] hw/arm/smmu: Add PTE NS/NSTable helpers Tao Tang
2026-08-21 15:14 ` Jim MacArthur
2026-08-27 12:25 ` Eric Auger
2026-09-01 14:05 ` Mostafa Saleh
2026-08-13 16:24 ` [RFC v5 10/28] hw/arm/smmuv3: Store CD NSCFG in TT info Tao Tang
2026-08-21 15:16 ` Jim MacArthur
2026-09-01 14:07 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 11/28] hw/arm/smmu-common: Implement secure state handling in ptw Tao Tang
2026-08-20 22:26 ` Pierrick Bouvier
2026-08-27 15:13 ` Eric Auger
2026-09-01 14:09 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 12/28] hw/arm/smmuv3: Tag IOTLB cache keys with SEC_SID Tao Tang
2026-08-20 22:21 ` Pierrick Bouvier
2026-08-27 16:56 ` Eric Auger
2026-09-01 14:11 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 13/28] hw/arm/smmuv3: Pass sec_sid into cmdq consume path Tao Tang
2026-08-21 15:57 ` Jim MacArthur
2026-09-01 14:14 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 14/28] hw/arm/smmuv3: Make evtq producer use SEC_SID Tao Tang
2026-08-21 15:58 ` Jim MacArthur
2026-09-01 14:15 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 15/28] hw/arm/smmu: Make CMDQ invalidation security-state aware Tao Tang
2026-08-20 22:29 ` Pierrick Bouvier
2026-08-21 16:00 ` Tao Tang
2026-08-28 8:43 ` Eric Auger
2026-08-28 8:54 ` Eric Auger
2026-08-13 16:25 ` [RFC v5 16/28] hw/arm/smmuv3: Add access checks for GERROR_IRQ_CFG registers Tao Tang
2026-08-28 9:47 ` Eric Auger
2026-09-01 14:18 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 17/28] hw/arm/smmuv3: Add access checks for STRTAB_BASE and CR2 registers Tao Tang
2026-08-28 10:05 ` Eric Auger
2026-09-01 14:22 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 18/28] hw/arm/smmuv3: Add access checks for CMDQ and EVENTQ registers Tao Tang
2026-08-28 10:09 ` Eric Auger
2026-08-13 16:25 ` [RFC v5 19/28] hw/arm/smmuv3: Determine register bank from MMIO offset Tao Tang
2026-08-25 11:17 ` Jim MacArthur
2026-08-28 10:26 ` Eric Auger
2026-09-01 14:26 ` Mostafa Saleh
2026-08-13 16:25 ` [RFC v5 20/28] hw/arm/smmuv3: Route IRQ and GERROR handling by SEC_SID Tao Tang
2026-08-20 22:23 ` Pierrick Bouvier
2026-08-31 4:48 ` Eric Auger
2026-09-01 14:33 ` Mostafa Saleh
2026-08-13 16:26 ` [RFC v5 21/28] hw/arm/smmuv3: Implement SMMU_S_INIT register Tao Tang
2026-08-25 12:06 ` Jim MacArthur
2026-08-31 5:23 ` Eric Auger
2026-08-13 16:26 ` [RFC v5 22/28] hw/arm/smmuv3: Harden security checks in MMIO handlers Tao Tang
2026-08-25 12:18 ` Jim MacArthur
2026-08-31 5:56 ` Eric Auger
2026-08-13 16:26 ` [RFC v5 24/28] hw/arm/smmuv3: Select sec-sid from PCI property and validate SECURE_IMPL Tao Tang
2026-08-31 8:22 ` Eric Auger
2026-08-13 16:26 ` [RFC v5 25/28] hw/arm/smmuv3: Reject IOMMU notifiers for non-NS devices Tao Tang
2026-08-20 22:23 ` Pierrick Bouvier
2026-08-31 8:24 ` Eric Auger
2026-08-13 16:26 ` [RFC v5 26/28] hw/arm/smmuv3: Initialize the secure register bank Tao Tang
2026-08-25 13:39 ` Jim MacArthur
2026-08-31 8:37 ` Eric Auger
2026-08-13 16:26 ` [RFC v5 27/28] hw/arm/smmuv3: Add secure bank migration and secure-impl property Tao Tang
2026-08-25 13:50 ` Jim MacArthur
2026-08-31 8:51 ` Eric Auger
2026-08-13 16:26 ` [RFC v5 28/28] [NOT-MERGE] hw/arm/smmuv3: temporarily enable SEL2 bit and some other features Tao Tang
2026-08-31 8:54 ` Eric Auger
2026-08-20 22:16 ` [RFC v5 00/28] hw/arm/smmuv3: Support Secure state for SMMUv3 Pierrick Bouvier
2026-08-21 16:15 ` Tao Tang
2026-09-01 14:47 ` Mostafa Saleh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=apbX6_O6T6zKvY22@google.com \
--to=smostafa@google.com \
--cc=chao.liu@processmission.com \
--cc=chenbaozi@phytium.com.cn \
--cc=eric.auger@redhat.com \
--cc=jim.macarthur@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=tangtao1634@phytium.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.