hw/arm/smmuv3-accel: Support AUTO properties
PATCH v2 1/8 hw/arm/smmuv3-accel: Check ATS compatibility between host and guest
In reply to Nathan ChenFrom: Nathan Chen <[email protected]>
Compare the host SMMUv3 ATS support bit with the guest SMMUv3 ATS support bit in IDR0 and fail the compatibility check if ATS support is opted as enabled on the guest SMMUv3 when it is not supported on host SMMUv3.
--- hw/arm/smmuv3-accel.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/arm/smmuv3-accel.c +7 -0
@@ -101,6 +101,13 @@ smmuv3_accel_check_hw_compatible(SMMUv3State *s, smmuv3_oas_bits(FIELD_EX32(s->idr[5], IDR5, OAS)));return false; } +/* Check ATS value opted is compatible with Host SMMUv3 */ +if (FIELD_EX32 (info->idr[0 ],IDR0 ,ATS ) < +FIELD_EX32 (s->idr[0 ],IDR0 ,ATS )) { +error_setg (errp,"Host SMMUv3 doesn't support Address Translation" +" Services" ); +return false; + }/* QEMU SMMUv3 supports GRAN4K/GRAN16K/GRAN64K translation granules */ if (FIELD_EX32(info->idr[5], IDR5, GRAN4K) !=
Signature · 1 line
2.43.0
v2 cover hw/arm/smmuv3-accel: Support AUTO properties
Hi,
This is a follow-up to the previous RFC series [0] that introduces support for specifying 'auto' for arm-smmuv3 accelerated mode's ATS, RIL, SSIDSIZE, and OAS feature properties. Based on feedback from the previous mailing list discussion, this refresh only converts the properties to the auto form, keeping the default values from Shameer's HW-accel SMMUv3 series [1]. A future series will introduce support for resolving the 'auto' values based on host SMMUv3 IDR values, as well as setting per-device ATS capability.
When set to 'auto', RIL and OAS will use the defaults set from smmuv3_init_id_regs() while ATS and SSIDSIZE will remain at the initialized 0 value; i.e. RIL enabled, 44-bit OAS, ATS support disabled, 0-bit SSIDSIZE.
A complete branch can be found here:
https://github.com/NathanChenNVIDIA/qemu/tree/smmuv3-accel-auto-v2
Please take a look and let me know your feedback.
Thanks,
Nathan
Changes from RFCv1:
- Remove changes that resolve the 'auto' values based on host SMMUv3
- Restore defaults values for RIL, OAS, SSIDSIZE, and ATS
- Update OasMode to accept all OAS sizes instead of only auto, 44, and 48
- Include comment in SsidSizeMode schema clarifying enum value ordering
- Replace ats-enabled prop with a helper that accepts the dynamic casted TYPE_ARM_SMMUV3 object
- Separate out guest vs. host ATS check in smmuv3_accel_check_hw_compatible() to a different commit
- Document accel, RIL, OAS, SSIDSIZE, and ATS properties in qemu-options.hx
Testing:
Basic sanity testing was performed on an NVIDIA Grace platform with GPU device assignment and running CUDA test apps on the guest. Additional testing and feedback are welcome.
[0] https://lore.kernel.org/qemu-devel/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
Nathan Chen (8):
hw/arm/smmuv3-accel: Check ATS compatibility between host and guest hw/arm/smmuv3-accel: Change ATS property to OnOffAuto hw/arm/smmuv3-accel: Change RIL property to OnOffAuto
qdev: Add a SsidSizeMode property
hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeMode
qdev: Add an OasMode property
hw/arm/smmuv3-accel: Change OAS property to OasMode qemu-options.hx: Document arm-smmuv3 device's accel properties
hw/arm/smmuv3-accel.c | 42 ++++++++++++++++++---- hw/arm/smmuv3.c | 38 ++++++++++---------- hw/arm/virt-acpi-build.c | 2 +- hw/core/qdev-properties-system.c | 27 +++++++++++++++ include/hw/arm/smmuv3.h | 11 +++--- include/hw/core/qdev-properties-system.h | 6 ++++ qapi/misc-arm.json | 44 ++++++++++++++++++++++++ qapi/pragma.json | 1 + qemu-options.hx | 29 +++++++++++++++- 9 files changed, 169 insertions(+), 31 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 4/8 qdev: Add a SsidSizeMode property
From: Nathan Chen <[email protected]>
Introduce a new enum type property allowing to set a Substream ID size for HW-accelerated smmuv3. Values are auto and 0..20. The auto value allows SSID size property to be derived from host IOMMU capabilities. A value of 0 disables SubstreamID, while non-zero values specify the SSID size in bits.
--- hw/core/qdev-properties-system.c | 14 ++++++++++++++ include/hw/core/qdev-properties-system.h | 3 +++ qapi/misc-arm.json | 16 ++++++++++++++++ qapi/pragma.json | 1 + 4 files changed, 34 insertions(+)
hw/core/qdev-properties-system.c +14 -0
@@ -18,6 +18,7 @@#include "qapi/qapi-types-block.h" #include "qapi/qapi-types-machine.h" #include "qapi/qapi-types-migration.h" +#include "qapi/qapi-types-misc-arm.h" #include "qapi/qapi-visit-virtio.h" #include "qapi/qmp/qerror.h" #include "qemu/ctype.h"
@@ -723,6 +724,19 @@ const PropertyInfo qdev_prop_zero_page_detection = { .set_default_value = qdev_propinfo_set_default_value_enum, }; +/* --- SsidSizeMode --- */ + +QEMU_BUILD_BUG_ON (sizeof (SsidSizeMode) !=sizeof (int )); + +const PropertyInfo qdev_prop_ssidsize_mode = { + .type ="SsidSizeMode" , + .description ="ssidsize mode: auto, 0-20" , + .enum_table = &SsidSizeMode_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +}; +/* --- Reserved Region --- */ /*
include/hw/core/qdev-properties-system.h +3 -0
@@ -14,6 +14,7 @@ extern const PropertyInfo qdev_prop_multifd_compression;extern const PropertyInfo qdev_prop_mig_mode;extern const PropertyInfo qdev_prop_granule_mode;extern const PropertyInfo qdev_prop_zero_page_detection; +extern const PropertyInfo qdev_prop_ssidsize_mode;extern const PropertyInfo qdev_prop_losttickpolicy;extern const PropertyInfo qdev_prop_blockdev_on_error;extern const PropertyInfo qdev_prop_bios_chs_trans;
@@ -61,6 +62,8 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_list;#define DEFINE_PROP_ZERO_PAGE_DETECTION (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_zero_page_detection, \ ZeroPageDetection) +#define DEFINE_PROP_SSIDSIZE_MODE (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_ssidsize_mode, SsidSizeMode)#define DEFINE_PROP_LOSTTICKPOLICY (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy)
qapi/misc-arm.json +16 -0
@@ -45,3 +45,19 @@ # { "version": 3, "emulated": false, "kernel": true } ] } ## { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } + +## +# @SsidSizeMode: +# +# SMMUv3 SubstreamID size configuration mode. +# +# @auto: derive from host IOMMU capabilities +# +# Values 0-20: SSIDSIZE value in bits. 0 disables SubstreamID. +# +# Since: 11.0 +## +{ 'enum': 'SsidSizeMode', + 'data': [ 'auto', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', + '19', '20' ] } # order matters, see ssid_size_mode_auto()
qapi/pragma.json +1 -0
@@ -68,6 +68,7 @@ 'S390CpuEntitlement', 'S390CpuPolarization', 'S390CpuState', + 'SsidSizeMode', 'String', 'StringWrapper', 'SysEmuTarget',
Signature · 1 line
2.43.0
PATCH v2 2/8 hw/arm/smmuv3-accel: Change ATS property to OnOffAuto
In reply to Nathan ChenFrom: Nathan Chen <[email protected]>
Change accel SMMUv3 ATS property from bool to OnOffAuto. Setting 'auto' will result in the default value being used, i.e. 0 in IDR0 which translates to 'off'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 ATS support.
--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 9 +++++++-- hw/arm/virt-acpi-build.c | 2 +- include/hw/arm/smmuv3.h | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-)
hw/arm/smmuv3-accel.c +6 -2
@@ -827,8 +827,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); -/* QEMU SMMUv3 has no ATS. Advertise ATS if opt-in by property */ - s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS , s->ats); +/* Only override ATS if user explicitly set ON or OFF */ +if (s->ats ==ON_OFF_AUTO_ON ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,1 ); + }else if (s->ats ==ON_OFF_AUTO_OFF ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,0 ); + }/* Advertise 48-bit OAS in IDR5 when requested (default is 44 bits). */ if (s->oas ==SMMU_OAS_48BIT ) {
hw/arm/smmuv3.c +7 -2
@@ -317,6 +317,11 @@ static void smmuv3_init_id_regs(SMMUv3State *s)smmuv3_accel_idr_override (s); } +bool smmuv3_ats_enabled (SMMUv3State *s) +{ +return FIELD_EX32 (s->idr[0 ],IDR0 ,ATS ); +} +static void smmuv3_reset (SMMUv3State *s) { s->cmdq.base =deposit64 (s->cmdq.base,0 ,5 ,SMMU_CMDQS );
@@ -1971,7 +1976,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"ril can only be disabled if accel=on" );return false; } -if (s->ats) { +if (s->ats ==ON_OFF_AUTO_ON ) {error_setg (errp,"ats can only be enabled if accel=on" );return false; }
@@ -2128,7 +2133,7 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_UINT64 ("msi-gpa" , SMMUv3State, msi_gpa,0 ),/* RIL can be turned off for accel cases */ DEFINE_PROP_BOOL ("ril" , SMMUv3State, ril, true), -DEFINE_PROP_BOOL ("ats" , SMMUv3State, ats, false), +DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0), };
hw/arm/virt-acpi-build.c +1 -1
@@ -402,7 +402,7 @@ static int iort_smmuv3_devices(Object *obj, void *opaque) bus =PCI_BUS (object_property_get_link (obj,"primary-bus" , &error_abort)); sdev.accel =object_property_get_bool (obj,"accel" , &error_abort); - sdev.ats =object_property_get_bool (obj,"ats" , &error_abort); + sdev.ats =smmuv3_ats_enabled (ARM_SMMUV3 (obj)); pbus =PLATFORM_BUS_DEVICE (vms->platform_bus_dev); sbdev =SYS_BUS_DEVICE (obj); sdev.base =platform_bus_get_mmio_addr (pbus, sbdev,0 );
include/hw/arm/smmuv3.h +3 -1
@@ -70,7 +70,7 @@ struct SMMUv3State {uint64_t msi_gpa;Error *migration_blocker;bool ril; -bool ats; +OnOffAuto ats;uint8_t oas;uint8_t ssidsize; };
@@ -91,6 +91,8 @@ struct SMMUv3Class {ResettablePhases parent_phases; }; +bool smmuv3_ats_enabled (struct SMMUv3State *s); +#define TYPE_ARM_SMMUV3 "arm-smmuv3"OBJECT_DECLARE_TYPE (SMMUv3State, SMMUv3Class,ARM_SMMUV3 )
Signature · 1 line
2.43.0
PATCH v2 5/8 hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeMode
In reply to Nathan ChenFrom: Nathan Chen <[email protected]>
Change accel SMMUv3 SSIDSIZE property from uint8_t to SsidSizeMode. Setting 'auto' will use the default value, i.e. 0 in IDR1. A future patch will implement resolution of 'auto' value to match the host SMMUv3 SSIDSIZE value.
--- hw/arm/smmuv3-accel.c | 17 +++++++++++++++-- hw/arm/smmuv3.c | 16 ++++++---------- include/hw/arm/smmuv3.h | 3 ++- 3 files changed, 23 insertions(+), 13 deletions(-)
hw/arm/smmuv3-accel.c +15 -2
@@ -803,7 +803,7 @@ static uint64_t smmuv3_accel_get_viommu_flags(void *opaque)SMMUState *bs = opaque;SMMUv3State *s =ARM_SMMUV3 (bs); -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) { flags |=VIOMMU_FLAG_PASID_SUPPORTED ; }return flags;
@@ -818,6 +818,16 @@ static const PCIIOMMUOps smmuv3_accel_ops = { .get_msi_direct_gpa = smmuv3_accel_get_msi_gpa, }; +static uint8_t ssidsize_mode_to_value (SsidSizeMode mode) +{ +/* SSID_SIZE_MODE_0 = 1, SSID_SIZE_MODE_1 = 2, etc. */ +/* SSID_SIZE_MODE_AUTO = 0 */ +if (mode ==SSID_SIZE_MODE_AUTO ) { +return 0 ; + } +return mode -1 ;/* Enum values are offset by 1 from actual values */ +} +void smmuv3_accel_idr_override (SMMUv3State *s) {if (!s->accel) {
@@ -847,7 +857,10 @@ void smmuv3_accel_idr_override(SMMUv3State *s)* By default QEMU SMMUv3 has no SubstreamID support. Update IDR1 if user * has enabled it. */ - s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , s->ssidsize); +if (s->ssidsize !=SSID_SIZE_MODE_AUTO ) { + s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , +ssidsize_mode_to_value (s->ssidsize)); + } }/* Based on SMUUv3 GPBA.ABORT configuration, attach a corresponding HWPT */
hw/arm/smmuv3.c +6 -10
@@ -20,6 +20,7 @@#include "qemu/bitops.h" #include "hw/core/irq.h" #include "hw/core/sysbus.h" +#include "hw/core/qdev-properties-system.h" #include "migration/blocker.h" #include "migration/vmstate.h" #include "hw/core/qdev-properties.h"
@@ -625,7 +626,7 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, }/* Multiple context descriptors require SubstreamID support */ -if (!s->ssidsize &&STE_S1CDMAX (ste) !=0 ) { +if (s->ssidsize ==SSID_SIZE_MODE_0 &&STE_S1CDMAX (ste) !=0 ) {qemu_log_mask (LOG_UNIMP ,"SMMUv3: multiple S1 context descriptors require SubstreamID support. " "Configure ssidsize > 0 (requires accel=on)\n" );
@@ -1984,7 +1985,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS must be 44 bits when accel=off" );return false; } -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) {error_setg (errp,"ssidsize can only be set if accel=on" );return false; }
@@ -2002,11 +2003,6 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS can only be set to 44 or 48 bits" );return false; } -if (s->ssidsize >SMMU_SSID_MAX_BITS ) { -error_setg (errp,"ssidsize must be in the range 0 to %d" , -SMMU_SSID_MAX_BITS ); -return false; - }return true; }
@@ -2135,7 +2131,8 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), - DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0), +DEFINE_PROP_SSIDSIZE_MODE ("ssidsize" , SMMUv3State, ssidsize, + SSID_SIZE_MODE_0), };static void smmuv3_instance_init (Object *obj)
@@ -2173,8 +2170,7 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data)"Number of bits used to represent SubstreamIDs (SSIDs). " "A value of N allows SSIDs in the range [0 .. 2^N - 1]. " "Valid range is 0-20, where 0 disables SubstreamID support. " -"Defaults to 0. A value greater than 0 is required to enable " - "PASID support."); + "A value greater than 0 is required to enable PASID support."); } static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
include/hw/arm/smmuv3.h +2 -1
@@ -21,6 +21,7 @@#include "hw/arm/smmu-common.h" #include "qom/object.h" +#include "qapi/qapi-types-misc-arm.h" #define TYPE_SMMUV3_IOMMU_MEMORY_REGION "smmuv3-iommu-memory-region"
@@ -72,7 +73,7 @@ struct SMMUv3State {OnOffAuto ril;OnOffAuto ats;uint8_t oas; -uint8_t ssidsize; +SsidSizeMode ssidsize; }; typedef enum {
Signature · 1 line
2.43.0
PATCH v2 6/8 qdev: Add an OasMode property
In reply to Nathan ChenFrom: Nathan Chen <[email protected]>
Introduce a new enum type property allowing to set an Output Address Size. Values are auto, 32, 36, 40, 42, 44, 48, 52, and 56, where a value of N specifies an N-bit OAS.
--- hw/core/qdev-properties-system.c | 13 +++++++++++ include/hw/core/qdev-properties-system.h | 3 +++ qapi/misc-arm.json | 28 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+)
hw/core/qdev-properties-system.c +13 -0
@@ -737,6 +737,19 @@ const PropertyInfo qdev_prop_ssidsize_mode = { .set_default_value = qdev_propinfo_set_default_value_enum, }; +/* --- OasMode --- */ + +QEMU_BUILD_BUG_ON (sizeof (OasMode) !=sizeof (int )); + +const PropertyInfo qdev_prop_oas_mode = { + .type ="OasMode" , + .description ="oas mode: auto, 32, 36, 40, 42, 44, 48, 52, 56" , + .enum_table = &OasMode_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +}; +/* --- Reserved Region --- */ /*
include/hw/core/qdev-properties-system.h +3 -0
@@ -15,6 +15,7 @@ extern const PropertyInfo qdev_prop_mig_mode;extern const PropertyInfo qdev_prop_granule_mode;extern const PropertyInfo qdev_prop_zero_page_detection;extern const PropertyInfo qdev_prop_ssidsize_mode; +extern const PropertyInfo qdev_prop_oas_mode;extern const PropertyInfo qdev_prop_losttickpolicy;extern const PropertyInfo qdev_prop_blockdev_on_error;extern const PropertyInfo qdev_prop_bios_chs_trans;
@@ -64,6 +65,8 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_list; ZeroPageDetection)#define DEFINE_PROP_SSIDSIZE_MODE (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_ssidsize_mode, SsidSizeMode) +#define DEFINE_PROP_OAS_MODE (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_oas_mode, OasMode)#define DEFINE_PROP_LOSTTICKPOLICY (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy)
qapi/misc-arm.json +28 -0
@@ -61,3 +61,31 @@ 'data': [ 'auto', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20' ] } # order matters, see ssid_size_mode_auto() + +## +# @OasMode: +# +# SMMUv3 Output Address Size configuration mode. +# +# @auto: derive from host IOMMU capabilities +# +# @32: 32-bit output address size +# +# @36: 36-bit output address size +# +# @40: 40-bit output address size +# +# @42: 42-bit output address size +# +# @44: 44-bit output address size +# +# @48: 48-bit output address size +# +# @52: 52-bit output address size +# +# @56: 56-bit output address size +# +# Since: 11.0 +## +{ 'enum': 'OasMode', + 'data': [ 'auto', '32', '36', '40', '42', '44', '48', '52', '56' ] }
Signature · 1 line
2.43.0
PATCH v2 8/8 qemu-options.hx: Document arm-smmuv3 device's accel properties
In reply to Nathan ChenFrom: Nathan Chen <[email protected]>
Document arm-smmuv3 properties for setting HW-acceleration, Range Invalidation, and Address Translation Services support, as well as setting Output Address size and Substream ID size.
--- qemu-options.hx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
qemu-options.hx +28 -1
@@ -1274,13 +1274,40 @@ SRST ``aw-bits=val`` (val between 32 and 64, default depends on machine) This decides the address width of the IOVA address space. -``-device arm-smmuv3,primary-bus=id`` +``-device arm-smmuv3,primary-bus=id[,option=...]`` This is only supported by ``-machine virt`` (ARM). ``primary-bus=id`` Accepts either the default root complex (pcie.0) or a pxb-pcie based root complex. + ``accel=on|off`` (default: off) + Enables guest to try to leverage host SMMUv3 features for acceleration. + By default, enabling accel configures the host SMMUv3 in nested mode to + support vfio-pci pass-through. + + ``ril=on|off`` (default: on) + Support for Range Invalidation, which allows the SMMUv3 driver to + invalidate TLB entries for a range of IOVAs at once instead of issuing + separate commands to invalidate each page. Must match with host SMMUv3 + Range Invalidation support. + + ``ats=on|off`` (default: off) + Support for Address Translation Services, which enables PCIe devices to + cache address translations in their local TLB and reduce latency. Host + SMMUv3 must support ATS in order to enable this feature for the vIOMMU. + + ``oas=val`` (supported values are 44 and 48. default: 44) + Sets the Output Address Size in bits. The value set here must be less + than or equal to the host SMMUv3's supported OAS, so that the + intermediate physical addresses (IPA) consumed by host SMMU for stage-2 + translation do not exceed the host's max supported IPA size. + + ``ssidsize=val`` (val between 0 and 20. default: 0) + Sets the Substream ID size in bits. When set to a non-zero value, + PASID capability is advertised to the vIOMMU and accelerated use cases + such as Shared Virtual Addressing (SVA) are supported. + ``-device amd-iommu[,option=...]`` Enables emulation of an AMD-Vi I/O Memory Management Unit (IOMMU). Only available with ``-machine q35``, it supports the following options:
Signature · 1 line
2.43.0
PATCH v2 7/8 hw/arm/smmuv3-accel: Change OAS property to OasMode
In reply to Nathan ChenFrom: Nathan Chen <[email protected]>
Change accel SMMUv3 OAS property from uint8_t to OasMode. Setting 'auto' will use the default value of 44 set in smmuv3_init_id_regs(). A future patch will implement resolution of 'auto' value to match the host SMMUv3 OAS value.
--- hw/arm/smmuv3-accel.c | 2 +- hw/arm/smmuv3.c | 9 +++++---- include/hw/arm/smmuv3.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-)
hw/arm/smmuv3-accel.c +1 -1
@@ -849,7 +849,7 @@ void smmuv3_accel_idr_override(SMMUv3State *s) }/* Advertise 48-bit OAS in IDR5 when requested (default is 44 bits). */ -if (s->oas ==SMMU_OAS_48BIT ) { +if (s->oas ==OAS_MODE_48 ) { s->idr[5 ] =FIELD_DP32 (s->idr[5 ],IDR5 ,OAS ,SMMU_IDR5_OAS_48 ); }
hw/arm/smmuv3.c +5 -4
@@ -1981,7 +1981,7 @@ 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 !=SMMU_OAS_44BIT ) { +if (s->oas >OAS_MODE_44 ) {error_setg (errp,"OAS must be 44 bits when accel=off" );return false; }
@@ -1999,8 +1999,9 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)return false; } -if (s->oas !=SMMU_OAS_44BIT && s->oas !=SMMU_OAS_48BIT ) { -error_setg (errp,"OAS can only be set to 44 or 48 bits" ); +if (s->oas !=OAS_MODE_AUTO && s->oas !=OAS_MODE_44 && + s->oas !=OAS_MODE_48 ) { +error_setg (errp,"OAS can only be set to auto, 44 bits, or 48 bits" );return false; }
@@ -2130,7 +2131,7 @@ static const Property smmuv3_properties[] = {/* RIL can be turned off for accel cases */ DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ), -DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), +DEFINE_PROP_OAS_MODE ("oas" , SMMUv3State, oas,OAS_MODE_44 ),DEFINE_PROP_SSIDSIZE_MODE ("ssidsize" , SMMUv3State, ssidsize, SSID_SIZE_MODE_0), };
include/hw/arm/smmuv3.h +1 -1
@@ -72,7 +72,7 @@ struct SMMUv3State {Error *migration_blocker;OnOffAuto ril;OnOffAuto ats; -uint8_t oas; +OasMode oas;SsidSizeMode ssidsize; };
Signature · 1 line
2.43.0
PATCH v2 3/8 hw/arm/smmuv3-accel: Change RIL property to OnOffAuto
In reply to Nathan ChenFrom: Nathan Chen <[email protected]>
Change accel SMMUv3 RIL property from bool to OnOffAuto. Setting 'auto' will use the default set in smmuv3_init_id_regs(), i.e. 1 in IDR3 which translates to 'on'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 RIL support.
--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 4 ++-- include/hw/arm/smmuv3.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)
hw/arm/smmuv3-accel.c +6 -2
@@ -824,8 +824,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)return ; } -/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ - s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); +/* Only override RIL if user explicitly set ON or OFF */ +if (s->ril ==ON_OFF_AUTO_ON ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,1 ); + }else if (s->ril ==ON_OFF_AUTO_OFF ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,0 ); + }/* Only override ATS if user explicitly set ON or OFF */ if (s->ats ==ON_OFF_AUTO_ON ) {
hw/arm/smmuv3.c +2 -2
@@ -1972,7 +1972,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)#endif if (!s->accel) { -if (!s->ril) { +if (s->ril ==ON_OFF_AUTO_OFF ) {error_setg (errp,"ril can only be disabled if accel=on" );return false; }
@@ -2132,7 +2132,7 @@ static const Property smmuv3_properties[] = {/* GPA of MSI doorbell, for SMMUv3 accel use. */ DEFINE_PROP_UINT64 ("msi-gpa" , SMMUv3State, msi_gpa,0 ),/* RIL can be turned off for accel cases */ -DEFINE_PROP_BOOL ("ril" , SMMUv3State, ril, true), +DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0),
include/hw/arm/smmuv3.h +1 -1
@@ -69,7 +69,7 @@ struct SMMUv3State {struct SMMUv3AccelState *s_accel;uint64_t msi_gpa;Error *migration_blocker; -bool ril; +OnOffAuto ril;OnOffAuto ats;uint8_t oas;uint8_t ssidsize;
Signature · 1 line
2.43.0
Re: [PATCH v2 1/8] hw/arm/smmuv3-accel: Check ATS compatibility between host and guest
In reply to Nathan ChenHi Nathan,
Quoted 5 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Compare the host SMMUv3 ATS support bit with the guest SMMUv3 ATS support bit in IDR0 and fail the compatibility check if ATS support is opted as enabled on the guest SMMUv3 when it is not supported on host SMMUv3.
Miss
Quoted 11 lines
Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/arm/smmuv3-accel.c +0
-0
hw/arm/smmuv3-accel.c smmuv3_accel_check_hw_compatible(SMMUv3State *s, · line 108
Quoted 8 lines
hw/arm/smmuv3-accel.c +5
-0@@ -101,6 +101,13 @@ smmuv3_accel_check_hw_compatible(SMMUv3State *s, smmuv3_oas_bits(FIELD_EX32(s->idr[5], IDR5, OAS)));return false; } +/* Check ATS value opted is compatible with Host SMMUv3 */ +if (FIELD_EX32 (info->idr[0 ],IDR0 ,ATS ) < +FIELD_EX32 (s->idr[0 ],IDR0 ,ATS )) { +error_setg (errp,"Host SMMUv3 doesn't support Address Translation" +" Services" );
I think you can keep it on the same line. Checkpatch will just issue a warning.
hw/arm/smmuv3-accel.c smmuv3_accel_check_hw_compatible(SMMUv3State *s, · line 113
Quoted 5 lines
hw/arm/smmuv3-accel.c +2
-0+return false; + }/* QEMU SMMUv3 supports GRAN4K/GRAN16K/GRAN64K translation granules */ if (FIELD_EX32(info->idr[5], IDR5, GRAN4K) !=
Otherwise
Eric
Re: [PATCH v2 2/8] hw/arm/smmuv3-accel: Change ATS property to OnOffAuto
In reply to Nathan ChenHi Nathan,
Quoted 6 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Change accel SMMUv3 ATS property from bool to OnOffAuto. Setting 'auto' will result in the default value being used, i.e. 0 in IDR0 which translates to 'off'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 ATS support.
i.e. 0 in IDR0 which translates to 'off': this is unclear to me what you want to say.
I would clearly state here that at the moment the auto value is not implemented. This is just to get the property right and do not break JSON/QMP when getting the auto mode introduced. Also I think you want to enforce that in the code, ie. the end user is not trying to set to AUTO.
Thanks
Eric
Quoted 97 lines
Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 9 +++++++-- hw/arm/virt-acpi-build.c | 2 +- include/hw/arm/smmuv3.h | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-)hw/arm/smmuv3-accel.c +6
-2@@ -827,8 +827,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); -/* QEMU SMMUv3 has no ATS. Advertise ATS if opt-in by property */ - s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS , s->ats); +/* Only override ATS if user explicitly set ON or OFF */ +if (s->ats ==ON_OFF_AUTO_ON ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,1 ); + }else if (s->ats ==ON_OFF_AUTO_OFF ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,0 ); + }/* Advertise 48-bit OAS in IDR5 when requested (default is 44 bits). */ if (s->oas ==SMMU_OAS_48BIT ) {hw/arm/smmuv3.c +7
-2@@ -317,6 +317,11 @@ static void smmuv3_init_id_regs(SMMUv3State *s)smmuv3_accel_idr_override (s); } +bool smmuv3_ats_enabled (SMMUv3State *s) +{ +return FIELD_EX32 (s->idr[0 ],IDR0 ,ATS ); +} +static void smmuv3_reset (SMMUv3State *s) { s->cmdq.base =deposit64 (s->cmdq.base,0 ,5 ,SMMU_CMDQS );@@ -1971,7 +1976,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"ril can only be disabled if accel=on" );return false; } -if (s->ats) { +if (s->ats ==ON_OFF_AUTO_ON ) {error_setg (errp,"ats can only be enabled if accel=on" );return false; }@@ -2128,7 +2133,7 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_UINT64 ("msi-gpa" , SMMUv3State, msi_gpa,0 ),/* RIL can be turned off for accel cases */ DEFINE_PROP_BOOL ("ril" , SMMUv3State, ril, true), -DEFINE_PROP_BOOL ("ats" , SMMUv3State, ats, false), +DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0), };hw/arm/virt-acpi-build.c +1
-1@@ -402,7 +402,7 @@ static int iort_smmuv3_devices(Object *obj, void *opaque) bus =PCI_BUS (object_property_get_link (obj,"primary-bus" , &error_abort)); sdev.accel =object_property_get_bool (obj,"accel" , &error_abort); - sdev.ats =object_property_get_bool (obj,"ats" , &error_abort); + sdev.ats =smmuv3_ats_enabled (ARM_SMMUV3 (obj)); pbus =PLATFORM_BUS_DEVICE (vms->platform_bus_dev); sbdev =SYS_BUS_DEVICE (obj); sdev.base =platform_bus_get_mmio_addr (pbus, sbdev,0 );include/hw/arm/smmuv3.h +3
-1@@ -70,7 +70,7 @@ struct SMMUv3State {uint64_t msi_gpa;Error *migration_blocker;bool ril; -bool ats; +OnOffAuto ats;uint8_t oas;uint8_t ssidsize; };@@ -91,6 +91,8 @@ struct SMMUv3Class {ResettablePhases parent_phases; }; +bool smmuv3_ats_enabled (struct SMMUv3State *s); +#define TYPE_ARM_SMMUV3 "arm-smmuv3"OBJECT_DECLARE_TYPE (SMMUv3State, SMMUv3Class,ARM_SMMUV3 )
Re: [PATCH v2 2/8] hw/arm/smmuv3-accel: Change ATS property to OnOffAuto
In reply to Nathan ChenQuoted 6 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Change accel SMMUv3 ATS property from bool to OnOffAuto. Setting 'auto' will result in the default value being used, i.e. 0 in IDR0 which translates to 'off'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 ATS support.
You may also add a Fixes tag
Eric
Quoted 97 lines
Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 9 +++++++-- hw/arm/virt-acpi-build.c | 2 +- include/hw/arm/smmuv3.h | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-)hw/arm/smmuv3-accel.c +6
-2@@ -827,8 +827,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); -/* QEMU SMMUv3 has no ATS. Advertise ATS if opt-in by property */ - s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS , s->ats); +/* Only override ATS if user explicitly set ON or OFF */ +if (s->ats ==ON_OFF_AUTO_ON ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,1 ); + }else if (s->ats ==ON_OFF_AUTO_OFF ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,0 ); + }/* Advertise 48-bit OAS in IDR5 when requested (default is 44 bits). */ if (s->oas ==SMMU_OAS_48BIT ) {hw/arm/smmuv3.c +7
-2@@ -317,6 +317,11 @@ static void smmuv3_init_id_regs(SMMUv3State *s)smmuv3_accel_idr_override (s); } +bool smmuv3_ats_enabled (SMMUv3State *s) +{ +return FIELD_EX32 (s->idr[0 ],IDR0 ,ATS ); +} +static void smmuv3_reset (SMMUv3State *s) { s->cmdq.base =deposit64 (s->cmdq.base,0 ,5 ,SMMU_CMDQS );@@ -1971,7 +1976,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"ril can only be disabled if accel=on" );return false; } -if (s->ats) { +if (s->ats ==ON_OFF_AUTO_ON ) {error_setg (errp,"ats can only be enabled if accel=on" );return false; }@@ -2128,7 +2133,7 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_UINT64 ("msi-gpa" , SMMUv3State, msi_gpa,0 ),/* RIL can be turned off for accel cases */ DEFINE_PROP_BOOL ("ril" , SMMUv3State, ril, true), -DEFINE_PROP_BOOL ("ats" , SMMUv3State, ats, false), +DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0), };hw/arm/virt-acpi-build.c +1
-1@@ -402,7 +402,7 @@ static int iort_smmuv3_devices(Object *obj, void *opaque) bus =PCI_BUS (object_property_get_link (obj,"primary-bus" , &error_abort)); sdev.accel =object_property_get_bool (obj,"accel" , &error_abort); - sdev.ats =object_property_get_bool (obj,"ats" , &error_abort); + sdev.ats =smmuv3_ats_enabled (ARM_SMMUV3 (obj)); pbus =PLATFORM_BUS_DEVICE (vms->platform_bus_dev); sbdev =SYS_BUS_DEVICE (obj); sdev.base =platform_bus_get_mmio_addr (pbus, sbdev,0 );include/hw/arm/smmuv3.h +3
-1@@ -70,7 +70,7 @@ struct SMMUv3State {uint64_t msi_gpa;Error *migration_blocker;bool ril; -bool ats; +OnOffAuto ats;uint8_t oas;uint8_t ssidsize; };@@ -91,6 +91,8 @@ struct SMMUv3Class {ResettablePhases parent_phases; }; +bool smmuv3_ats_enabled (struct SMMUv3State *s); +#define TYPE_ARM_SMMUV3 "arm-smmuv3"OBJECT_DECLARE_TYPE (SMMUv3State, SMMUv3Class,ARM_SMMUV3 )
Re: [PATCH v2 3/8] hw/arm/smmuv3-accel: Change RIL property to OnOffAuto
In reply to Nathan ChenHi Nathan,
Quoted 6 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Change accel SMMUv3 RIL property from bool to OnOffAuto. Setting 'auto' will use the default set in
smmuv3_init_id_regs(), i.e. 1 in IDR3 which translates to 'on'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 RIL support.
Please a check to test the AUTO value is not set at the moment.
Add the Fixes tag too. Otherwise looks good.
Eric
Quoted 62 lines
Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 4 ++-- include/hw/arm/smmuv3.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)hw/arm/smmuv3-accel.c +6
-2@@ -824,8 +824,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)return ; } -/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ - s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); +/* Only override RIL if user explicitly set ON or OFF */ +if (s->ril ==ON_OFF_AUTO_ON ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,1 ); + }else if (s->ril ==ON_OFF_AUTO_OFF ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,0 ); + }/* Only override ATS if user explicitly set ON or OFF */ if (s->ats ==ON_OFF_AUTO_ON ) {hw/arm/smmuv3.c +2
-2@@ -1972,7 +1972,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)#endif if (!s->accel) { -if (!s->ril) { +if (s->ril ==ON_OFF_AUTO_OFF ) {error_setg (errp,"ril can only be disabled if accel=on" );return false; }@@ -2132,7 +2132,7 @@ static const Property smmuv3_properties[] = {/* GPA of MSI doorbell, for SMMUv3 accel use. */ DEFINE_PROP_UINT64 ("msi-gpa" , SMMUv3State, msi_gpa,0 ),/* RIL can be turned off for accel cases */ -DEFINE_PROP_BOOL ("ril" , SMMUv3State, ril, true), +DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0),include/hw/arm/smmuv3.h +1
-1@@ -69,7 +69,7 @@ struct SMMUv3State {struct SMMUv3AccelState *s_accel;uint64_t msi_gpa;Error *migration_blocker; -bool ril; +OnOffAuto ril;OnOffAuto ats;uint8_t oas;uint8_t ssidsize;
Re: [PATCH v2 4/8] qdev: Add a SsidSizeMode property
In reply to Nathan ChenQuoted 7 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Introduce a new enum type property allowing to set a Substream ID size for HW-accelerated smmuv3. Values are auto and 0..20. The auto value allows SSID size property to be derived from host IOMMU capabilities. A value of 0 disables SubstreamID, while non-zero values specify the SSID size in bits.
Eric
Quoted 98 lines
Signed-off-by Nathan Chen <[email protected]>--- hw/core/qdev-properties-system.c | 14 ++++++++++++++ include/hw/core/qdev-properties-system.h | 3 +++ qapi/misc-arm.json | 16 ++++++++++++++++ qapi/pragma.json | 1 + 4 files changed, 34 insertions(+)hw/core/qdev-properties-system.c +14
-0@@ -18,6 +18,7 @@#include "qapi/qapi-types-block.h" #include "qapi/qapi-types-machine.h" #include "qapi/qapi-types-migration.h" +#include "qapi/qapi-types-misc-arm.h" #include "qapi/qapi-visit-virtio.h" #include "qapi/qmp/qerror.h" #include "qemu/ctype.h" @@ -723,6 +724,19 @@ const PropertyInfo qdev_prop_zero_page_detection = { .set_default_value = qdev_propinfo_set_default_value_enum, }; +/* --- SsidSizeMode --- */ + +QEMU_BUILD_BUG_ON (sizeof (SsidSizeMode) !=sizeof (int )); + +const PropertyInfo qdev_prop_ssidsize_mode = { + .type ="SsidSizeMode" , + .description ="ssidsize mode: auto, 0-20" , + .enum_table = &SsidSizeMode_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +}; +/* --- Reserved Region --- */ /* include/hw/core/qdev-properties-system.h +3
-0@@ -14,6 +14,7 @@ extern const PropertyInfo qdev_prop_multifd_compression;extern const PropertyInfo qdev_prop_mig_mode;extern const PropertyInfo qdev_prop_granule_mode;extern const PropertyInfo qdev_prop_zero_page_detection; +extern const PropertyInfo qdev_prop_ssidsize_mode;extern const PropertyInfo qdev_prop_losttickpolicy;extern const PropertyInfo qdev_prop_blockdev_on_error;extern const PropertyInfo qdev_prop_bios_chs_trans;@@ -61,6 +62,8 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_list;#define DEFINE_PROP_ZERO_PAGE_DETECTION (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_zero_page_detection, \ ZeroPageDetection) +#define DEFINE_PROP_SSIDSIZE_MODE (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_ssidsize_mode, SsidSizeMode)#define DEFINE_PROP_LOSTTICKPOLICY (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy)qapi/misc-arm.json +16
-0@@ -45,3 +45,19 @@ # { "version": 3, "emulated": false, "kernel": true } ] } ## { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } + +## +# @SsidSizeMode: +# +# SMMUv3 SubstreamID size configuration mode. +# +# @auto: derive from host IOMMU capabilities +# +# Values 0-20: SSIDSIZE value in bits. 0 disables SubstreamID. +# +# Since: 11.0 +## +{ 'enum': 'SsidSizeMode', + 'data': [ 'auto', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', + '19', '20' ] } # order matters, see ssid_size_mode_auto()qapi/pragma.json +1
-0@@ -68,6 +68,7 @@ 'S390CpuEntitlement', 'S390CpuPolarization', 'S390CpuState', + 'SsidSizeMode', 'String', 'StringWrapper', 'SysEmuTarget',
Re: [PATCH v2 5/8] hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeMode
In reply to Nathan ChenQuoted 6 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Change accel SMMUv3 SSIDSIZE property from
uint8_tto SsidSizeMode. Setting 'auto' will use the default value, i.e. 0 in IDR1. A future patch will implement resolution of 'auto' value to match the host SMMUv3 SSIDSIZE value.
At the moment we need to reject auto setting as it is not supported
Quoted 103 lines
Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 17 +++++++++++++++-- hw/arm/smmuv3.c | 16 ++++++---------- include/hw/arm/smmuv3.h | 3 ++- 3 files changed, 23 insertions(+), 13 deletions(-)hw/arm/smmuv3-accel.c +15
-2@@ -803,7 +803,7 @@ static uint64_t smmuv3_accel_get_viommu_flags(void *opaque)SMMUState *bs = opaque;SMMUv3State *s =ARM_SMMUV3 (bs); -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) { flags |=VIOMMU_FLAG_PASID_SUPPORTED ; }return flags;@@ -818,6 +818,16 @@ static const PCIIOMMUOps smmuv3_accel_ops = { .get_msi_direct_gpa = smmuv3_accel_get_msi_gpa, }; +static uint8_t ssidsize_mode_to_value (SsidSizeMode mode) +{ +/* SSID_SIZE_MODE_0 = 1, SSID_SIZE_MODE_1 = 2, etc. */ +/* SSID_SIZE_MODE_AUTO = 0 */ +if (mode ==SSID_SIZE_MODE_AUTO ) { +return 0 ; + } +return mode -1 ;/* Enum values are offset by 1 from actual values */ +} +void smmuv3_accel_idr_override (SMMUv3State *s) {if (!s->accel) {@@ -847,7 +857,10 @@ void smmuv3_accel_idr_override(SMMUv3State *s)* By default QEMU SMMUv3 has no SubstreamID support. Update IDR1 if user * has enabled it. */ - s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , s->ssidsize); +if (s->ssidsize !=SSID_SIZE_MODE_AUTO ) { + s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , +ssidsize_mode_to_value (s->ssidsize)); + } }/* Based on SMUUv3 GPBA.ABORT configuration, attach a corresponding HWPT */ hw/arm/smmuv3.c +5
-8@@ -20,6 +20,7 @@#include "qemu/bitops.h" #include "hw/core/irq.h" #include "hw/core/sysbus.h" +#include "hw/core/qdev-properties-system.h" #include "migration/blocker.h" #include "migration/vmstate.h" #include "hw/core/qdev-properties.h" @@ -625,7 +626,7 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, }/* Multiple context descriptors require SubstreamID support */ -if (!s->ssidsize &&STE_S1CDMAX (ste) !=0 ) { +if (s->ssidsize ==SSID_SIZE_MODE_0 &&STE_S1CDMAX (ste) !=0 ) {qemu_log_mask (LOG_UNIMP ,"SMMUv3: multiple S1 context descriptors require SubstreamID support. " "Configure ssidsize > 0 (requires accel=on)\n" );@@ -1984,7 +1985,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS must be 44 bits when accel=off" );return false; } -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) {error_setg (errp,"ssidsize can only be set if accel=on" );return false; }@@ -2002,11 +2003,6 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS can only be set to 44 or 48 bits" );return false; } -if (s->ssidsize >SMMU_SSID_MAX_BITS ) { -error_setg (errp,"ssidsize must be in the range 0 to %d" , -SMMU_SSID_MAX_BITS ); -return false; - }return true; }@@ -2135,7 +2131,8 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), - DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0), +DEFINE_PROP_SSIDSIZE_MODE ("ssidsize" , SMMUv3State, ssidsize, + SSID_SIZE_MODE_0), };static void smmuv3_instance_init (Object *obj)
hw/arm/smmuv3.c static void smmuv3_class_init(ObjectClass *klass, const void *data) · line 2173
Quoted 6 lines
hw/arm/smmuv3.c +1
-2@@ -2173,8 +2170,7 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data)"Number of bits used to represent SubstreamIDs (SSIDs). " "A value of N allows SSIDs in the range [0 .. 2^N - 1]. " "Valid range is 0-20, where 0 disables SubstreamID support. " -"Defaults to 0. A value greater than 0 is required to enable " - "PASID support."); + "A value greater than 0 is required to enable PASID support.");
Why removing "Defaults to 0"?
Quoted 16 lines
hw/arm/smmuv3.c +0
-0} static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,include/hw/arm/smmuv3.h +1
-0@@ -21,6 +21,7 @@#include "hw/arm/smmu-common.h" #include "qom/object.h" +#include "qapi/qapi-types-misc-arm.h" #define TYPE_SMMUV3_IOMMU_MEMORY_REGION "smmuv3-iommu-memory-region"
include/hw/arm/smmuv3.h struct SMMUv3State { · line 79
Quoted 8 lines
include/hw/arm/smmuv3.h +1
-1@@ -72,7 +73,7 @@ struct SMMUv3State {OnOffAuto ril;OnOffAuto ats;uint8_t oas; -uint8_t ssidsize; +SsidSizeMode ssidsize; }; typedef enum {
Thanks
Eric
Re: [PATCH v2 6/8] qdev: Add an OasMode property
In reply to Nathan ChenQuoted 84 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Introduce a new enum type property allowing to set an Output Address Size. Values are auto, 32, 36, 40, 42, 44, 48, 52, and 56, where a value of N specifies an N-bit OAS.
Signed-off-by Nathan Chen <[email protected]>--- hw/core/qdev-properties-system.c | 13 +++++++++++ include/hw/core/qdev-properties-system.h | 3 +++ qapi/misc-arm.json | 28 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+)hw/core/qdev-properties-system.c +13
-0@@ -737,6 +737,19 @@ const PropertyInfo qdev_prop_ssidsize_mode = { .set_default_value = qdev_propinfo_set_default_value_enum, }; +/* --- OasMode --- */ + +QEMU_BUILD_BUG_ON (sizeof (OasMode) !=sizeof (int )); + +const PropertyInfo qdev_prop_oas_mode = { + .type ="OasMode" , + .description ="oas mode: auto, 32, 36, 40, 42, 44, 48, 52, 56" , + .enum_table = &OasMode_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +}; +/* --- Reserved Region --- */ /* include/hw/core/qdev-properties-system.h +3
-0@@ -15,6 +15,7 @@ extern const PropertyInfo qdev_prop_mig_mode;extern const PropertyInfo qdev_prop_granule_mode;extern const PropertyInfo qdev_prop_zero_page_detection;extern const PropertyInfo qdev_prop_ssidsize_mode; +extern const PropertyInfo qdev_prop_oas_mode;extern const PropertyInfo qdev_prop_losttickpolicy;extern const PropertyInfo qdev_prop_blockdev_on_error;extern const PropertyInfo qdev_prop_bios_chs_trans;@@ -64,6 +65,8 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_list; ZeroPageDetection)#define DEFINE_PROP_SSIDSIZE_MODE (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_ssidsize_mode, SsidSizeMode) +#define DEFINE_PROP_OAS_MODE (_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_oas_mode, OasMode)#define DEFINE_PROP_LOSTTICKPOLICY (_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy)qapi/misc-arm.json +18
-0@@ -61,3 +61,31 @@ 'data': [ 'auto', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20' ] } # order matters, see ssid_size_mode_auto() + +## +# @OasMode: +# +# SMMUv3 Output Address Size configuration mode. +# +# @auto: derive from host IOMMU capabilities +# +# @32: 32-bit output address size +# +# @36: 36-bit output address size +# +# @40: 40-bit output address size +# +# @42: 42-bit output address size +# +# @44: 44-bit output address size +#
qapi/misc-arm.json line 91
Quoted 10 lines
qapi/misc-arm.json +10
-0+# @48: 48-bit output address size +# +# @52: 52-bit output address size +# +# @56: 56-bit output address size +# +# Since: 11.0 +## +{ 'enum': 'OasMode', + 'data': [ 'auto', '32', '36', '40', '42', '44', '48', '52', '56' ] }
Eric
Re: [PATCH v2 7/8] hw/arm/smmuv3-accel: Change OAS property to OasMode
In reply to Nathan ChenQuoted 6 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Change accel SMMUv3 OAS property from
uint8_tto OasMode. Setting 'auto' will use the default value of 44 set insmmuv3_init_id_regs(). A future patch will implement resolution of 'auto' value to match the host SMMUv3 OAS value.
Same I think we don't want auto mode to be selectable at the moment. Because then you will change the semantic of the auto mode, returning the host value and not 44 anymore.
Eric
Quoted 68 lines
Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 2 +- hw/arm/smmuv3.c | 9 +++++---- include/hw/arm/smmuv3.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-)hw/arm/smmuv3-accel.c +1
-1@@ -849,7 +849,7 @@ void smmuv3_accel_idr_override(SMMUv3State *s) }/* Advertise 48-bit OAS in IDR5 when requested (default is 44 bits). */ -if (s->oas ==SMMU_OAS_48BIT ) { +if (s->oas ==OAS_MODE_48 ) { s->idr[5 ] =FIELD_DP32 (s->idr[5 ],IDR5 ,OAS ,SMMU_IDR5_OAS_48 ); }hw/arm/smmuv3.c +5
-4@@ -1981,7 +1981,7 @@ 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 !=SMMU_OAS_44BIT ) { +if (s->oas >OAS_MODE_44 ) {error_setg (errp,"OAS must be 44 bits when accel=off" );return false; }@@ -1999,8 +1999,9 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)return false; } -if (s->oas !=SMMU_OAS_44BIT && s->oas !=SMMU_OAS_48BIT ) { -error_setg (errp,"OAS can only be set to 44 or 48 bits" ); +if (s->oas !=OAS_MODE_AUTO && s->oas !=OAS_MODE_44 && + s->oas !=OAS_MODE_48 ) { +error_setg (errp,"OAS can only be set to auto, 44 bits, or 48 bits" );return false; }@@ -2130,7 +2131,7 @@ static const Property smmuv3_properties[] = {/* RIL can be turned off for accel cases */ DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ), -DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), +DEFINE_PROP_OAS_MODE ("oas" , SMMUv3State, oas,OAS_MODE_44 ),DEFINE_PROP_SSIDSIZE_MODE ("ssidsize" , SMMUv3State, ssidsize, SSID_SIZE_MODE_0), };include/hw/arm/smmuv3.h +1
-1@@ -72,7 +72,7 @@ struct SMMUv3State {Error *migration_blocker;OnOffAuto ril;OnOffAuto ats; -uint8_t oas; +OasMode oas;SsidSizeMode ssidsize; };
Re: [PATCH v2 8/8] qemu-options.hx: Document arm-smmuv3 device's accel properties
In reply to Nathan ChenQuoted 19 lines · Nathan Chen
From: Nathan Chen <[email protected]>
Document arm-smmuv3 properties for setting HW-acceleration, Range Invalidation, and Address Translation Services support, as well as setting Output Address size and Substream ID size.
Signed-off-by Nathan Chen <[email protected]>--- qemu-options.hx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)qemu-options.hx +0
-0@@ -1274,13 +1274,40 @@ SRST ``aw-bits=val`` (val between 32 and 64, default depends on machine) This decides the address width of the IOVA address space.
qemu-options.hx SRST · line 1285
Quoted 10 lines
qemu-options.hx +3
-1-``-device arm-smmuv3,primary-bus=id`` +``-device arm-smmuv3,primary-bus=id[,option=...]`` This is only supported by ``-machine virt`` (ARM). ``primary-bus=id`` Accepts either the default root complex (pcie.0) or a pxb-pcie based root complex. + ``accel=on|off`` (default: off) + Enables guest to try to leverage host SMMUv3 features for acceleration.
Enables guest to leverage
qemu-options.hx SRST · line 1286
Quoted 1 line
qemu-options.hx +1
-0+ By default, enabling accel configures the host SMMUv3 in nested mode to
I would remove "By default, "
qemu-options.hx SRST · line 1287
Quoted 1 line
qemu-options.hx +1
-0+ support vfio-pci pass-through.
passthrough
Quoted 16 lines
qemu-options.hx +16
-0+ + ``ril=on|off`` (default: on) + Support for Range Invalidation, which allows the SMMUv3 driver to + invalidate TLB entries for a range of IOVAs at once instead of issuing + separate commands to invalidate each page. Must match with host SMMUv3 + Range Invalidation support. + + ``ats=on|off`` (default: off) + Support for Address Translation Services, which enables PCIe devices to + cache address translations in their local TLB and reduce latency. Host + SMMUv3 must support ATS in order to enable this feature for the vIOMMU. + + ``oas=val`` (supported values are 44 and 48. default: 44) + Sets the Output Address Size in bits. The value set here must be less + than or equal to the host SMMUv3's supported OAS, so that the + intermediate physical addresses (IPA) consumed by host SMMU for stage-2
qemu-options.hx SRST · line 1313
Quoted 10 lines
qemu-options.hx +7
-0+ translation do not exceed the host's max supported IPA size. + + ``ssidsize=val`` (val between 0 and 20. default: 0) + Sets the Substream ID size in bits. When set to a non-zero value, + PASID capability is advertised to the vIOMMU and accelerated use cases + such as Shared Virtual Addressing (SVA) are supported. + ``-device amd-iommu[,option=...]`` Enables emulation of an AMD-Vi I/O Memory Management Unit (IOMMU). Only available with ``-machine q35``, it supports the following options:
Besides,
Eric
Hi Nathan,
Quoted 1 line · Nathan Chen
Hi,
If we want this to be taken in qemu 11.0 you need to clearly indicate that in the series title:
using a subject prefix like "PATCH for-11.0"
Then you need to clearly justify what those patches are fixes for stuff introduced in qemu 11.0, something like:
In qemu 11 we introduced new options for vSMMU but feedbacks received when starting the integration of layered products shows the need for auto/host retrieved values. To avoid breaking JSON/QMP compat, we want to fix the option types so that they can later support the auto mode. At the moment the auto mode is not supported though.
Thanks
Eric
Quoted 65 lines
This is a follow-up to the previous RFC series [0] that introduces support for specifying 'auto' for arm-smmuv3 accelerated mode's ATS, RIL, SSIDSIZE, and OAS feature properties. Based on feedback from the previous mailing list discussion, this refresh only converts the properties to the auto form, keeping the default values from Shameer's HW-accel SMMUv3 series [1]. A future series will introduce support for resolving the 'auto' values based on host SMMUv3 IDR values, as well as setting per-device ATS capability.
When set to 'auto', RIL and OAS will use the defaults set from
smmuv3_init_id_regs()while ATS and SSIDSIZE will remain at the initialized 0 value; i.e. RIL enabled, 44-bit OAS, ATS support disabled, 0-bit SSIDSIZE.A complete branch can be found here:
https://github.com/NathanChenNVIDIA/qemu/tree/smmuv3-accel-auto-v2Please take a look and let me know your feedback.
Thanks,
NathanChanges from RFCv1:
- Remove changes that resolve the 'auto' values based on host SMMUv3
- Restore defaults values for RIL, OAS, SSIDSIZE, and ATS
- Update OasMode to accept all OAS sizes instead of only auto, 44, and 48
- Include comment in SsidSizeMode schema clarifying enum value ordering
- Replace ats-enabled prop with a helper that accepts the dynamic castedTYPE_ARM_SMMUV3object
- Separate out guest vs. host ATS check insmmuv3_accel_check_hw_compatible()to a different commit
- Document accel, RIL, OAS, SSIDSIZE, and ATS properties in qemu-options.hxTesting:
Basic sanity testing was performed on an NVIDIA Grace platform with GPU device assignment and running CUDA test apps on the guest. Additional testing and feedback are welcome.[0] https://lore.kernel.org/qemu-devel/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/Nathan Chen (8):
hw/arm/smmuv3-accel: Check ATS compatibility between host and guest hw/arm/smmuv3-accel: Change ATS property to OnOffAuto hw/arm/smmuv3-accel: Change RIL property to OnOffAuto
qdev: Add a SsidSizeMode property
hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeMode
qdev: Add an OasMode property
hw/arm/smmuv3-accel: Change OAS property to OasMode qemu-options.hx: Document arm-smmuv3 device's accel propertieshw/arm/smmuv3-accel.c | 42 ++++++++++++++++++---- hw/arm/smmuv3.c | 38 ++++++++++---------- hw/arm/virt-acpi-build.c | 2 +- hw/core/qdev-properties-system.c | 27 +++++++++++++++ include/hw/arm/smmuv3.h | 11 +++--- include/hw/core/qdev-properties-system.h | 6 ++++ qapi/misc-arm.json | 44 ++++++++++++++++++++++++ qapi/pragma.json | 1 + qemu-options.hx | 29 +++++++++++++++- 9 files changed, 169 insertions(+), 31 deletions(-)
RE: [PATCH v2 8/8] qemu-options.hx: Document arm-smmuv3 device's accel properties
In reply to Nathan ChenQuoted 48 lines
-----Original Message-----
From: Nathan Chen <[email protected]>
Sent: 12 March 2026 21:03
To: [email protected]; [email protected]
Cc: Eric Auger <[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin <[email protected]>; Igor Mammedov <[email protected]>; Ani Sinha <[email protected]>; Shannon Zhao <[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé <[email protected]>; Eduardo Habkost <[email protected]>; Eric Blake <[email protected]>; Markus Armbruster <[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen <[email protected]>; Matt Ochs <[email protected]>; Nathan Chen <[email protected]>
Subject: [PATCH v2 8/8] qemu-options.hx: Document arm-smmuv3 device's accel propertiesFrom: Nathan Chen <[email protected]>
Document arm-smmuv3 properties for setting HW-acceleration, Range Invalidation, and Address Translation Services support, as well as setting Output Address size and Substream ID size.
Signed-off-by Nathan Chen <[email protected]>--- qemu-options.hx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)qemu-options.hx +4
-1@@ -1274,13 +1274,40 @@ SRST ``aw-bits=val`` (val between 32 and 64, default depends on machine) This decides the address width of the IOVA address space. -``-device arm-smmuv3,primary-bus=id`` +``-device arm-smmuv3,primary-bus=id[,option=...]`` This is only supported by ``-machine virt`` (ARM). ``primary-bus=id`` Accepts either the default root complex (pcie.0) or a pxb-pcie based root complex. + ``accel=on|off`` (default: off) + Enables guest to try to leverage host SMMUv3 features for acceleration. + By default, enabling accel configures the host SMMUv3 in nested mode
Quoted 2 lines
to
+ support vfio-pci pass-through.
It might be worth mentioning that the properties below are only applicable when accel=on.
Also, should we explicitly mention that "auto" is currently not supported?
Thanks,
Shameer
Quoted 31 lines
qemu-options.hx +5
-0+ + ``ril=on|off`` (default: on) + Support for Range Invalidation, which allows the SMMUv3 driver to + invalidate TLB entries for a range of IOVAs at once instead of issuing + separate commands to invalidate each page. Must match with hostSMMUv3
qemu-options.hx +6
-0+ Range Invalidation support. + + ``ats=on|off`` (default: off) + Support for Address Translation Services, which enables PCIe devices to + cache address translations in their local TLB and reduce latency. Host + SMMUv3 must support ATS in order to enable this feature for thevIOMMU.
qemu-options.hx +5
-0+ + ``oas=val`` (supported values are 44 and 48. default: 44) + Sets the Output Address Size in bits. The value set here must be less + than or equal to the host SMMUv3's supported OAS, so that the + intermediate physical addresses (IPA) consumed by host SMMU forstage-2
qemu-options.hx +7
-1+ translation do not exceed the host's max supported IPA size. + + ``ssidsize=val`` (val between 0 and 20. default: 0) + Sets the Substream ID size in bits. When set to a non-zero value, + PASID capability is advertised to the vIOMMU and accelerated use cases + such as Shared Virtual Addressing (SVA) are supported. + ``-device amd-iommu[,option=...]`` Enables emulation of an AMD-Vi I/O Memory Management Unit (IOMMU). Only available with ``-machine q35``, it supports the following options: --2.43.0
RE: [PATCH v2 2/8] hw/arm/smmuv3-accel: Change ATS property to OnOffAuto
In reply to Nathan ChenQuoted 39 lines
-----Original Message-----
From: Nathan Chen <[email protected]>
Sent: 12 March 2026 21:03
To: [email protected]; [email protected]
Cc: Eric Auger <[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin <[email protected]>; Igor Mammedov <[email protected]>; Ani Sinha <[email protected]>; Shannon Zhao <[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé <[email protected]>; Eduardo Habkost <[email protected]>; Eric Blake <[email protected]>; Markus Armbruster <[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen <[email protected]>; Matt Ochs <[email protected]>; Nathan Chen <[email protected]>
Subject: [PATCH v2 2/8] hw/arm/smmuv3-accel: Change ATS property to OnOffAutoFrom: Nathan Chen <[email protected]>
Change accel SMMUv3 ATS property from bool to OnOffAuto. Setting 'auto' will result in the default value being used, i.e. 0 in IDR0 which translates to 'off'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 ATS support.
Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 9 +++++++-- hw/arm/virt-acpi-build.c | 2 +- include/hw/arm/smmuv3.h | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-)hw/arm/smmuv3-accel.c +0
-0@@ -827,8 +827,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */
hw/arm/smmuv3-accel.c void smmuv3_accel_idr_override(SMMUv3State *s) · line 835
Quoted 10 lines
hw/arm/smmuv3-accel.c +6
-2s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); -/* QEMU SMMUv3 has no ATS. Advertise ATS if opt-in by property */ - s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS , s->ats); +/* Only override ATS if user explicitly set ON or OFF */ +if (s->ats ==ON_OFF_AUTO_ON ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,1 ); + }else if (s->ats ==ON_OFF_AUTO_OFF ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,0 ); + }
The else condition is not required as ATS will be set to 0 by default.
Thanks,
Shameer
Quoted 78 lines
hw/arm/smmuv3-accel.c +0
-0/* Advertise 48-bit OAS in IDR5 when requested (default is 44 bits). */ if (s->oas ==SMMU_OAS_48BIT ) {hw/arm/smmuv3.c +6
-1@@ -317,6 +317,11 @@ static void smmuv3_init_id_regs(SMMUv3State *s)smmuv3_accel_idr_override (s); } +bool smmuv3_ats_enabled (SMMUv3State *s) +{ +return FIELD_EX32 (s->idr[0 ],IDR0 ,ATS ); +} +static void smmuv3_reset (SMMUv3State *s) { s->cmdq.base =deposit64 (s->cmdq.base,0 ,5 ,SMMU_CMDQS );@@ -1971,7 +1976,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"ril can only be disabled if accel=on" );return false; } -if (s->ats) { +if (s->ats ==ON_OFF_AUTO_ON ) {error_setg (errp,"ats can only be enabled if accel=on" );return false;}hw/arm/smmuv3.c +1
-1@@ -2128,7 +2133,7 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_UINT64 ("msi-gpa" , SMMUv3State, msi_gpa,0 ),/* RIL can be turned off for accel cases */ DEFINE_PROP_BOOL ("ril" , SMMUv3State, ril, true), - DEFINE_PROP_BOOL("ats", SMMUv3State, ats, false), +DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0),};
hw/arm/virt-acpi-build.c +1
-1@@ -402,7 +402,7 @@ static int iort_smmuv3_devices(Object *obj, void *opaque) bus =PCI_BUS (object_property_get_link (obj,"primary-bus" , &error_abort)); sdev.accel =object_property_get_bool (obj,"accel" , &error_abort); - sdev.ats =object_property_get_bool (obj,"ats" , &error_abort); + sdev.ats =smmuv3_ats_enabled (ARM_SMMUV3 (obj)); pbus =PLATFORM_BUS_DEVICE (vms->platform_bus_dev);sbdev = SYS_BUS_DEVICE(obj); sdev.base = platform_bus_get_mmio_addr(pbus, sbdev, 0);include/hw/arm/smmuv3.h +3
-2@@ -70,7 +70,7 @@ struct SMMUv3State {uint64_t msi_gpa;Error *migration_blocker;bool ril; -bool ats; +OnOffAuto ats;uint8_t oas;uint8_t ssidsize; };@@ -91,6 +91,8 @@ struct SMMUv3Class {ResettablePhases parent_phases; }; +bool smmuv3_ats_enabled (struct SMMUv3State *s); +#define TYPE_ARM_SMMUV3 "arm-smmuv3"OBJECT_DECLARE_TYPE (SMMUv3State, SMMUv3Class,ARM_SMMUV3 ) --2.43.0
RE: [PATCH v2 3/8] hw/arm/smmuv3-accel: Change RIL property to OnOffAuto
In reply to Nathan ChenQuoted 38 lines
-----Original Message-----
From: Nathan Chen <[email protected]>
Sent: 12 March 2026 21:03
To: [email protected]; [email protected]
Cc: Eric Auger <[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin <[email protected]>; Igor Mammedov <[email protected]>; Ani Sinha <[email protected]>; Shannon Zhao <[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé <[email protected]>; Eduardo Habkost <[email protected]>; Eric Blake <[email protected]>; Markus Armbruster <[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen <[email protected]>; Matt Ochs <[email protected]>; Nathan Chen <[email protected]>
Subject: [PATCH v2 3/8] hw/arm/smmuv3-accel: Change RIL property to OnOffAutoFrom: Nathan Chen <[email protected]>
Change accel SMMUv3 RIL property from bool to OnOffAuto. Setting 'auto' will use the default set in
smmuv3_init_id_regs(), i.e. 1 in IDR3 which translates to 'on'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 RIL support.Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 4 ++-- include/hw/arm/smmuv3.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)hw/arm/smmuv3-accel.c +0
-0@@ -824,8 +824,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)return ;
hw/arm/smmuv3-accel.c void smmuv3_accel_idr_override(SMMUv3State *s) · line 832
Quoted 10 lines
hw/arm/smmuv3-accel.c +6
-2} -/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ - s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); +/* Only override RIL if user explicitly set ON or OFF */ +if (s->ril ==ON_OFF_AUTO_ON ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,1 ); + }else if (s->ril ==ON_OFF_AUTO_OFF ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,0 ); + }
Same here. We only need override if RIL is explicitly OFF.
Thanks,
Shameer
Quoted 43 lines
hw/arm/smmuv3-accel.c +0
-0/* Only override ATS if user explicitly set ON or OFF */ if (s->ats ==ON_OFF_AUTO_ON ) {hw/arm/smmuv3.c +1
-1@@ -1972,7 +1972,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)#endif if (!s->accel) { -if (!s->ril) { +if (s->ril ==ON_OFF_AUTO_OFF ) {error_setg (errp,"ril can only be disabled if accel=on" );return false;}hw/arm/smmuv3.c +1
-1@@ -2132,7 +2132,7 @@ static const Property smmuv3_properties[] = {/* GPA of MSI doorbell, for SMMUv3 accel use. */ DEFINE_PROP_UINT64 ("msi-gpa" , SMMUv3State, msi_gpa,0 ),/* RIL can be turned off for accel cases */ - DEFINE_PROP_BOOL("ril", SMMUv3State, ril, true), +DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats, ON_OFF_AUTO_OFF),
DEFINE_PROP_UINT8("oas", SMMUv3State, oas, 44),DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0),include/hw/arm/smmuv3.h +1
-2@@ -69,7 +69,7 @@ struct SMMUv3State {struct SMMUv3AccelState *s_accel;uint64_t msi_gpa;Error *migration_blocker; -bool ril; +OnOffAuto ril;OnOffAuto ats;uint8_t oas;uint8_t ssidsize; --2.43.0
RE: [PATCH v2 5/8] hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeMode
In reply to Nathan ChenQuoted 49 lines
-----Original Message-----
From: Nathan Chen <[email protected]>
Sent: 12 March 2026 21:03
To: [email protected]; [email protected]
Cc: Eric Auger <[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin <[email protected]>; Igor Mammedov <[email protected]>; Ani Sinha <[email protected]>; Shannon Zhao <[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé <[email protected]>; Eduardo Habkost <[email protected]>; Eric Blake <[email protected]>; Markus Armbruster <[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen <[email protected]>; Matt Ochs <[email protected]>; Nathan Chen <[email protected]>
Subject: [PATCH v2 5/8] hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeModeFrom: Nathan Chen <[email protected]>
Change accel SMMUv3 SSIDSIZE property from
uint8_tto SsidSizeMode. Setting 'auto' will use the default value, i.e. 0 in IDR1. A future patch will implement resolution of 'auto' value to match the host SMMUv3 SSIDSIZE value.Signed-off-by Nathan Chen <[email protected]>--- hw/arm/smmuv3-accel.c | 17 +++++++++++++++-- hw/arm/smmuv3.c | 16 ++++++---------- include/hw/arm/smmuv3.h | 3 ++- 3 files changed, 23 insertions(+), 13 deletions(-)hw/arm/smmuv3-accel.c +1
-1@@ -803,7 +803,7 @@ static uint64_tsmmuv3_accel_get_viommu_flags (void *opaque) SMMUState *bs = opaque;SMMUv3State *s =ARM_SMMUV3 (bs); -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) { flags |=VIOMMU_FLAG_PASID_SUPPORTED ; }return flags;hw/arm/smmuv3-accel.c +0
-0@@ -818,6 +818,16 @@ static const PCIIOMMUOps smmuv3_accel_ops = { .get_msi_direct_gpa = smmuv3_accel_get_msi_gpa, };
hw/arm/smmuv3-accel.c static const PCIIOMMUOps smmuv3_accel_ops = { · line 829
Quoted 10 lines
hw/arm/smmuv3-accel.c +9
-0+static uint8_t ssidsize_mode_to_value (SsidSizeMode mode) +{ +/* SSID_SIZE_MODE_0 = 1, SSID_SIZE_MODE_1 = 2, etc. */ +/* SSID_SIZE_MODE_AUTO = 0 */ +if (mode ==SSID_SIZE_MODE_AUTO ) { +return 0 ; + } +return mode -1 ;/* Enum values are offset by 1 from actual values */ +}
Maybe better to consolidate these comments and move them to a function level block comment above.
Thanks,
Shameer
Quoted 111 lines
hw/arm/smmuv3-accel.c +1
-0+void smmuv3_accel_idr_override (SMMUv3State *s) {if (!s->accel) {@@ -847,7 +857,10 @@ void smmuv3_accel_idr_override(SMMUv3State *s)* By default QEMU SMMUv3 has no SubstreamID support. Update IDR1 if user
* has enabled it.
*/hw/arm/smmuv3-accel.c +4
-1- s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , s->ssidsize); +if (s->ssidsize !=SSID_SIZE_MODE_AUTO ) { + s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , +ssidsize_mode_to_value (s->ssidsize)); + } }/* Based on SMUUv3 GPBA.ABORT configuration, attach a corresponding HWPT */
hw/arm/smmuv3.c +2
-1@@ -20,6 +20,7 @@#include "qemu/bitops.h" #include "hw/core/irq.h" #include "hw/core/sysbus.h" +#include "hw/core/qdev-properties-system.h" #include "migration/blocker.h" #include "migration/vmstate.h" #include "hw/core/qdev-properties.h" @@ -625,7 +626,7 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, }/* Multiple context descriptors require SubstreamID support */ -if (!s->ssidsize &&STE_S1CDMAX (ste) !=0 ) { +if (s->ssidsize ==SSID_SIZE_MODE_0 &&STE_S1CDMAX (ste) !=0 ) { qemu_log_mask(LOG_UNIMP, "SMMUv3: multiple S1 context descriptors require SubstreamIDsupport. "
"Configure ssidsize > 0 (requires accel=on)\n");hw/arm/smmuv3.c +1
-1@@ -1984,7 +1985,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS must be 44 bits when accel=off" );return false; } -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) {error_setg (errp,"ssidsize can only be set if accel=on" );return false;}hw/arm/smmuv3.c +0
-5@@ -2002,11 +2003,6 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS can only be set to 44 or 48 bits" );return false; } -if (s->ssidsize >SMMU_SSID_MAX_BITS ) { -error_setg (errp,"ssidsize must be in the range 0 to %d" , -SMMU_SSID_MAX_BITS ); -return false; - }return true;}
hw/arm/smmuv3.c +2
-1@@ -2135,7 +2131,8 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), - DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0), +DEFINE_PROP_SSIDSIZE_MODE ("ssidsize" , SMMUv3State, ssidsize, + SSID_SIZE_MODE_0), };static void
smmuv3_instance_init(Object *obj)hw/arm/smmuv3.c +1
-2@@ -2173,8 +2170,7 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data)"Number of bits used to represent SubstreamIDs (SSIDs). " "A value of N allows SSIDs in the range [0 .. 2^N - 1]. " "Valid range is 0-20, where 0 disables SubstreamID support. " -"Defaults to 0. A value greater than 0 is required to enable " - "PASID support."); + "A value greater than 0 is required to enable PASID support."); }static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
include/hw/arm/smmuv3.h +1
-0@@ -21,6 +21,7 @@#include "hw/arm/smmu-common.h" #include "qom/object.h" +#include "qapi/qapi-types-misc-arm.h" #define TYPE_SMMUV3_IOMMU_MEMORY_REGION "smmuv3-iommu-memory-region"
include/hw/arm/smmuv3.h +1
-2@@ -72,7 +73,7 @@ struct SMMUv3State {OnOffAuto ril;OnOffAuto ats;uint8_t oas; -uint8_t ssidsize; +SsidSizeMode ssidsize; }; typedef enum { --2.43.0
Quoted 10 lines · Eric Auger
Hi Nathan,
Quoted 1 line · Nathan Chen
Hi,
If we want this to be taken in qemu 11.0 you need to clearly indicate that in the series title:
using a subject prefix like "PATCH for-11.0"
Quoted 8 lines
Then you need to clearly justify what those patches are fixes for stuff introduced in qemu 11.0, something like:
In qemu 11 we introduced new options for vSMMU but feedbacks received when starting the integration of layered products shows the need for auto/host retrieved values. To avoid breaking JSON/QMP compat, we want to fix the option types so that they can later support the auto mode. At the moment the auto mode is not supported though.
Yes. At the moment this is on my "look at it for 11.1" pile. If you want it in 11.0 then it must very clearly state the justfication (i.e. why it is not new feature work) and be as small as possible to achieve its aim.
-- PMM
Re: [PATCH v2 1/8] hw/arm/smmuv3-accel: Check ATS compatibility between host and guest
In reply to Eric AugerHi Eric,
Quoted 10 lines · Eric Auger
Hi Nathan,
Quoted 5 lines · Nathan Chen
From: Nathan Chen<[email protected]>
Compare the host SMMUv3 ATS support bit with the guest SMMUv3 ATS support bit in IDR0 and fail the compatibility check if ATS support is opted as enabled on the guest SMMUv3 when it is not supported on host SMMUv3.
Miss
Fixes f7f5013a55a3 ("hw/arm/smmuv3-accel: Add support for ATS")
I'll include this in the next refresh.
Quoted 5 lines
Quoted 5 lines
Signed-off-by Nathan Chen<[email protected]>--- hw/arm/smmuv3-accel.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 15 lines
hw/arm/smmuv3-accel.c smmuv3_accel_check_hw_compatible(SMMUv3State *s, · line 108
Quoted 13 lines
hw/arm/smmuv3-accel.c +5
-0@@ -101,6 +101,13 @@ smmuv3_accel_check_hw_compatible(SMMUv3State *s, smmuv3_oas_bits(FIELD_EX32(s->idr[5], IDR5, OAS)));return false; } +/* Check ATS value opted is compatible with Host SMMUv3 */ +if (FIELD_EX32 (info->idr[0 ],IDR0 ,ATS ) < +FIELD_EX32 (s->idr[0 ],IDR0 ,ATS )) { +error_setg (errp,"Host SMMUv3 doesn't support Address Translation" +" Services" );I think you can keep it on the same line. Checkpatch will just issue a warning.
Ok, I will put this on the same line.
Quoted 7 lines
hw/arm/smmuv3-accel.c smmuv3_accel_check_hw_compatible(SMMUv3State *s, · line 113
Quoted 5 lines
hw/arm/smmuv3-accel.c +2
-0+return false; + }/* QEMU SMMUv3 supports GRAN4K/GRAN16K/GRAN64K translation granules */ if (FIELD_EX32(info->idr[5], IDR5, GRAN4K) !=Otherwise
Reviewed-by Eric Auger<[email protected]>
Thanks for the feedback and R-by!
Nathan
Re: [PATCH v2 2/8] hw/arm/smmuv3-accel: Change ATS property to OnOffAuto
In reply to Eric AugerHi Eric,
Quoted 5 lines · Eric Auger
Hi Nathan,
Quoted 2 lines · Nathan Chen
From: Nathan Chen<[email protected]>
Quoted 7 lines
Quoted 4 lines
Change accel SMMUv3 ATS property from bool to OnOffAuto. Setting 'auto' will result in the default value being used, i.e. 0 in IDR0 which translates to 'off'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 ATS support.
i.e. 0 in IDR0 which translates to 'off': this is unclear to me what you want to say.
I would clearly state here that at the moment the auto value is not implemented. This is just to get the property right and do not break JSON/QMP when getting the auto mode introduced. Also I think you want to enforce that in the code, ie. the end user is not trying to set to AUTO.
That makes sense, in the next refresh I will enforce not setting auto for these properties and reflect that in the commit messages.
Thanks,
Nathan
Re: [PATCH v2 5/8] hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeMode
In reply to Eric AugerQuoted 9 lines · Eric Auger
Quoted 6 lines · Nathan Chen
From: Nathan Chen<[email protected]>
Change accel SMMUv3 SSIDSIZE property from
uint8_tto SsidSizeMode. Setting 'auto' will use the default value, i.e. 0 in IDR1. A future patch will implement resolution of 'auto' value to match the host SMMUv3 SSIDSIZE value.At the moment we need to reject auto setting as it is not supported
I will enforce rejecting auto setting for this and the other properties in the next refresh.
Quoted 100 lines
Quoted 100 lines
Signed-off-by Nathan Chen<[email protected]>--- hw/arm/smmuv3-accel.c | 17 +++++++++++++++-- hw/arm/smmuv3.c | 16 ++++++---------- include/hw/arm/smmuv3.h | 3 ++- 3 files changed, 23 insertions(+), 13 deletions(-)hw/arm/smmuv3-accel.c +15
-2@@ -803,7 +803,7 @@ static uint64_t smmuv3_accel_get_viommu_flags(void *opaque)SMMUState *bs = opaque;SMMUv3State *s =ARM_SMMUV3 (bs); -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) { flags |=VIOMMU_FLAG_PASID_SUPPORTED ; }return flags;@@ -818,6 +818,16 @@ static const PCIIOMMUOps smmuv3_accel_ops = { .get_msi_direct_gpa = smmuv3_accel_get_msi_gpa, }; +static uint8_t ssidsize_mode_to_value (SsidSizeMode mode) +{ +/* SSID_SIZE_MODE_0 = 1, SSID_SIZE_MODE_1 = 2, etc. */ +/* SSID_SIZE_MODE_AUTO = 0 */ +if (mode ==SSID_SIZE_MODE_AUTO ) { +return 0 ; + } +return mode -1 ;/* Enum values are offset by 1 from actual values */ +} +void smmuv3_accel_idr_override (SMMUv3State *s) {if (!s->accel) {@@ -847,7 +857,10 @@ void smmuv3_accel_idr_override(SMMUv3State *s)* By default QEMU SMMUv3 has no SubstreamID support. Update IDR1 if user * has enabled it. */ - s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , s->ssidsize); +if (s->ssidsize !=SSID_SIZE_MODE_AUTO ) { + s->idr[1 ] =FIELD_DP32 (s->idr[1 ],IDR1 ,SSIDSIZE , +ssidsize_mode_to_value (s->ssidsize)); + } }/* Based on SMUUv3 GPBA.ABORT configuration, attach a corresponding HWPT */ hw/arm/smmuv3.c +5
-8@@ -20,6 +20,7 @@#include "qemu/bitops.h" #include "hw/core/irq.h" #include "hw/core/sysbus.h" +#include "hw/core/qdev-properties-system.h" #include "migration/blocker.h" #include "migration/vmstate.h" #include "hw/core/qdev-properties.h" @@ -625,7 +626,7 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, }/* Multiple context descriptors require SubstreamID support */ -if (!s->ssidsize &&STE_S1CDMAX (ste) !=0 ) { +if (s->ssidsize ==SSID_SIZE_MODE_0 &&STE_S1CDMAX (ste) !=0 ) {qemu_log_mask (LOG_UNIMP ,"SMMUv3: multiple S1 context descriptors require SubstreamID support. " "Configure ssidsize > 0 (requires accel=on)\n" );@@ -1984,7 +1985,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS must be 44 bits when accel=off" );return false; } -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) {error_setg (errp,"ssidsize can only be set if accel=on" );return false; }@@ -2002,11 +2003,6 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)error_setg (errp,"OAS can only be set to 44 or 48 bits" );return false; } -if (s->ssidsize >SMMU_SSID_MAX_BITS ) { -error_setg (errp,"ssidsize must be in the range 0 to %d" , -SMMU_SSID_MAX_BITS ); -return false; - }return true; }@@ -2135,7 +2131,8 @@ static const Property smmuv3_properties[] = {DEFINE_PROP_ON_OFF_AUTO ("ril" , SMMUv3State, ril,ON_OFF_AUTO_ON ),DEFINE_PROP_ON_OFF_AUTO ("ats" , SMMUv3State, ats,ON_OFF_AUTO_OFF ),DEFINE_PROP_UINT8 ("oas" , SMMUv3State, oas,44 ), - DEFINE_PROP_UINT8("ssidsize", SMMUv3State, ssidsize, 0), +DEFINE_PROP_SSIDSIZE_MODE ("ssidsize" , SMMUv3State, ssidsize, + SSID_SIZE_MODE_0), };
Quoted 9 lines
hw/arm/smmuv3.c static void smmuv3_class_init(ObjectClass *klass, const void *data) · line 2173
Quoted 8 lines
hw/arm/smmuv3.c +1
-2static void smmuv3_instance_init (Object *obj)@@ -2173,8 +2170,7 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data)"Number of bits used to represent SubstreamIDs (SSIDs). " "A value of N allows SSIDs in the range [0 .. 2^N - 1]. " "Valid range is 0-20, where 0 disables SubstreamID support. " -"Defaults to 0. A value greater than 0 is required to enable " - "PASID support."); + "A value greater than 0 is required to enable PASID support.");Why removing "Defaults to 0"?
This was left over from the v1 RFC. I will fix this in the next refresh.
Thanks,
Nathan
Re: [PATCH v2 8/8] qemu-options.hx: Document arm-smmuv3 device's accel properties
In reply to Shameer Kolothum ThodiQuoted 52 lines · Shameer Kolothum Thodi
Quoted 47 lines
-----Original Message-----
From: Nathan Chen<[email protected]>
Sent: 12 March 2026 21:03 To:[email protected];[email protected]
Cc: Eric Auger<[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin<[email protected]>; Igor Mammedov<[email protected]>; Ani Sinha<[email protected]>; Shannon Zhao<[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé<[email protected]>; Eduardo Habkost<[email protected]>; Eric Blake<[email protected]>; Markus Armbruster<[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen<[email protected]>; Matt Ochs<[email protected]>; Nathan Chen<[email protected]>
Subject: [PATCH v2 8/8] qemu-options.hx: Document arm-smmuv3 device's accel propertiesFrom: Nathan Chen<[email protected]>
Document arm-smmuv3 properties for setting HW-acceleration, Range Invalidation, and Address Translation Services support, as well as setting Output Address size and Substream ID size.
Signed-off-by Nathan Chen<[email protected]>--- qemu-options.hx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)qemu-options.hx +4
-1@@ -1274,13 +1274,40 @@ SRST ``aw-bits=val`` (val between 32 and 64, default depends on machine) This decides the address width of the IOVA address space. -``-device arm-smmuv3,primary-bus=id`` +``-device arm-smmuv3,primary-bus=id[,option=...]`` This is only supported by ``-machine virt`` (ARM). ``primary-bus=id`` Accepts either the default root complex (pcie.0) or a pxb-pcie based root complex. + ``accel=on|off`` (default: off) + Enables guest to try to leverage host SMMUv3 features for acceleration. + By default, enabling accel configures the host SMMUv3 in nested modeQuoted 2 lines
to
+ support vfio-pci pass-through.It might be worth mentioning that the properties below are only applicable when accel=on.
Quoted 2 lines
Also, should we explicitly mention that "auto" is currently not supported?
Yes, I will mention accel=on being a requirement and call out that "auto" is currently not supported.
Thanks,
Nathan
Re: [PATCH v2 2/8] hw/arm/smmuv3-accel: Change ATS property to OnOffAuto
In reply to Shameer Kolothum ThodiQuoted 40 lines · Shameer Kolothum Thodi
Quoted 40 lines
-----Original Message-----
From: Nathan Chen<[email protected]>
Sent: 12 March 2026 21:03 To:[email protected];[email protected]
Cc: Eric Auger<[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin<[email protected]>; Igor Mammedov<[email protected]>; Ani Sinha<[email protected]>; Shannon Zhao<[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé<[email protected]>; Eduardo Habkost<[email protected]>; Eric Blake<[email protected]>; Markus Armbruster<[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen<[email protected]>; Matt Ochs<[email protected]>; Nathan Chen<[email protected]>
Subject: [PATCH v2 2/8] hw/arm/smmuv3-accel: Change ATS property to OnOffAutoFrom: Nathan Chen<[email protected]>
Change accel SMMUv3 ATS property from bool to OnOffAuto. Setting 'auto' will result in the default value being used, i.e. 0 in IDR0 which translates to 'off'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 ATS support.
Signed-off-by Nathan Chen<[email protected]>--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 9 +++++++-- hw/arm/virt-acpi-build.c | 2 +- include/hw/arm/smmuv3.h | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-)hw/arm/smmuv3-accel.c +0
-0@@ -827,8 +827,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril);
Quoted 9 lines
hw/arm/smmuv3-accel.c void smmuv3_accel_idr_override(SMMUv3State *s) · line 835
Quoted 8 lines
hw/arm/smmuv3-accel.c +6
-2-/* QEMU SMMUv3 has no ATS. Advertise ATS if opt-in by property */ - s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS , s->ats); +/* Only override ATS if user explicitly set ON or OFF */ +if (s->ats ==ON_OFF_AUTO_ON ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,1 ); + }else if (s->ats ==ON_OFF_AUTO_OFF ) { + s->idr[0 ] =FIELD_DP32 (s->idr[0 ],IDR0 ,ATS ,0 ); + }The else condition is not required as ATS will be set to 0 by default.
I see, I will remove the else condition here.
Thanks,
Nathan
Re: [PATCH v2 3/8] hw/arm/smmuv3-accel: Change RIL property to OnOffAuto
In reply to Shameer Kolothum ThodiQuoted 39 lines · Shameer Kolothum Thodi
Quoted 39 lines
-----Original Message-----
From: Nathan Chen<[email protected]>
Sent: 12 March 2026 21:03 To:[email protected];[email protected]
Cc: Eric Auger<[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin<[email protected]>; Igor Mammedov<[email protected]>; Ani Sinha<[email protected]>; Shannon Zhao<[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé<[email protected]>; Eduardo Habkost<[email protected]>; Eric Blake<[email protected]>; Markus Armbruster<[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen<[email protected]>; Matt Ochs<[email protected]>; Nathan Chen<[email protected]>
Subject: [PATCH v2 3/8] hw/arm/smmuv3-accel: Change RIL property to OnOffAutoFrom: Nathan Chen<[email protected]>
Change accel SMMUv3 RIL property from bool to OnOffAuto. Setting 'auto' will use the default set in
smmuv3_init_id_regs(), i.e. 1 in IDR3 which translates to 'on'. A future patch will implement resolution of 'auto' value to match the host SMMUv3 RIL support.Signed-off-by Nathan Chen<[email protected]>--- hw/arm/smmuv3-accel.c | 8 ++++++-- hw/arm/smmuv3.c | 4 ++-- include/hw/arm/smmuv3.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)hw/arm/smmuv3-accel.c +0
-0@@ -824,8 +824,12 @@ void smmuv3_accel_idr_override(SMMUv3State *s)return ; }
Quoted 9 lines
hw/arm/smmuv3-accel.c void smmuv3_accel_idr_override(SMMUv3State *s) · line 832
Quoted 8 lines
hw/arm/smmuv3-accel.c +6
-2-/* By default QEMU SMMUv3 has RIL. Update IDR3 if user has disabled it */ - s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL , s->ril); +/* Only override RIL if user explicitly set ON or OFF */ +if (s->ril ==ON_OFF_AUTO_ON ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,1 ); + }else if (s->ril ==ON_OFF_AUTO_OFF ) { + s->idr[3 ] =FIELD_DP32 (s->idr[3 ],IDR3 ,RIL ,0 ); + }Same here. We only need override if RIL is explicitly OFF.
Ok, I will remove the condition for setting it to ON.
Thanks,
Nathan
Re: [PATCH v2 5/8] hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeMode
In reply to Shameer Kolothum ThodiQuoted 49 lines · Shameer Kolothum Thodi
Quoted 49 lines
-----Original Message-----
From: Nathan Chen<[email protected]>
Sent: 12 March 2026 21:03 To:[email protected];[email protected]
Cc: Eric Auger<[email protected]>; Peter Maydell <[email protected]>; Michael S . Tsirkin<[email protected]>; Igor Mammedov<[email protected]>; Ani Sinha<[email protected]>; Shannon Zhao<[email protected]>; Paolo Bonzini <[email protected]>; Daniel P . Berrangé<[email protected]>; Eduardo Habkost<[email protected]>; Eric Blake<[email protected]>; Markus Armbruster<[email protected]>; Shameer Kolothum Thodi <[email protected]>; Nicolin Chen<[email protected]>; Matt Ochs<[email protected]>; Nathan Chen<[email protected]>
Subject: [PATCH v2 5/8] hw/arm/smmuv3-accel: Change SSIDSIZE property to SsidSizeModeFrom: Nathan Chen<[email protected]>
Change accel SMMUv3 SSIDSIZE property from
uint8_tto SsidSizeMode. Setting 'auto' will use the default value, i.e. 0 in IDR1. A future patch will implement resolution of 'auto' value to match the host SMMUv3 SSIDSIZE value.Signed-off-by Nathan Chen<[email protected]>--- hw/arm/smmuv3-accel.c | 17 +++++++++++++++-- hw/arm/smmuv3.c | 16 ++++++---------- include/hw/arm/smmuv3.h | 3 ++- 3 files changed, 23 insertions(+), 13 deletions(-)hw/arm/smmuv3-accel.c +1
-1@@ -803,7 +803,7 @@ static uint64_tsmmuv3_accel_get_viommu_flags (void *opaque) SMMUState *bs = opaque;SMMUv3State *s =ARM_SMMUV3 (bs); -if (s->ssidsize) { +if (s->ssidsize >SSID_SIZE_MODE_0 ) { flags |=VIOMMU_FLAG_PASID_SUPPORTED ; }return flags;hw/arm/smmuv3-accel.c +0
-0@@ -818,6 +818,16 @@ static const PCIIOMMUOps smmuv3_accel_ops = { .get_msi_direct_gpa = smmuv3_accel_get_msi_gpa, };
Quoted 11 lines
hw/arm/smmuv3-accel.c static const PCIIOMMUOps smmuv3_accel_ops = { · line 829
Quoted 9 lines
hw/arm/smmuv3-accel.c +9
-0+static uint8_t ssidsize_mode_to_value (SsidSizeMode mode) +{ +/* SSID_SIZE_MODE_0 = 1, SSID_SIZE_MODE_1 = 2, etc. */ +/* SSID_SIZE_MODE_AUTO = 0 */ +if (mode ==SSID_SIZE_MODE_AUTO ) { +return 0 ; + } +return mode -1 ;/* Enum values are offset by 1 from actual values */ +}Maybe better to consolidate these comments and move them to a function level block comment above.
Yes, I will move it above and include more details about the function implementation in the block comment.
Thanks,
Nathan
Hi,
Quoted 17 lines · Peter Maydell
Quoted 8 lines · Eric Auger
Hi Nathan,
Quoted 1 line · Nathan Chen
Hi,
If we want this to be taken in qemu 11.0 you need to clearly indicate that in the series title:
using a subject prefix like "PATCH for-11.0"Quoted 8 lines
Then you need to clearly justify what those patches are fixes for stuff introduced in qemu 11.0, something like:
In qemu 11 we introduced new options for vSMMU but feedbacks received when starting the integration of layered products shows the need for auto/host retrieved values. To avoid breaking JSON/QMP compat, we want to fix the option types so that they can later support the auto mode. At the moment the auto mode is not supported though.
Quoted 4 lines
Yes. At the moment this is on my "look at it for 11.1" pile. If you want it in 11.0 then it must very clearly state the justfication (i.e. why it is not new feature work) and be as small as possible to achieve its aim.
I see, I will send out another revision today with the correct prefix and justification for belonging in 11.0. I will keep these guidelines in mind for the future.
Thanks,
Nathan