File qclib.correctly.interpret.sthyi.check.patch of Package qclib-devel.2591

From stefan.raspl@de.ibm.com

Turns out the combination cc==3&&rc==4 was mistakenly treated as an error
instead of indication of lack of support of STHYI.
This can only happen in z/VM 6.2 and (presumably) a certain APAR.

---
Index: qclib-1.0.0/query_capacity_sthyi.c
===================================================================
--- qclib-1.0.0.orig/query_capacity_sthyi.c
+++ qclib-1.0.0/query_capacity_sthyi.c
@@ -58,9 +58,9 @@ static int qc_is_sthyi_available(void) {
 	return (stfle_buffer[STHYI_FACILITY_BIT/64] >> (63 - (STHYI_FACILITY_BIT%64))) & 1;
 }
 
-static int qc_sthyi(char *sthyi_buffer) {
+static int qc_sthyi(struct sthyi_priv *priv) {
 	register unsigned long function_code asm("2") = 0;
-	register unsigned long buffer asm("4") = (unsigned long) sthyi_buffer;
+	register unsigned long buffer asm("4") = (unsigned long) priv->data;
 	register unsigned long return_code asm("5");
 	int cc = -1;
 
@@ -72,10 +72,11 @@ static int qc_sthyi(char *sthyi_buffer)
 		      : "memory", "cc");
 	if (cc == 0) {
 		/* buffer was updated */
+		priv->avail = STHYI_AVAILABLE;
 		return 1;
 	}
-	/* if cc==-1: exception. never mind, return 0 */
-	/* if cc==3: never mind, r carries return code */
+	if (cc == 3 && return_code == 4)
+		return 1;
 	return 0;
 }
 
@@ -483,12 +484,11 @@ static int qc_sthyi_open(struct qc_handl
 		}
 		qc_debug(hdl, "STHYI is available\n");
 		/* we assume we are not relocated at this spot, between STFLE and STHYI */
-		if (!qc_sthyi(priv->data)) {
+		if (!qc_sthyi(priv)) {
 			qc_debug(hdl, "Error: STHYI execution failed\n");
 			rc = -3;
 			goto out;
 		}
-		priv->avail = STHYI_AVAILABLE;
 	}
 	goto out;
 
openSUSE Build Service is sponsored by