qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

s390x: refactor error handling for MSCH handler

Simplify the error handling of the MSCH. Let the code detecting the
condition tell (in a less ambiguous way) how it's to be handled. No
changes in behavior.

Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Message-Id: <20171017140453.51099-8-pasic@linux.vnet.ibm.com>
[CH: fix return code for fctl != 0]
Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>

authored by

Halil Pasic and committed by
Cornelia Huck
6bb6f194 ae9f1be3

+10 -33
+5 -13
hw/s390x/css.c
··· 1347 1347 } 1348 1348 } 1349 1349 1350 - int css_do_msch(SubchDev *sch, const SCHIB *orig_schib) 1350 + IOInstEnding css_do_msch(SubchDev *sch, const SCHIB *orig_schib) 1351 1351 { 1352 1352 SCSW *s = &sch->curr_status.scsw; 1353 1353 PMCW *p = &sch->curr_status.pmcw; 1354 1354 uint16_t oldflags; 1355 - int ret; 1356 1355 SCHIB schib; 1357 1356 1358 1357 if (!(sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_DNV)) { 1359 - ret = 0; 1360 - goto out; 1358 + return IOINST_CC_EXPECTED; 1361 1359 } 1362 1360 1363 1361 if (s->ctrl & SCSW_STCTL_STATUS_PEND) { 1364 - ret = -EINPROGRESS; 1365 - goto out; 1362 + return IOINST_CC_STATUS_PRESENT; 1366 1363 } 1367 1364 1368 1365 if (s->ctrl & 1369 1366 (SCSW_FCTL_START_FUNC|SCSW_FCTL_HALT_FUNC|SCSW_FCTL_CLEAR_FUNC)) { 1370 - ret = -EBUSY; 1371 - goto out; 1367 + return IOINST_CC_BUSY; 1372 1368 } 1373 1369 1374 1370 copy_schib_from_guest(&schib, orig_schib); ··· 1395 1391 && (p->flags & PMCW_FLAGS_MASK_ENA) == 0) { 1396 1392 sch->disable_cb(sch); 1397 1393 } 1398 - 1399 - ret = 0; 1400 - 1401 - out: 1402 - return ret; 1394 + return IOINST_CC_EXPECTED; 1403 1395 } 1404 1396 1405 1397 IOInstEnding css_do_xsch(SubchDev *sch)
+1 -1
include/hw/s390x/css.h
··· 239 239 void css_conditional_io_interrupt(SubchDev *sch); 240 240 int css_do_stsch(SubchDev *sch, SCHIB *schib); 241 241 bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid); 242 - int css_do_msch(SubchDev *sch, const SCHIB *schib); 242 + IOInstEnding css_do_msch(SubchDev *sch, const SCHIB *schib); 243 243 IOInstEnding css_do_xsch(SubchDev *sch); 244 244 IOInstEnding css_do_csch(SubchDev *sch); 245 245 IOInstEnding css_do_hsch(SubchDev *sch);
+4 -19
target/s390x/ioinst.c
··· 111 111 SubchDev *sch; 112 112 SCHIB schib; 113 113 uint64_t addr; 114 - int ret = -ENODEV; 115 - int cc; 116 114 CPUS390XState *env = &cpu->env; 117 115 uint8_t ar; 118 116 ··· 131 129 } 132 130 trace_ioinst_sch_id("msch", cssid, ssid, schid); 133 131 sch = css_find_subch(m, cssid, ssid, schid); 134 - if (sch && css_subch_visible(sch)) { 135 - ret = css_do_msch(sch, &schib); 132 + if (!sch || !css_subch_visible(sch)) { 133 + setcc(cpu, 3); 134 + return; 136 135 } 137 - switch (ret) { 138 - case -ENODEV: 139 - cc = 3; 140 - break; 141 - case -EBUSY: 142 - cc = 2; 143 - break; 144 - case 0: 145 - cc = 0; 146 - break; 147 - default: 148 - cc = 1; 149 - break; 150 - } 151 - setcc(cpu, cc); 136 + setcc(cpu, css_do_msch(sch, &schib)); 152 137 } 153 138 154 139 static void copy_orb_from_guest(ORB *dest, const ORB *src)