OSDN Git Service

s390/dasd: use register pair instead of register asm
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 21 Jun 2021 20:19:28 +0000 (22:19 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 28 Jun 2021 09:18:29 +0000 (11:18 +0200)
Using register asm statements has been proven to be very error prone,
especially when using code instrumentation where gcc may add function
calls, which clobbers register contents in an unexpected way.

Therefore get rid of register asm statement in dasd code, even though
there is currently nothing wrong with it. This way we know for sure
that the above mentioned bug class won't be introduced here.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/block/dasd_diag.c

index fd42a5f..6bb7752 100644 (file)
@@ -69,25 +69,24 @@ static const u8 DASD_DIAG_CMS1[] = { 0xc3, 0xd4, 0xe2, 0xf1 };/* EBCDIC CMS1 */
  * resulting condition code and DIAG return code. */
 static inline int __dia250(void *iob, int cmd)
 {
-       register unsigned long reg2 asm ("2") = (unsigned long) iob;
+       union register_pair rx = { .even = (unsigned long)iob, };
        typedef union {
                struct dasd_diag_init_io init_io;
                struct dasd_diag_rw_io rw_io;
        } addr_type;
-       int rc;
+       int cc;
 
-       rc = 3;
+       cc = 3;
        asm volatile(
-               "       diag    2,%2,0x250\n"
-               "0:     ipm     %0\n"
-               "       srl     %0,28\n"
-               "       or      %0,3\n"
+               "       diag    %[rx],%[cmd],0x250\n"
+               "0:     ipm     %[cc]\n"
+               "       srl     %[cc],28\n"
                "1:\n"
                EX_TABLE(0b,1b)
-               : "+d" (rc), "=m" (*(addr_type *) iob)
-               : "d" (cmd), "d" (reg2), "m" (*(addr_type *) iob)
-               : "3", "cc");
-       return rc;
+               : [cc] "+&d" (cc), [rx] "+&d" (rx.pair), "+m" (*(addr_type *)iob)
+               : [cmd] "d" (cmd)
+               : "cc");
+       return cc | rx.odd;
 }
 
 static inline int dia250(void *iob, int cmd)