All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim MacArthur <jim.macarthur@linaro.org>
To: Tao Tang <tangtao1634@phytium.com.cn>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Mostafa Saleh" <smostafa@google.com>,
	"Chao Liu" <chao.liu@processmission.com>,
	"Chen Baozi" <chenbaozi@phytium.com.cn>
Subject: Re: [PATCH v6 15/35] hw/arm/smmuv3: Limit IOMMU notifications to Non-secure targets
Date: Tue, 1 Dec 2026 10:46:20 +0000	[thread overview]
Message-ID: <aw6lfM6YDTm1B4DQ@linaro.org> (raw)
In-Reply-To: <20261114161753.3645568-6-tangtao1634@phytium.com.cn>

On Sun, Nov 15, 2026 at 12:17:49AM +0800, Tao Tang wrote:
> IOMMU notifiers are supported only for Non-secure devices. Add a wrapper
> for full invalidation notifications and filter range notifications by
> the target SEC_SID before walking the registered notifier list.
> 
> Keep the underlying common notifier helpers unchanged. Command handlers
> can then select whether to notify according to the invalidation target.
> 
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>  hw/arm/smmuv3.c | 27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
> index f7ca3859bc2..ce00461210b 100644
> --- a/hw/arm/smmuv3.c
> +++ b/hw/arm/smmuv3.c
> @@ -1307,10 +1307,16 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
>  /* invalidate an asid/vmid/iova range tuple in all mr's */
>  static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, int vmid,
>                                        dma_addr_t iova, uint8_t tg,
> -                                      uint64_t num_pages, int stage)
> +                                      uint64_t num_pages, int stage,
> +                                      SMMUSecSID sec_sid)
>  {
>      SMMUDevice *sdev;
>  
> +    /* IOMMU notifiers are supported only for Non-secure devices. */
> +    if (sec_sid != SMMU_SEC_SID_NS) {
> +        return;
> +    }
> +
>      QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
>          IOMMUMemoryRegion *mr = &sdev->iommu;
>          IOMMUNotifier *n;
> @@ -1324,6 +1330,14 @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, int vmid,
>      }
>  }
>  
> +static void smmuv3_inv_notifiers_all(SMMUState *s, SMMUSecSID sec_sid)
> +{
> +    /* IOMMU notifiers are supported only for Non-secure devices. */
> +    if (sec_sid == SMMU_SEC_SID_NS) {
> +        smmu_inv_notifiers_all(s);
> +    }
> +}
> +
>  static void smmuv3_range_inval(SMMUState *s, Cmd *cmd, SMMUStage stage,
>                                 SMMUSecSID sec_sid)
>  {
> @@ -1352,7 +1366,8 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd, SMMUStage stage,
>      if (!tg) {
>          trace_smmuv3_range_inval(sec_sid, vmid, asid, addr,
>                                   tg, 1, ttl, leaf, stage);
> -        smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1, stage);
> +        smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1, stage,
> +                                  sec_sid);
>          if (stage == SMMU_STAGE_1) {
>              smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl, sec_sid);
>          } else {
> @@ -1376,7 +1391,7 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd, SMMUStage stage,
>          trace_smmuv3_range_inval(sec_sid, vmid, asid, addr, tg,
>                                   num_pages, ttl, leaf, stage);
>          smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg,
> -                                  num_pages, stage);
> +                                  num_pages, stage, sec_sid);
>          if (stage == SMMU_STAGE_1) {
>              smmu_iotlb_inv_iova(s, asid, vmid, addr, tg,
>                                  num_pages, ttl, sec_sid);
> @@ -1530,7 +1545,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s, Error **errp, SMMUSecSID sec_sid)
>              }
>  
>              trace_smmuv3_cmdq_tlbi_nh_asid(sec_sid, asid);
> -            smmu_inv_notifiers_all(&s->smmu_state);
> +            smmuv3_inv_notifiers_all(bs, sec_sid);
>              smmu_iotlb_inv_asid_vmid(bs, asid, vmid, sec_sid);
>              if (!smmuv3_accel_issue_inv_cmd(s, &cmd, NULL, errp)) {
>                  cmd_error = SMMU_CERROR_ILL;
> @@ -1561,7 +1576,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s, Error **errp, SMMUSecSID sec_sid)
>          }
>          case SMMU_CMD_TLBI_NSNH_ALL:
>              trace_smmuv3_cmdq_tlbi_nsnh();
> -            smmu_inv_notifiers_all(&s->smmu_state);
> +            smmuv3_inv_notifiers_all(bs, SMMU_SEC_SID_NS);
>              smmu_iotlb_inv_all(bs);
>              if (!smmuv3_accel_issue_inv_cmd(s, &cmd, NULL, errp)) {
>                  cmd_error = SMMU_CERROR_ILL;
> @@ -1590,7 +1605,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s, Error **errp, SMMUSecSID sec_sid)
>              }
>  
>              trace_smmuv3_cmdq_tlbi_s12_vmid(vmid);
> -            smmu_inv_notifiers_all(&s->smmu_state);
> +            smmuv3_inv_notifiers_all(bs, SMMU_SEC_SID_NS);
>              smmu_iotlb_inv_vmid(bs, vmid, SMMU_SEC_SID_NS);
>              break;
>          }
> -- 
> 2.34.1
> 

