Skip to contentSkip to conversation

xen: arm: correct vfp save/restore asm constraints.

PATCH In review Ian Campbell 4 participants 6 messages Jul 8, 2013 – Jul 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: arm: correct vfp save/restore asm constraints.

Some versions of gcc complain:

Quoted 3 lines

vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable

There is no way to express the constraint we want (which is the address of the array, clobbering the whole array). Therefore we have to fake it up by using two constraints.

---
 xen/arch/arm/arm32/vfp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
xen/arch/arm/arm32/vfp.c +9 -8
index 6780131..0069acd 100644
@@ -22,15 +22,15 @@ void vfp_save_state(struct vcpu *v)
     }
 
     /* Save {d0-d15} */
-    asm volatile("stc p11, cr0, %0, #32*4"
-                 : "=Q" (v->arch.vfp.fpregs1));
+    asm volatile("stc p11, cr0, [%1], #32*4"
+                 : "=Q" (*v->arch.vfp.fpregs1) : "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 )
     {
         /* Save {d16-d31} */
-        asm volatile("stcl p11, cr0, %0, #32*4"
-                     : "=Q" (v->arch.vfp.fpregs2));
+        asm volatile("stcl p11, cr0, [%1], #32*4"
+                     : "=Q" (*v->arch.vfp.fpregs2) : "r" (v->arch.vfp.fpregs2));
     }
 
     WRITE_CP32(v->arch.vfp.fpexc & ~(FPEXC_EN), FPEXC);
@@ -38,17 +38,18 @@ void vfp_save_state(struct vcpu *v)
 
 void vfp_restore_state(struct vcpu *v)
 {
+    //uint64_t test[16];
     WRITE_CP32(READ_CP32(FPEXC) | FPEXC_EN, FPEXC);
 
     /* Restore {d0-d15} */
-    asm volatile("ldc p11, cr0, %0, #32*4"
-                 : : "Q" (v->arch.vfp.fpregs1));
+    asm volatile("ldc p11, cr0, [%1], #32*4"
+                 : : "Q" (*v->arch.vfp.fpregs1), "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 ) /* 32 x 64 bits registers */
         /* Restore {d16-d31} */
-        asm volatile("ldcl p11, cr0, %0, #32*4"
-                     : : "Q" (v->arch.vfp.fpregs2));
+        asm volatile("ldcl p11, cr0, [%1], #32*4"
+                     : : "Q" (*v->arch.vfp.fpregs2), "r" (v->arch.vfp.fpregs2));
 
     if ( v->arch.vfp.fpexc & FPEXC_EX )
     {
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 10 lines · Ian Campbell

Some versions of gcc complain:

Quoted 3 lines

vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable

There is no way to express the constraint we want (which is the address of the array, clobbering the whole array). Therefore we have to fake it up by using two constraints.

Ahem.

Quoted 52 lines
---
 xen/arch/arm/arm32/vfp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
xen/arch/arm/arm32/vfp.c +9 -8
index 6780131..0069acd 100644
@@ -22,15 +22,15 @@ void vfp_save_state(struct vcpu *v)
     }
 
     /* Save {d0-d15} */
-    asm volatile("stc p11, cr0, %0, #32*4"
-                 : "=Q" (v->arch.vfp.fpregs1));
+    asm volatile("stc p11, cr0, [%1], #32*4"
+                 : "=Q" (*v->arch.vfp.fpregs1) : "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 )
     {
         /* Save {d16-d31} */
-        asm volatile("stcl p11, cr0, %0, #32*4"
-                     : "=Q" (v->arch.vfp.fpregs2));
+        asm volatile("stcl p11, cr0, [%1], #32*4"
+                     : "=Q" (*v->arch.vfp.fpregs2) : "r" (v->arch.vfp.fpregs2));
     }
 
     WRITE_CP32(v->arch.vfp.fpexc & ~(FPEXC_EN), FPEXC);
@@ -38,17 +38,18 @@ void vfp_save_state(struct vcpu *v)
 
 void vfp_restore_state(struct vcpu *v)
 {
+    //uint64_t test[16];
     WRITE_CP32(READ_CP32(FPEXC) | FPEXC_EN, FPEXC);
 
     /* Restore {d0-d15} */
-    asm volatile("ldc p11, cr0, %0, #32*4"
-                 : : "Q" (v->arch.vfp.fpregs1));
+    asm volatile("ldc p11, cr0, [%1], #32*4"
+                 : : "Q" (*v->arch.vfp.fpregs1), "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 ) /* 32 x 64 bits registers */
         /* Restore {d16-d31} */
-        asm volatile("ldcl p11, cr0, %0, #32*4"
-                     : : "Q" (v->arch.vfp.fpregs2));
+        asm volatile("ldcl p11, cr0, [%1], #32*4"
+                     : : "Q" (*v->arch.vfp.fpregs2), "r" (v->arch.vfp.fpregs2));
 
     if ( v->arch.vfp.fpexc & FPEXC_EX )
     {
Acked-by on v1 1/1
#2 lore raw
In reply to Ian Campbell
Quoted 11 lines · Ian Campbell

Some versions of gcc complain:

Quoted 3 lines

vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable

There is no way to express the constraint we want (which is the address of the array, clobbering the whole array). Therefore we have to fake it up by using two constraints.

Quoted 59 lines
---
 xen/arch/arm/arm32/vfp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
xen/arch/arm/arm32/vfp.c +9 -9
index 6780131..0069acd 100644
@@ -22,15 +22,15 @@ void vfp_save_state(struct vcpu *v)
     }
 
     /* Save {d0-d15} */
-    asm volatile("stc p11, cr0, %0, #32*4"
-                 : "=Q" (v->arch.vfp.fpregs1));
+    asm volatile("stc p11, cr0, [%1], #32*4"
+                 : "=Q" (*v->arch.vfp.fpregs1) : "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 )
     {
         /* Save {d16-d31} */
-        asm volatile("stcl p11, cr0, %0, #32*4"
-                     : "=Q" (v->arch.vfp.fpregs2));
+        asm volatile("stcl p11, cr0, [%1], #32*4"
+                     : "=Q" (*v->arch.vfp.fpregs2) : "r" (v->arch.vfp.fpregs2));
     }
 
     WRITE_CP32(v->arch.vfp.fpexc & ~(FPEXC_EN), FPEXC);
@@ -38,17 +38,18 @@ void vfp_save_state(struct vcpu *v)
 
 void vfp_restore_state(struct vcpu *v)
 {
+    //uint64_t test[16];
     WRITE_CP32(READ_CP32(FPEXC) | FPEXC_EN, FPEXC);
 
     /* Restore {d0-d15} */
-    asm volatile("ldc p11, cr0, %0, #32*4"
-                 : : "Q" (v->arch.vfp.fpregs1));
+    asm volatile("ldc p11, cr0, [%1], #32*4"
+                 : : "Q" (*v->arch.vfp.fpregs1), "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 ) /* 32 x 64 bits registers */
         /* Restore {d16-d31} */
-        asm volatile("ldcl p11, cr0, %0, #32*4"
-                     : : "Q" (v->arch.vfp.fpregs2));
+        asm volatile("ldcl p11, cr0, [%1], #32*4"
+                     : : "Q" (*v->arch.vfp.fpregs2), "r" (v->arch.vfp.fpregs2));
 
     if ( v->arch.vfp.fpexc & FPEXC_EX )
     {
--

1.8.3.2

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 6 lines · Julien Grall
Quoted 5 lines · Ian Campbell

Some versions of gcc complain:

Quoted 3 lines

vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable

Quoted 8 lines
Quoted 6 lines

There is no way to express the constraint we want (which is the address of the array, clobbering the whole array). Therefore we have to fake it up by using two constraints.

Thanks, I'd commit this ASAP since it has broken the push tests but unfortunately I'm travelling and the ssh gateway I would need to use is down. (which is also why this comes from my personal email).

If one of the other committers wants to throw this in in the meantime then please do so.

Ian.

Quoted 60 lines
Quoted 60 lines
---
 xen/arch/arm/arm32/vfp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
xen/arch/arm/arm32/vfp.c +9 -9
index 6780131..0069acd 100644
@@ -22,15 +22,15 @@ void vfp_save_state(struct vcpu *v)
     }
 
     /* Save {d0-d15} */
-    asm volatile("stc p11, cr0, %0, #32*4"
-                 : "=Q" (v->arch.vfp.fpregs1));
+    asm volatile("stc p11, cr0, [%1], #32*4"
+                 : "=Q" (*v->arch.vfp.fpregs1) : "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 )
     {
         /* Save {d16-d31} */
-        asm volatile("stcl p11, cr0, %0, #32*4"
-                     : "=Q" (v->arch.vfp.fpregs2));
+        asm volatile("stcl p11, cr0, [%1], #32*4"
+                     : "=Q" (*v->arch.vfp.fpregs2) : "r" (v->arch.vfp.fpregs2));
     }
 
     WRITE_CP32(v->arch.vfp.fpexc & ~(FPEXC_EN), FPEXC);
@@ -38,17 +38,18 @@ void vfp_save_state(struct vcpu *v)
 
 void vfp_restore_state(struct vcpu *v)
 {
+    //uint64_t test[16];
     WRITE_CP32(READ_CP32(FPEXC) | FPEXC_EN, FPEXC);
 
     /* Restore {d0-d15} */
-    asm volatile("ldc p11, cr0, %0, #32*4"
-                 : : "Q" (v->arch.vfp.fpregs1));
+    asm volatile("ldc p11, cr0, [%1], #32*4"
+                 : : "Q" (*v->arch.vfp.fpregs1), "r" (v->arch.vfp.fpregs1));
 
     /* 32 x 64 bits registers? */
     if ( (READ_CP32(MVFR0) & MVFR0_A_SIMD_MASK) == 2 ) /* 32 x 64 bits registers */
         /* Restore {d16-d31} */
-        asm volatile("ldcl p11, cr0, %0, #32*4"
-                     : : "Q" (v->arch.vfp.fpregs2));
+        asm volatile("ldcl p11, cr0, [%1], #32*4"
+                     : : "Q" (*v->arch.vfp.fpregs2), "r" (v->arch.vfp.fpregs2));
 
     if ( v->arch.vfp.fpexc & FPEXC_EX )
     {
--

1.8.3.2

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

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

Some versions of gcc complain:

Quoted 3 lines

vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable

There is no way to express the constraint we want (which is the address of

the

Quoted 1 line
Quoted 1 line

array, clobbering the whole array). Therefore we have to fake it up by

using

Quoted 5 lines
Quoted 4 lines

two constraints.

Quoted 8 lines
Quoted 1 line

Thanks, I'd commit this ASAP since it has broken the push tests but unfortunately I'm travelling and the ssh gateway I would need to use is down. (which is also why this comes from my personal email).

If one of the other committers wants to throw this in in the meantime then please do so.

Done.

Jan

#5 lore raw
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Julien Grall
Quoted 6 lines · Ian Campbell

Some versions of gcc complain:

Quoted 3 lines

vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable

There is no way to express the constraint we want (which is the address of

the

Quoted 1 line
Quoted 1 line

array, clobbering the whole array). Therefore we have to fake it up by

using

Quoted 6 lines
Quoted 4 lines

two constraints.

Quoted 8 lines
Quoted 6 lines

Thanks, I'd commit this ASAP since it has broken the push tests but unfortunately I'm travelling and the ssh gateway I would need to use is down. (which is also why this comes from my personal email).

If one of the other committers wants to throw this in in the meantime then please do so.

Done.

Thanks.