[PATCH v15 16/17] hvf: arm: disable SME when nested virt is active

Mohamed Mediouni posted 17 patches 1 month, 1 week ago
Maintainers: Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Alexander Graf <agraf@csgraf.de>
There is a newer version of this series
[PATCH v15 16/17] hvf: arm: disable SME when nested virt is active
Posted by Mohamed Mediouni 1 month, 1 week ago
Currently, Apple doesn't support the nested virtualisation + SME combination.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
 target/arm/hvf/hvf.c | 3 +++
 target/arm/hvf_arm.h | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 0183dd8a60..61ba5acce4 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1181,6 +1181,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
 
     if (hvf_nested_virt_enabled()) {
         FIELD_DP64_IDREG(&host_isar, ID_AA64DFR0, PMUVER, 0x1);
+        /* SME is not implemented with nested virt on the Apple side */
+        SET_IDREG(&host_isar, ID_AA64PFR1,
+              GET_IDREG(&host_isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MASK);
     }
 
     ahcf->isar = host_isar;
diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h
index 6b1c3b9792..9cb58ad9ab 100644
--- a/target/arm/hvf_arm.h
+++ b/target/arm/hvf_arm.h
@@ -11,6 +11,7 @@
 #ifndef QEMU_HVF_ARM_H
 #define QEMU_HVF_ARM_H
 
+#include "system/hvf.h"
 #include "target/arm/cpu-qom.h"
 
 /**
@@ -35,6 +36,10 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu);
         if (__builtin_available(macOS 15.2, *)) {
             size_t svl_bytes;
             hv_return_t result = hv_sme_config_get_max_svl_bytes(&svl_bytes);
+            /* Nested virt not supported together with SME right now. */
+            if (hvf_nested_virt_enabled()) {
+                return false;
+            }
             if (result == HV_UNSUPPORTED) {
                 return false;
             }
-- 
2.50.1 (Apple Git-155)
Re: [PATCH v15 16/17] hvf: arm: disable SME when nested virt is active
Posted by Peter Maydell 1 month, 1 week ago
On Fri, 6 Mar 2026 at 13:02, Mohamed Mediouni <mohamed@unpredictable.fr> wrote:
>
> Currently, Apple doesn't support the nested virtualisation + SME combination.
>
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> ---
>  target/arm/hvf/hvf.c | 3 +++
>  target/arm/hvf_arm.h | 5 +++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 0183dd8a60..61ba5acce4 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -1181,6 +1181,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
>
>      if (hvf_nested_virt_enabled()) {
>          FIELD_DP64_IDREG(&host_isar, ID_AA64DFR0, PMUVER, 0x1);
> +        /* SME is not implemented with nested virt on the Apple side */
> +        SET_IDREG(&host_isar, ID_AA64PFR1,
> +              GET_IDREG(&host_isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MASK);

This is
  FIELD_DP64_IDREG(&host_isar, ID_AA64PFR1, SME, 0);

isn't it?


thanks
-- PMM
Re: [PATCH v15 16/17] hvf: arm: disable SME when nested virt is active
Posted by Mohamed Mediouni 1 month, 1 week ago

> On 6. Mar 2026, at 14:32, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> On Fri, 6 Mar 2026 at 13:02, Mohamed Mediouni <mohamed@unpredictable.fr> wrote:
>> 
>> Currently, Apple doesn't support the nested virtualisation + SME combination.
>> 
>> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
>> ---
>> target/arm/hvf/hvf.c | 3 +++
>> target/arm/hvf_arm.h | 5 +++++
>> 2 files changed, 8 insertions(+)
>> 
>> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
>> index 0183dd8a60..61ba5acce4 100644
>> --- a/target/arm/hvf/hvf.c
>> +++ b/target/arm/hvf/hvf.c
>> @@ -1181,6 +1181,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
>> 
>>     if (hvf_nested_virt_enabled()) {
>>         FIELD_DP64_IDREG(&host_isar, ID_AA64DFR0, PMUVER, 0x1);
>> +        /* SME is not implemented with nested virt on the Apple side */
>> +        SET_IDREG(&host_isar, ID_AA64PFR1,
>> +              GET_IDREG(&host_isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MASK);
> 
> This is
>  FIELD_DP64_IDREG(&host_isar, ID_AA64PFR1, SME, 0);
> 
> isn't it?
> 
Hi,

That's an equivalent sequence indeed. Should I respin for this?

Thank you,
> 
> thanks
> -- PMM
Re: [PATCH v15 16/17] hvf: arm: disable SME when nested virt is active
Posted by Peter Maydell 1 month, 1 week ago
On Fri, 6 Mar 2026 at 13:34, Mohamed Mediouni <mohamed@unpredictable.fr> wrote:
>
>
>
> > On 6. Mar 2026, at 14:32, Peter Maydell <peter.maydell@linaro.org> wrote:
> >
> > On Fri, 6 Mar 2026 at 13:02, Mohamed Mediouni <mohamed@unpredictable.fr> wrote:
> >>
> >> Currently, Apple doesn't support the nested virtualisation + SME combination.
> >>
> >> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> >> ---
> >> target/arm/hvf/hvf.c | 3 +++
> >> target/arm/hvf_arm.h | 5 +++++
> >> 2 files changed, 8 insertions(+)
> >>
> >> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> >> index 0183dd8a60..61ba5acce4 100644
> >> --- a/target/arm/hvf/hvf.c
> >> +++ b/target/arm/hvf/hvf.c
> >> @@ -1181,6 +1181,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
> >>
> >>     if (hvf_nested_virt_enabled()) {
> >>         FIELD_DP64_IDREG(&host_isar, ID_AA64DFR0, PMUVER, 0x1);
> >> +        /* SME is not implemented with nested virt on the Apple side */
> >> +        SET_IDREG(&host_isar, ID_AA64PFR1,
> >> +              GET_IDREG(&host_isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MASK);
> >
> > This is
> >  FIELD_DP64_IDREG(&host_isar, ID_AA64PFR1, SME, 0);
> >
> > isn't it?
> >
> Hi,
>
> That's an equivalent sequence indeed. Should I respin for this?

No, I'll fix it locally.

thanks
-- PMM