qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: Shameer Kolothum <skolothumtho@nvidia.com>,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: eric.auger@redhat.com, peter.maydell@linaro.org, jgg@nvidia.com,
	nicolinc@nvidia.com, ddutile@redhat.com, berrange@redhat.com,
	nathanc@nvidia.com, mochs@nvidia.com, smostafa@google.com,
	wangzhou1@hisilicon.com, jiangkunkun@huawei.com,
	jonathan.cameron@huawei.com, zhangfei.gao@linaro.org,
	zhenzhong.duan@intel.com, yi.l.liu@intel.com, kjaju@nvidia.com
Subject: Re: [PATCH v6 29/33] hw/arm/smmuv3-accel: Add property to specify OAS bits
Date: Thu, 11 Dec 2025 16:23:21 +0100	[thread overview]
Message-ID: <8a6dec90-aba6-49cc-98c9-9d8205d83ac5@redhat.com> (raw)
In-Reply-To: <20251120132213.56581-30-skolothumtho@nvidia.com>

On 11/20/25 14:22, Shameer Kolothum wrote:
> QEMU SMMUv3 currently sets the output address size (OAS) to 44 bits.
> With accelerator mode enabled, a device may use SVA, where CPU page tables
> are shared with the SMMU, requiring an OAS at least as large as the
> CPU’s output address size. A user option is added to configure this.
> 
> However, the OAS value advertised by the virtual SMMU must remain
> compatible with the capabilities of the host SMMUv3. In accelerated
> mode, the host SMMU performs stage-2 translation and must be able to
> consume the intermediate physical addresses (IPA) produced by stage-1.
> 
> The OAS exposed by the virtual SMMU defines the maximum IPA width that
> stage-1 translations may generate. For AArch64 implementations, the
> maximum usable IPA size on the host SMMU is determined by its own OAS.
> Check that the configured OAS does not exceed what the host SMMU
> can safely support.
> 
> Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
> ---
>   hw/arm/smmuv3-accel.c    | 20 ++++++++++++++++++++
>   hw/arm/smmuv3-internal.h |  3 ++-
>   hw/arm/smmuv3.c          | 16 +++++++++++++++-
>   include/hw/arm/smmuv3.h  |  1 +
>   4 files changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c
> index 73c7ce586a..35a94c720a 100644
> --- a/hw/arm/smmuv3-accel.c
> +++ b/hw/arm/smmuv3-accel.c
> @@ -27,6 +27,12 @@
>   static MemoryRegion root, sysmem;
>   static AddressSpace *shared_as_sysmem;
>   
> +static int smmuv3_oas_bits(uint32_t oas)
> +{
> +    static const int map[] = { 32, 36, 40, 42, 44, 48, 52, 56 };
> +    return (oas < ARRAY_SIZE(map)) ? map[oas] : -EINVAL;
> +}
> +
>   static bool
>   smmuv3_accel_check_hw_compatible(SMMUv3State *s,
>                                    struct iommu_hw_info_arm_smmuv3 *info,
> @@ -68,6 +74,15 @@ smmuv3_accel_check_hw_compatible(SMMUv3State *s,
>           error_setg(errp, "Host SMMUv3 doesn't support Range Invalidation");
>           return false;
>       }
> +    /* Check OAS value opted is compatible with Host SMMUv3 IPA */
> +    if (FIELD_EX32(info->idr[5], IDR5, OAS) <
> +                FIELD_EX32(s->idr[5], IDR5, OAS)) {
> +        error_setg(errp, "Host SMMUv3 supports only %d-bit IPA, but the vSMMU "
> +                   "OAS implies %d-bit IPA",
> +                   smmuv3_oas_bits(FIELD_EX32(info->idr[5], IDR5, OAS)),
> +                   smmuv3_oas_bits(FIELD_EX32(info->idr[5], IDR5, OAS)));
> +        return false;
> +    }
>   
>       /* QEMU SMMUv3 supports GRAN4K/GRAN16K/GRAN64K translation granules */
>       if (FIELD_EX32(info->idr[5], IDR5, GRAN4K) !=
> @@ -650,6 +665,11 @@ void smmuv3_accel_idr_override(SMMUv3State *s)
>   
>       /* QEMU SMMUv3 has no ATS. Advertise ATS if opt-on by property */
>       s->idr[0] = FIELD_DP32(s->idr[0], IDR0, ATS, s->ats);
> +
> +    /* Advertise 48-bit OAS in IDR5 when requested (default is 44 bits). */
> +    if (s->oas == 48) {

Intel has defines for AS width :

  VTD_HOST_AW_48BIT
  VTD_HOST_AW_39BIT

I suggest doing the same for SMMUv3 to avoid using directly
numerical values like here and below.

Thanks,

C.


> +        s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS_48);
> +    }
>   }
>   
>   /* Based on SMUUv3 GPBA.ABORT configuration, attach a corresponding HWPT */
> diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
> index a76e4e2484..0f44a4e1d3 100644
> --- a/hw/arm/smmuv3-internal.h
> +++ b/hw/arm/smmuv3-internal.h
> @@ -111,7 +111,8 @@ REG32(IDR5,                0x14)
>        FIELD(IDR5, VAX,        10, 2);
>        FIELD(IDR5, STALL_MAX,  16, 16);
>   
> -#define SMMU_IDR5_OAS 4
> +#define SMMU_IDR5_OAS_44 4
> +#define SMMU_IDR5_OAS_48 5
>   
>   REG32(IIDR,                0x18)
>   REG32(AIDR,                0x1c)
> diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
> index ad476146f6..a7bd4eeb77 100644
> --- a/hw/arm/smmuv3.c
> +++ b/hw/arm/smmuv3.c
> @@ -299,7 +299,8 @@ static void smmuv3_init_id_regs(SMMUv3State *s)
>       s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
>       s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2);
>   
> -    s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
> +    /* OAS: 44 bits */
> +    s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS_44);
>       /* 4K, 16K and 64K granule support */
>       s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1);
>       s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1);
> @@ -1945,8 +1946,17 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)
>               error_setg(errp, "ats can only be enabled if accel=on");
>               return false;
>           }
> +        if (s->oas != 44) {
> +            error_setg(errp, "OAS can only be set to 44 bits if accel=off");
> +            return false;
> +        }
>           return true;
>       }
> +
> +    if (s->oas != 44 && s->oas != 48) {
> +        error_setg(errp, "OAS can only be set to 44 or 48 bits");
> +        return false;
> +    }
>       return true;
>   }
>   
> @@ -2073,6 +2083,7 @@ static const Property smmuv3_properties[] = {
>       /* RIL can be turned off for accel cases */
>       DEFINE_PROP_BOOL("ril", SMMUv3State, ril, true),
>       DEFINE_PROP_BOOL("ats", SMMUv3State, ats, false),
> +    DEFINE_PROP_UINT8("oas", SMMUv3State, oas, 44),
>   };
>   
>   static void smmuv3_instance_init(Object *obj)
> @@ -2103,6 +2114,9 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data)
>       object_class_property_set_description(klass, "ats",
>           "Enable/disable ATS support (for accel=on). Please ensure host "
>           "platform has ATS support before enabling this");
> +    object_class_property_set_description(klass, "oas",
> +        "Specify Output Address Size (for accel =on). Supported values "
> +        "are 44 or 48 bits. Defaults to 44 bits");
>   }
>   
>   static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
> diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
> index 242d6429ed..d488a39cd0 100644
> --- a/include/hw/arm/smmuv3.h
> +++ b/include/hw/arm/smmuv3.h
> @@ -71,6 +71,7 @@ struct SMMUv3State {
>       Error *migration_blocker;
>       bool ril;
>       bool ats;
> +    uint8_t oas;
>   };
>   
>   typedef enum {



  parent reply	other threads:[~2025-12-11 15:24 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20 13:21 [PATCH v6 00/33] hw/arm/virt: Add support for user-creatable accelerated SMMUv3 Shameer Kolothum
2025-11-20 13:21 ` [PATCH v6 01/33] backends/iommufd: Introduce iommufd_backend_alloc_viommu Shameer Kolothum
2025-11-20 13:21 ` [PATCH v6 02/33] backends/iommufd: Introduce iommufd_backend_alloc_vdev Shameer Kolothum
2025-11-20 13:21 ` [PATCH v6 03/33] hw/arm/smmu-common: Factor out common helper functions and export Shameer Kolothum
2025-11-20 13:21 ` [PATCH v6 04/33] hw/arm/smmu-common: Make iommu ops part of SMMUState Shameer Kolothum
2025-12-11 11:03   ` Cédric Le Goater
2025-11-20 13:21 ` [PATCH v6 05/33] hw/arm/smmuv3-accel: Introduce smmuv3 accel device Shameer Kolothum
2025-12-11 12:54   ` Cédric Le Goater
2025-11-20 13:21 ` [PATCH v6 06/33] hw/arm/smmuv3-accel: Initialize shared system address space Shameer Kolothum
2025-12-08 17:05   ` Eric Auger
2025-11-20 13:21 ` [PATCH v6 07/33] hw/pci/pci: Move pci_init_bus_master() after adding device to bus Shameer Kolothum
2025-11-20 20:44   ` Nicolin Chen
2025-11-20 13:21 ` [PATCH v6 08/33] hw/pci/pci: Add optional supports_address_space() callback Shameer Kolothum
2025-11-20 20:51   ` Nicolin Chen
2025-11-21 10:38     ` Shameer Kolothum
2025-11-21 17:28       ` Nicolin Chen
2025-11-21 17:32         ` Shameer Kolothum
2025-12-11 14:40   ` Cédric Le Goater
2025-11-20 13:21 ` [PATCH v6 09/33] hw/pci-bridge/pci_expander_bridge: Move TYPE_PXB_PCIE_DEV to header Shameer Kolothum
2025-11-20 20:52   ` Nicolin Chen
2025-11-20 13:21 ` [PATCH v6 10/33] hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd Shameer Kolothum
2025-11-20 13:21 ` [PATCH v6 11/33] hw/arm/smmuv3: Implement get_viommu_cap() callback Shameer Kolothum
2025-11-20 13:21 ` [PATCH v6 12/33] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback Shameer Kolothum
2025-12-09  7:57   ` Eric Auger
2025-12-11 13:41   ` Cédric Le Goater
2025-11-20 13:21 ` [PATCH v6 13/33] hw/arm/smmuv3: propagate smmuv3_cmdq_consume() errors to caller Shameer Kolothum
2025-11-20 20:59   ` Nicolin Chen
2025-12-04 16:28   ` Eric Auger
2025-11-20 13:21 ` [PATCH v6 14/33] hw/arm/smmuv3-accel: Add nested vSTE install/uninstall support Shameer Kolothum
2025-12-09  8:14   ` Eric Auger
2025-11-20 13:21 ` [PATCH v6 15/33] hw/arm/smmuv3-accel: Install SMMUv3 GBPA based hwpt Shameer Kolothum
2025-11-20 21:03   ` Nicolin Chen
2025-11-20 13:21 ` [PATCH v6 16/33] hw/pci/pci: Introduce a callback to retrieve the MSI doorbell GPA directly Shameer Kolothum
2025-11-20 21:05   ` Nicolin Chen
2025-12-04 16:38   ` Eric Auger
2025-12-04 18:57     ` Shameer Kolothum
2025-12-08 17:03       ` Eric Auger
2025-11-20 13:21 ` [PATCH v6 17/33] hw/arm/smmuv3: Add support for providing a direct MSI doorbell GPA Shameer Kolothum
2025-11-20 21:21   ` Nicolin Chen
2025-11-21  9:57     ` Shameer Kolothum
2025-11-21 17:56       ` Nicolin Chen
2025-11-24  8:05         ` Shameer Kolothum
2025-11-24 18:34           ` Nicolin Chen
2025-11-24 19:01             ` Shameer Kolothum
2025-11-24 20:08               ` Nicolin Chen
2025-12-11 14:03   ` Cédric Le Goater
2025-11-20 13:21 ` [PATCH v6 18/33] hw/arm/smmuv3-accel: Add support to issue invalidation cmd to host Shameer Kolothum
2025-11-20 13:21 ` [PATCH v6 19/33] hw/arm/smmuv3: Initialize ID registers early during realize() Shameer Kolothum
2025-11-20 13:22 ` [PATCH v6 20/33] hw/arm/smmuv3-accel: Get host SMMUv3 hw info and validate Shameer Kolothum
2025-11-20 21:27   ` Nicolin Chen
2025-11-20 21:30     ` Nicolin Chen
2025-11-20 13:22 ` [PATCH v6 21/33] hw/pci-host/gpex: Allow to generate preserve boot config DSM #5 Shameer Kolothum
2025-11-20 13:22 ` [PATCH v6 22/33] hw/arm/virt: Set PCI preserve_config for accel SMMUv3 Shameer Kolothum
2025-11-20 13:22 ` [PATCH v6 23/33] tests/qtest/bios-tables-test: Prepare for IORT revison upgrade Shameer Kolothum
2025-11-20 13:22 ` [PATCH v6 24/33] hw/arm/virt-acpi-build: Add IORT RMR regions to handle MSI nested binding Shameer Kolothum
2025-11-20 13:22 ` [PATCH v6 25/33] tests/qtest/bios-tables-test: Update IORT blobs after revision upgrade Shameer Kolothum
2025-11-20 13:22 ` [PATCH v6 26/33] hw/arm/smmuv3: Add accel property for SMMUv3 device Shameer Kolothum
2025-12-11 15:11   ` Cédric Le Goater
2025-11-20 13:22 ` [PATCH v6 27/33] hw/arm/smmuv3-accel: Add a property to specify RIL support Shameer Kolothum
2025-11-20 21:34   ` Nicolin Chen via
2025-11-21 10:04     ` Shameer Kolothum
2025-12-11 15:14   ` Cédric Le Goater
2025-11-20 13:22 ` [PATCH v6 28/33] hw/arm/smmuv3-accel: Add support for ATS Shameer Kolothum
2025-11-20 21:40   ` Nicolin Chen
2025-11-24 12:00   ` Zhangfei Gao
2025-11-24 12:48     ` Shameer Kolothum
2025-12-08 17:36   ` Eric Auger
2025-11-20 13:22 ` [PATCH v6 29/33] hw/arm/smmuv3-accel: Add property to specify OAS bits Shameer Kolothum
2025-11-20 21:47   ` Nicolin Chen
2025-12-08 17:17     ` Eric Auger
2025-12-11 15:23   ` Cédric Le Goater [this message]
2025-11-20 13:22 ` [PATCH v6 30/33] backends/iommufd: Retrieve PASID width from iommufd_backend_get_device_info() Shameer Kolothum
2025-11-20 21:50   ` Nicolin Chen
2025-12-11 15:24   ` Cédric Le Goater
2025-11-20 13:22 ` [PATCH v6 31/33] Extend get_cap() callback to support PASID Shameer Kolothum
2025-11-20 21:56   ` Nicolin Chen
2025-12-08 17:20   ` Eric Auger
2025-12-11 15:26   ` Cédric Le Goater
2025-11-20 13:22 ` [PATCH v6 32/33] vfio: Synthesize vPASID capability to VM Shameer Kolothum
2025-11-20 21:59   ` Nicolin Chen
2025-12-09  9:51   ` Eric Auger
2025-12-09 11:17     ` Yi Liu
2025-11-20 13:22 ` [PATCH v6 33/33] hw/arm/smmuv3-accel: Add support for PASID enable Shameer Kolothum
2025-11-20 22:09   ` Nicolin Chen
2025-11-21 10:22     ` Shameer Kolothum
2025-11-21 17:50       ` Nicolin Chen
2025-11-21 18:36         ` Nicolin Chen
2025-11-21 18:44         ` Jason Gunthorpe
2025-11-24  8:17         ` Shameer Kolothum
2025-11-20 17:06 ` [PATCH v6 00/33] hw/arm/virt: Add support for user-creatable accelerated SMMUv3 Nicolin Chen
2025-11-24 12:09   ` Zhangfei Gao
2025-12-08 10:08 ` Duan, Zhenzhong
2025-12-08 11:15   ` Shameer Kolothum
2025-12-09  2:30     ` Duan, Zhenzhong
2025-12-09  3:33       ` Yi Liu
2025-12-09 10:31 ` Cédric Le Goater
2025-12-10 15:07   ` Shameer Kolothum
2025-12-10 16:07     ` Cédric Le Goater
2025-12-10 16:18       ` Eric Auger

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=8a6dec90-aba6-49cc-98c9-9d8205d83ac5@redhat.com \
    --to=clg@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ddutile@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=jiangkunkun@huawei.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kjaju@nvidia.com \
    --cc=mochs@nvidia.com \
    --cc=nathanc@nvidia.com \
    --cc=nicolinc@nvidia.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=skolothumtho@nvidia.com \
    --cc=smostafa@google.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=yi.l.liu@intel.com \
    --cc=zhangfei.gao@linaro.org \
    --cc=zhenzhong.duan@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).