Skip to contentSkip to conversation

Fix Guest random crash on Cortex-N1/A76/A75 cores

PATCH Superseded Wei Chen 3 participants 11 messages Aug 24, 2020 – Aug 25, 2020

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Wei Chen

author
#0 lore raw

v2 cover Fix Guest random crash on Cortex-N1/A76/A75 cores

On latest Arm Cortex-N1/A76/A75 cores, Xen guests will encouter random crash when they have wordloads. It's because Xen will ignore FP/SIMD registers in vCPU context switch (see patch#1 for more details).

This patch set fix guest random crash on these new cores, and throw messages when Xen detects known FP/SIMD features.

---
v1 --> v2:
1. Use "< 8" instead of "<= 1" to detect FP/SIMD features.
2. Give messages for unknown FP/SIMD features.
3. Fix typos.

v1:
https://lists.xenproject.org/archives/html/xen-devel/2020-08/msg00857.html

Wei Chen (2):
xen/arm: Missing N1/A76/A75 FP registers in vCPU context switch xen/arm: Throw messages for unknown FP/SIMD implement ID

 xen/arch/arm/setup.c             | 26 ++++++++++++++++++++++++--
 xen/include/asm-arm/cpufeature.h |  4 ++--
 2 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/2 xen/arm: Missing N1/A76/A75 FP registers in vCPU context switch

Xen has cpu_has_fp/cpu_has_simd to detect whether the CPU supports FP/SIMD or not. But currently, these two MACROs only consider value 0 of ID_AA64PFR0_EL1.FP/SIMD as FP/SIMD features enabled. But for CPUs that support FP/SIMD and half-precision floating-point arithmetic, the ID_AA64PFR0_EL1.FP/SIMD are 1 (see Arm ARM DDI0487F.b, D13.2.64). For these CPUs, xen will treat them as no FP/SIMD supporti, the vfp_save/restore_state will not take effect.

From the TRM documents of Cortex-A75/A76/N1, we know these CPUs support basic Advanced SIMD/FP and half-precision floating-point arithmetic. In this case, on N1/A76/A75 platforms, Xen will always miss the floating pointer registers save/restore. If different vCPUs are running on the same pCPU, the floating pointer registers will be corrupted randomly.

This patch fixes Xen on these new cores.

---
 xen/include/asm-arm/cpufeature.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/asm-arm/cpufeature.h +2 -2
index 674beb0353..10878ead8a 100644
@@ -13,8 +13,8 @@
 #define cpu_has_el2_64    (boot_cpu_feature64(el2) >= 1)
 #define cpu_has_el3_32    (boot_cpu_feature64(el3) == 2)
 #define cpu_has_el3_64    (boot_cpu_feature64(el3) >= 1)
-#define cpu_has_fp        (boot_cpu_feature64(fp) == 0)
-#define cpu_has_simd      (boot_cpu_feature64(simd) == 0)
+#define cpu_has_fp        (boot_cpu_feature64(fp) < 8)
+#define cpu_has_simd      (boot_cpu_feature64(simd) < 8)
 #define cpu_has_gicv3     (boot_cpu_feature64(gic) == 1)
 #endif
 
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v2 2/2 xen/arm: Throw messages for unknown FP/SIMD implement ID

In reply to Wei Chen

Arm ID_AA64PFR0_EL1 register provides two fields to describe CPU FP/SIMD implementations. Currently, we exactly know the meaning of 0x0, 0x1 and 0xf of these fields. Xen treats value < 8 as FP/SIMD features presented. If there is a value 0x2 bumped in the future, Xen behaviors for value <= 0x1 can also take effect. But what Xen done for value <= 0x1 may not always cover new value 0x2 required. We throw these messages to break the silence when Xen detected unknown FP/SIMD IDs to notice user to check.

---
 xen/arch/arm/setup.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
xen/arch/arm/setup.c +24 -2
index 7968cee47d..c7802d0e49 100644
@@ -99,6 +99,28 @@ static const char * __initdata processor_implementers[] = {
     ['i'] = "Intel Corporation",
 };
 
