From: Nathan Chen <[email protected]> Allow accelerated SMMUv3 OAS property to be derived from host IOMMU capabilities. Derive host values using IOMMU_GET_HW_INFO, retrieving OAS from IDR5.
This keeps the OAS value advertised by the virtual SMMU compatible with the capabilities of the host SMMUv3, 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. Reviewed-by: Eric Auger <[email protected]> Signed-off-by: Nathan Chen <[email protected]> --- hw/arm/smmuv3-accel.c | 8 +++++++- hw/arm/smmuv3.c | 15 ++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c index 5b1af062ee..05257f74ed 100644 --- a/hw/arm/smmuv3-accel.c +++ b/hw/arm/smmuv3-accel.c @@ -68,6 +68,11 @@ static void smmuv3_accel_auto_finalise(SMMUv3State *s, FIELD_EX32(info->idr[1], IDR1, SSIDSIZE)); } + if (s->oas == OAS_MODE_AUTO) { + s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, + FIELD_EX32(info->idr[5], IDR5, OAS)); + } + accel->auto_finalised = true; } @@ -989,7 +994,8 @@ bool smmuv3_accel_init(SMMUv3State *s, Error **errp) if (s->ats == ON_OFF_AUTO_AUTO || s->ril == ON_OFF_AUTO_AUTO || - s->ssidsize == SSID_SIZE_MODE_AUTO) { + s->ssidsize == SSID_SIZE_MODE_AUTO || + s->oas == OAS_MODE_AUTO) { s->s_accel->auto_mode = true; } diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index cd30275717..31c2eec2f4 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1968,9 +1968,11 @@ static void smmu_reset_exit(Object *obj, ResetType type) static bool smmu_validate_property(SMMUv3State *s, Error **errp) { - 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"); + if (s->oas != OAS_MODE_44 && s->oas != OAS_MODE_48 && + s->oas != OAS_MODE_AUTO) { + error_setg(errp, "QEMU SMMUv3 model only implements auto, " + "44 bit, or 48 bit OAS. Other OasMode values are " + "not supported."); return false; } @@ -1984,7 +1986,7 @@ static bool smmu_validate_property(SMMUv3State *s, Error **errp) return false; } if (s->oas > OAS_MODE_44) { - error_setg(errp, "OAS must be 44 bits when accel=off"); + error_setg(errp, "oas must be 44 bits when accel=off"); return false; } if (s->ssidsize > SSID_SIZE_MODE_0) { @@ -2169,9 +2171,8 @@ static void smmuv3_class_init(ObjectClass *klass, const void *data) "Please ensure host platform supports ATS before setting it " "to on."); 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. oas=auto is not " - "supported."); + "Set Output Address Size in bits (for accel=on). " + "Valid values are 44, 48, and auto. Defaults to 44 bits."); object_class_property_set_description(klass, "ssidsize", "Set number of bits used to represent SubstreamIDs (SSIDs). " "Valid values are 0-20 and auto. Defaults to 0. " -- 2.43.0
