lib: s390x: Inline asm cleanup
cover lib: s390x: Inline asm cleanup
The library should not have unnamed inline assembly arguments for the sake of readability. This series names the arguments and removes unused ones.
Janosch Frank (2):
lib: s390x: sigp: Name inline assembly arguments
lib: s390x: css: Name inline assembly arguments and clean them up
lib/s390x/asm/sigp.h | 10 +++--- lib/s390x/css.h | 76 ++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 43 deletions(-)
Signature · 1 line
2.40.1
RFC 1/2 lib: s390x: sigp: Name inline assembly arguments
Less need to count the operands makes the code easier to read.
--- lib/s390x/asm/sigp.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
lib/s390x/asm/sigp.h +5 -5
@@ -54,11 +54,11 @@ static inline int sigp(uint16_t addr, uint8_t order, unsigned long parm, asmvolatile (" tmll %[bogus_cc],3\n" -" sigp %1,%2,0(%3)\n" -" ipm %0\n" -" srl %0,28\n" - :"=d" (cc),"+d" (reg1) - :"d" (addr),"a" (order), [bogus_cc]"d" (bogus_cc) +" sigp %[reg1],%[addr],0(%[order])\n" +" ipm %[cc]\n" +" srl %[cc],28\n" + : [cc]"=d" (cc), [reg1]"+d" (reg1) + : [addr]"d" (addr), [order]"a" (order), [bogus_cc]"d" (bogus_cc) :"cc" );if (status) *status = reg1;
Signature · 1 line
2.40.1
Re: [kvm-unit-tests RFC 1/2] lib: s390x: sigp: Name inline assembly arguments
Quoted 3 lines · On Thu, 1 Feb 2024 14:23:55 +0000 Janosch Frank <[email protected]> wrote:
Less need to count the operands makes the code easier to read.
Signed-off-by Janosch Frank <[email protected]>
Quoted 25 lines
--- lib/s390x/asm/sigp.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)lib/s390x/asm/sigp.h +5
-5@@ -54,11 +54,11 @@ static inline int sigp(uint16_t addr, uint8_t order, unsigned long parm, asmvolatile (" tmll %[bogus_cc],3\n" -" sigp %1,%2,0(%3)\n" -" ipm %0\n" -" srl %0,28\n" - :"=d" (cc),"+d" (reg1) - :"d" (addr),"a" (order), [bogus_cc]"d" (bogus_cc) +" sigp %[reg1],%[addr],0(%[order])\n" +" ipm %[cc]\n" +" srl %[cc],28\n" + : [cc]"=d" (cc), [reg1]"+d" (reg1) + : [addr]"d" (addr), [order]"a" (order), [bogus_cc]"d" (bogus_cc) :"cc" );if (status) *status = reg1;
RFC 2/2 lib: s390x: css: Name inline assembly arguments and clean them up
In reply to Janosch FrankLess need to count the operands makes the code easier to read. For ssch and msch the second addr argument which was unused was removed.
--- lib/s390x/css.h | 76 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-)
lib/s390x/css.h +38 -38
@@ -135,11 +135,11 @@ static inline int ssch(unsigned long schid, struct orb *addr)int cc; asmvolatile ( -" ssch 0(%2)\n" -" ipm %0\n" -" srl %0,28\n" - :"=d" (cc) - :"d" (reg1),"a" (addr),"m" (*addr) +" ssch 0(%[addr])\n" +" ipm %[cc]\n" +" srl %[cc],28\n" + : [cc]"=d" (cc) + :"d" (reg1), [addr]"a" (addr) :"cc" ,"memory" );return cc; }
@@ -152,11 +152,11 @@ static inline int stsch(unsigned long schid, struct schib *addr) asmvolatile (" tmll %[bogus_cc],3\n" -" stsch 0(%3)\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc),"=m" (*addr) - :"d" (reg1),"a" (addr), [bogus_cc]"d" (bogus_cc) +" stsch 0(%[addr])\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc),"=m" (*addr) + :"d" (reg1), [addr]"a" (addr), [bogus_cc]"d" (bogus_cc) :"cc" );return cc; }
@@ -167,11 +167,11 @@ static inline int msch(unsigned long schid, struct schib *addr)int cc; asmvolatile ( -" msch 0(%3)\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc) - :"d" (reg1),"m" (*addr),"a" (addr) +" msch 0(%[addr])\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) + :"d" (reg1), [addr]"a" (addr) :"cc" );return cc; }
@@ -184,11 +184,11 @@ static inline int tsch(unsigned long schid, struct irb *addr) asmvolatile (" tmll %[bogus_cc],3\n" -" tsch 0(%3)\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc),"=m" (*addr) - :"d" (reg1),"a" (addr), [bogus_cc]"d" (bogus_cc) +" tsch 0(%[addr])\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc),"=m" (*addr) + :"d" (reg1), [addr]"a" (addr), [bogus_cc]"d" (bogus_cc) :"cc" );return cc; }
@@ -200,9 +200,9 @@ static inline int hsch(unsigned long schid) asmvolatile (" hsch\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc) +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) :"d" (reg1) :"cc" );return cc;
@@ -215,9 +215,9 @@ static inline int xsch(unsigned long schid) asmvolatile (" xsch\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc) +" ipm %[cc]\n" +" srl %cc,28" + : [cc]"=d" (cc) :"d" (reg1) :"cc" );return cc;
@@ -230,9 +230,9 @@ static inline int csch(unsigned long schid) asmvolatile (" csch\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc) +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) :"d" (reg1) :"cc" );return cc;
@@ -245,9 +245,9 @@ static inline int rsch(unsigned long schid) asmvolatile (" rsch\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc) +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) :"d" (reg1) :"cc" );return cc;
@@ -262,9 +262,9 @@ static inline int rchp(unsigned long chpid) asmvolatile (" tmll %[bogus_cc],3\n" " rchp\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc) +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) :"d" (reg1), [bogus_cc]"d" (bogus_cc) :"cc" );return cc;
@@ -369,9 +369,9 @@ static inline int _chsc(void *p)int cc; asmvolatile (" .insn rre,0xb25f0000,%2,0\n" -" ipm %0\n" -" srl %0,28\n" - :"=d" (cc),"=m" (p) +" ipm %[cc]\n" +" srl %[cc],28\n" + : [cc]"=d" (cc),"=m" (p) :"d" (p),"m" (p) :"cc" );
Signature · 1 line
2.40.1
Re: [kvm-unit-tests RFC 2/2] lib: s390x: css: Name inline assembly arguments and clean them up
Quoting Janosch Frank (2024-02-01 15:23:56)
[...]
Quoted 4 lines
lib/s390x/css.h +0
-0
[...]
Quoted 4 lines
lib/s390x/css.h +0
-0@@ -167,11 +167,11 @@ static inline int msch(unsigned long schid, struct schib *addr)int cc; asm volatile(
lib/s390x/css.h static inline int msch(unsigned long schid, struct schib *addr) · line 174
Quoted 10 lines
lib/s390x/css.h +5
-5- " msch 0(%3)\n" - " ipm %0\n" - " srl %0,28" - : "=d" (cc) - : "d" (reg1), "m" (*addr), "a" (addr) +" msch 0(%[addr])\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc] "=d" (cc) + : "d" (reg1), [addr] "a" (addr)
I think there was a reason why the "m"(*addr) was here. Either add it back or add a memory clobber.
I will only take the first patch of this series for now.
Heiko Carstens
maintainerRe: [kvm-unit-tests RFC 2/2] lib: s390x: css: Name inline assembly arguments and clean them up
Quoted 10 lines · Nico Boehr
Quoting Janosch Frank (2024-02-01 15:23:56)
[...]Quoted 4 lines
lib/s390x/css.h +0
-0[...]
Quoted 3 lines
lib/s390x/css.h +0
-0@@ -167,11 +167,11 @@ static inline int msch(unsigned long schid, struct schib *addr)int cc;
Quoted 14 lines
lib/s390x/css.h static inline int msch(unsigned long schid, struct schib *addr) · line 174
Quoted 11 lines
lib/s390x/css.h +5
-5asmvolatile ( -" msch 0(%3)\n" -" ipm %0\n" -" srl %0,28" - :"=d" (cc) - : "d" (reg1), "m" (*addr), "a" (addr) +" msch 0(%[addr])\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) + : "d" (reg1), [addr] "a" (addr)I think there was a reason why the "m"(*addr) was here. Either add it back or add a memory clobber.
It is there to tell the compiler that the memory contents at *addr are used as input. Without that, and only the "a" contraint, the compiler is free to discard any potential previous writes to *addr.
The best solution here would be to use the Q constraint (memory reference with short displacement and without index register) for the second operand address of msch. Or simply copy the current implementation from the kernel (drivers/s390/cio/ioasm.c).