Skip to contentSkip to conversation

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

PATCH Superseded Wei Chen 2 participants 6 messages Aug 25, 2020

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Wei Chen

author
#0 lore raw

v3 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.

---
v2 --> v3:
1. Improve the warning messages to give clear meanings
2. Fix typos

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             | 12 ++++++++++++
 xen/include/asm-arm/cpufeature.h |  6 ++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 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 support, 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
#2 lore raw

PATCH v3 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             | 12 ++++++++++++
 xen/include/asm-arm/cpufeature.h |  2 ++
 2 files changed, 14 insertions(+)
xen/arch/arm/setup.c +12 -0
index 7968cee47d..ef39ce1ec6 100644
@@ -133,6 +133,18 @@ static void __init processor_id(void)
            cpu_has_simd ? " AdvancedSIMD" : "",
            cpu_has_gicv3 ? " GICv3-SysReg" : "");
 
+    /* Warn user if we find unknown floating-point features */
+    if ( cpu_has_unknown_fp )
+        printk(XENLOG_WARNING "WARNING: Unknown Floating-point ID:%d, "
+               "this may result to corruption on the platform\n",
+               boot_cpu_feature64(fp));
+
+    /* Warn user if we find unknown AdvancedSIMD features */
+    if ( cpu_has_unknown_simd )
+        printk(XENLOG_WARNING "WARNING: Unknown AdvancedSIMD ID:%d, "
+               "this may result to corruption on the platform\n",
+               boot_cpu_feature64(simd));
+
     printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",
            boot_cpu_data.dbg64.bits[0], boot_cpu_data.dbg64.bits[1]);
     printk("  Auxiliary Features: %016"PRIx64" %016"PRIx64"\n",
xen/include/asm-arm/cpufeature.h +2 -0
index 10878ead8a..a32309986e 100644
@@ -16,6 +16,8 @@
 #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)
+#define cpu_has_unknown_fp   (cpu_has_fp && (boot_cpu_feature64(fp) >= 2))
+#define cpu_has_unknown_simd (cpu_has_simd && (boot_cpu_feature64(simd) >= 2))
 #endif
 
 #define cpu_feature32(c, feat)         ((c)->pfr32.feat)
Signature · 1 line
2.17.1
#3 lore raw

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

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.

OOI, is this reviewed-by coming from internal review?

Quoted 33 lines
---
  xen/arch/arm/setup.c             | 12 ++++++++++++
  xen/include/asm-arm/cpufeature.h |  2 ++
  2 files changed, 14 insertions(+)
xen/arch/arm/setup.c +12 -0
index 7968cee47d..ef39ce1ec6 100644
@@ -133,6 +133,18 @@ static void __init processor_id(void)
             cpu_has_simd ? " AdvancedSIMD" : "",
             cpu_has_gicv3 ? " GICv3-SysReg" : "");
 
