From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B630F606A322 for ; Thu, 3 Dec 2026 21:06:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=HewLSLV2 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZE0k-00083m-HJ; Thu, 03 Dec 2026 16:06:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZE0h-00083U-46 for qemu-devel@nongnu.org; Thu, 03 Dec 2026 16:06:35 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xZE0e-0003T9-Th for qemu-devel@nongnu.org; Thu, 03 Dec 2026 16:06:34 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4bb6860f867so2785e9.1 for ; Thu, 03 Dec 2026 13:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796331990; x=1796936790; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=EMYpk9DTYsIz6Ry+HjYPqQ9Ih9g9v3sDW/uCnMMpIHo=; b=HewLSLV27SdJy/u0B6hrqy5Nax09D8r2ukyVm4ki3OqW1DOS9Ker3Nz5mC2mg+BnTr I2QX8iSS6rmnwB7D+kuPkU1Twq0JyeIAfX8RQWF/1zk8imjHNblbJKYnZ8Wf/rlnxN9Z xVebHQAtKZ6loyOcVF9Z1cvjLLuj0LA4ffh0EQxoDzWpj1hxAsJIY7AhgmMFylRXVuu7 5b/Lmob3SGtfhrtrcXD4W3yndHPinacATyRmrc2aKN/8Wz74pKyZpqHw4IIBHB4NT/I4 9eWxIPZykYeA47eLxeuS/QBwNuU4ZMs0nydbCkdOsYw4UNF00PUswNUdMuvlUu66ErNt aV8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796331990; x=1796936790; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EMYpk9DTYsIz6Ry+HjYPqQ9Ih9g9v3sDW/uCnMMpIHo=; b=PgWgc/MSdWUmu42kofRuOsu91jIBE8UkYCTZkjFga934Rp10NnibOP3kMUl+37Qd39 uDF2HDJvG5+HFdqAlbLQOnrWF2Q40gG0o/aXdM95DFPetea2oWZ4b71bYVv3imLKgtMQ cdjTHjsRF8fKA87tbx53eyNpZav95XfD2lJvvxO0pkLga5QFqEFYlhtfRB87QHpllzdz 1YHsOCuUVtbTaknHjhoMtWMn2U2zg/metUeQRo2IrDsG3K67vNPxJ7ww2WubSoyvVcsb T4rbY6quT3D1PJ2q36A3Fws7u4Bj8WKjPz2j02qeP0/XSOSvfQIc2yMDWhLe1j362UfS 4CKw== X-Forwarded-Encrypted: i=1; AL+hErHtXTrh+4zGhEN1lpUve0NULiUhAWjgjPcYASCGsGKjABcrtSYn8TwwbjgaMkpsBBkmHihF8ed0K42z@nongnu.org X-Gm-Message-State: APuU4Z/K7IMGaXdf+khRmndgmWT6n1Z7BHhE5GlhIO9pR0vu7SwDMUix e0HxLCTN27xTCNZ6Ud8D6RG7OUjJnCCGw+pl0tirI+OxuH7HZ8F8J5btbNH+BwcIEQ== X-Gm-Gg: AZFdTZdzFKsSIsZtF2Zk9jybBibjnEt6qbHPHkXp/BEMi6X19tRRdOq34Z3cTQh3k6m GqRFMKSEqXhDB5DEPRef++RKCx4KzEyLd0PE13qCs3BL9rKqiXvWanyzpYu+a1iCgixr8Z1meXb CxvT/PKLBF1b1+b0cBjNSOoSAwQQoOVwprjrPCSpPkacYNLAgjWmQyIPuNDoA627CA8rMC5oaA5 JVxuPShRC0UCT3xaHg3V8X8DvYPSuHXA4XOKbA+pAN06ggzmeQ1cRTBfePEUt6z4a12IM1gLT6u +d7A4exZ2o5J92oZPgeYI4GVhFCRO3rYzjwNlk+khP5/BjPhW4STiX4uG7CDXVUTUIpz3/0/5XB dI8hare/XBZXAG7Gc7GLBH9bpY0mPNsOHWXAd2OeqSIYzgM/nvts91MDtcJSc4Zi4XTMs0zdolq I6wn3TiX7gRzbuKj9fmGVmec2UtJtV08LQNDDgTL1Apm7SuEGxlKE4oP28DKyl5v/y6DnIMRN2E naR1BsMKtOnqz+OD9o4KF9VBAqU+v1+B+AtEnUbmttJ8kYzoxMzU/zXXn8RRpWAt227lHrEk8uv ObIsveLY6CHdB1CoGkb3v/oireeT+sJMZASX0/xnUMjSoVR+sjE8kzsYRPEUDxG4BM0pGw== X-Received: by 2002:a05:600d:6011:b0:4bb:eaf0:6e19 with SMTP id 5b1f17b1804b1-4bbeaf072c4mr4275e9.27.1796331989072; Thu, 03 Dec 2026 13:06:29 -0800 (PST) Received: from google.com (160.193.189.35.bc.googleusercontent.com. [35.189.193.160]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17426825csm1332894f8f.46.2026.12.03.13.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 13:06:27 -0800 (PST) Date: Thu, 3 Dec 2026 21:06:24 +0000 From: Mostafa Saleh To: Tao Tang Cc: Peter Maydell , Leif Lindholm , Eric Auger , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Pierrick Bouvier , Chao Liu , Chen Baozi , Jim MacArthur Subject: Re: [PATCH v6 27/35] hw/arm/smmuv3: Route IRQ and GERROR handling by SEC_SID Message-ID: References: <20261114154623.3599750-1-tangtao1634@phytium.com.cn> <20261114160501.3626474-1-tangtao1634@phytium.com.cn> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261114160501.3626474-1-tangtao1634@phytium.com.cn> Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=smostafa@google.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -144 X-Spam_score: -14.5 X-Spam_bar: -------------- X-Spam_report: (-14.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, FSL_HELO_FAKE=3.099, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Sun, Nov 15, 2026 at 12:05:01AM +0800, Tao Tang wrote: > Interrupt and global error handling currently always selects the > Non-secure register bank, even when the event or command originates > from the Secure programming interface. This splits CMDQ_CONS.ERR from > GERROR.CMDQ_ERR and prevents Secure software from acknowledging the > error through S_GERRORN. > > Pass SEC_SID through the IRQ and GERROR helpers and all queue call > sites so interrupt enable checks, global error reporting, and > acknowledgement use the originating programming-interface bank. > > Add separate wired interrupt outputs for Secure EventQ, CMD_SYNC > and GERROR. Select the output by SEC_SID, register the new outputs > and wire them to the GIC on virt and sbsa-ref. Adjust the CMDQV ACPI > interrupt index to account for the additional SMMU outputs. > > Signed-off-by: Tao Tang > Reviewed-by: Pierrick Bouvier > Reviewed-by: Eric Auger > --- > include/hw/arm/smmuv3.h | 11 ++++++++++- > include/hw/arm/virt.h | 1 + > hw/arm/sbsa-ref.c | 8 ++++++++ > hw/arm/smmuv3.c | 41 ++++++++++++++++++++++++++++------------ > hw/arm/virt-acpi-build.c | 3 ++- > hw/arm/virt.c | 7 +++++++ > 6 files changed, 57 insertions(+), 14 deletions(-) > > diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h > index 8cd2edc3412..cb05cb19e32 100644 > --- a/include/hw/arm/smmuv3.h > +++ b/include/hw/arm/smmuv3.h > @@ -57,6 +57,14 @@ typedef struct SMMUv3RegBank { > SMMUQueue eventq, cmdq; > } SMMUv3RegBank; > > +enum { > + SMMU_IRQ_NUM_NS = 4, > + SMMU_IRQ_S_EVTQ = SMMU_IRQ_NUM_NS, > + SMMU_IRQ_S_CMD_SYNC, > + SMMU_IRQ_S_GERROR, > + SMMU_IRQ_NUM, > +}; Why not extend enum SMMUIrq instead of adding a new one? Thanks, Mostafa > + > struct SMMUv3State { > SMMUState smmu_state; > > @@ -67,7 +75,7 @@ struct SMMUv3State { > > SMMUv3RegBank bank[SMMU_SEC_SID_NUM]; > > - qemu_irq irq[4]; > + qemu_irq irq[SMMU_IRQ_NUM]; > QemuMutex mutex; > char *stage; > uint8_t identifier; > @@ -104,6 +112,7 @@ struct SMMUv3Class { > }; > > bool smmuv3_ats_enabled(struct SMMUv3State *s); > +int smmuv3_get_num_irqs(struct SMMUv3State *s); > > #define TYPE_ARM_SMMUV3 "arm-smmuv3" > OBJECT_DECLARE_TYPE(SMMUv3State, SMMUv3Class, ARM_SMMUV3) > diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h > index 22e66d1a113..e1ec8fe53d4 100644 > --- a/include/hw/arm/virt.h > +++ b/include/hw/arm/virt.h > @@ -79,6 +79,7 @@ enum { > VIRT_GICV5_ITS_TR_EL3, > VIRT_GICV5_ITS_TR_REALM, > VIRT_SMMU, > + VIRT_SMMU_SECURE, > VIRT_UART0, > VIRT_MMIO, > VIRT_RTC, > diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c > index 158b461eb48..ad6d0171723 100644 > --- a/hw/arm/sbsa-ref.c > +++ b/hw/arm/sbsa-ref.c > @@ -82,6 +82,7 @@ enum { > SBSA_GWDT_REFRESH, > SBSA_GWDT_CONTROL, > SBSA_SMMU, > + SBSA_SMMU_SECURE, > SBSA_UART, > SBSA_RTC, > SBSA_PCIE, > @@ -155,6 +156,7 @@ static const int sbsa_ref_irqmap[] = { > [SBSA_XHCI] = 11, > [SBSA_SMMU] = 12, /* ... to 15 */ > [SBSA_GWDT_WS0] = 16, > + [SBSA_SMMU_SECURE] = 17, > }; > > static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) > @@ -618,6 +620,7 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus, > { > hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base; > int irq = sbsa_ref_irqmap[SBSA_SMMU]; > + int secure_irq = sbsa_ref_irqmap[SBSA_SMMU_SECURE]; > DeviceState *dev; > int i; > > @@ -636,6 +639,11 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus, > sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, > qdev_get_gpio_in(sms->gic, irq + i)); > } > + for (i = SMMU_IRQ_NUM_NS; i < smmuv3_get_num_irqs(ARM_SMMUV3(dev)); i++) { > + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, > + qdev_get_gpio_in(sms->gic, > + secure_irq + i - SMMU_IRQ_NUM_NS)); > + } > } > > static void create_pcie(SBSAMachineState *sms, > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > index 54647964c21..97a8663349e 100644 > --- a/hw/arm/smmuv3.c > +++ b/hw/arm/smmuv3.c > @@ -49,23 +49,30 @@ > * > * @irq: irq type > * @gerror_mask: mask of gerrors to toggle (relevant if @irq is GERROR) > + * @sec_sid: security state of the programming interface > */ > static void smmuv3_trigger_irq(SMMUv3State *s, SMMUIrq irq, > - uint32_t gerror_mask) > + uint32_t gerror_mask, SMMUSecSID sec_sid) > { > - SMMUSecSID sec_sid = SMMU_SEC_SID_NS; > SMMUv3RegBank *bank = smmuv3_bank(s, sec_sid); > + int irq_index = irq; > > bool pulse = false; > > switch (irq) { > case SMMU_IRQ_EVTQ: > + if (sec_sid == SMMU_SEC_SID_S) { > + irq_index = SMMU_IRQ_S_EVTQ; > + } Instead of these repeated checks, I wonder if we can do better, as having one bit in index for the secure interrupt that can be or-ed with the NS one or add an S_IRQ offset. > pulse = smmuv3_eventq_irq_enabled(s, sec_sid); > break; > case SMMU_IRQ_PRIQ: > qemu_log_mask(LOG_UNIMP, "PRI not yet supported\n"); > break; > case SMMU_IRQ_CMD_SYNC: > + if (sec_sid == SMMU_SEC_SID_S) { > + irq_index = SMMU_IRQ_S_CMD_SYNC; > + } > pulse = true; > break; > case SMMU_IRQ_GERROR: > @@ -73,6 +80,9 @@ static void smmuv3_trigger_irq(SMMUv3State *s, SMMUIrq irq, > uint32_t pending = bank->gerror ^ bank->gerrorn; > uint32_t new_gerrors = ~pending & gerror_mask; > > + if (sec_sid == SMMU_SEC_SID_S) { > + irq_index = SMMU_IRQ_S_GERROR; > + } > if (!new_gerrors) { > /* only toggle non pending errors */ > return; > @@ -85,14 +95,14 @@ static void smmuv3_trigger_irq(SMMUv3State *s, SMMUIrq irq, > } > } > if (pulse) { > - trace_smmuv3_trigger_irq(irq); > - qemu_irq_pulse(s->irq[irq]); > + trace_smmuv3_trigger_irq(irq_index); > + qemu_irq_pulse(s->irq[irq_index]); > } > } > > -static void smmuv3_write_gerrorn(SMMUv3State *s, uint32_t new_gerrorn) > +static void smmuv3_write_gerrorn(SMMUv3State *s, uint32_t new_gerrorn, > + SMMUSecSID sec_sid) > { > - SMMUSecSID sec_sid = SMMU_SEC_SID_NS; > SMMUv3RegBank *bank = smmuv3_bank(s, sec_sid); > uint32_t pending = bank->gerror ^ bank->gerrorn; > uint32_t toggled = bank->gerrorn ^ new_gerrorn; > @@ -173,7 +183,7 @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s, SMMUSecSID sec_sid, > } > > if (!smmuv3_q_empty(q)) { > - smmuv3_trigger_irq(s, SMMU_IRQ_EVTQ, 0); > + smmuv3_trigger_irq(s, SMMU_IRQ_EVTQ, 0, sec_sid); > } > return MEMTX_OK; > } > @@ -187,7 +197,8 @@ void smmuv3_propagate_event(SMMUv3State *s, Evt *evt, SMMUSecSID sec_sid) > QEMU_LOCK_GUARD(&s->mutex); > 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); > + smmuv3_trigger_irq(s, SMMU_IRQ_GERROR, > + R_GERROR_EVENTQ_ABT_ERR_MASK, sec_sid); > } > } > > @@ -1483,7 +1494,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s, Error **errp, SMMUSecSID sec_sid) > switch (type) { > case SMMU_CMD_SYNC: > if (CMD_SYNC_CS(&cmd) & CMD_SYNC_SIG_IRQ) { > - smmuv3_trigger_irq(s, SMMU_IRQ_CMD_SYNC, 0); > + smmuv3_trigger_irq(s, SMMU_IRQ_CMD_SYNC, 0, sec_sid); > } > break; > case SMMU_CMD_PREFETCH_CONFIG: > @@ -1733,7 +1744,8 @@ static int smmuv3_cmdq_consume(SMMUv3State *s, Error **errp, SMMUSecSID sec_sid) > if (cmd_error) { > trace_smmuv3_cmdq_consume_error(smmu_cmd_string(type), cmd_error); > smmu_write_cmdq_err(s, cmd_error, sec_sid); > - smmuv3_trigger_irq(s, SMMU_IRQ_GERROR, R_GERROR_CMDQ_ERR_MASK); > + smmuv3_trigger_irq(s, SMMU_IRQ_GERROR, > + R_GERROR_CMDQ_ERR_MASK, sec_sid); > } > > trace_smmuv3_cmdq_consume_out(Q_PROD(q), Q_CONS(q), > @@ -1849,7 +1861,7 @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset, > bank->irq_ctrl = data; > break; > case A_GERRORN: > - smmuv3_write_gerrorn(s, data); > + smmuv3_write_gerrorn(s, data, reg_sec_sid); > /* > * By acknowledging the CMDQ_ERR, SW may notify cmds can > * be processed again > @@ -2239,11 +2251,16 @@ static const MemoryRegionOps smmu_mem_ops = { > }, > }; > > +int smmuv3_get_num_irqs(SMMUv3State *s) > +{ > + return SMMU_IRQ_NUM; > +} > + > static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(s->irq); i++) { > + for (i = 0; i < smmuv3_get_num_irqs(s); i++) { > sysbus_init_irq(dev, &s->irq[i]); > } > } > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index d368913e766..43529b73e4a 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -1169,7 +1169,8 @@ static void acpi_dsdt_add_tegra241_cmdqv(Aml *scope, VirtMachineState *vms) > sbdev = SYS_BUS_DEVICE(obj); > base = platform_bus_get_mmio_addr(pbus, sbdev, 1); > base += vms->memmap[VIRT_PLATFORM_BUS].base; > - irq = platform_bus_get_irqn(pbus, sbdev, NUM_SMMU_IRQS); > + irq = platform_bus_get_irqn(pbus, sbdev, > + smmuv3_get_num_irqs(ARM_SMMUV3(obj))); > irq += vms->irqmap[VIRT_PLATFORM_BUS]; > irq += ARM_SPI_BASE; > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 0b11f7e328c..d1e12ae1b54 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -267,6 +267,7 @@ static const int a15irqmap[] = { > [VIRT_UART1] = 8, > [VIRT_ACPI_GED] = 9, > [VIRT_GWDT_WS0] = 10, > + [VIRT_SMMU_SECURE] = 11, > [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ > [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ > [VIRT_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ > @@ -2069,6 +2070,7 @@ static void create_smmu(const VirtMachineState *vms, PCIBus *bus) > { > VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); > int irq = vms->irqmap[VIRT_SMMU]; > + int secure_irq = vms->irqmap[VIRT_SMMU_SECURE]; > int i; > hwaddr base = vms->memmap[VIRT_SMMU].base; > hwaddr size = vms->memmap[VIRT_SMMU].size; > @@ -2095,6 +2097,11 @@ static void create_smmu(const VirtMachineState *vms, PCIBus *bus) > sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, > qdev_get_gpio_in(vms->gic, irq + i)); > } > + for (i = SMMU_IRQ_NUM_NS; i < smmuv3_get_num_irqs(ARM_SMMUV3(dev)); i++) { > + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, > + qdev_get_gpio_in(vms->gic, > + secure_irq + i - SMMU_IRQ_NUM_NS)); > + } > create_smmuv3_dt_bindings(vms, base, size, irq); > } > > -- > 2.34.1 >