+static const char * __initdata fp_implements[] = {
+    "Floating-point",
+    "Floating-point + half-precision floating-point arithmetic",
+    "Floating-point Unknown ID 0x2",
+    "Floating-point Unknown ID 0x3",
+    "Floating-point Unknown ID 0x4",
+    "Floating-point Unknown ID 0x5",
+    "Floating-point Unknown ID 0x6",
+    "Floating-point Unknown ID 0x7",
+};
+
+static const char * __initdata advsimd_implements[] = {
+    "AdvancedSIMD",
+    "AdvancedSIMD + half-precision floating-point arithmetic",
+    "AdvancedSIMD Unknown ID 0x2",
+    "AdvancedSIMD Unknown ID 0x3",
+    "AdvancedSIMD Unknown ID 0x4",
+    "AdvancedSIMD Unknown ID 0x5",
+    "AdvancedSIMD Unknown ID 0x6",
+    "AdvancedSIMD Unknown ID 0x7",
+};
+
 static void __init processor_id(void)
 {
     const char *implementer = "Unknown";
@@ -129,8 +151,8 @@ static void __init processor_id(void)
            cpu_has_el1_32 ? "64+32" : cpu_has_el1_64 ? "64" : "No",
            cpu_has_el0_32 ? "64+32" : cpu_has_el0_64 ? "64" : "No");
     printk("    Extensions:%s%s%s\n",
-           cpu_has_fp ? " FloatingPoint" : "",
-           cpu_has_simd ? " AdvancedSIMD" : "",
+           cpu_has_fp ? fp_implements[boot_cpu_feature64(fp)] : "",
+           cpu_has_simd ? advsimd_implements[boot_cpu_feature64(simd)] : "",
            cpu_has_gicv3 ? " GICv3-SysReg" : "");
 
     printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",
Signature · 1 line
2.17.1
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] xen/arm: Missing N1/A76/A75 FP registers in vCPU context switch

In reply to Wei Chen

Hi,

Quoted 6 lines · Wei Chen

Xen has cpu_has_fp/cpu_has_simd to detect whether the CPU supports FP/SIMD or not. But currently, these two MACROs only consider value 0 of ID_AA64PFR0_EL1.FP/SIMD as FP/SIMD features enabled. But for CPUs that support FP/SIMD and half-precision floating-point arithmetic, the ID_AA64PFR0_EL1.FP/SIMD are 1 (see Arm ARM DDI0487F.b, D13.2.64). For these CPUs, xen will treat them as no FP/SIMD supporti, the

s/supporti/support/

Quoted 8 lines

vfp_save/restore_state will not take effect.

From the TRM documents of Cortex-A75/A76/N1, we know these CPUs support
basic Advanced SIMD/FP and half-precision floating-point arithmetic. In this case, on N1/A76/A75 platforms, Xen will always miss the floating pointer registers save/restore. If different vCPUs are running on the same pCPU, the floating pointer registers will be corrupted randomly.

Quoted 4 lines

This patch fixes Xen on these new cores.

Cheers,

Quoted 20 lines
---
  xen/include/asm-arm/cpufeature.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/asm-arm/cpufeature.h +2 -2
index 674beb0353..10878ead8a 100644
@@ -13,8 +13,8 @@
  #define cpu_has_el2_64    (boot_cpu_feature64(el2) >= 1)
  #define cpu_has_el3_32    (boot_cpu_feature64(el3) == 2)
  #define cpu_has_el3_64    (boot_cpu_feature64(el3) >= 1)
-#define cpu_has_fp        (boot_cpu_feature64(fp) == 0)
-#define cpu_has_simd      (boot_cpu_feature64(simd) == 0)
+#define cpu_has_fp        (boot_cpu_feature64(fp) < 8)
+#define cpu_has_simd      (boot_cpu_feature64(simd) < 8)
  #define cpu_has_gicv3     (boot_cpu_feature64(gic) == 1)
  #endif
 
Signature · 1 line
Julien Grall
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

In reply to Wei Chen

