[PATCH v16 24/26] whpx: arm64: check for physical address width after WHPX availability

Mohamed Mediouni posted 26 patches 3 weeks, 2 days ago
Maintainers: Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>, Pedro Barbuda <pbarbuda@microsoft.com>, Mohamed Mediouni <mohamed@unpredictable.fr>, Peter Maydell <peter.maydell@linaro.org>, Shannon Zhao <shannon.zhaosl@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Alexander Graf <agraf@csgraf.de>
There is a newer version of this series
[PATCH v16 24/26] whpx: arm64: check for physical address width after WHPX availability
Posted by Mohamed Mediouni 3 weeks, 2 days ago
In the case where WHPX isn't supported on the platform, makes the
intended error appear instead of failing at getting the IPA width.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/arm/whpx/whpx-all.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c
index 3329deeb57..79e9065d3a 100644
--- a/target/arm/whpx/whpx-all.c
+++ b/target/arm/whpx/whpx-all.c
@@ -654,7 +654,7 @@ uint32_t whpx_arm_get_ipa_bit_size(void)
         WHvCapabilityCodePhysicalAddressWidth, &whpx_cap,
         sizeof(whpx_cap), &whpx_cap_size);
     if (FAILED(hr)) {
-        error_report("WHPX: failed to get supported"
+        error_report("WHPX: failed to get supported "
              "physical address width, hr=%08lx", hr);
     }
 
@@ -874,15 +874,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
         goto error;
     }
 
-    if (mc->get_physical_address_range) {
-        pa_range = mc->get_physical_address_range(ms,
-            whpx_arm_get_ipa_bit_size(), whpx_arm_get_ipa_bit_size());
-        if (pa_range < 0) {
-            ret = -EINVAL;
-            goto error;
-        }
-    }
-
     whpx->mem_quota = ms->ram_size;
 
     hr = whp_dispatch.WHvGetCapability(
@@ -910,6 +901,14 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
         goto error;
     }
 
+    if (mc->get_physical_address_range) {
+        pa_range = mc->get_physical_address_range(ms,
+            whpx_arm_get_ipa_bit_size(), whpx_arm_get_ipa_bit_size());
+        if (pa_range < 0) {
+            return -EINVAL;
+        }
+    }
+
     hr = whp_dispatch.WHvCreatePartition(&whpx->partition);
     if (FAILED(hr)) {
         error_report("WHPX: Failed to create partition, hr=%08lx", hr);
-- 
2.50.1 (Apple Git-155)
Re: [PATCH v16 24/26] whpx: arm64: check for physical address width after WHPX availability
Posted by Philippe Mathieu-Daudé 2 weeks, 5 days ago
On 16/1/26 14:52, Mohamed Mediouni wrote:
> In the case where WHPX isn't supported on the platform, makes the
> intended error appear instead of failing at getting the IPA width.
> 
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/whpx/whpx-all.c | 19 +++++++++----------
>   1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c
> index 3329deeb57..79e9065d3a 100644
> --- a/target/arm/whpx/whpx-all.c
> +++ b/target/arm/whpx/whpx-all.c
> @@ -654,7 +654,7 @@ uint32_t whpx_arm_get_ipa_bit_size(void)
>           WHvCapabilityCodePhysicalAddressWidth, &whpx_cap,
>           sizeof(whpx_cap), &whpx_cap_size);
>       if (FAILED(hr)) {
> -        error_report("WHPX: failed to get supported"
> +        error_report("WHPX: failed to get supported "
>                "physical address width, hr=%08lx", hr);
>       }
>   
> @@ -874,15 +874,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
>           goto error;
>       }
>   
> -    if (mc->get_physical_address_range) {
> -        pa_range = mc->get_physical_address_range(ms,
> -            whpx_arm_get_ipa_bit_size(), whpx_arm_get_ipa_bit_size());
> -        if (pa_range < 0) {
> -            ret = -EINVAL;
> -            goto error;
> -        }
> -    }
> -
>       whpx->mem_quota = ms->ram_size;
>   
>       hr = whp_dispatch.WHvGetCapability(
> @@ -910,6 +901,14 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
>           goto error;
>       }
>   
> +    if (mc->get_physical_address_range) {
> +        pa_range = mc->get_physical_address_range(ms,
> +            whpx_arm_get_ipa_bit_size(), whpx_arm_get_ipa_bit_size());
> +        if (pa_range < 0) {
> +            return -EINVAL;
> +        }
> +    }
> +
>       hr = whp_dispatch.WHvCreatePartition(&whpx->partition);
>       if (FAILED(hr)) {
>           error_report("WHPX: Failed to create partition, hr=%08lx", hr);

Squash with patch 18/26 "whpx: arm64: clamp down IPA size"?
Re: [PATCH v16 24/26] whpx: arm64: check for physical address width after WHPX availability
Posted by Philippe Mathieu-Daudé 2 weeks, 5 days ago
On 16/1/26 14:52, Mohamed Mediouni wrote:
> In the case where WHPX isn't supported on the platform, makes the
> intended error appear instead of failing at getting the IPA width.
> 
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   target/arm/whpx/whpx-all.c | 19 +++++++++----------
>   1 file changed, 9 insertions(+), 10 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>