cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
016a62
From f7d509d82aeb0af595c6dcfade7904b248ed180b Mon Sep 17 00:00:00 2001
016a62
From: Thomas Huth <thuth@redhat.com>
016a62
Date: Mon, 14 Oct 2019 10:06:38 +0100
016a62
Subject: [PATCH 13/21] s390-bios: cio error handling
016a62
016a62
RH-Author: Thomas Huth <thuth@redhat.com>
016a62
Message-id: <20191014100645.22862-11-thuth@redhat.com>
016a62
Patchwork-id: 91787
016a62
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 10/17] s390-bios: cio error handling
016a62
Bugzilla: 1664376
016a62
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
016a62
RH-Acked-by: David Hildenbrand <david@redhat.com>
016a62
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
016a62
016a62
From: "Jason J. Herne" <jjherne@linux.ibm.com>
016a62
016a62
Add verbose error output for when unexpected i/o errors happen. This eases the
016a62
burden of debugging and reporting i/o errors. No error information is printed
016a62
in the success case, here is an example of what is output on error:
016a62
016a62
cio device error
016a62
  ssid  : 0x0000000000000000
016a62
  cssid : 0x0000000000000000
016a62
  sch_no: 0x0000000000000000
016a62
016a62
Interrupt Response Block Data:
016a62
    Function Ctrl : [Start]
016a62
    Activity Ctrl : [Start-Pending]
016a62
    Status Ctrl : [Alert] [Primary] [Secondary] [Status-Pending]
016a62
    Device Status : [Unit-Check]
016a62
    Channel Status :
016a62
    cpa=: 0x000000007f8d6038
016a62
    prev_ccw=: 0x0000000000000000
016a62
    this_ccw=: 0x0000000000000000
016a62
Eckd Dasd Sense Data (fmt 32-bytes):
016a62
    Sense Condition Flags :
016a62
    Residual Count     =: 0x0000000000000000
016a62
    Phys Drive ID      =: 0x000000000000009e
016a62
    low cyl address    =: 0x0000000000000000
016a62
    head addr & hi cyl =: 0x0000000000000000
016a62
    format/message     =: 0x0000000000000008
016a62
    fmt-dependent[0-7] =: 0x0000000000000004
016a62
    fmt-dependent[8-15]=: 0xe561282305082fff
016a62
    prog action code   =: 0x0000000000000016
016a62
    Configuration info =: 0x00000000000040e0
016a62
    mcode / hi-cyl     =: 0x0000000000000000
016a62
    cyl & head addr [0]=: 0x0000000000000000
016a62
    cyl & head addr [1]=: 0x0000000000000000
016a62
    cyl & head addr [2]=: 0x0000000000000000
016a62
016a62
The Sense Data section is currently only printed for ECKD DASD.
016a62
016a62
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
016a62
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
016a62
Message-Id: <1554388475-18329-10-git-send-email-jjherne@linux.ibm.com>
016a62
Signed-off-by: Thomas Huth <thuth@redhat.com>
016a62
(cherry picked from commit 86c58705bb186cfa73a03851047da2c2c37b9418)
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 pc-bios/s390-ccw/cio.c  | 235 ++++++++++++++++++++++++++++++++++++++++++++++++
016a62
 pc-bios/s390-ccw/libc.h |  11 +++
016a62
 2 files changed, 246 insertions(+)
016a62
016a62
diff --git a/pc-bios/s390-ccw/cio.c b/pc-bios/s390-ccw/cio.c
016a62
index c43e50b..339ec5f 100644
016a62
--- a/pc-bios/s390-ccw/cio.c
016a62
+++ b/pc-bios/s390-ccw/cio.c
016a62
@@ -85,6 +85,228 @@ static bool irb_error(Irb *irb)
016a62
     return irb->scsw.dstat != (SCSW_DSTAT_DEVEND | SCSW_DSTAT_CHEND);
016a62
 }
016a62
 