Hi,

Quoted 11 lines · Wei Chen

Arm ID_AA64PFR0_EL1 register provides two fields to describe CPU FP/SIMD implementations. Currently, we exactly know the meaning of 0x0, 0x1 and 0xf of these fields. Xen treats value < 8 as FP/SIMD features presented. If there is a value 0x2 bumped in the future, Xen behaviors for value <= 0x1 can also take effect. But what Xen done for value <= 0x1 may not always cover new value 0x2 required. We throw these messages to break the silence when Xen detected unknown FP/SIMD IDs to notice user to check.

Quoted 1 line
Quoted 51 lines

---
xen/arch/arm/setup.c | 26 ++++++++++++++++++++++++--

1 file changed, 24 insertions(+), 2 deletions(-)
xen/arch/arm/setup.c +24 -2
index 7968cee47d..c7802d0e49 100644
@@ -99,6 +99,28 @@ static const char * __initdata processor_implementers[] = {
    ['i'] = "Intel Corporation",
 };
 
+static const char * __initdata fp_implements[] = {
+    "Floating-point",
+    "Floating-point + half-precision floating-point arithmetic",
+    "Floating-point Unknown ID 0x2",
+    "Floating-point Unknown ID 0x3",
+    "Floating-point Unknown ID 0x4",
+    "Floating-point Unknown ID 0x5",
+    "Floating-point Unknown ID 0x6",
+    "Floating-point Unknown ID 0x7",
+};
+
+static const char * __initdata advsimd_implements[] = {
+    "AdvancedSIMD",
+    "AdvancedSIMD + half-precision floating-point arithmetic",
+    "AdvancedSIMD Unknown ID 0x2",
+    "AdvancedSIMD Unknown ID 0x3",
+    "AdvancedSIMD Unknown ID 0x4",
+    "AdvancedSIMD Unknown ID 0x5",
+    "AdvancedSIMD Unknown ID 0x6",
+    "AdvancedSIMD Unknown ID 0x7",
+};
+
 static void __init processor_id(void)
 {
    const char *implementer = "Unknown";
@@ -129,8 +151,8 @@ static void __init processor_id(void)
           cpu_has_el1_32 ? "64+32" : cpu_has_el1_64 ? "64" : "No",
           cpu_has_el0_32 ? "64+32" : cpu_has_el0_64 ? "64" : "No");
    printk("    Extensions:%s%s%s\n",
-           cpu_has_fp ? " FloatingPoint" : "",
-           cpu_has_simd ? " AdvancedSIMD" : "",
+           cpu_has_fp ? fp_implements[boot_cpu_feature64(fp)] : "",
+           cpu_has_simd ? advsimd_implements[boot_cpu_feature64(simd)] : "",
           cpu_has_gicv3 ? " GICv3-SysReg" : "");
 
    printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",
Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

In reply to Wei Chen

Hi Wei,

Quoted 6 lines · Wei Chen

Arm ID_AA64PFR0_EL1 register provides two fields to describe CPU FP/SIMD implementations. Currently, we exactly know the meaning of 0x0, 0x1 and 0xf of these fields. Xen treats value < 8 as FP/SIMD features presented. If there is a value 0x2 bumped in the future, Xen behaviors for value <= 0x1 can also take effect. But what Xen done for value <= 0x1 may not always cover new value 0x2 required.

Right, but this will also happen with all the other features. This may actually confuse the users as they may think the rest of the features are fully supported which is not correct. For instance, dom0 will crash if you boot Xen on a SVE-capable hardware.

Quoted 2 lines

We throw these messages to break the silence when Xen detected unknown FP/SIMD IDs to notice user to check.

It feels a bit odd to me to print unknown for the FP/SIMD feature but not for all the rest.

IMHO, the right approach is to sanitize ID registers exposed to domains and only expose features we know are correctly handled.

Quoted 40 lines
---
  xen/arch/arm/setup.c | 26 ++++++++++++++++++++++++--
  1 file changed, 24 insertions(+), 2 deletions(-)