+    /* Warn user if we find unknown floating-point features */
+    if ( cpu_has_unknown_fp )
+        printk(XENLOG_WARNING "WARNING: Unknown Floating-point ID:%d, "
+               "this may result to corruption on the platform\n",
+               boot_cpu_feature64(fp));
+
+    /* Warn user if we find unknown AdvancedSIMD features */
+    if ( cpu_has_unknown_simd )
+        printk(XENLOG_WARNING "WARNING: Unknown AdvancedSIMD ID:%d, "
+               "this may result to corruption on the platform\n",
+               boot_cpu_feature64(simd));
+
      printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",
             boot_cpu_data.dbg64.bits[0], boot_cpu_data.dbg64.bits[1]);
      printk("  Auxiliary Features: %016"PRIx64" %016"PRIx64"\n",
xen/include/asm-arm/cpufeature.h +0 -0
index 10878ead8a..a32309986e 100644

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

Quoted 5 lines
xen/include/asm-arm/cpufeature.h +2 -0
@@ -16,6 +16,8 @@
  #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)
+#define cpu_has_unknown_fp   (cpu_has_fp && (boot_cpu_feature64(fp) >= 2))
+#define cpu_has_unknown_simd (cpu_has_simd && (boot_cpu_feature64(simd) >= 2))

I would rather prefer if we don't introduce cpu_has_unknown_{fp, simd} but open-code directly in the 'if'.

Other than that the code looks ok to me.

Cheers,

Signature · 1 line
Julien Grall
author
#4 lore raw

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

Hi Julien,

Quoted 23 lines

-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2020年8月25日 19:18
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 v3 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

Hi,

Quoted 9 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 4 lines
Quoted 2 lines

OOI, is this reviewed-by coming from internal review?

Ahh. No, I remember Bertrand gave me a reviewed-by in v2, so I picked it. I had left OSS for a while, and forgot something. If I can't pick it directly, could you please tell me how can I handle such reviewed-by?

Quoted 41 lines
Quoted 13 lines
---
  xen/arch/arm/setup.c             | 12 ++++++++++++
  xen/include/asm-arm/cpufeature.h |  2 ++
  2 files changed, 14 insertions(+)
xen/arch/arm/setup.c +0 -0
index 7968cee47d..ef39ce1ec6 100644
@@ -133,6 +133,18 @@ static void __init processor_id(void)
             cpu_has_simd ? " AdvancedSIMD" : "",
             cpu_has_gicv3 ? " GICv3-SysReg" : "");

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

Quoted 10 lines
xen/arch/arm/setup.c +9 -0
 
+    /* Warn user if we find unknown floating-point features */
+    if ( cpu_has_unknown_fp )
+        printk(XENLOG_WARNING "WARNING: Unknown Floating-point ID:%d, "
+               "this may result to corruption on the platform\n",
+               boot_cpu_feature64(fp));
+
+    /* Warn user if we find unknown AdvancedSIMD features */
+    if ( cpu_has_unknown_simd )
+        printk(XENLOG_WARNING "WARNING: Unknown AdvancedSIMD ID:%d,

"

xen/include/asm-

Quoted 7 lines
xen/arch/arm/setup.c +3 -0
+               "this may result to corruption on the platform\n",
+               boot_cpu_feature64(simd));
+
      printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",
             boot_cpu_data.dbg64.bits[0], boot_cpu_data.dbg64.bits[1]);
      printk("  Auxiliary Features: %016"PRIx64" %016"PRIx64"\n",
xen/include/asm- renamed from xen/include/asm-arm/cpufeature.h +0 -0

arm/cpufeature.h

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

Quoted 8 lines

index 10878ead8a..a32309986e 100644

xen/include/asm-arm/cpufeature.h +1 -0
@@ -16,6 +16,8 @@
  #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)
+#define cpu_has_unknown_fp   (cpu_has_fp && (boot_cpu_feature64(fp) >=

2))

Quoted 7 lines

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

Quoted 1 line
xen/include/asm-arm/cpufeature.h +1 -0
+#define cpu_has_unknown_simd (cpu_has_simd &&

(boot_cpu_feature64(simd) >= 2))

I would rather prefer if we don't introduce cpu_has_unknown_{fp, simd} but open-code directly in the 'if'.

Other than that the code looks ok to me.

Thanks, I could address it in v4.

Quoted 5 lines

Cheers,

--
Julien Grall

#5 lore raw

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

Quoted 25 lines · Wei Chen

Hi Julien,

Quoted 23 lines

-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2020年8月25日 19:18
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 v3 2/2] xen/arm: Throw messages for unknown FP/SIMD implement ID

Hi,

Quoted 9 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 8 lines
Quoted 4 lines
Quoted 2 lines

OOI, is this reviewed-by coming from internal review?

Ahh. No, I remember Bertrand gave me a reviewed-by in v2, so I picked it. I had left OSS for a while, and forgot something. If I can't pick it directly, could you please tell me how can I handle such reviewed-by?

In general reviewed-by implies the code was reviewed carefully. They should only be carried to a new version if they changes are very trivial.

You can also ask the reviewer if he/she is happy with the changes you will make so you can carry the tag.

Cheers,

Signature · 1 line
Julien Grall