lib: s390x: css: Name inline assembly arguments and clean them up
PATCH 1/1 lib: s390x: css: Name inline assembly arguments and clean them up
Less need to count the operands makes the code easier to read.
---
This one has been gathering dust for a while.rfc->v1: Moved to Q constraint (thanks Heiko)
--- 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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28\n" + : [cc]"=d" (cc) + :"d" (reg1), [addr]"Q" (*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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc), [addr]"=Q" (*addr) + :"d" (reg1), [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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) + :"d" (reg1), [addr]"Q" (*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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc), [addr]"=Q" (*addr) + :"d" (reg1), [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.43.0
lib/s390x/css.h static inline int xsch(unsigned long schid) · line 219
Quoted 9 lines · Janosch Frank
lib/s390x/css.h +2
-3@@ -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"
Should this be:
" srl %[cc],28"
instead?
With that fixed (if it needs fixing):
Quoted 12 lines · Nico Boehr
lib/s390x/css.h static inline int xsch(unsigned long schid) · line 219
Quoted 9 lines · Janosch Frank
lib/s390x/css.h +2
-3@@ -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"Should this be:
Quoted 7 lines
" srl %[cc],28"instead?
With that fixed (if it needs fixing):
Reviewed-by Nico Boehr <[email protected]>
Thanks!
Fixed and applied.
Quoted 9 lines · On Tue, 4 Feb 2025 09:51:33 +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]>---
This one has been gathering dust for a while.
rfc->v1: Moved to Q constraint (thanks Heiko)---
[...]
lib/s390x/css.h static inline int _chsc(void *p) · line 375
Quoted 8 lines
lib/s390x/css.h +3
-3asmvolatile (" .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)
this bit (which you did not touch) is actually the most confusing to me. what's the point of separately specifying both "d" and "m" constraints for (p) ? (and it also has a "=m" in the output clobberlist)
Quoted 2 lines
: "cc");
Quoted 15 lines · Claudio Imbrenda
Quoted 9 lines · On Tue, 4 Feb 2025 09:51:33 +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]>---
This one has been gathering dust for a while.
rfc->v1: Moved to Q constraint (thanks Heiko)---
[...]
Quoted 12 lines
lib/s390x/css.h static inline int _chsc(void *p) · line 375
Quoted 8 lines
asm volatile(" .insn rre,0xb25f0000,%2,0\n"
lib/s390x/css.h +3
-3- " 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)this bit (which you did not touch) is actually the most confusing to me. what's the point of separately specifying both "d" and "m" constraints for (p) ? (and it also has a "=m" in the output clobberlist)
I'll add a second patch to bring this into line with the kernel's ioasm.c implementation.
Quoted 15 lines · Claudio Imbrenda
Quoted 9 lines · On Tue, 4 Feb 2025 09:51:33 +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]>---
This one has been gathering dust for a while.
rfc->v1: Moved to Q constraint (thanks Heiko)---
[...]
Quoted 12 lines
lib/s390x/css.h static inline int _chsc(void *p) · line 375
Quoted 8 lines
asm volatile(" .insn rre,0xb25f0000,%2,0\n"
lib/s390x/css.h +3
-3- " 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)this bit (which you did not touch) is actually the most confusing to me. what's the point of separately specifying both "d" and "m" constraints for (p) ? (and it also has a "=m" in the output clobberlist)
I consulted the kernel code as well as Heiko and the architecture.
CHSC is one of those request/response do everything instructions and is similar to sclp. A header is read from memory and a response is written below the header. The addressed memory needs to be page aligned and can be up to a page in size.
Which means:
- We need the address in R1
- CPU reads from the memory area designated by R1
- CPU writes to the memory area designated by R1
My guess is that nobody bothered defining all of the structs and that's how we ended up here. If you look at the kernel assembly you'll notice a page size typedef for the +m clobber of the memory area pointer.
Heiko suggested to drop the two "m" clobbers and just add a generic memory clobber. If we even want to touch this at all...
Quoted 41 lines · On Thu, 6 Feb 2025 11:36:11 +0100 Janosch Frank <[email protected]> wrote:
Quoted 15 lines · Claudio Imbrenda
Quoted 9 lines · On Tue, 4 Feb 2025 09:51:33 +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]>---
This one has been gathering dust for a while.
rfc->v1: Moved to Q constraint (thanks Heiko)---
[...]
Quoted 12 lines
lib/s390x/css.h static inline int _chsc(void *p) · line 375
Quoted 8 lines
asm volatile(" .insn rre,0xb25f0000,%2,0\n"
lib/s390x/css.h +3
-3- " 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)this bit (which you did not touch) is actually the most confusing to me. what's the point of separately specifying both "d" and "m" constraints for (p) ? (and it also has a "=m" in the output clobberlist)
I consulted the kernel code as well as Heiko and the architecture.
CHSC is one of those request/response do everything instructions and is similar to sclp. A header is read from memory and a response is written below the header. The addressed memory needs to be page aligned and can be up to a page in size.
Which means:
- We need the address in R1
- CPU reads from the memory area designated by R1
- CPU writes to the memory area designated by R1
Quoted 6 lines
My guess is that nobody bothered defining all of the structs and that's how we ended up here. If you look at the kernel assembly you'll notice a page size typedef for the +m clobber of the memory area pointer.
Heiko suggested to drop the two "m" clobbers and just add a generic memory clobber. If we even want to touch this at all...
tbh, yes, I would like to have it as simple as possible. this is not super performance-sensitive, IMHO it's more important that the code is readable and understandable.
On Thu Feb 6, 2025 at 11:36 AM CET, Janosch Frank wrote:
[...]
Quoted 2 lines
Heiko suggested to drop the two "m" clobbers and just add a generic memory clobber. If we even want to touch this at all...
We are a testing framework and don't care about the last bit of performance. I would argue that we can just always go with a memory clobber, since they are less error-prone and easier to understand.
If you don't mind, go with a memory clobber in v2. Otherwise let me know, I think I may have a few other cleanups lying around and could do it when I send them out.
Quoted 3 lines · On Tue, 4 Feb 2025 09:51:33 +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 159 lines
---
This one has been gathering dust for a while.
rfc->v1: Moved to Q constraint (thanks Heiko)--- 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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28\n" + : [cc]"=d" (cc) + :"d" (reg1), [addr]"Q" (*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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc), [addr]"=Q" (*addr) + :"d" (reg1), [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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc) + :"d" (reg1), [addr]"Q" (*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 %[addr]\n" +" ipm %[cc]\n" +" srl %[cc],28" + : [cc]"=d" (cc), [addr]"=Q" (*addr) + :"d" (reg1), [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" );