Skip to contentSkip to conversation

hvf: arm: override HV_SYS_REG_MDCR_EL2

PATCH In review Mohamed Mediouni 3 participants 5 messages May 1 – May 5

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hvf: arm: override HV_SYS_REG_MDCR_EL2

In older SDKs, MDCR_EL2 was defined incorrectly.

As such, override it with a #define if compiling with an older macOS SDK.

This is a workaround because the macOS CI setup we currently rely on has not been kept up to date, to be able to land nested virtualization support.

Once CI is updated, the SME stubs can be removed and this commit can be reverted.

---
 target/arm/hvf/hvf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
target/arm/hvf/hvf.c +9 -0
index 4f0f7ffba1..79209bc8e9 100644
@@ -468,6 +468,15 @@ static const struct hvf_reg_match hvf_sme2_preg_match[] = {
 #define HVF_TO_KVMID(HVF)  \
     (CP_REG_ARM64 | CP_REG_SIZE_U64 | CP_REG_ARM64_SYSREG | (HVF))
 
+/*
+ * In older SDKs, MDCR_EL2 was defined incorrectly.
+ * As such, override it with a #define if compiling with an older macOS SDK.
+ * https://lore.kernel.org/qemu-devel/[email protected]/
+ */
+#if !defined(MAC_OS_VERSION_26_0)
+#define HV_SYS_REG_MDCR_EL2 0xe089
+#endif
+
 /*
  * Verify this at compile-time.
  *
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw
Quoted 22 lines · Mohamed Mediouni

In older SDKs, MDCR_EL2 was defined incorrectly.

As such, override it with a #define if compiling with an older macOS SDK.

This is a workaround because the macOS CI setup we currently rely on has not been kept up to date, to be able to land nested virtualization support.

Once CI is updated, the SME stubs can be removed and this commit can be reverted.

---
  target/arm/hvf/hvf.c | 9 +++++++++
  1 file changed, 9 insertions(+)
target/arm/hvf/hvf.c +0 -0
index 4f0f7ffba1..79209bc8e9 100644

target/arm/hvf/hvf.c static const struct hvf_reg_match hvf_sme2_preg_match[] = { · line 476

Quoted 9 lines
target/arm/hvf/hvf.c +6 -0
@@ -468,6 +468,15 @@ static const struct hvf_reg_match hvf_sme2_preg_match[] = {
  #define HVF_TO_KVMID(HVF)  \
      (CP_REG_ARM64 | CP_REG_SIZE_U64 | CP_REG_ARM64_SYSREG | (HVF))
 
+/*
+ * In older SDKs, MDCR_EL2 was defined incorrectly.
+ * As such, override it with a #define if compiling with an older macOS SDK.
+ * https://lore.kernel.org/qemu-devel/[email protected]/
+ */
+#if !defined(MAC_OS_VERSION_26_0)

Not sure about this check, i.e. wouldn't it clash with 26.1 release? I'd expect a check such:

   #if MAC_OS_X_VERSION_MAX_ALLOWED < 260000
Quoted 6 lines
target/arm/hvf/hvf.c +3 -0
+#define HV_SYS_REG_MDCR_EL2 0xe089
+#endif
+
  /*
   * Verify this at compile-time.
   *
#2 lore raw
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 17 lines · Mohamed Mediouni

In older SDKs, MDCR_EL2 was defined incorrectly.
As such, override it with a #define if compiling with an older macOS SDK.
This is a workaround because the macOS CI setup we currently rely on has not been kept up to date, to be able to land nested virtualization support.
Once CI is updated, the SME stubs can be removed and this commit can be reverted.

---
 target/arm/hvf/hvf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
target/arm/hvf/hvf.c +0 -0
index 4f0f7ffba1..79209bc8e9 100644

target/arm/hvf/hvf.c static const struct hvf_reg_match hvf_sme2_preg_match[] = { · line 475

Quoted 8 lines
target/arm/hvf/hvf.c +5 -0
@@ -468,6 +468,15 @@ static const struct hvf_reg_match hvf_sme2_preg_match[] = {
 #define HVF_TO_KVMID(HVF)  \
     (CP_REG_ARM64 | CP_REG_SIZE_U64 | CP_REG_ARM64_SYSREG | (HVF))
 +/*
+ * In older SDKs, MDCR_EL2 was defined incorrectly.
+ * As such, override it with a #define if compiling with an older macOS SDK.
+ * https://lore.kernel.org/qemu-devel/[email protected]/
+ */
+#if !defined(MAC_OS_VERSION_26_0)

Not sure about this check, i.e. wouldn't it clash with 26.1 release? I'd expect a check such:

Quoted 1 line
  #if MAC_OS_X_VERSION_MAX_ALLOWED < 260000

Hi,

MAC_OS_VERSION_26_0 will be defined in all future SDKs.

See AvailabilityVersions.h in the macOS SDK, has all of them since 10.0

Quoted 9 lines
Quoted 7 lines
target/arm/hvf/hvf.c +3 -0
+#define HV_SYS_REG_MDCR_EL2 0xe089
+#endif
+
 /*
  * Verify this at compile-time.
  *
#3 lore raw
Quoted 34 lines · Mohamed Mediouni
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 17 lines · Mohamed Mediouni

In older SDKs, MDCR_EL2 was defined incorrectly.
As such, override it with a #define if compiling with an older macOS SDK.
This is a workaround because the macOS CI setup we currently rely on has not been kept up to date, to be able to land nested virtualization support.
Once CI is updated, the SME stubs can be removed and this commit can be reverted.

---
  target/arm/hvf/hvf.c | 9 +++++++++
  1 file changed, 9 insertions(+)
target/arm/hvf/hvf.c +0 -0
index 4f0f7ffba1..79209bc8e9 100644

target/arm/hvf/hvf.c static const struct hvf_reg_match hvf_sme2_preg_match[] = { · line 475

Quoted 8 lines
target/arm/hvf/hvf.c +5 -0
@@ -468,6 +468,15 @@ static const struct hvf_reg_match hvf_sme2_preg_match[] = {
  #define HVF_TO_KVMID(HVF)  \
      (CP_REG_ARM64 | CP_REG_SIZE_U64 | CP_REG_ARM64_SYSREG | (HVF))
  +/*
+ * In older SDKs, MDCR_EL2 was defined incorrectly.
+ * As such, override it with a #define if compiling with an older macOS SDK.
+ * https://lore.kernel.org/qemu-devel/[email protected]/
+ */
+#if !defined(MAC_OS_VERSION_26_0)

Not sure about this check, i.e. wouldn't it clash with 26.1 release? I'd expect a check such:

Quoted 7 lines
Quoted 1 line
   #if MAC_OS_X_VERSION_MAX_ALLOWED < 260000

Hi,

MAC_OS_VERSION_26_0 will be defined in all future SDKs.

See AvailabilityVersions.h in the macOS SDK, has all of them since 10.0

Right.

Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
target/arm/hvf/hvf.c +3 -0
+#define HV_SYS_REG_MDCR_EL2 0xe089
+#endif
+
  /*
   * Verify this at compile-time.
   *
#4 lore raw
In reply to Mohamed Mediouni
Quoted 6 lines · Mohamed Mediouni

In older SDKs, MDCR_EL2 was defined incorrectly.

As such, override it with a #define if compiling with an older macOS SDK.

Quoted 8 lines

This is a workaround because the macOS CI setup we currently rely on has not been kept up to date, to be able to land nested virtualization support.

Once CI is updated, the SME stubs can be removed and this commit can be reverted.

I put this patch into my v2 pullreq; hopefully it will get through the CI gauntlet this time :-)

-- PMM