xen/arch/arm/setup.c +22 -0
index 7968cee47d..c7802d0e49 100644
@@ -99,6 +99,28 @@ static const char * __initdata processor_implementers[] = {
      ['i'] = "Intel Corporation",
  };
 
+static const char * __initdata fp_implements[] = {
+    "Floating-point",
+    "Floating-point + half-precision floating-point arithmetic",
+    "Floating-point Unknown ID 0x2",
+    "Floating-point Unknown ID 0x3",
+    "Floating-point Unknown ID 0x4",
+    "Floating-point Unknown ID 0x5",
+    "Floating-point Unknown ID 0x6",
+    "Floating-point Unknown ID 0x7",
+};
+
+static const char * __initdata advsimd_implements[] = {
+    "AdvancedSIMD",
+    "AdvancedSIMD + half-precision floating-point arithmetic",
+    "AdvancedSIMD Unknown ID 0x2",
+    "AdvancedSIMD Unknown ID 0x3",
+    "AdvancedSIMD Unknown ID 0x4",
+    "AdvancedSIMD Unknown ID 0x5",
+    "AdvancedSIMD Unknown ID 0x6",
+    "AdvancedSIMD Unknown ID 0x7",
+};
+
  static void __init processor_id(void)
  {
      const char *implementer = "Unknown";

xen/arch/arm/setup.c static void __init processor_id(void) · line 155

Quoted 7 lines
xen/arch/arm/setup.c +2 -2
@@ -129,8 +151,8 @@ static void __init processor_id(void)
             cpu_has_el1_32 ? "64+32" : cpu_has_el1_64 ? "64" : "No",
             cpu_has_el0_32 ? "64+32" : cpu_has_el0_64 ? "64" : "No");
      printk("    Extensions:%s%s%s\n",
-           cpu_has_fp ? " FloatingPoint" : "",
-           cpu_has_simd ? " AdvancedSIMD" : "",
+           cpu_has_fp ? fp_implements[boot_cpu_feature64(fp)] : "",
+           cpu_has_simd ? advsimd_implements[boot_cpu_feature64(simd)] : "",

So far, each extension name are just a word and they are all separated with spaces. With this change, there will be multiple words per extension which is quite confusion.

If we decide to go ahead printing the "unknown", then we want to provide a full description of the extension on a separate line. Maybe:

"AdvancedSIMD: With half-precision floating-point arithmetic".

xen/arch/arm/setup.c static void __init processor_id(void) · line 158

Quoted 4 lines
xen/arch/arm/setup.c +0 -0
             cpu_has_gicv3 ? " GICv3-SysReg" : "");
 
      printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",

Cheers,

Signature · 1 line
Julien Grall
#7 lore raw

Re: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

Hi Julien,

Quoted 5 lines · Julien Grall

Hi Wei,

On 24/08/2020 04:28, Wei Chen wrote:

Quoted 8 lines
Quoted 6 lines

Arm ID_AA64PFR0_EL1 register provides two fields to describe CPU FP/SIMD implementations. Currently, we exactly know the meaning of 0x0, 0x1 and 0xf of these fields. Xen treats value < 8 as FP/SIMD features presented. If there is a value 0x2 bumped in the future, Xen behaviors for value <= 0x1 can also take effect. But what Xen done for value <= 0x1 may not always cover new value 0x2 required.

Right, but this will also happen with all the other features. This may actually confuse the users as they may think the rest of the features are fully supported which is not correct. For instance, dom0 will crash if you boot Xen on a SVE-capable hardware.

I would see this as an improvement already.
More could be done for SVE (and other bits) but this should be in another patch set.

Quoted 7 lines
Quoted 3 lines

We throw these messages to break the silence when Xen detected unknown FP/SIMD IDs to notice user to check.

It feels a bit odd to me to print unknown for the FP/SIMD feature but not for all the rest.

IMHO, the right approach is to sanitize ID registers exposed to domains and only expose features we know are correctly handled.