Reviewed-by: Jim MacArthur <jim.macarthur@linaro.org>


  reply	other threads:[~2026-12-01 10:46 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 15:46 [PATCH v6 00/35] hw/arm/smmuv3: Support Secure state for SMMUv3 Tao Tang
2026-11-14 16:05 ` [PATCH v6 27/35] hw/arm/smmuv3: Route IRQ and GERROR handling by SEC_SID Tao Tang
2026-11-14 16:07 ` [PATCH v6 30/35] hw/pci: Add sec-sid property to PCIDevice Tao Tang
2026-11-14 16:07 ` [PATCH v6 31/35] hw/arm/smmuv3: Select sec-sid from PCI property and validate SECURE_IMPL Tao Tang
2026-11-14 16:07 ` [PATCH v6 34/35] hw/arm/smmuv3: Add the secure-impl property Tao Tang
2026-11-14 16:13 ` [PATCH v6 01/35] hw/arm/smmuv3: Introduce Secure registers Tao Tang
2026-11-14 16:13 ` [PATCH v6 02/35] hw/arm/smmuv3: Introduce banked registers for SMMUv3 state Tao Tang
2026-11-14 16:13 ` [PATCH v6 03/35] hw/arm/smmuv3: Thread SEC_SID through helper APIs Tao Tang
2026-11-14 16:13 ` [PATCH v6 04/35] hw/arm/smmuv3: Track SEC_SID in configs and events Tao Tang
2026-11-14 16:13 ` [PATCH v6 05/35] hw/arm/smmu-common: Add security-aware address space selector Tao Tang
2026-11-14 16:16 ` [PATCH v6 06/35] hw/arm/smmuv3: Plumb transaction attributes into config helpers Tao Tang
2026-11-14 16:16 ` [PATCH v6 07/35] hw/arm/smmuv3: Reject Secure STEs with stage-2 enabled Tao Tang
2026-11-14 16:16 ` [PATCH v6 08/35] hw/arm/smmu-common: Key configuration cache on SMMUDevice and SEC_SID Tao Tang
2026-11-14 16:16 ` [PATCH v6 09/35] hw/arm/smmu: Add PTE NS/NSTable helpers Tao Tang
2026-11-14 16:17 ` [PATCH v6 10/35] hw/arm/smmuv3: Store CD NSCFG in TT info Tao Tang
2026-11-14 16:17 ` [PATCH v6 11/35] hw/arm/smmu-common: Implement Secure state handling in ptw Tao Tang
2026-11-14 16:17 ` [PATCH v6 12/35] hw/arm/smmuv3: Tag IOTLB cache keys with SEC_SID Tao Tang
2026-11-14 16:17 ` [PATCH v6 13/35] hw/arm/smmuv3: Pass sec_sid into cmdq consume path Tao Tang
2026-11-14 16:17 ` [PATCH v6 14/35] hw/arm/smmuv3: Make evtq producer use SEC_SID Tao Tang
2026-11-14 16:17 ` [PATCH v6 15/35] hw/arm/smmuv3: Limit IOMMU notifications to Non-secure targets Tao Tang
2026-12-01 10:46   ` Jim MacArthur [this message]
2026-11-14 16:17 ` [PATCH v6 16/35] hw/arm/smmuv3: Scope configuration invalidation by SEC_SID Tao Tang
2026-12-01 12:32   ` Jim MacArthur
2026-11-14 16:17 ` [PATCH v6 17/35] hw/arm/smmuv3: Scope IOTLB " Tao Tang
2026-12-01 13:15   ` Jim MacArthur
2026-11-14 16:17 ` [PATCH v6 18/35] hw/arm/smmuv3: Fix VMID tagging for Secure stage 1 Tao Tang
2026-12-01 13:20   ` Jim MacArthur
2026-11-14 16:17 ` [PATCH v6 19/35] hw/arm/smmuv3: Keep accelerated invalidation Non-secure-only Tao Tang
2026-12-01 14:14   ` Jim MacArthur
2026-11-14 16:19 ` [PATCH v6 20/35] hw/arm/smmuv3: Fix ATC invalidation command checks Tao Tang
2026-12-01 18:30   ` Jim MacArthur
2026-11-14 16:19 ` [PATCH v6 21/35] hw/arm/smmuv3: Make GERROR_IRQ_CFG registers RES0 without MSI Tao Tang
2026-11-14 16:19 ` [PATCH v6 22/35] hw/arm/smmuv3: Ignore CR2 writes while the SMMU is enabled Tao Tang
2026-11-14 16:19 ` [PATCH v6 23/35] hw/arm/smmuv3: Guard stream table register writes Tao Tang
2026-11-14 16:19 ` [PATCH v6 24/35] hw/arm/smmuv3: Guard command queue " Tao Tang
2026-11-14 16:19 ` [PATCH v6 25/35] hw/arm/smmuv3: Guard event " Tao Tang
2026-11-14 16:19 ` [PATCH v6 26/35] hw/arm/smmuv3: Determine register bank from MMIO offset Tao Tang
2026-11-14 16:19 ` [PATCH v6 28/35] hw/arm/smmuv3: Implement SMMU_S_INIT register Tao Tang
2026-11-14 16:19 ` [PATCH v6 29/35] hw/arm/smmuv3: Harden security checks in MMIO handlers Tao Tang
2026-11-14 16:20 ` [PATCH v6 32/35] hw/arm/smmuv3: Reject IOMMU notifiers for non-NS devices Tao Tang
2026-11-14 16:20 ` [PATCH v6 33/35] hw/arm/smmuv3: Initialize the Secure register bank Tao Tang
2026-11-14 16:20 ` [PATCH v6 35/35] hw/arm/smmuv3: Migrate " Tao Tang

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=aw6lfM6YDTm1B4DQ@linaro.org \
    --to=jim.macarthur@linaro.org \
    --cc=chao.liu@processmission.com \
    --cc=chenbaozi@phytium.com.cn \
    --cc=eric.auger@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=smostafa@google.com \
    --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.