s390x/css: ccw interpretation fixes
cover s390x/css: ccw interpretation fixes
Here come some bug fixes concerning CCW interpretation.
Patch #1 was already posted as a stand alone patch, is (kind of) required by patch #4 so it's included in this series too.
Halil Pasic (4):
s390x/css: drop data-check in interpretation
s390x/css: fix NULL handling for CCW addresses
s390x/css: remove dubious error handling branch
s390x/css: fix incorrect length indication
hw/s390x/3270-ccw.c | 24 +++++----- hw/s390x/css.c | 79 ++++++++++++++---------------- hw/s390x/virtio-ccw.c | 128 ++++++++++++++++++++++++------------------------- include/hw/s390x/css.h | 13 ++++- 4 files changed, 125 insertions(+), 119 deletions(-)
Signature · 1 line
2.13.5
PATCH 1/4 s390x/css: drop data-check in interpretation
The architecture says that channel-data check is indicating that an uncorrected storage (memory) error has been detected in regard to the data residing in main storage (memory) that is currently used for an I/O operation. The described detection is done using the CBC technology.
The ccw interpretation code is however generating a channel-data check effectively when the (device specific) ccw_cb returns -EFAULT. In case of virtio-ccw devices this happens when mapping memory fails, or when a NULL pointer is encountered. So this behavior is not architecture conform.
Furthermore the best fit for these situations (null pointer, mapping a piece of guest memory fails) from architectural perspective the condition described as the channel subsystem refers to a location that is not available, which when encountered shall result in a channel-program check.
To fix this, all we have to do is to get rid of the switch case matching -EFAULT: the default is generating a channel-program check.
---
Was posted as stand alone patch. See:
http://patchwork.ozlabs.org/patch/810995/
If you are going to, *please review there*.
--- hw/s390x/css.c | 9 --------- 1 file changed, 9 deletions(-)
hw/s390x/css.c +0 -9
@@ -980,15 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sch)SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; s->cpa = sch->channel_prog +8 ;break ; -case -EFAULT : -/* memory problem, generate channel data check */ - s->ctrl &= ~SCSW_ACTL_START_PEND ; - s->cstat =SCSW_CSTAT_DATA_CHECK ; - s->ctrl &= ~SCSW_CTRL_MASK_STCTL ; - s->ctrl |=SCSW_STCTL_PRIMARY |SCSW_STCTL_SECONDARY | -SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; - s->cpa = sch->channel_prog +8 ; -break ;case -EBUSY :/* subchannel busy, generate deferred cc 1 */ s->flags &= ~SCSW_FLAGS_MASK_CC ;
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 1/4] s390x/css: drop data-check in interpretation
Quoted 21 lines · On Fri, 8 Sep 2017 17:24:43 +0200 Halil Pasic <[email protected]> wrote:
The architecture says that channel-data check is indicating that an uncorrected storage (memory) error has been detected in regard to the data residing in main storage (memory) that is currently used for an I/O operation. The described detection is done using the CBC technology.
The ccw interpretation code is however generating a channel-data check effectively when the (device specific)
ccw_cbreturns-EFAULT. In case of virtio-ccw devices this happens when mapping memory fails, or when a NULL pointer is encountered. So this behavior is not architecture conform.Furthermore the best fit for these situations (null pointer, mapping a piece of guest memory fails) from architectural perspective the condition described as the channel subsystem refers to a location that is not available, which when encountered shall result in a channel-program check.
To fix this, all we have to do is to get rid of the switch case matching
-EFAULT: the default is generating a channel-program check.
Quoted 6 lines
---
Was posted as stand alone patch. See:
http://patchwork.ozlabs.org/patch/810995/If you are going to, *please review there*.
Countered. *Please review here*
(It makes it easier for me.)
Quoted 2 lines
Signed-off-by Halil Pasic <[email protected]>
Your s-o-b should go before the triple-dash delimiter. I can fix that up.
Quoted 14 lines
--- hw/s390x/css.c | 9 --------- 1 file changed, 9 deletions(-)hw/s390x/css.c +0
-2@@ -980,15 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sch)SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; s->cpa = sch->channel_prog +8 ;break ; -case -EFAULT : -/* memory problem, generate channel data check */
hw/s390x/css.c static void sch_handle_start_func_virtual(SubchDev *sch) · line 985
Quoted 10 lines
hw/s390x/css.c +0
-7- s->ctrl &= ~SCSW_ACTL_START_PEND ; - s->cstat =SCSW_CSTAT_DATA_CHECK ; - s->ctrl &= ~SCSW_CTRL_MASK_STCTL ; - s->ctrl |=SCSW_STCTL_PRIMARY |SCSW_STCTL_SECONDARY | -SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; - s->cpa = sch->channel_prog +8 ; -break ;case -EBUSY :/* subchannel busy, generate deferred cc 1 */ s->flags &= ~SCSW_FLAGS_MASK_CC ;
Looks reasonable. Queued.
Re: [Qemu-devel] [PATCH 1/4] s390x/css: drop data-check in interpretation
Quoted 33 lines · Cornelia Huck
Quoted 21 lines · On Fri, 8 Sep 2017 17:24:43 +0200 Halil Pasic <[email protected]> wrote:
The architecture says that channel-data check is indicating that an uncorrected storage (memory) error has been detected in regard to the data residing in main storage (memory) that is currently used for an I/O operation. The described detection is done using the CBC technology.
The ccw interpretation code is however generating a channel-data check effectively when the (device specific)
ccw_cbreturns-EFAULT. In case of virtio-ccw devices this happens when mapping memory fails, or when a NULL pointer is encountered. So this behavior is not architecture conform.Furthermore the best fit for these situations (null pointer, mapping a piece of guest memory fails) from architectural perspective the condition described as the channel subsystem refers to a location that is not available, which when encountered shall result in a channel-program check.
To fix this, all we have to do is to get rid of the switch case matching
-EFAULT: the default is generating a channel-program check.Quoted 6 lines
---
Was posted as stand alone patch. See:
http://patchwork.ozlabs.org/patch/810995/If you are going to, *please review there*.
Countered. *Please review here*
Quoted 7 lines
(It makes it easier for me.)
Quoted 2 lines
Signed-off-by Halil Pasic <[email protected]>Your s-o-b should go before the triple-dash delimiter. I can fix that up.
Thanks! Btw. the original (there) was correct in this respect.
Quoted 19 lines
Quoted 19 lines
--- hw/s390x/css.c | 9 --------- 1 file changed, 9 deletions(-)hw/s390x/css.c +0
-6@@ -980,15 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sch)SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; s->cpa = sch->channel_prog +8 ;break ; -case -EFAULT : -/* memory problem, generate channel data check */ - s->ctrl &= ~SCSW_ACTL_START_PEND ; - s->cstat =SCSW_CSTAT_DATA_CHECK ; - s->ctrl &= ~SCSW_CTRL_MASK_STCTL ; - s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
Quoted 9 lines
hw/s390x/css.c static void sch_handle_start_func_virtual(SubchDev *sch) · line 985
Quoted 6 lines
hw/s390x/css.c +0
-3-SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; - s->cpa = sch->channel_prog +8 ; -break ;case -EBUSY :/* subchannel busy, generate deferred cc 1 */ s->flags &= ~SCSW_FLAGS_MASK_CC ;Looks reasonable. Queued.
Thanks!
Halil
PATCH 2/4 s390x/css: fix NULL handling for CCW addresses
In reply to Halil PasicBack then in the time of df1fe5bb49 ("s390: Virtual channel subsystem support.", 2013-01-24) -EIO used to map to a channel-program check (via the default label of the switch statement). Then 2dc95b4cac ("s390x/3270: 3270 data stream handling", 2016-04-01) came along and that changed dramatically.
Let us roll back this undesired side effect, and go back to channel-program check.
---
I'm not sure 0 as CCW address it's strictly illegal. Yes 0 is an unlikely address for a CCW but I would appreciate a PoP reference clarifying this...
Another reason to not use Unix/POSIX error codes like this.
--- hw/s390x/css.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/css.c +1 -1
@@ -793,7 +793,7 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr,CCW1 ccw;if (!ccw_addr) { -return -EIO ; +return -EINVAL ;/* channel-program check */ }/* Check doubleword aligned and 31 or 24 (fmt 0) bit addressable. */ if (ccw_addr & (sch->ccw_fmt_1 ?0x80000007 :0xff000007 )) {
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 2/4] s390x/css: fix NULL handling for CCW addresses
Quoted 9 lines · On Fri, 8 Sep 2017 17:24:44 +0200 Halil Pasic <[email protected]> wrote:
Back then in the time of
df1fe5bb49("s390: Virtual channel subsystem support.", 2013-01-24)-EIOused to map to a channel-program check (via the default label of the switch statement). Then2dc95b4cac("s390x/3270: 3270 data stream handling", 2016-04-01) came along and that changed dramatically.Let us roll back this undesired side effect, and go back to channel-program check.
Quoted 7 lines
Signed-off-by Halil Pasic <[email protected]>Fixes 2dc95b4cac "s390x/3270: 3270 data stream handling"---
I'm not sure 0 as CCW address it's strictly illegal. Yes 0 is an unlikely address for a CCW but I would appreciate a PoP reference clarifying this...
0 is not an address we can fetch from, I think that is enough to trigger a channel-program check.
Quoted 11 lines
Another reason to not use Unix/POSIX error codes like this.
--- hw/s390x/css.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/s390x/css.c +0
-0
hw/s390x/css.c static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, · line 799
Quoted 8 lines
hw/s390x/css.c +1
-1@@ -793,7 +793,7 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr,CCW1 ccw;if (!ccw_addr) { -return -EIO ; +return -EINVAL ;/* channel-program check */ }/* Check doubleword aligned and 31 or 24 (fmt 0) bit addressable. */ if (ccw_addr & (sch->ccw_fmt_1 ?0x80000007 :0xff000007 )) {
Thanks, queued.
PATCH 3/4 s390x/css: remove dubious error handling branch
In reply to Halil PasicThe case in question actually never happens. Let us get rid of the dead code.
--- hw/s390x/css.c | 7 ------- 1 file changed, 7 deletions(-)
hw/s390x/css.c +0 -7
@@ -980,13 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sch)SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; s->cpa = sch->channel_prog +8 ;break ; -case -EBUSY : -/* subchannel busy, generate deferred cc 1 */ - s->flags &= ~SCSW_FLAGS_MASK_CC ; - s->flags |= (1 <<8 ); - s->ctrl &= ~SCSW_CTRL_MASK_STCTL ; - s->ctrl |=SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; -break ;case -EINPROGRESS :/* channel program has been suspended */ s->ctrl &= ~SCSW_ACTL_START_PEND ;
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 3/4] s390x/css: remove dubious error handling branch
On Fri, 8 Sep 2017 17:24:45 +0200
Halil Pasic <[email protected]> wrote:
s/dubious/unused/
Quoted 2 lines
The case in question actually never happens. Let us get rid of the dead code.
I had tried to be complete in my initial implementation. With the current implementation, it can never happen, yes. We can easily resurrect it from git history should we need it in the future.
Quoted 14 lines
Signed-off-by Halil Pasic <[email protected]>--- hw/s390x/css.c | 7 ------- 1 file changed, 7 deletions(-)hw/s390x/css.c +0
-0@@ -980,13 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sch)SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; s->cpa = sch->channel_prog +8 ;break ;
hw/s390x/css.c static void sch_handle_start_func_virtual(SubchDev *sch) · line 985
Quoted 10 lines
hw/s390x/css.c +0
-7-case -EBUSY : -/* subchannel busy, generate deferred cc 1 */ - s->flags &= ~SCSW_FLAGS_MASK_CC ; - s->flags |= (1 <<8 ); - s->ctrl &= ~SCSW_CTRL_MASK_STCTL ; - s->ctrl |=SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; -break ;case -EINPROGRESS :/* channel program has been suspended */ s->ctrl &= ~SCSW_ACTL_START_PEND ;
Thanks, queued.
Re: [Qemu-devel] [PATCH 3/4] s390x/css: remove dubious error handling branch
Quoted 5 lines · Cornelia Huck
On Fri, 8 Sep 2017 17:24:45 +0200
Halil Pasic <[email protected]> wrote:s/dubious/unused/
Nod.
Quoted 7 lines
Quoted 2 lines
The case in question actually never happens. Let us get rid of the dead code.
I had tried to be complete in my initial implementation. With the current implementation, it can never happen, yes. We can easily resurrect it from git history should we need it in the future.
I've tried to understand the branch but I failed. Weather the subchannel is busy or not should be already decided, and if the device is busy that is probably supposed to be indicated via device status (word 2 bit 3).
So I wrote dubious because I could not figure it out. But unused is certainly nicer.
I think shall the need emerge the preferred way of handling would be to use the custom handling (-EIO) branch.
Quoted 18 lines
Quoted 18 lines
Signed-off-by Halil Pasic <[email protected]>--- hw/s390x/css.c | 7 ------- 1 file changed, 7 deletions(-)hw/s390x/css.c +0
-4@@ -980,13 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sch)SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; s->cpa = sch->channel_prog +8 ;break ; -case -EBUSY : -/* subchannel busy, generate deferred cc 1 */ - s->flags &= ~SCSW_FLAGS_MASK_CC ; - s->flags |= (1 <<8 );
Quoted 9 lines
hw/s390x/css.c static void sch_handle_start_func_virtual(SubchDev *sch) · line 985
Quoted 6 lines
hw/s390x/css.c +0
-3- s->ctrl &= ~SCSW_CTRL_MASK_STCTL ; - s->ctrl |=SCSW_STCTL_ALERT |SCSW_STCTL_STATUS_PEND ; -break ;case -EINPROGRESS :/* channel program has been suspended */ s->ctrl &= ~SCSW_ACTL_START_PEND ;Thanks, queued.
Thanks!
Re: [Qemu-devel] [PATCH 3/4] s390x/css: remove dubious error handling branch
Quoted 16 lines · On Mon, 11 Sep 2017 15:08:52 +0200 Halil Pasic <[email protected]> wrote:
Quoted 10 lines · Cornelia Huck
Quoted 2 lines · On Fri, 8 Sep 2017 17:24:45 +0200 Halil Pasic <[email protected]> wrote:
The case in question actually never happens. Let us get rid of the dead code.
I had tried to be complete in my initial implementation. With the current implementation, it can never happen, yes. We can easily resurrect it from git history should we need it in the future.
I've tried to understand the branch but I failed. Weather the subchannel is busy or not should be already decided, and if the device is busy that is probably supposed to be indicated via device status (word 2 bit 3).
Quoted 5 lines
So I wrote dubious because I could not figure it out. But unused is certainly nicer.
I think shall the need emerge the preferred way of handling would be to use the custom handling (
-EIO) branch.
What this is trying to do is deferred cc 1 handling. On a real system, a ssch may return with cc 0 to indicate that the channel program has been accepted; but when the channel subsystem actually tries to execute it, a status is already pending. Basically, it's a race condition:
Therefore the 'deferred' cc 1.
Maybe I should have called this 'deferred subchannel busy'... but anyway, this cannot happen in our current implementation.
PATCH 4/4 s390x/css: fix incorrect length indication
In reply to Halil PasicWe report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
--- hw/s390x/3270-ccw.c | 24 +++++----- hw/s390x/css.c | 67 +++++++++++++++----------- hw/s390x/virtio-ccw.c | 128 ++++++++++++++++++++++++------------------------- include/hw/s390x/css.h | 13 ++++- 4 files changed, 127 insertions(+), 105 deletions(-)
hw/s390x/3270-ccw.c +13 -11
@@ -18,46 +18,48 @@#include "hw/s390x/3270-ccw.h" /* Handle READ ccw commands from guest */ -static int handle_payload_3270_read (EmulatedCcw3270Device *dev,CCW1 *ccw) +static CcwProcStatus handle_payload_3270_read (EmulatedCcw3270Device *dev, +CCW1 *ccw) {EmulatedCcw3270Class *ck =EMULATED_CCW_3270_GET_CLASS (dev);CcwDevice *ccw_dev =CCW_DEVICE (dev);int len;if (!ccw->cda) { -return -EFAULT ; +return CSS_DO_PGM_CHK ; } len = ck->read_payload_3270 (dev, ccw->cda, ccw->count); ccw_dev->sch->curr_status.scsw.count = ccw->count - len; -return 0 ; +return CSS_DO_SUCCESS ; }/* Handle WRITE ccw commands to write data to client */ -static int handle_payload_3270_write (EmulatedCcw3270Device *dev,CCW1 *ccw) +static CcwProcStatus handle_payload_3270_write (EmulatedCcw3270Device *dev, +CCW1 *ccw) {EmulatedCcw3270Class *ck =EMULATED_CCW_3270_GET_CLASS (dev);CcwDevice *ccw_dev =CCW_DEVICE (dev);int len;if (!ccw->cda) { -return -EFAULT ; +return CSS_DO_PGM_CHK ; } len = ck->write_payload_3270 (dev, ccw->cmd_code, ccw->cda, ccw->count);if (len <=0 ) { -return -EIO ; +return CSS_E_CUSTOM ; } ccw_dev->sch->curr_status.scsw.count = ccw->count - len; -return 0 ; +return CSS_DO_SUCCESS ; } -static int emulated_ccw_3270_cb (SubchDev *sch,CCW1 ccw) +static CcwProcStatus emulated_ccw_3270_cb (SubchDev *sch,CCW1 ccw) { -int rc =0 ; +CcwProcStatus rc =CSS_DO_SUCCESS ;EmulatedCcw3270Device *dev = sch->driver_data;switch (ccw.cmd_code) {
@@ -72,11 +74,11 @@ static int emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw) rc =handle_payload_3270_read (dev, &ccw);break ;default : - rc = -ENOSYS ; + rc =CSS_DO_UNIT_CHK_REJ ;break ; } -if (rc == -EIO ) { +if (rc ==CSS_E_CUSTOM ) {/* I/O error, specific devices generate specific conditions */ SCSW *s = &sch->curr_status.scsw;
hw/s390x/css.c +38 -29
198 lines not on this page · raw message
hw/s390x/virtio-ccw.c +64 -64
417 lines not on this page · raw message
include/hw/s390x/css.h +12 -1
@@ -75,6 +75,17 @@ typedef struct CMBE {uint32_t reserved[7 ]; }QEMU_PACKED CMBE ; + +typedef enum CcwProcStatus { +CSS_DO_SUCCESS =0 ,/* requet successful completin */ +CSS_DO_CONT_CHAIN ,/* request continue ccw-chaning */ +CSS_DO_SUSPEND ,/* request subchannel suspended */ +CSS_DO_PGM_CHK ,/* request channel-program check */ +CSS_DO_UNIT_CHK_REJ ,/* request unit check cmd reject */ +CSS_DO_INCORR_LEN ,/* request incorrect length */ +CSS_E_CUSTOM /* SCSW updated by device */ +}CcwProcStatus ; +typedef struct SubchDev SubchDev ;struct SubchDev {/* channel-subsystem related things: */
@@ -93,7 +104,7 @@ struct SubchDev {uint16_t migrated_schid;/* used for missmatch detection */ ORB orb;/* transport-provided data: */ -int (*ccw_cb) (SubchDev *,CCW1 ); +CcwProcStatus (*ccw_cb) (SubchDev *,CCW1 );void (*disable_cb)(SubchDev *);int (*do_subchannel_work) (SubchDev *);SenseId id;
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 4/4] s390x/css: fix incorrect length indication
Quoted 5 lines · On Fri, 8 Sep 2017 17:24:46 +0200 Halil Pasic <[email protected]> wrote:
We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
I'm not sure whether this is the way to go. I mainly dislike the size of the patch (and the fact that it mixes a fix and a change of function signature).
Can we instead choose a mapping for incorrect length, and defer a possible rework?
(Another idea would be to have the callback prepare the scsw via helper functions. We'd just keep -EAGAIN to keep processing a chain and 0 to stop.)
Quoted 3 lines
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
Confused. If it is suppressed, there should not be an error, no?
Quoted 8 lines
Signed-off-by Halil Pasic <[email protected]>--- hw/s390x/3270-ccw.c | 24 +++++----- hw/s390x/css.c | 67 +++++++++++++++----------- hw/s390x/virtio-ccw.c | 128 ++++++++++++++++++++++++------------------------- include/hw/s390x/css.h | 13 ++++- 4 files changed, 127 insertions(+), 105 deletions(-)
Re: [Qemu-devel] [PATCH 4/4] s390x/css: fix incorrect length indication
Quoted 9 lines · Cornelia Huck
Quoted 5 lines · On Fri, 8 Sep 2017 17:24:46 +0200 Halil Pasic <[email protected]> wrote:
We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
Quoted 3 lines
I'm not sure whether this is the way to go. I mainly dislike the size of the patch (and the fact that it mixes a fix and a change of function signature).
Do you agree that we should move away from POSIX errno codes? I think if we do, this cant' get much smaller.
Quoted 4 lines
Can we instead choose a mapping for incorrect length, and defer a possible rework?
In the commit message, I say that I don't have a fitting errno. If you tell me which one to use, I would be glad to split this up. I don't like mixing re-factoring and changing behavior myself.
Can I have your position on the re-factoring (that is let us imagine I did not change handling for incorrect length)?
Quoted 4 lines
(Another idea would be to have the callback prepare the scsw via helper functions. We'd just keep
-EAGAINto keep processing a chain and 0 to stop.)
That was my first idea how to improve on this. I should still have the code (patches), but I'm not sure whether it's clean or lumped together with other experiments.
After pushing the handling down the call chain (caller would use inline functions to manipulate SCSW), I've realized that it does not buy us much/anything expect the better names, while we get the machine code manipulating the SCSW generated in multiple instead of in one place. I also showed the results to Dong Jia and he was ambivalent too: said something like it does look better, but it ain't better enough to make it worthwhile.
This is why I've decided to go with a less intrusive approach:
just change the names so that it's obvious what's happening.
If you like, I look for those patches and if it ain't too much work post them as an RFC -- so we have both options in front of our eyes.
Quoted 5 lines
Quoted 3 lines
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
Confused. If it is suppressed, there should not be an error, no?
No.
Quoted 1 line
From VIRTIO 1.0 4.3.1.2 Device Requirements: Basic Concepts
"If a driver did suppress length checks for a channel command, the device MUST present a check condition if the transmitted data does not contain enough data to process the command."
(http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1230001)
So for virtio we have to present a check condition. Architecturally it might look better if the one refusing is the device and not the CSS, but for that we would have to change the VIRTIO spec. With the given constraints a program check is IMHO the best fit.
Quoted 10 lines
Quoted 9 lines
Signed-off-by Halil Pasic <[email protected]>--- hw/s390x/3270-ccw.c | 24 +++++----- hw/s390x/css.c | 67 +++++++++++++++----------- hw/s390x/virtio-ccw.c | 128 ++++++++++++++++++++++++------------------------- include/hw/s390x/css.h | 13 ++++- 4 files changed, 127 insertions(+), 105 deletions(-)
Re: [Qemu-devel] [PATCH 4/4] s390x/css: fix incorrect length indication
Quoted 10 lines · On Mon, 11 Sep 2017 13:36:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 9 lines · Cornelia Huck
Quoted 5 lines · On Fri, 8 Sep 2017 17:24:46 +0200 Halil Pasic <[email protected]> wrote:
We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
Quoted 6 lines
Quoted 3 lines
I'm not sure whether this is the way to go. I mainly dislike the size of the patch (and the fact that it mixes a fix and a change of function signature).
Do you agree that we should move away from POSIX errno codes? I think if we do, this cant' get much smaller.
I'm not really a fan of defining our own return values, tbh.
Quoted 6 lines
Quoted 5 lines
Can we instead choose a mapping for incorrect length, and defer a possible rework?
Quoted 6 lines
In the commit message, I say that I don't have a fitting errno. If you tell me which one to use, I would be glad to split this up. I don't like mixing re-factoring and changing behavior myself.
Can I have your position on the re-factoring (that is let us imagine I did not change handling for incorrect length)?
If there is no return code that can be made to fit, we probably won't be able to get around some kind of refactoring... but then I'd prefer to do the refactoring first and the fix second.
Quoted 18 lines
Quoted 5 lines
(Another idea would be to have the callback prepare the scsw via helper functions. We'd just keep
-EAGAINto keep processing a chain and 0 to stop.)That was my first idea how to improve on this. I should still have the code (patches), but I'm not sure whether it's clean or lumped together with other experiments.
After pushing the handling down the call chain (caller would use inline functions to manipulate SCSW), I've realized that it does not buy us much/anything expect the better names, while we get the machine code manipulating the SCSW generated in multiple instead of in one place. I also showed the results to Dong Jia and he was ambivalent too: said something like it does look better, but it ain't better enough to make it worthwhile.
Quoted 2 lines
This is why I've decided to go with a less intrusive approach:
just change the names so that it's obvious what's happening.
Something like return channel_program_check(...); or so would be quite obvious, I think.
But yes, it will be easier to evaluate this for an actual patch ;)
Quoted 14 lines
Quoted 4 lines
Quoted 2 lines
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
Confused. If it is suppressed, there should not be an error, no?
No.
From VIRTIO 1.0 4.3.1.2 Device Requirements: Basic Concepts
"If a driver did suppress length checks for a channel command, the device MUST present a check condition if the transmitted data does not contain enough data to process the command."
(http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1230001)
Quoted 4 lines
So for virtio we have to present a check condition. Architecturally it might look better if the one refusing is the device and not the CSS, but for that we would have to change the VIRTIO spec. With the given constraints a program check is IMHO the best fit.
Ah, but that's not general length checking for virtio-ccw :)
Reword the sentence to use 'short data with incorrect length checking suppressed' or so?
Re: [Qemu-devel] [PATCH 4/4] s390x/css: fix incorrect length indication
Quoted 13 lines · Cornelia Huck
Quoted 10 lines · On Mon, 11 Sep 2017 13:36:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 9 lines · Cornelia Huck
Quoted 5 lines · On Fri, 8 Sep 2017 17:24:46 +0200 Halil Pasic <[email protected]> wrote:
We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I'm not sure whether this is the way to go. I mainly dislike the size of the patch (and the fact that it mixes a fix and a change of function signature).
Do you agree that we should move away from POSIX errno codes? I think if we do, this cant' get much smaller.
I'm not really a fan of defining our own return values, tbh.
I've suspected. But your statement, although being useful, does not answer my question. I think we need to agree on this question before proceeding.
In my opinion both the EIO bug and this bug are great examples why the POSIX errno codes are sub-optimal and misleading, but that's my opinion.
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Can we instead choose a mapping for incorrect length, and defer a possible rework?
In the commit message, I say that I don't have a fitting errno. If you tell me which one to use, I would be glad to split this up. I don't like mixing re-factoring and changing behavior myself.
Quoted 7 lines
Quoted 2 lines
Can I have your position on the re-factoring (that is let us imagine I did not change handling for incorrect length)?
If there is no return code that can be made to fit, we probably won't be able to get around some kind of refactoring... but then I'd prefer to do the refactoring first and the fix second.
That is a can do. I dislike refactoring known bugs, because fixing bugs is usually higher priority than making the code nicer, or even marginally faster. (Btw I found these while trying to refactor.) This however is a weak principle of mine and can be easily overpowered by a maintainer request for example.
Quoted 18 lines
Quoted 18 lines
Quoted 5 lines
(Another idea would be to have the callback prepare the scsw via helper functions. We'd just keep
-EAGAINto keep processing a chain and 0 to stop.)That was my first idea how to improve on this. I should still have the code (patches), but I'm not sure whether it's clean or lumped together with other experiments.
After pushing the handling down the call chain (caller would use inline functions to manipulate SCSW), I've realized that it does not buy us much/anything expect the better names, while we get the machine code manipulating the SCSW generated in multiple instead of in one place. I also showed the results to Dong Jia and he was ambivalent too: said something like it does look better, but it ain't better enough to make it worthwhile.
Quoted 8 lines
Quoted 2 lines
This is why I've decided to go with a less intrusive approach:
just change the names so that it's obvious what's happening.Something like return
channel_program_check(...); or so would be quite obvious, I think.But yes, it will be easier to evaluate this for an actual patch ;)
OK, I will look into this, and probably send an RFC these days.
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines
Quoted 2 lines
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
Confused. If it is suppressed, there should not be an error, no?
No.
From VIRTIO 1.0 4.3.1.2 Device Requirements: Basic Concepts
"If a driver did suppress length checks for a channel command, the device MUST present a check condition if the transmitted data does not contain enough data to process the command."
(http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1230001)
Quoted 6 lines
Quoted 4 lines
So for virtio we have to present a check condition. Architecturally it might look better if the one refusing is the device and not the CSS, but for that we would have to change the VIRTIO spec. With the given constraints a program check is IMHO the best fit.
Ah, but that's not general length checking for virtio-ccw :)
What is general length checking for virtio-ccw? Did I say it was general length checking for virtio-ccw?
Quoted 4 lines
Reword the sentence to use 'short data with incorrect length checking suppressed' or so?
Could you provide a whole sentence? I think my original sentence is OK (purpose: indicate that virtio is special, and that we have to bend the architecture a bit), but I agree, being a little more verbose may be a good idea. I just can't come up with a nice sentence.
Halil
Re: [Qemu-devel] [PATCH 4/4] s390x/css: fix incorrect length indication
Quoted 24 lines · On Tue, 12 Sep 2017 17:43:03 +0200 Halil Pasic <[email protected]> wrote:
Quoted 13 lines · Cornelia Huck
Quoted 10 lines · On Mon, 11 Sep 2017 13:36:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 9 lines · Cornelia Huck
Quoted 5 lines · On Fri, 8 Sep 2017 17:24:46 +0200 Halil Pasic <[email protected]> wrote:
We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I'm not sure whether this is the way to go. I mainly dislike the size of the patch (and the fact that it mixes a fix and a change of function signature).
Do you agree that we should move away from POSIX errno codes? I think if we do, this cant' get much smaller.
I'm not really a fan of defining our own return values, tbh.
Quoted 7 lines
I've suspected. But your statement, although being useful, does not answer my question. I think we need to agree on this question before proceeding.
In my opinion both the EIO bug and this bug are great examples why the POSIX errno codes are sub-optimal and misleading, but that's my opinion.
It depends. I prefer them over home-grown ones.
(And I tend to dislike absolute statements.)
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Can we instead choose a mapping for incorrect length, and defer a possible rework?
In the commit message, I say that I don't have a fitting errno. If you tell me which one to use, I would be glad to split this up. I don't like mixing re-factoring and changing behavior myself.
Quoted 7 lines
Quoted 2 lines
Can I have your position on the re-factoring (that is let us imagine I did not change handling for incorrect length)?
If there is no return code that can be made to fit, we probably won't be able to get around some kind of refactoring... but then I'd prefer to do the refactoring first and the fix second.
Quoted 5 lines
That is a can do. I dislike refactoring known bugs, because fixing bugs is usually higher priority than making the code nicer, or even marginally faster. (Btw I found these while trying to refactor.) This however is a weak principle of mine and can be easily overpowered by a maintainer request for example.
If a good fix requires refactoring, I'd prefer to do the refactoring first. I'd prefer an ugly fix first only for serious issues (and I don't think that one counts as one.)
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
Quoted 2 lines
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
Confused. If it is suppressed, there should not be an error, no?
No.
From VIRTIO 1.0 4.3.1.2 Device Requirements: Basic Concepts
"If a driver did suppress length checks for a channel command, the device MUST present a check condition if the transmitted data does not contain enough data to process the command."
(http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1230001)So for virtio we have to present a check condition. Architecturally it might look better if the one refusing is the device and not the CSS, but for that we would have to change the VIRTIO spec. With the given constraints a program check is IMHO the best fit.
Quoted 4 lines
Quoted 1 line
Ah, but that's not general length checking for virtio-ccw :)
What is general length checking for virtio-ccw? Did I say it was general length checking for virtio-ccw?
Hm? Generally, suppressing is supposed to allow incorrect length specifications. For virtio-ccw, that only applies to 'too much' and not 'not enough'.
Also, reading the statement in the spec: It only talks about a 'check condition', not _which_ one - so there's no requirement to keep a channel-program check (other than possibly confusing guests)?
Re: [Qemu-devel] [PATCH 4/4] s390x/css: fix incorrect length indication
Quoted 31 lines · Cornelia Huck
Quoted 28 lines · On Tue, 12 Sep 2017 17:43:03 +0200 Halil Pasic <[email protected]> wrote:
Quoted 13 lines · Cornelia Huck
Quoted 10 lines · On Mon, 11 Sep 2017 13:36:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 9 lines · Cornelia Huck
Quoted 5 lines · On Fri, 8 Sep 2017 17:24:46 +0200 Halil Pasic <[email protected]> wrote:
We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I'm not sure whether this is the way to go. I mainly dislike the size of the patch (and the fact that it mixes a fix and a change of function signature).
Do you agree that we should move away from POSIX errno codes? I think if we do, this cant' get much smaller.
I'm not really a fan of defining our own return values, tbh.
I've suspected. But your statement, although being useful, does not answer my question. I think we need to agree on this question before proceeding.
Quoted 8 lines
Quoted 3 lines
In my opinion both the EIO bug and this bug are great examples why the POSIX errno codes are sub-optimal and misleading, but that's my opinion.
It depends. I prefer them over home-grown ones.
(And I tend to dislike absolute statements.)
Ah, we may have a misunderstanding here. POSIX errno codes are great if they are used for what they are supposed to. The context was meant to be implicitly included in the statement limiting it's scope.
Other than spotting a possible misunderstanding (I hope I did not misunderstand what do you mean by absolute statements myself) this did not bring me any further.
Quoted 25 lines
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Can we instead choose a mapping for incorrect length, and defer a possible rework?
In the commit message, I say that I don't have a fitting errno. If you tell me which one to use, I would be glad to split this up. I don't like mixing re-factoring and changing behavior myself.
Quoted 7 lines
Quoted 2 lines
Can I have your position on the re-factoring (that is let us imagine I did not change handling for incorrect length)?
If there is no return code that can be made to fit, we probably won't be able to get around some kind of refactoring... but then I'd prefer to do the refactoring first and the fix second.
Quoted 5 lines
That is a can do. I dislike refactoring known bugs, because fixing bugs is usually higher priority than making the code nicer, or even marginally faster. (Btw I found these while trying to refactor.) This however is a weak principle of mine and can be easily overpowered by a maintainer request for example.
Quoted 4 lines
If a good fix requires refactoring, I'd prefer to do the refactoring first. I'd prefer an ugly fix first only for serious issues (and I don't think that one counts as one.)
Agree, this isn't a serous issue -- I've even asked Viktor M. should I care about it before doing this patch: along the lines do we care about adhering to the architecture spec. if our guests are agnostic about the difference/divergence.
Quoted 24 lines
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
Quoted 2 lines
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
Confused. If it is suppressed, there should not be an error, no?
No.
From VIRTIO 1.0 4.3.1.2 Device Requirements: Basic Concepts
"If a driver did suppress length checks for a channel command, the device MUST present a check condition if the transmitted data does not contain enough data to process the command."
(http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1230001)So for virtio we have to present a check condition. Architecturally it might look better if the one refusing is the device and not the CSS, but for that we would have to change the VIRTIO spec. With the given constraints a program check is IMHO the best fit.
Quoted 4 lines
Quoted 1 line
Ah, but that's not general length checking for virtio-ccw :)
What is general length checking for virtio-ccw? Did I say it was general length checking for virtio-ccw?
Quoted 8 lines
Hm? Generally, suppressing is supposed to allow incorrect length specifications. For virtio-ccw, that only applies to 'too much' and not 'not enough'.
Also, reading the statement in the spec: It only talks about a 'check condition', not _which_ one - so there's no requirement to keep a channel-program check (other than possibly confusing guests)?
.
You are right, and I was wrong. We could also present an unit-check (that's also check -- and is the only one in device status. The spec even says the 'device must present', although I device is in virtio sense and not in PoP sense here, and does not use 'present subchannel status' as in the previous sentence. For a unit check I would have expected the some sense bit specified to though (like it's specified that under certain conditions we have to do an unit check with a command reject (that is sense bit 0). What shall we do in your opinion?
Re: [Qemu-devel] [PATCH 4/4] s390x/css: fix incorrect length indication
Quoted 41 lines · On Tue, 12 Sep 2017 19:19:56 +0200 Halil Pasic <[email protected]> wrote:
Quoted 31 lines · Cornelia Huck
Quoted 28 lines · On Tue, 12 Sep 2017 17:43:03 +0200 Halil Pasic <[email protected]> wrote:
Quoted 13 lines · Cornelia Huck
Quoted 10 lines · On Mon, 11 Sep 2017 13:36:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 9 lines · Cornelia Huck
Quoted 5 lines · On Fri, 8 Sep 2017 17:24:46 +0200 Halil Pasic <[email protected]> wrote:
We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I'm not sure whether this is the way to go. I mainly dislike the size of the patch (and the fact that it mixes a fix and a change of function signature).
Do you agree that we should move away from POSIX errno codes? I think if we do, this cant' get much smaller.
I'm not really a fan of defining our own return values, tbh.
I've suspected. But your statement, although being useful, does not answer my question. I think we need to agree on this question before proceeding.
Quoted 8 lines
Quoted 3 lines
In my opinion both the EIO bug and this bug are great examples why the POSIX errno codes are sub-optimal and misleading, but that's my opinion.
It depends. I prefer them over home-grown ones.
(And I tend to dislike absolute statements.)
Quoted 7 lines
Ah, we may have a misunderstanding here. POSIX errno codes are great if they are used for what they are supposed to. The context was meant to be implicitly included in the statement limiting it's scope.
Other than spotting a possible misunderstanding (I hope I did not misunderstand what do you mean by absolute statements myself) this did not bring me any further.
As said, I'd probably prefer the alternative approach, as I'm not really a fan of defining a set of return codes.
Quoted 32 lines
Quoted 24 lines
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
Quoted 2 lines
For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check).
Confused. If it is suppressed, there should not be an error, no?
No.
From VIRTIO 1.0 4.3.1.2 Device Requirements: Basic Concepts
"If a driver did suppress length checks for a channel command, the device MUST present a check condition if the transmitted data does not contain enough data to process the command."
(http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1230001)So for virtio we have to present a check condition. Architecturally it might look better if the one refusing is the device and not the CSS, but for that we would have to change the VIRTIO spec. With the given constraints a program check is IMHO the best fit.
Quoted 4 lines
Quoted 1 line
Ah, but that's not general length checking for virtio-ccw :)
What is general length checking for virtio-ccw? Did I say it was general length checking for virtio-ccw?
Quoted 8 lines
Hm? Generally, suppressing is supposed to allow incorrect length specifications. For virtio-ccw, that only applies to 'too much' and not 'not enough'.
Also, reading the statement in the spec: It only talks about a 'check condition', not _which_ one - so there's no requirement to keep a channel-program check (other than possibly confusing guests)?
Quoted 9 lines
.
You are right, and I was wrong. We could also present an unit-check (that's also check -- and is the only one in device status. The spec even says the 'device must present', although I device is in virtio sense and not in PoP sense here, and does not use 'present subchannel status' as in the previous sentence. For a unit check I would have expected the some sense bit specified to though (like it's specified that under certain conditions we have to do an unit check with a command reject (that is sense bit 0). What shall we do in your opinion?
Whatever matches both the architecture and the qemu code flow best ;)
If we can present an incorrect-length check on short data even with suppression set, that seems like the most consistent one.
Else I would keep the current behaviour. Defining a sense bit (we'd need to spec that) seems like overkill to me.