I actually started to look into this last week because I came to an issue comparable to SVE with pointer authentication. Maybe we should discuss this subject separately as clearing TID3 bit in HCR and emulating all ID registers is possible but I want to check first if this could have big impacts on performances and see discuss how to design this as there could be a huge amount of cases for example if we want to allow different parameters for different domains.

Cheers

Bertrand

Quoted 59 lines
Quoted 38 lines
---
 xen/arch/arm/setup.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
xen/arch/arm/setup.c +21 -0
index 7968cee47d..c7802d0e49 100644
@@ -99,6 +99,28 @@ static const char * __initdata processor_implementers[] = {
     ['i'] = "Intel Corporation",
 };
 +static const char * __initdata fp_implements[] = {
+    "Floating-point",
+    "Floating-point + half-precision floating-point arithmetic",
+    "Floating-point Unknown ID 0x2",
+    "Floating-point Unknown ID 0x3",
+    "Floating-point Unknown ID 0x4",
+    "Floating-point Unknown ID 0x5",
+    "Floating-point Unknown ID 0x6",
+    "Floating-point Unknown ID 0x7",
+};
+
+static const char * __initdata advsimd_implements[] = {
+    "AdvancedSIMD",
+    "AdvancedSIMD + half-precision floating-point arithmetic",
+    "AdvancedSIMD Unknown ID 0x2",
+    "AdvancedSIMD Unknown ID 0x3",
+    "AdvancedSIMD Unknown ID 0x4",
+    "AdvancedSIMD Unknown ID 0x5",
+    "AdvancedSIMD Unknown ID 0x6",
+    "AdvancedSIMD Unknown ID 0x7",
+};
+
 static void __init processor_id(void)
 {
     const char *implementer = "Unknown";

xen/arch/arm/setup.c static void __init processor_id(void) · line 155

Quoted 7 lines
xen/arch/arm/setup.c +2 -2
@@ -129,8 +151,8 @@ static void __init processor_id(void)
            cpu_has_el1_32 ? "64+32" : cpu_has_el1_64 ? "64" : "No",
            cpu_has_el0_32 ? "64+32" : cpu_has_el0_64 ? "64" : "No");
     printk("    Extensions:%s%s%s\n",
-           cpu_has_fp ? " FloatingPoint" : "",
-           cpu_has_simd ? " AdvancedSIMD" : "",
+           cpu_has_fp ? fp_implements[boot_cpu_feature64(fp)] : "",
+           cpu_has_simd ? advsimd_implements[boot_cpu_feature64(simd)] : "",

So far, each extension name are just a word and they are all separated with spaces. With this change, there will be multiple words per extension which is quite confusion.

If we decide to go ahead printing the "unknown", then we want to provide a full description of the extension on a separate line. Maybe:

"AdvancedSIMD: With half-precision floating-point arithmetic".

xen/arch/arm/setup.c static void __init processor_id(void) · line 158

Quoted 2 lines
xen/arch/arm/setup.c +0 -0
            cpu_has_gicv3 ? " GICv3-SysReg" : "");
       printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",

Cheers,

Signature · 1 line
Julien Grall
#8 lore raw

Re: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

Quoted 1 line · Bertrand Marquis

Hi Julien,

Hi,

Quoted 13 lines
Quoted 13 lines · Julien Grall

Hi Wei,

Quoted 6 lines · Wei Chen

Arm ID_AA64PFR0_EL1 register provides two fields to describe CPU FP/SIMD implementations. Currently, we exactly know the meaning of 0x0, 0x1 and 0xf of these fields. Xen treats value < 8 as FP/SIMD features presented. If there is a value 0x2 bumped in the future, Xen behaviors for value <= 0x1 can also take effect. But what Xen done for value <= 0x1 may not always cover new value 0x2 required.

Quoted 3 lines
Quoted 1 line

Right, but this will also happen with all the other features. This may actually confuse the users as they may think the rest of the features are fully supported which is not correct. For instance, dom0 will crash if you boot Xen on a SVE-capable hardware.

I would see this as an improvement already.

TBH, I only view this patch as a band-aid. I am OK with them but they need to be useful.