016a62
+static void print_eckd_dasd_sense_data(SenseDataEckdDasd *sd)
016a62
+{
016a62
+    char msgline[512];
016a62
+
016a62
+    if (sd->config_info & 0x8000) {
016a62
+        sclp_print("Eckd Dasd Sense Data (fmt 24-bytes):\n");
016a62
+    } else {
016a62
+        sclp_print("Eckd Dasd Sense Data (fmt 32-bytes):\n");
016a62
+    }
016a62
+
016a62
+    strcat(msgline, "    Sense Condition Flags :");
016a62
+    if (sd->common_status & SNS_STAT0_CMD_REJECT) {
016a62
+        strcat(msgline, " [Cmd-Reject]");
016a62
+    }
016a62
+    if (sd->common_status & SNS_STAT0_INTERVENTION_REQ) {
016a62
+        strcat(msgline, " [Intervention-Required]");
016a62
+    }
016a62
+    if (sd->common_status & SNS_STAT0_BUS_OUT_CHECK) {
016a62
+        strcat(msgline, " [Bus-Out-Parity-Check]");
016a62
+    }
016a62
+    if (sd->common_status & SNS_STAT0_EQUIPMENT_CHECK) {
016a62
+        strcat(msgline, " [Equipment-Check]");
016a62
+    }
016a62
+    if (sd->common_status & SNS_STAT0_DATA_CHECK) {
016a62
+        strcat(msgline, " [Data-Check]");
016a62
+    }
016a62
+    if (sd->common_status & SNS_STAT0_OVERRUN) {
016a62
+        strcat(msgline, " [Overrun]");
016a62
+    }
016a62
+    if (sd->common_status & SNS_STAT0_INCOMPL_DOMAIN) {
016a62
+        strcat(msgline, " [Incomplete-Domain]");
016a62
+    }
016a62
+
016a62
+    if (sd->status[0] & SNS_STAT1_PERM_ERR) {
016a62
+        strcat(msgline, " [Permanent-Error]");
016a62
+    }
016a62
+    if (sd->status[0] & SNS_STAT1_INV_TRACK_FORMAT) {
016a62
+        strcat(msgline, " [Invalid-Track-Fmt]");
016a62
+    }
016a62
+    if (sd->status[0] & SNS_STAT1_EOC) {
016a62
+        strcat(msgline, " [End-of-Cyl]");
016a62
+    }
016a62
+    if (sd->status[0] & SNS_STAT1_MESSAGE_TO_OPER) {
016a62
+        strcat(msgline, " [Operator-Msg]");
016a62
+    }
016a62
+    if (sd->status[0] & SNS_STAT1_NO_REC_FOUND) {
016a62
+        strcat(msgline, " [No-Record-Found]");
016a62
+    }
016a62
+    if (sd->status[0] & SNS_STAT1_FILE_PROTECTED) {
016a62
+        strcat(msgline, " [File-Protected]");
016a62
+    }
016a62
+    if (sd->status[0] & SNS_STAT1_WRITE_INHIBITED) {
016a62
+        strcat(msgline, " [Write-Inhibited]");
016a62
+    }
016a62
+    if (sd->status[0] & SNS_STAT1_IMPRECISE_END) {
016a62
+        strcat(msgline, " [Imprecise-Ending]");
016a62
+    }
016a62
+
016a62
+    if (sd->status[1] & SNS_STAT2_REQ_INH_WRITE) {
016a62
+        strcat(msgline, " [Req-Inhibit-Write]");
016a62
+    }
016a62
+    if (sd->status[1] & SNS_STAT2_CORRECTABLE) {
016a62
+        strcat(msgline, " [Correctable-Data-Check]");
016a62
+    }
016a62
+    if (sd->status[1] & SNS_STAT2_FIRST_LOG_ERR) {
016a62
+        strcat(msgline, " [First-Error-Log]");
016a62
+    }
016a62
+    if (sd->status[1] & SNS_STAT2_ENV_DATA_PRESENT) {
016a62
+        strcat(msgline, " [Env-Data-Present]");
016a62
+    }
016a62
+    if (sd->status[1] & SNS_STAT2_IMPRECISE_END) {
016a62
+        strcat(msgline, " [Imprecise-End]");
016a62
+    }
016a62
+    strcat(msgline, "\n");
016a62
+    sclp_print(msgline);
016a62
+
016a62
+    print_int("    Residual Count     =", sd->res_count);
016a62
+    print_int("    Phys Drive ID      =", sd->phys_drive_id);
016a62
+    print_int("    low cyl address    =", sd->low_cyl_addr);
016a62
+    print_int("    head addr & hi cyl =", sd->head_high_cyl_addr);
016a62
+    print_int("    format/message     =", sd->fmt_msg);
016a62
+    print_int("    fmt-dependent[0-7] =", sd->fmt_dependent_info[0]);
016a62
+    print_int("    fmt-dependent[8-15]=", sd->fmt_dependent_info[1]);
016a62
+    print_int("    prog action code   =", sd->program_action_code);
016a62
+    print_int("    Configuration info =", sd->config_info);
016a62
+    print_int("    mcode / hi-cyl     =", sd->mcode_hicyl);
016a62
+    print_int("    cyl & head addr [0]=", sd->cyl_head_addr[0]);
016a62
+    print_int("    cyl & head addr [1]=", sd->cyl_head_addr[1]);
016a62
+    print_int("    cyl & head addr [2]=", sd->cyl_head_addr[2]);
016a62
+}
016a62
+
016a62
+static void print_irb_err(Irb *irb)
016a62
+{
016a62
+    uint64_t this_ccw = *(uint64_t *)u32toptr(irb->scsw.cpa);
016a62
+    uint64_t prev_ccw = *(uint64_t *)u32toptr(irb->scsw.cpa - 8);
016a62
+    char msgline[256];
016a62
+
016a62
+    sclp_print("Interrupt Response Block Data:\n");
016a62
+
016a62
+    strcat(msgline, "    Function Ctrl :");
016a62
+    if (irb->scsw.ctrl & SCSW_FCTL_START_FUNC) {
016a62
+        strcat(msgline, " [Start]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_FCTL_HALT_FUNC) {
016a62
+        strcat(msgline, " [Halt]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_FCTL_CLEAR_FUNC) {
016a62
+        strcat(msgline, " [Clear]");
016a62
+    }
016a62
+    strcat(msgline, "\n");
016a62
+    sclp_print(msgline);
016a62
+
016a62
+    msgline[0] = '\0';
016a62
+    strcat(msgline, "    Activity Ctrl :");
016a62
+    if (irb->scsw.ctrl & SCSW_ACTL_RESUME_PEND) {
016a62
+        strcat(msgline, " [Resume-Pending]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_ACTL_START_PEND) {
016a62
+        strcat(msgline, " [Start-Pending]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_ACTL_HALT_PEND) {
016a62
+        strcat(msgline, " [Halt-Pending]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_ACTL_CLEAR_PEND) {
016a62
+        strcat(msgline, " [Clear-Pending]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_ACTL_CH_ACTIVE) {
016a62
+        strcat(msgline, " [Channel-Active]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_ACTL_DEV_ACTIVE) {
016a62
+        strcat(msgline, " [Device-Active]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_ACTL_SUSPENDED) {
016a62
+        strcat(msgline, " [Suspended]");
016a62
+    }
016a62
+    strcat(msgline, "\n");
016a62
+    sclp_print(msgline);
016a62
+
016a62
+    msgline[0] = '\0';
016a62
+    strcat(msgline, "    Status Ctrl :");
016a62
+    if (irb->scsw.ctrl & SCSW_SCTL_ALERT) {
016a62
+        strcat(msgline, " [Alert]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_SCTL_INTERMED) {
016a62
+        strcat(msgline, " [Intermediate]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_SCTL_PRIMARY) {
016a62
+        strcat(msgline, " [Primary]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_SCTL_SECONDARY) {
016a62
+        strcat(msgline, " [Secondary]");
016a62
+    }
016a62
+    if (irb->scsw.ctrl & SCSW_SCTL_STATUS_PEND) {
016a62
+        strcat(msgline, " [Status-Pending]");
016a62
+    }
016a62
+
016a62
+    strcat(msgline, "\n");
016a62
+    sclp_print(msgline);
016a62
+
016a62
+    msgline[0] = '\0';
016a62
+    strcat(msgline, "    Device Status :");
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_ATTN) {
016a62
+        strcat(msgline, " [Attention]");
016a62
+    }
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_STATMOD) {
016a62
+        strcat(msgline, " [Status-Modifier]");
016a62
+    }
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_CUEND) {
016a62
+        strcat(msgline, " [Ctrl-Unit-End]");
016a62
+    }
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_BUSY) {
016a62
+        strcat(msgline, " [Busy]");
016a62
+    }
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_CHEND) {
016a62
+        strcat(msgline, " [Channel-End]");
016a62
+    }
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_DEVEND) {
016a62
+        strcat(msgline, " [Device-End]");
016a62
+    }
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_UCHK) {
016a62
+        strcat(msgline, " [Unit-Check]");
016a62
+    }
016a62
+    if (irb->scsw.dstat & SCSW_DSTAT_UEXCP) {
016a62
+        strcat(msgline, " [Unit-Exception]");
016a62
+    }
016a62
+    strcat(msgline, "\n");
016a62
+    sclp_print(msgline);
016a62
+
016a62
+    msgline[0] = '\0';
016a62
+    strcat(msgline, "    Channel Status :");
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_PCINT) {
016a62
+        strcat(msgline, " [Program-Ctrl-Interruption]");
016a62
+    }
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_BADLEN) {
016a62
+        strcat(msgline, " [Incorrect-Length]");
016a62
+    }
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_PROGCHK) {
016a62
+        strcat(msgline, " [Program-Check]");
016a62
+    }
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_PROTCHK) {
016a62
+        strcat(msgline, " [Protection-Check]");
016a62
+    }
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_CHDCHK) {
016a62
+        strcat(msgline, " [Channel-Data-Check]");
016a62
+    }
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_CHCCHK) {
016a62
+        strcat(msgline, " [Channel-Ctrl-Check]");
016a62
+    }
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_ICCHK) {
016a62
+        strcat(msgline, " [Interface-Ctrl-Check]");
016a62
+    }
016a62
+    if (irb->scsw.cstat & SCSW_CSTAT_CHAINCHK) {
016a62
+        strcat(msgline, " [Chaining-Check]");
016a62
+    }
016a62
+    strcat(msgline, "\n");
016a62
+    sclp_print(msgline);
016a62
+
016a62
+    print_int("    cpa=", irb->scsw.cpa);
016a62
+    print_int("    prev_ccw=", prev_ccw);
016a62
+    print_int("    this_ccw=", this_ccw);
016a62
+}
016a62
+
016a62
 /*
016a62
  * Handles executing ssch, tsch and returns the irb obtained from tsch.
016a62
  * Returns 0 on success, -1 if unexpected status pending and we need to retry,
016a62
@@ -180,6 +402,19 @@ int do_cio(SubChannelId schid, uint16_t cutype, uint32_t ccw_addr, int fmt)
016a62
             continue;
016a62
         }
016a62
 
016a62
+        sclp_print("cio device error\n");
016a62
+        print_int("  ssid  ", schid.ssid);
016a62
+        print_int("  cssid ", schid.cssid);
016a62
+        print_int("  sch_no", schid.sch_no);
016a62
+        print_int("  ctrl-unit type", cutype);
016a62
+        sclp_print("\n");
016a62
+        print_irb_err(&irb);
016a62
+        if (cutype == CU_TYPE_DASD_3990 || cutype == CU_TYPE_DASD_2107 ||
016a62
+            cutype == CU_TYPE_UNKNOWN) {
016a62
+            if (!basic_sense(schid, cutype, &sd, sizeof(sd))) {
016a62
+                print_eckd_dasd_sense_data(&sd);
016a62
+            }
016a62
+        }
016a62
         rc = -1;
016a62
         break;
016a62
     }
016a62
diff --git a/pc-bios/s390-ccw/libc.h b/pc-bios/s390-ccw/libc.h
016a62
index 818517f..bcdc457 100644
016a62
--- a/pc-bios/s390-ccw/libc.h
016a62
+++ b/pc-bios/s390-ccw/libc.h
016a62
@@ -67,6 +67,17 @@ static inline size_t strlen(const char *str)
016a62
     return i;
016a62
 }
016a62
 
016a62
+static inline char *strcat(char *dest, const char *src)
016a62
+{
016a62
+    int i;
016a62
+    char *dest_end = dest + strlen(dest);
016a62
+
016a62
+    for (i = 0; i <= strlen(src); i++) {
016a62
+        dest_end[i] = src[i];
016a62
+    }
016a62
+    return dest;
016a62
+}
016a62
+
016a62
 static inline int isdigit(int c)
016a62
 {
016a62
     return (c >= '0') && (c <= '9');
016a62
-- 
016a62
1.8.3.1
016a62