On Fri, 13 Feb 2026 10:39:41 +0000 Shameer Kolothum <[email protected]> wrote:
> Factor out the code that propagates event records to the guest into a > helper function. The accelerated SMMUv3 path can use this to propagate > host events in a subsequent patch. > > Since this helper may be called from outside the SMMUv3 core, take the > mutex before accessing the Event Queue. Totally trivial but it might be worth stating that / why it is harmless (or indeed necessary?) to take the lock in existing paths. I was kind of expecting to see locked helper wrapping an unlocked version that was used to replace the original code. So guess I'm missing something. > > No functional change intended. > > Reviewed-by: Nicolin Chen <[email protected]> > Reviewed-by: Eric Auger <[email protected]> > Tested-by: Nicolin Chen <[email protected]> > Signed-off-by: Shameer Kolothum <[email protected]> > --- > hw/arm/smmuv3-internal.h | 4 ++++ > hw/arm/smmuv3.c | 21 +++++++++++++++------ > hw/arm/trace-events | 2 +- > 3 files changed, 20 insertions(+), 7 deletions(-) > > diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h > index a6464425ec..b666109ad9 100644 > --- a/hw/arm/smmuv3-internal.h > +++ b/hw/arm/smmuv3-internal.h > @@ -352,7 +352,11 @@ typedef struct SMMUEventInfo { > (x)->word[6] = (uint32_t)(addr & 0xffffffff); \ > } while (0) > > +#define EVT_GET_TYPE(x) extract32((x)->word[0], 0, 8) > +#define EVT_GET_SID(x) ((x)->word[1]) > + > void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *event); > +void smmuv3_propagate_event(SMMUv3State *s, Evt *evt); > int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo > *event); > > static inline int oas2bits(int oas_field) > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > index f804d3af25..bcb9176c51 100644 > --- a/hw/arm/smmuv3.c > +++ b/hw/arm/smmuv3.c > @@ -168,10 +168,23 @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s, > Evt *evt) > return MEMTX_OK; > } > > +void smmuv3_propagate_event(SMMUv3State *s, Evt *evt) > +{ > + MemTxResult r; > + > + trace_smmuv3_propagate_event(smmu_event_string(EVT_GET_TYPE(evt)), > + EVT_GET_SID(evt)); > + qemu_mutex_lock(&s->mutex); Could use QEMU_LOCK_GUARD(&s->mutex); though gain is minor so feel free to not do so. > + r = smmuv3_write_eventq(s, evt); > + if (r != MEMTX_OK) { > + smmuv3_trigger_irq(s, SMMU_IRQ_GERROR, R_GERROR_EVENTQ_ABT_ERR_MASK); > + } > + qemu_mutex_unlock(&s->mutex); > +}