When I read "unknown value...", I have no clue whether the message is good or bad. It would be better to extend the message with what could go wrong. E.g "Unknown value X, this may result to corruption on the platform".

I would also consider to taint Xen as it may become unstable with this option set.

Quoted 6 lines

More could be done for SVE (and other bits) but this should be in another patch set.

Quoted 4 lines
Quoted 3 lines

We throw these messages to break the silence when Xen detected unknown FP/SIMD IDs to notice user to check.

Quoted 7 lines
Quoted 3 lines

It feels a bit odd to me to print unknown for the FP/SIMD feature but not for all the rest.

IMHO, the right approach is to sanitize ID registers exposed to domains and only expose features we know are correctly handled.

I actually started to look into this last week because I came to an issue comparable to SVE with pointer authentication. Maybe we should discuss this subject separately as clearing TID3 bit in HCR and emulating all ID registers is possible but I want to check first if this could have big impacts on performances

I don't expect any performance drop. In Linux, they will cache all the values and use alternative to avoid runtime check.

I also don't expect any OS to use them at runtime in hotpath.

Quoted 2 lines

and see discuss how to design this as there
could be a huge amount of cases for example if we want to allow different parameters for different domains.

I would suggest to first consider a simple approach where we expose the same view of the ID registers to all the guests but it is sanitized.

We can then discuss whether we want to have a per-guest view of the ID registers and how to configure it.

Regarding the implementation, I personally quite like the Linux cpufeature framework. It is quite powerful and I believe would suit quite well Xen.

Cheers,

Signature · 1 line
Julien Grall
author
#3 lore raw

RE: [PATCH v2 1/2] xen/arm: Missing N1/A76/A75 FP registers in vCPU context switch

In reply to Julien Grall

Hi,

Quoted 14 lines

-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2020年8月24日 21:15
To: Wei Chen <[email protected]>; [email protected]; [email protected]
Cc: Andre Przywara <[email protected]>; Bertrand Marquis <[email protected]>; Penny Zheng <[email protected]>; Kaly Xin <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2 1/2] xen/arm: Missing N1/A76/A75 FP registers in vCPU context switch

Hi,

On 24/08/2020 04:28, Wei Chen wrote:

Quoted 8 lines
Quoted 6 lines

Xen has cpu_has_fp/cpu_has_simd to detect whether the CPU supports FP/SIMD or not. But currently, these two MACROs only consider value 0 of ID_AA64PFR0_EL1.FP/SIMD as FP/SIMD features enabled. But for CPUs that support FP/SIMD and half-precision floating-point arithmetic, the ID_AA64PFR0_EL1.FP/SIMD are 1 (see Arm ARM DDI0487F.b, D13.2.64). For these CPUs, xen will treat them as no FP/SIMD supporti, the

s/supporti/support/

I will fix this typo in next version.

Quoted 43 lines
Quoted 4 lines

vfp_save/restore_state will not take effect.

From the TRM documents of Cortex-A75/A76/N1, we know these CPUs

support

Quoted 9 lines

basic Advanced SIMD/FP and half-precision floating-point arithmetic. In this case, on N1/A76/A75 platforms, Xen will always miss the floating pointer registers save/restore. If different vCPUs are running on the same pCPU, the floating pointer registers will be corrupted randomly.

This patch fixes Xen on these new cores.

Cheers,

xen/include/asm-

Quoted 5 lines
---
  xen/include/asm-arm/cpufeature.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/asm- renamed from xen/include/asm-arm/cpufeature.h +0 -0

arm/cpufeature.h

Quoted 5 lines

index 674beb0353..10878ead8a 100644

xen/include/asm-arm/cpufeature.h line 20

Quoted 10 lines
xen/include/asm-arm/cpufeature.h +2 -2
@@ -13,8 +13,8 @@
  #define cpu_has_el2_64    (boot_cpu_feature64(el2) >= 1)
  #define cpu_has_el3_32    (boot_cpu_feature64(el3) == 2)
  #define cpu_has_el3_64    (boot_cpu_feature64(el3) >= 1)
