From: Nathan Chen <nathanc@nvidia.com>
Allow accelerated SMMUv3 SSID size property to be derived from host
IOMMU capabilities. Derive host values using IOMMU_GET_HW_INFO,
retrieving SSID size from IDR1. When the auto SSID size is resolved
to a non-zero value, PASID capability is advertised to the vIOMMU
and accelerated use cases such as Shared Virtual Addressing (SVA)
are supported.
Signed-off-by: Nathan Chen <nathanc@nvidia.com>
---
hw/arm/smmuv3-accel.c | 14 ++++++++++++--
hw/arm/smmuv3.c | 11 +++++------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c
index 9e7ec6a930..03393fd7ba 100644
--- a/hw/arm/smmuv3-accel.c
+++ b/hw/arm/smmuv3-accel.c
@@ -56,6 +56,13 @@ static void smmuv3_accel_auto_finalise(SMMUv3State *s,
FIELD_EX32(info->idr[3], IDR3, RIL));
}
+ /* Update SSIDSIZE if auto from info */
+ if (s->ssidsize == SSID_SIZE_MODE_AUTO) {
+ /* Store for get_viommu_flags() to determine PASID support */
+ s->idr[1] = FIELD_DP32(s->idr[1], IDR1, SSIDSIZE,
+ FIELD_EX32(info->idr[1], IDR1, SSIDSIZE));
+ }
+
accel->auto_finalised = true;
}
@@ -828,7 +835,9 @@ static uint64_t smmuv3_accel_get_viommu_flags(void *opaque)
SMMUState *bs = opaque;
SMMUv3State *s = ARM_SMMUV3(bs);
- if (s->ssidsize > SSID_SIZE_MODE_0) {
+ if (s->ssidsize > SSID_SIZE_MODE_0 ||
+ (s->ssidsize == SSID_SIZE_MODE_AUTO &&
+ FIELD_EX32(s->idr[1], IDR1, SSIDSIZE))) {
flags |= VIOMMU_FLAG_PASID_SUPPORTED;
}
return flags;
@@ -952,7 +961,8 @@ void smmuv3_accel_init(SMMUv3State *s)
smmuv3_accel_as_init(s);
if (s->ats == ON_OFF_AUTO_AUTO ||
- s->ril == ON_OFF_AUTO_AUTO) {
+ s->ril == ON_OFF_AUTO_AUTO ||
+ s->ssidsize == SSID_SIZE_MODE_AUTO) {
s->s_accel->auto_mode = true;
}
}
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 74cc81ae32..67c499d22b 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -627,7 +627,10 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
}
/* Multiple context descriptors require SubstreamID support */
- if (s->ssidsize == SSID_SIZE_MODE_0 && STE_S1CDMAX(ste) != 0) {
+ if ((s->ssidsize == SSID_SIZE_MODE_0 ||
+ (s->ssidsize == SSID_SIZE_MODE_AUTO &&
+ !FIELD_EX32(s->idr[1], IDR1, SSIDSIZE))) &&
+ STE_S1CDMAX(ste) != 0) {
qemu_log_mask(LOG_UNIMP,
"SMMUv3: multiple S1 context descriptors require SubstreamID support. "
"Configure ssidsize > 0 (requires accel=on)\n");
@@ -1973,10 +1976,6 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp)
}
#endif
- if (s->ssidsize == SSID_SIZE_MODE_AUTO) {
- error_setg(errp, "ssidsize auto mode is not supported");
- return false;
- }
if (s->oas != OAS_MODE_44 && s->oas != OAS_MODE_48) {
error_setg(errp, "QEMU SMMUv3 model only implements 44 and 48 bit"
"OAS; other OasMode values are not supported");
@@ -2197,7 +2196,7 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data)
"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. ssidsize=auto is not supported.");
+ "PASID support.");
}
static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
--
2.43.0