Skip to contentSkip to conversation

xen: arm: arm64: Adding VFP save/restore support.

PATCH Applied Pranavkumar Sawargaonkar 4 participants 14 messages Feb 6, 2014 – Feb 7, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: arm: arm64: Adding VFP save/restore support.

This patch adds VFP save/restore support form arm64 across context switch.

---
 xen/arch/arm/arm64/vfp.c        |   49 +++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/arm64/vfp.h |    4 ++++
 2 files changed, 53 insertions(+)
xen/arch/arm/arm64/vfp.c +49 -0
index 74e6a50..8c1479a 100644
@@ -1,13 +1,62 @@
 #include <xen/sched.h>
 #include <asm/processor.h>
+#include <asm/cpufeature.h>
 #include <asm/vfp.h>
 
 void vfp_save_state(struct vcpu *v)
 {
     /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("stp q0, q1, [%0, #16 * 0]\n\t"
+                 "stp q2, q3, [%0, #16 * 2]\n\t"
+                 "stp q4, q5, [%0, #16 * 4]\n\t"
+                 "stp q6, q7, [%0, #16 * 6]\n\t"
+                 "stp q8, q9, [%0, #16 * 8]\n\t"
+                 "stp q10, q11, [%0, #16 * 10]\n\t"
+                 "stp q12, q13, [%0, #16 * 12]\n\t"
+                 "stp q14, q15, [%0, #16 * 14]\n\t"
+                 "stp q16, q17, [%0, #16 * 16]\n\t"
+                 "stp q18, q19, [%0, #16 * 18]\n\t"
+                 "stp q20, q21, [%0, #16 * 20]\n\t"
+                 "stp q22, q23, [%0, #16 * 22]\n\t"
+                 "stp q24, q25, [%0, #16 * 24]\n\t"
+                 "stp q26, q27, [%0, #16 * 26]\n\t"
+                 "stp q28, q29, [%0, #16 * 28]\n\t"
+                 "stp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    v->arch.vfp.fpsr = READ_SYSREG32(FPSR);
+    v->arch.vfp.fpcr = READ_SYSREG32(FPCR);
+    v->arch.vfp.fpexc32_el2 = READ_SYSREG32(FPEXC32_EL2);
 }
 
 void vfp_restore_state(struct vcpu *v)
 {
     /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("ldp q0, q1, [%0, #16 * 0]\n\t"
+                 "ldp q2, q3, [%0, #16 * 2]\n\t"
+                 "ldp q4, q5, [%0, #16 * 4]\n\t"
+                 "ldp q6, q7, [%0, #16 * 6]\n\t"
+                 "ldp q8, q9, [%0, #16 * 8]\n\t"
+                 "ldp q10, q11, [%0, #16 * 10]\n\t"
+                 "ldp q12, q13, [%0, #16 * 12]\n\t"
+                 "ldp q14, q15, [%0, #16 * 14]\n\t"
+                 "ldp q16, q17, [%0, #16 * 16]\n\t"
+                 "ldp q18, q19, [%0, #16 * 18]\n\t"
+                 "ldp q20, q21, [%0, #16 * 20]\n\t"
+                 "ldp q22, q23, [%0, #16 * 22]\n\t"
+                 "ldp q24, q25, [%0, #16 * 24]\n\t"
+                 "ldp q26, q27, [%0, #16 * 26]\n\t"
+                 "ldp q28, q29, [%0, #16 * 28]\n\t"
+                 "ldp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    WRITE_SYSREG32(v->arch.vfp.fpsr, FPSR);
+    WRITE_SYSREG32(v->arch.vfp.fpcr, FPCR);
+    WRITE_SYSREG32(v->arch.vfp.fpexc32_el2, FPEXC32_EL2);
 }
xen/include/asm-arm/arm64/vfp.h +4 -0
index 3733d2c..373f156 100644
@@ -3,6 +3,10 @@
 
 struct vfp_state
 {
+    uint64_t fpregs[64];
+    uint32_t fpcr;
+    uint32_t fpexc32_el2;
+    uint32_t fpsr;
 };
 
 #endif /* _ARM_ARM64_VFP_H */
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Pranavkumar Sawargaonkar

This patch adds VFP save/restore support form arm64 across context switch.

This should go in for 4.4 -- not context switching floating point registers is obviously a big problem. (bit embarrassed that I forgot about this...)

Quoted 10 lines
---
 xen/arch/arm/arm64/vfp.c        |   49 +++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/arm64/vfp.h |    4 ++++
 2 files changed, 53 insertions(+)
xen/arch/arm/arm64/vfp.c +0 -0
index 74e6a50..8c1479a 100644

xen/arch/arm/arm64/vfp.c line 8

Quoted 8 lines
xen/arch/arm/arm64/vfp.c +1 -0
@@ -1,13 +1,62 @@
 #include <xen/sched.h>
 #include <asm/processor.h>
+#include <asm/cpufeature.h>
 #include <asm/vfp.h>
 
 void vfp_save_state(struct vcpu *v)
 {
     /* TODO: implement it */

You can probably remove this comment, and the one in restore, unless there is something still left to do?

Actually, I'll do it on commit, so:

Quoted 69 lines
xen/arch/arm/arm64/vfp.c +48 -0
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("stp q0, q1, [%0, #16 * 0]\n\t"
+                 "stp q2, q3, [%0, #16 * 2]\n\t"
+                 "stp q4, q5, [%0, #16 * 4]\n\t"
+                 "stp q6, q7, [%0, #16 * 6]\n\t"
+                 "stp q8, q9, [%0, #16 * 8]\n\t"
+                 "stp q10, q11, [%0, #16 * 10]\n\t"
+                 "stp q12, q13, [%0, #16 * 12]\n\t"
+                 "stp q14, q15, [%0, #16 * 14]\n\t"
+                 "stp q16, q17, [%0, #16 * 16]\n\t"
+                 "stp q18, q19, [%0, #16 * 18]\n\t"
+                 "stp q20, q21, [%0, #16 * 20]\n\t"
+                 "stp q22, q23, [%0, #16 * 22]\n\t"
+                 "stp q24, q25, [%0, #16 * 24]\n\t"
+                 "stp q26, q27, [%0, #16 * 26]\n\t"
+                 "stp q28, q29, [%0, #16 * 28]\n\t"
+                 "stp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    v->arch.vfp.fpsr = READ_SYSREG32(FPSR);
+    v->arch.vfp.fpcr = READ_SYSREG32(FPCR);
+    v->arch.vfp.fpexc32_el2 = READ_SYSREG32(FPEXC32_EL2);
 }
 
 void vfp_restore_state(struct vcpu *v)
 {
     /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("ldp q0, q1, [%0, #16 * 0]\n\t"
+                 "ldp q2, q3, [%0, #16 * 2]\n\t"
+                 "ldp q4, q5, [%0, #16 * 4]\n\t"
+                 "ldp q6, q7, [%0, #16 * 6]\n\t"
+                 "ldp q8, q9, [%0, #16 * 8]\n\t"
+                 "ldp q10, q11, [%0, #16 * 10]\n\t"
+                 "ldp q12, q13, [%0, #16 * 12]\n\t"
+                 "ldp q14, q15, [%0, #16 * 14]\n\t"
+                 "ldp q16, q17, [%0, #16 * 16]\n\t"
+                 "ldp q18, q19, [%0, #16 * 18]\n\t"
+                 "ldp q20, q21, [%0, #16 * 20]\n\t"
+                 "ldp q22, q23, [%0, #16 * 22]\n\t"
+                 "ldp q24, q25, [%0, #16 * 24]\n\t"
+                 "ldp q26, q27, [%0, #16 * 26]\n\t"
+                 "ldp q28, q29, [%0, #16 * 28]\n\t"
+                 "ldp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    WRITE_SYSREG32(v->arch.vfp.fpsr, FPSR);
+    WRITE_SYSREG32(v->arch.vfp.fpcr, FPCR);
+    WRITE_SYSREG32(v->arch.vfp.fpexc32_el2, FPEXC32_EL2);
 }
xen/include/asm-arm/arm64/vfp.h +4 -0
index 3733d2c..373f156 100644
@@ -3,6 +3,10 @@
 
 struct vfp_state
 {
+    uint64_t fpregs[64];
+    uint32_t fpcr;
+    uint32_t fpexc32_el2;
+    uint32_t fpsr;
 };
 
 #endif /* _ARM_ARM64_VFP_H */
#2 lore raw

Hi Ian,

Quoted 25 lines · Ian Campbell
Quoted 4 lines · Pranavkumar Sawargaonkar

This patch adds VFP save/restore support form arm64 across context switch.

This should go in for 4.4 -- not context switching floating point registers is obviously a big problem. (bit embarrassed that I forgot about this...)

Quoted 15 lines
---
 xen/arch/arm/arm64/vfp.c        |   49 +++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/arm64/vfp.h |    4 ++++
 2 files changed, 53 insertions(+)
xen/arch/arm/arm64/vfp.c +1 -0
index 74e6a50..8c1479a 100644
@@ -1,13 +1,62 @@
 #include <xen/sched.h>
 #include <asm/processor.h>
+#include <asm/cpufeature.h>
 #include <asm/vfp.h>
 
Quoted 6 lines

xen/arch/arm/arm64/vfp.c line 8

Quoted 3 lines
xen/arch/arm/arm64/vfp.c +0 -0
 void vfp_save_state(struct vcpu *v)
 {
     /* TODO: implement it */

You can probably remove this comment, and the one in restore, unless there is something still left to do?

Oops, sorry let me remove and repost it.

Quoted 72 lines

Actually, I'll do it on commit, so:

Quoted 68 lines
xen/arch/arm/arm64/vfp.c +48 -0
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("stp q0, q1, [%0, #16 * 0]\n\t"
+                 "stp q2, q3, [%0, #16 * 2]\n\t"
+                 "stp q4, q5, [%0, #16 * 4]\n\t"
+                 "stp q6, q7, [%0, #16 * 6]\n\t"
+                 "stp q8, q9, [%0, #16 * 8]\n\t"
+                 "stp q10, q11, [%0, #16 * 10]\n\t"
+                 "stp q12, q13, [%0, #16 * 12]\n\t"
+                 "stp q14, q15, [%0, #16 * 14]\n\t"
+                 "stp q16, q17, [%0, #16 * 16]\n\t"
+                 "stp q18, q19, [%0, #16 * 18]\n\t"
+                 "stp q20, q21, [%0, #16 * 20]\n\t"
+                 "stp q22, q23, [%0, #16 * 22]\n\t"
+                 "stp q24, q25, [%0, #16 * 24]\n\t"
+                 "stp q26, q27, [%0, #16 * 26]\n\t"
+                 "stp q28, q29, [%0, #16 * 28]\n\t"
+                 "stp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    v->arch.vfp.fpsr = READ_SYSREG32(FPSR);
+    v->arch.vfp.fpcr = READ_SYSREG32(FPCR);
+    v->arch.vfp.fpexc32_el2 = READ_SYSREG32(FPEXC32_EL2);
 }
 
 void vfp_restore_state(struct vcpu *v)
 {
     /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("ldp q0, q1, [%0, #16 * 0]\n\t"
+                 "ldp q2, q3, [%0, #16 * 2]\n\t"
+                 "ldp q4, q5, [%0, #16 * 4]\n\t"
+                 "ldp q6, q7, [%0, #16 * 6]\n\t"
+                 "ldp q8, q9, [%0, #16 * 8]\n\t"
+                 "ldp q10, q11, [%0, #16 * 10]\n\t"
+                 "ldp q12, q13, [%0, #16 * 12]\n\t"
+                 "ldp q14, q15, [%0, #16 * 14]\n\t"
+                 "ldp q16, q17, [%0, #16 * 16]\n\t"
+                 "ldp q18, q19, [%0, #16 * 18]\n\t"
+                 "ldp q20, q21, [%0, #16 * 20]\n\t"
+                 "ldp q22, q23, [%0, #16 * 22]\n\t"
+                 "ldp q24, q25, [%0, #16 * 24]\n\t"
+                 "ldp q26, q27, [%0, #16 * 26]\n\t"
+                 "ldp q28, q29, [%0, #16 * 28]\n\t"
+                 "ldp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    WRITE_SYSREG32(v->arch.vfp.fpsr, FPSR);
+    WRITE_SYSREG32(v->arch.vfp.fpcr, FPCR);
+    WRITE_SYSREG32(v->arch.vfp.fpexc32_el2, FPEXC32_EL2);
 }
xen/include/asm-arm/arm64/vfp.h +4 -0
index 3733d2c..373f156 100644
@@ -3,6 +3,10 @@
 
 struct vfp_state
 {
+    uint64_t fpregs[64];
+    uint32_t fpcr;
+    uint32_t fpexc32_el2;
+    uint32_t fpsr;
 };
 
Quoted 3 lines

xen/include/asm-arm/arm64/vfp.h line 12

Quoted 1 line
xen/include/asm-arm/arm64/vfp.h +0 -0
 #endif /* _ARM_ARM64_VFP_H */

Thanks,
Pranav

#3 lore raw
In reply to Ian Campbell

Hi Ian,

Quoted 25 lines · Ian Campbell
Quoted 4 lines · Pranavkumar Sawargaonkar

This patch adds VFP save/restore support form arm64 across context switch.

This should go in for 4.4 -- not context switching floating point registers is obviously a big problem. (bit embarrassed that I forgot about this...)

Quoted 15 lines
---
 xen/arch/arm/arm64/vfp.c        |   49 +++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/arm64/vfp.h |    4 ++++
 2 files changed, 53 insertions(+)
xen/arch/arm/arm64/vfp.c +1 -0
index 74e6a50..8c1479a 100644
@@ -1,13 +1,62 @@
 #include <xen/sched.h>
 #include <asm/processor.h>
+#include <asm/cpufeature.h>
 #include <asm/vfp.h>
 
Quoted 8 lines

xen/arch/arm/arm64/vfp.c line 8

Quoted 3 lines
xen/arch/arm/arm64/vfp.c +0 -0
 void vfp_save_state(struct vcpu *v)
 {
     /* TODO: implement it */

You can probably remove this comment, and the one in restore, unless there is something still left to do?

Actually, I'll do it on commit, so:

Missed out above line. Please remove it during commit.

Quoted 1 line

Thanks,
Pranav

Quoted 72 lines
Quoted 70 lines
xen/arch/arm/arm64/vfp.c +48 -0
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("stp q0, q1, [%0, #16 * 0]\n\t"
+                 "stp q2, q3, [%0, #16 * 2]\n\t"
+                 "stp q4, q5, [%0, #16 * 4]\n\t"
+                 "stp q6, q7, [%0, #16 * 6]\n\t"
+                 "stp q8, q9, [%0, #16 * 8]\n\t"
+                 "stp q10, q11, [%0, #16 * 10]\n\t"
+                 "stp q12, q13, [%0, #16 * 12]\n\t"
+                 "stp q14, q15, [%0, #16 * 14]\n\t"
+                 "stp q16, q17, [%0, #16 * 16]\n\t"
+                 "stp q18, q19, [%0, #16 * 18]\n\t"
+                 "stp q20, q21, [%0, #16 * 20]\n\t"
+                 "stp q22, q23, [%0, #16 * 22]\n\t"
+                 "stp q24, q25, [%0, #16 * 24]\n\t"
+                 "stp q26, q27, [%0, #16 * 26]\n\t"
+                 "stp q28, q29, [%0, #16 * 28]\n\t"
+                 "stp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    v->arch.vfp.fpsr = READ_SYSREG32(FPSR);
+    v->arch.vfp.fpcr = READ_SYSREG32(FPCR);
+    v->arch.vfp.fpexc32_el2 = READ_SYSREG32(FPEXC32_EL2);
 }
 
 void vfp_restore_state(struct vcpu *v)
 {
     /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("ldp q0, q1, [%0, #16 * 0]\n\t"
+                 "ldp q2, q3, [%0, #16 * 2]\n\t"
+                 "ldp q4, q5, [%0, #16 * 4]\n\t"
+                 "ldp q6, q7, [%0, #16 * 6]\n\t"
+                 "ldp q8, q9, [%0, #16 * 8]\n\t"
+                 "ldp q10, q11, [%0, #16 * 10]\n\t"
+                 "ldp q12, q13, [%0, #16 * 12]\n\t"
+                 "ldp q14, q15, [%0, #16 * 14]\n\t"
+                 "ldp q16, q17, [%0, #16 * 16]\n\t"
+                 "ldp q18, q19, [%0, #16 * 18]\n\t"
+                 "ldp q20, q21, [%0, #16 * 20]\n\t"
+                 "ldp q22, q23, [%0, #16 * 22]\n\t"
+                 "ldp q24, q25, [%0, #16 * 24]\n\t"
+                 "ldp q26, q27, [%0, #16 * 26]\n\t"
+                 "ldp q28, q29, [%0, #16 * 28]\n\t"
+                 "ldp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    WRITE_SYSREG32(v->arch.vfp.fpsr, FPSR);
+    WRITE_SYSREG32(v->arch.vfp.fpcr, FPCR);
+    WRITE_SYSREG32(v->arch.vfp.fpexc32_el2, FPEXC32_EL2);
 }
xen/include/asm-arm/arm64/vfp.h +4 -0
index 3733d2c..373f156 100644
@@ -3,6 +3,10 @@
 
 struct vfp_state
 {
+    uint64_t fpregs[64];
+    uint32_t fpcr;
+    uint32_t fpexc32_el2;
+    uint32_t fpsr;
 };
 
 #endif /* _ARM_ARM64_VFP_H */
#4 lore raw
In reply to Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Pranavkumar Sawargaonkar

This patch adds VFP save/restore support form arm64 across context switch.

This should go in for 4.4 -- not context switching floating point registers is obviously a big problem. (bit embarrassed that I forgot about this...)

Yes, absolutely.

Quoted 95 lines
Quoted 11 lines
---
  xen/arch/arm/arm64/vfp.c        |   49 +++++++++++++++++++++++++++++++++++++++
  xen/include/asm-arm/arm64/vfp.h |    4 ++++
  2 files changed, 53 insertions(+)
xen/arch/arm/arm64/vfp.c +0 -0
index 74e6a50..8c1479a 100644

xen/arch/arm/arm64/vfp.c line 8

Quoted 8 lines
xen/arch/arm/arm64/vfp.c +1 -0
@@ -1,13 +1,62 @@
  #include <xen/sched.h>
  #include <asm/processor.h>
+#include <asm/cpufeature.h>
  #include <asm/vfp.h>
 
  void vfp_save_state(struct vcpu *v)
  {
      /* TODO: implement it */

You can probably remove this comment, and the one in restore, unless there is something still left to do?

Actually, I'll do it on commit, so:

Quoted 69 lines
xen/arch/arm/arm64/vfp.c +48 -0
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("stp q0, q1, [%0, #16 * 0]\n\t"
+                 "stp q2, q3, [%0, #16 * 2]\n\t"
+                 "stp q4, q5, [%0, #16 * 4]\n\t"
+                 "stp q6, q7, [%0, #16 * 6]\n\t"
+                 "stp q8, q9, [%0, #16 * 8]\n\t"
+                 "stp q10, q11, [%0, #16 * 10]\n\t"
+                 "stp q12, q13, [%0, #16 * 12]\n\t"
+                 "stp q14, q15, [%0, #16 * 14]\n\t"
+                 "stp q16, q17, [%0, #16 * 16]\n\t"
+                 "stp q18, q19, [%0, #16 * 18]\n\t"
+                 "stp q20, q21, [%0, #16 * 20]\n\t"
+                 "stp q22, q23, [%0, #16 * 22]\n\t"
+                 "stp q24, q25, [%0, #16 * 24]\n\t"
+                 "stp q26, q27, [%0, #16 * 26]\n\t"
+                 "stp q28, q29, [%0, #16 * 28]\n\t"
+                 "stp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    v->arch.vfp.fpsr = READ_SYSREG32(FPSR);
+    v->arch.vfp.fpcr = READ_SYSREG32(FPCR);
+    v->arch.vfp.fpexc32_el2 = READ_SYSREG32(FPEXC32_EL2);
  }
 
  void vfp_restore_state(struct vcpu *v)
  {
      /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("ldp q0, q1, [%0, #16 * 0]\n\t"
+                 "ldp q2, q3, [%0, #16 * 2]\n\t"
+                 "ldp q4, q5, [%0, #16 * 4]\n\t"
+                 "ldp q6, q7, [%0, #16 * 6]\n\t"
+                 "ldp q8, q9, [%0, #16 * 8]\n\t"
+                 "ldp q10, q11, [%0, #16 * 10]\n\t"
+                 "ldp q12, q13, [%0, #16 * 12]\n\t"
+                 "ldp q14, q15, [%0, #16 * 14]\n\t"
+                 "ldp q16, q17, [%0, #16 * 16]\n\t"
+                 "ldp q18, q19, [%0, #16 * 18]\n\t"
+                 "ldp q20, q21, [%0, #16 * 20]\n\t"
+                 "ldp q22, q23, [%0, #16 * 22]\n\t"
+                 "ldp q24, q25, [%0, #16 * 24]\n\t"
+                 "ldp q26, q27, [%0, #16 * 26]\n\t"
+                 "ldp q28, q29, [%0, #16 * 28]\n\t"
+                 "ldp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");
+
+    WRITE_SYSREG32(v->arch.vfp.fpsr, FPSR);
+    WRITE_SYSREG32(v->arch.vfp.fpcr, FPCR);
+    WRITE_SYSREG32(v->arch.vfp.fpexc32_el2, FPEXC32_EL2);
  }
xen/include/asm-arm/arm64/vfp.h +4 -0
index 3733d2c..373f156 100644
@@ -3,6 +3,10 @@
 
  struct vfp_state
  {
+    uint64_t fpregs[64];
+    uint32_t fpcr;
+    uint32_t fpexc32_el2;
+    uint32_t fpsr;
  };
 
  #endif /* _ARM_ARM64_VFP_H */
Applied
#5 lore raw
Quoted 6 lines · George Dunlap
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Pranavkumar Sawargaonkar

This patch adds VFP save/restore support form arm64 across context switch.

Quoted 7 lines
Quoted 3 lines

This should go in for 4.4 -- not context switching floating point registers is obviously a big problem. (bit embarrassed that I forgot about this...)

Yes, absolutely.

Applied, thanks all.

#6 lore raw
In reply to Pranavkumar Sawargaonkar

Hello,

Quoted 32 lines · Pranavkumar Sawargaonkar

This patch adds VFP save/restore support form arm64 across context switch.

---
  xen/arch/arm/arm64/vfp.c        |   49 +++++++++++++++++++++++++++++++++++++++
  xen/include/asm-arm/arm64/vfp.h |    4 ++++
  2 files changed, 53 insertions(+)
xen/arch/arm/arm64/vfp.c +11 -0
index 74e6a50..8c1479a 100644
@@ -1,13 +1,62 @@
  #include <xen/sched.h>
  #include <asm/processor.h>
+#include <asm/cpufeature.h>
  #include <asm/vfp.h>
 
  void vfp_save_state(struct vcpu *v)
  {
      /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("stp q0, q1, [%0, #16 * 0]\n\t"
+                 "stp q2, q3, [%0, #16 * 2]\n\t"
+                 "stp q4, q5, [%0, #16 * 4]\n\t"
+                 "stp q6, q7, [%0, #16 * 6]\n\t"
+                 "stp q8, q9, [%0, #16 * 8]\n\t"
+                 "stp q10, q11, [%0, #16 * 10]\n\t"
+                 "stp q12, q13, [%0, #16 * 12]\n\t"

xen/arch/arm/arm64/vfp.c line 28

Quoted 10 lines
xen/arch/arm/arm64/vfp.c +10 -0
+                 "stp q14, q15, [%0, #16 * 14]\n\t"
+                 "stp q16, q17, [%0, #16 * 16]\n\t"
+                 "stp q18, q19, [%0, #16 * 18]\n\t"
+                 "stp q20, q21, [%0, #16 * 20]\n\t"
+                 "stp q22, q23, [%0, #16 * 22]\n\t"
+                 "stp q24, q25, [%0, #16 * 24]\n\t"
+                 "stp q26, q27, [%0, #16 * 26]\n\t"
+                 "stp q28, q29, [%0, #16 * 28]\n\t"
+                 "stp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints (http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

I think you should use "=Q" also here to avoid cloberring the whole memory.

At the same time, is it necessary the (char *)?

Quoted 19 lines
xen/arch/arm/arm64/vfp.c +14 -0
+
+    v->arch.vfp.fpsr = READ_SYSREG32(FPSR);
+    v->arch.vfp.fpcr = READ_SYSREG32(FPCR);
+    v->arch.vfp.fpexc32_el2 = READ_SYSREG32(FPEXC32_EL2);
  }
 
  void vfp_restore_state(struct vcpu *v)
  {
      /* TODO: implement it */
+    if ( !cpu_has_fp )
+        return;
+
+    asm volatile("ldp q0, q1, [%0, #16 * 0]\n\t"
+                 "ldp q2, q3, [%0, #16 * 2]\n\t"
+                 "ldp q4, q5, [%0, #16 * 4]\n\t"
+                 "ldp q6, q7, [%0, #16 * 6]\n\t"
+                 "ldp q8, q9, [%0, #16 * 8]\n\t"
+                 "ldp q10, q11, [%0, #16 * 10]\n\t"
+                 "ldp q12, q13, [%0, #16 * 12]\n\t"

xen/arch/arm/arm64/vfp.c line 57

Quoted 10 lines
xen/arch/arm/arm64/vfp.c +10 -0
+                 "ldp q14, q15, [%0, #16 * 14]\n\t"
+                 "ldp q16, q17, [%0, #16 * 16]\n\t"
+                 "ldp q18, q19, [%0, #16 * 18]\n\t"
+                 "ldp q20, q21, [%0, #16 * 20]\n\t"
+                 "ldp q22, q23, [%0, #16 * 22]\n\t"
+                 "ldp q24, q25, [%0, #16 * 24]\n\t"
+                 "ldp q26, q27, [%0, #16 * 26]\n\t"
+                 "ldp q28, q29, [%0, #16 * 28]\n\t"
+                 "ldp q30, q31, [%0, #16 * 30]\n\t"
+                 :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

Same here.

Regards,

Signature · 1 line
Julien Grall
#7 lore raw
Quoted 7 lines · Julien Grall
Quoted 1 line

+ :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints
(http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

I think you should use "=Q" also here to avoid cloberring the whole memory.

Yes, I forgot to say: I think getting something in now is the priority, which is why I committed it, but this should be tightened up, probably for 4.5 unless the difference is benchmarkable.

Quoted 1 line

At the same time, is it necessary the (char *)?

I missed that, yes I suspect it is unnecessary.

Ian.

#8 lore raw
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Julien Grall
Quoted 1 line

+ :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints
(http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

Quoted 5 lines
Quoted 1 line

I think you should use "=Q" also here to avoid cloberring the whole memory.

Yes, I forgot to say: I think getting something in now is the priority, which is why I committed it, but this should be tightened up, probably for 4.5 unless the difference is benchmarkable.

The fix is very simple (a matter of 2 lines changes). I would prefer to delay this patch for a couple of days and having a correct implementation from the beginning, so we will not forgot to change the code for Xen 4.5.

Moreover Pranav usually answer quickly :).

Signature · 1 line
Julien Grall
#9 lore raw
Quoted 11 lines · Julien Grall
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Quoted 1 line

+ :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints
(http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

I think you should use "=Q" also here to avoid cloberring the whole memory.

Quoted 8 lines
Quoted 3 lines

Yes, I forgot to say: I think getting something in now is the priority, which is why I committed it, but this should be tightened up, probably for 4.5 unless the difference is benchmarkable.

The fix is very simple (a matter of 2 lines changes). I would prefer to delay this patch for a couple of days and having a correct implementation from the beginning, so we will not forgot to change the code for Xen 4.5.

And I would rather close this rather large hole right now and not wait for two more days when we are looking at doing what might be the final rc soon.

I had already applied before you said anything, so the point is moot.

Anyway, if someone wants to submit for 4.4 with a case for a release exception then I'm sure George will consider it.

Otherwise this thread is now in my QUEUE-4.5 folder so I'll get a reminder shortly after the release when I go through that.

Quoted 1 line

Moreover Pranav usually answer quickly :).

If he's awake/at work, it's out of office hours for him now.

Ian.

#10 lore raw

Hi Ian,

Quoted 30 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Quoted 1 line

+ :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints
(http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

I think you should use "=Q" also here to avoid cloberring the whole memory.

Quoted 8 lines
Quoted 3 lines

Yes, I forgot to say: I think getting something in now is the priority, which is why I committed it, but this should be tightened up, probably for 4.5 unless the difference is benchmarkable.

The fix is very simple (a matter of 2 lines changes). I would prefer to delay this patch for a couple of days and having a correct implementation from the beginning, so we will not forgot to change the code for Xen 4.5.

And I would rather close this rather large hole right now and not wait for two more days when we are looking at doing what might be the final rc soon.

I had already applied before you said anything, so the point is moot.

Anyway, if someone wants to submit for 4.4 with a case for a release exception then I'm sure George will consider it.

Quoted 6 lines

Otherwise this thread is now in my QUEUE-4.5 folder so I'll get a reminder shortly after the release when I go through that.

Quoted 1 line

Moreover Pranav usually answer quickly :).

If he's awake/at work, it's out of office hours for him now.

: ) :) , sorry somehow I missed this yesterday.

If "=Q" is really critical i can quickly send you a new patch against your commit in staging branch
(http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=712eb2e04da2cbcd9908f74ebd47c6df60d6d12f)

Quoted 3 lines

Ian.

Thanks,
Pranav

#11 lore raw

Hi Ian/ Julien,

Quoted 38 lines · Pranavkumar Sawargaonkar

Hi Ian,

Quoted 35 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Quoted 1 line

+ :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints
(http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

I think you should use "=Q" also here to avoid cloberring the whole memory.

Quoted 8 lines
Quoted 3 lines

Yes, I forgot to say: I think getting something in now is the priority, which is why I committed it, but this should be tightened up, probably for 4.5 unless the difference is benchmarkable.

The fix is very simple (a matter of 2 lines changes). I would prefer to delay this patch for a couple of days and having a correct implementation from the beginning, so we will not forgot to change the code for Xen 4.5.

And I would rather close this rather large hole right now and not wait for two more days when we are looking at doing what might be the final rc soon.

I had already applied before you said anything, so the point is moot.

Anyway, if someone wants to submit for 4.4 with a case for a release exception then I'm sure George will consider it.

Otherwise this thread is now in my QUEUE-4.5 folder so I'll get a reminder shortly after the release when I go through that.

Quoted 1 line

Moreover Pranav usually answer quickly :).

Quoted 7 lines
Quoted 1 line

If he's awake/at work, it's out of office hours for him now.

: ) :) , sorry somehow I missed this yesterday.

If "=Q" is really critical i can quickly send you a new patch against your commit in staging branch
(http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=712eb2e04da2cbcd9908f74ebd47c6df60d6d12f)

Posted a new patch with the desired fix -
"xen: arm: arm64: Fix memory cloberring issues during VFP save restore."

Quoted 5 lines
Quoted 3 lines

Ian.

Thanks,
Pranav

Thanks,
Pranav

#12 lore raw
In reply to Ian Campbell
Quoted 21 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Quoted 1 line

+ :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints
(http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

I think you should use "=Q" also here to avoid cloberring the whole memory.

Quoted 8 lines
Quoted 3 lines

Yes, I forgot to say: I think getting something in now is the priority, which is why I committed it, but this should be tightened up, probably for 4.5 unless the difference is benchmarkable.

The fix is very simple (a matter of 2 lines changes). I would prefer to delay this patch for a couple of days and having a correct implementation from the beginning, so we will not forgot to change the code for Xen 4.5.

Quoted 5 lines

And I would rather close this rather large hole right now and not wait for two more days when we are looking at doing what might be the final rc soon.

I had already applied before you said anything, so the point is moot.

But just for future reference: Be on your guard against the "hurry and get in" mentality; it's likely to be counterproductive. I'd rather have *more* care taken with the patches at this point than normally. If that means making a case to delay the release, that's what it will take. This would obviously have been a complete blocker -- there's no way we could in good release without FPU support for guests. :-)

-George

#13 lore raw
Quoted 26 lines · George Dunlap
Quoted 25 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Quoted 1 line

+ :: "r" ((char *)(&v->arch.vfp.fpregs)): "memory");

I remember we had a discussion when I have implemented vfp context switch for arm32 for the memory constraints
(http://lists.xen.org/archives/html/xen-devel/2013-06/msg00110.html).

I think you should use "=Q" also here to avoid cloberring the whole memory.

Quoted 8 lines
Quoted 3 lines

Yes, I forgot to say: I think getting something in now is the priority, which is why I committed it, but this should be tightened up, probably for 4.5 unless the difference is benchmarkable.

The fix is very simple (a matter of 2 lines changes). I would prefer to delay this patch for a couple of days and having a correct implementation from the beginning, so we will not forgot to change the code for Xen 4.5.

And I would rather close this rather large hole right now and not wait for two more days when we are looking at doing what might be the final rc soon.

Quoted 5 lines
Quoted 1 line

I had already applied before you said anything, so the point is moot.

But just for future reference: Be on your guard against the "hurry and get in" mentality; it's likely to be counterproductive. I'd rather have *more* care taken with the patches at this point than normally.

This was not a case of a careless rush to get something in. It was my opinion that the minor shortcoming wasn't worth waiting for compared with the benefit of getting that patch in sooner rather than later.

Note that the patch was not in any way wrong.

Quoted 5 lines

If that means making a case to delay the release, that's what it will take. This would obviously have been a complete blocker -- there's no way we could in good release without FPU support for guests. :-)

-George