-#define cpu_has_fp        (boot_cpu_feature64(fp) == 0)
-#define cpu_has_simd      (boot_cpu_feature64(simd) == 0)
+#define cpu_has_fp        (boot_cpu_feature64(fp) < 8)
+#define cpu_has_simd      (boot_cpu_feature64(simd) < 8)
  #define cpu_has_gicv3     (boot_cpu_feature64(gic) == 1)
  #endif
 

--
Julien Grall

author
#9 lore raw

RE: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

In reply to Julien Grall

Hi Julien, Bertrand,

Quoted 41 lines

-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2020年8月25日 1:23
To: Bertrand Marquis <[email protected]>
Cc: Wei Chen <[email protected]>; Xen-devel <xen- [email protected]>; [email protected]; Andre Przywara <[email protected]>; Penny Zheng <[email protected]>; Kaly Xin <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

Quoted 1 line · Bertrand Marquis

Hi Julien,

Hi,

Quoted 6 lines
Quoted 6 lines · Julien Grall

Hi Wei,

On 24/08/2020 04:28, Wei Chen wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Arm ID_AA64PFR0_EL1 register provides two fields to describe CPU FP/SIMD implementations. Currently, we exactly know the meaning of 0x0, 0x1 and 0xf of these fields. Xen treats value < 8 as FP/SIMD features presented. If there is a value 0x2 bumped in the future, Xen behaviors for value <= 0x1 can also take effect. But what Xen done for value <= 0x1 may not always cover new value 0x2 required.

Right, but this will also happen with all the other features. This may

actually confuse the users as they may think the rest of the features are fully supported which is not correct. For instance, dom0 will crash if you boot Xen on a SVE-capable hardware.

Quoted 2 lines

I would see this as an improvement already.

TBH, I only view this patch as a band-aid. I am OK with them but they need to be useful.

Quoted 8 lines

When I read "unknown value...", I have no clue whether the message is good or bad. It would be better to extend the message with what could go wrong. E.g "Unknown value X, this may result to corruption on the platform".

I would also consider to taint Xen as it may become unstable with this option set.

Hmm, yes, it seems current messages are pale. The user could not understand what we want the message expressed when he got one such message. I will improve them to give user a clear meaning. And I think a XENLOG_WARNING would be better to notice user. I will do them in v3.

Quoted 15 lines
Quoted 1 line

More could be done for SVE (and other bits) but this should be in another

patch set.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

We throw these messages to break the silence when Xen detected unknown FP/SIMD IDs to notice user to check.

It feels a bit odd to me to print unknown for the FP/SIMD feature but not

for all the rest.

Quoted 2 lines
Quoted 2 lines

IMHO, the right approach is to sanitize ID registers exposed to domains

and only expose features we know are correctly handled.

Quoted 2 lines

I actually started to look into this last week because I came to an issue

comparable to SVE with pointer authentication.

Quoted 9 lines
Quoted 1 line

Maybe we should discuss this subject separately as clearing TID3 bit in HCR

and emulating all ID registers is possible

Quoted 1 line

but I want to check first if this could have big impacts on performances

I don't expect any performance drop. In Linux, they will cache all the values and use alternative to avoid runtime check.

I also don't expect any OS to use them at runtime in hotpath.

I think this would not be a problem. Most ID check operations would be done in system/application initialization stage.

Quoted 7 lines
Quoted 2 lines

and see discuss how to design this as there
could be a huge amount of cases for example if we want to allow different

parameters for different domains.

I would suggest to first consider a simple approach where we expose the same view of the ID registers to all the guests but it is sanitized.

Can I ask the reason why we don't expose native ID registers to guest? Is it because we want to avoid guest using some unaware features of Xen?

Quoted 7 lines

We can then discuss whether we want to have a per-guest view of the ID registers and how to configure it.

Regarding the implementation, I personally quite like the Linux cpufeature framework. It is quite powerful and I believe would suit quite well Xen.

I agree with you. But I think is quite huge, and out of this patch set's scope. We need a separate thread to discuss the design and implement.

Quoted 4 lines

