yeahuh / rpms / qemu-kvm

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