]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
s390/zcrypt: fix ap_instructions_available() returncodes
authorHarald Freudenberger <freude@linux.ibm.com>
Thu, 9 Aug 2018 09:59:34 +0000 (11:59 +0200)
committerJoseph Salisbury <joseph.salisbury@canonical.com>
Thu, 15 Nov 2018 17:38:13 +0000 (12:38 -0500)
BugLink: https://bugs.launchpad.net/bugs/1787405
During review of KVM patches it was complained that the
ap_instructions_available() function returns 0 if AP
instructions are available and -ENODEV if not. The function
acts like a boolean function to check for AP instructions
available and thus should return 0 on failure and != 0 on
success. Changed to the suggested behaviour and adapted
the one and only caller of this function which is the ap
bus core code.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
(cherry picked from commit 2395103b3fbf2553d94a64ac3e29595cb040474b)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Acked-by: Kamal Mostafa <kamal@canonical.com>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
arch/s390/include/asm/ap.h
drivers/s390/crypto/ap_bus.c

index 630d35f89ede950f19cb7dd53c2aca32b91037a5..97d2391b9f6c2530800dfde10167731cd3996ea9 100644 (file)
@@ -49,20 +49,20 @@ struct ap_queue_status {
 /**
  * ap_intructions_available() - Test if AP instructions are available.
  *
- * Returns 0 if the AP instructions are installed.
+ * Returns 1 if the AP instructions are installed, otherwise 0.
  */
 static inline int ap_instructions_available(void)
 {
        register unsigned long reg0 asm ("0") = AP_MKQID(0, 0);
-       register unsigned long reg1 asm ("1") = -ENODEV;
-       register unsigned long reg2 asm ("2");
+       register unsigned long reg1 asm ("1") = 0;
+       register unsigned long reg2 asm ("2") = 0;
 
        asm volatile(
                "   .long 0xb2af0000\n"         /* PQAP(TAPQ) */
-               "0: la    %0,0\n"
+               "0: la    %0,1\n"
                "1:\n"
                EX_TABLE(0b, 1b)
-               : "+d" (reg1), "=d" (reg2)
+               : "+d" (reg1), "+d" (reg2)
                : "d" (reg0)
                : "cc");
        return reg1;
index 06f48fb7357ca3b9abb31b3e64f4c3dccef2186a..f341a7465634c6224049e90b09391a49953c0c1b 100644 (file)
@@ -1568,7 +1568,7 @@ int __init ap_module_init(void)
        if (rc)
                return rc;
 
-       if (ap_instructions_available() != 0) {
+       if (!ap_instructions_available()) {
                pr_warn("The hardware system does not support AP instructions\n");
                return -ENODEV;
        }