Cheers,

--
Julien Grall

#10 lore raw

Re: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

Quoted 91 lines · Wei Chen

Hi Julien, Bertrand,

Quoted 41 lines

-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2020年8月25日 1:23
To: Bertrand Marquis <[email protected]>
Cc: Wei Chen <[email protected]>; Xen-devel <xen- [email protected]>; [email protected]; Andre Przywara <[email protected]>; Penny Zheng <[email protected]>; Kaly Xin <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

Quoted 1 line · Bertrand Marquis

Hi Julien,

Hi,

Quoted 6 lines
Quoted 6 lines · Julien Grall

Hi Wei,

On 24/08/2020 04:28, Wei Chen wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Arm ID_AA64PFR0_EL1 register provides two fields to describe CPU FP/SIMD implementations. Currently, we exactly know the meaning of 0x0, 0x1 and 0xf of these fields. Xen treats value < 8 as FP/SIMD features presented. If there is a value 0x2 bumped in the future, Xen behaviors for value <= 0x1 can also take effect. But what Xen done for value <= 0x1 may not always cover new value 0x2 required.

Right, but this will also happen with all the other features. This may

actually confuse the users as they may think the rest of the features are fully supported which is not correct. For instance, dom0 will crash if you boot Xen on a SVE-capable hardware.

Quoted 2 lines

I would see this as an improvement already.

TBH, I only view this patch as a band-aid. I am OK with them but they need to be useful.

Quoted 8 lines

When I read "unknown value...", I have no clue whether the message is good or bad. It would be better to extend the message with what could go wrong. E.g "Unknown value X, this may result to corruption on the platform".

I would also consider to taint Xen as it may become unstable with this option set.

Hmm, yes, it seems current messages are pale. The user could not understand what we want the message expressed when he got one such message. I will improve them to give user a clear meaning. And I think a XENLOG_WARNING would be better to notice user. I will do them in v3.

Quoted 15 lines
Quoted 1 line

More could be done for SVE (and other bits) but this should be in another

patch set.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

We throw these messages to break the silence when Xen detected unknown FP/SIMD IDs to notice user to check.

It feels a bit odd to me to print unknown for the FP/SIMD feature but not

for all the rest.

Quoted 2 lines
Quoted 2 lines

IMHO, the right approach is to sanitize ID registers exposed to domains

and only expose features we know are correctly handled.

Quoted 2 lines

I actually started to look into this last week because I came to an issue

comparable to SVE with pointer authentication.

Quoted 9 lines
Quoted 1 line

Maybe we should discuss this subject separately as clearing TID3 bit in HCR

and emulating all ID registers is possible

Quoted 1 line

but I want to check first if this could have big impacts on performances

I don't expect any performance drop. In Linux, they will cache all the values and use alternative to avoid runtime check.

I also don't expect any OS to use them at runtime in hotpath.

I think this would not be a problem. Most ID check operations would be done in system/application initialization stage.

Quoted 2 lines
Quoted 2 lines

and see discuss how to design this as there
could be a huge amount of cases for example if we want to allow different

Quoted 8 lines
Quoted 5 lines

parameters for different domains.

I would suggest to first consider a simple approach where we expose the same view of the ID registers to all the guests but it is sanitized.

Can I ask the reason why we don't expose native ID registers to guest? Is it because we want to avoid guest using some unaware features of Xen?

We should avoid guest using features that we do not support or that we do not even enable.

If you take SVE or Pointer Authentication, we are not activating the bits in HCR or CPTR to let a guest use those so the fact that we still let those bit set in the processor features registers is making guests try to use them and crash.

Quoted 11 lines
Quoted 8 lines

We can then discuss whether we want to have a per-guest view of the ID registers and how to configure it.

Regarding the implementation, I personally quite like the Linux cpufeature framework. It is quite powerful and I believe would suit quite well Xen.

I agree with you. But I think is quite huge, and out of this patch set's scope. We need a separate thread to discuss the design and implement.

Definitely this is out of scope of this patch I agree.

Regards
Bertrand