* [Qemu-devel] [PATCH RFC] s390/css: handle CCW_FLAG_SKIP
@ 2019-05-06 17:17 Cornelia Huck
2019-05-06 20:58 ` Eric Farman
0 siblings, 1 reply; 3+ messages in thread
From: Cornelia Huck @ 2019-05-06 17:17 UTC (permalink / raw)
To: Halil Pasic, Christian Borntraeger
Cc: Eric Farman, qemu-s390x, Cornelia Huck, qemu-devel
If a ccw has CCW_FLAG_SKIP set, and the command is of type
read, read backwards, or sense, no data should be written
to the guest for that command.
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
Only extremely lightly tested (i.e., can boot a guest.)
---
hw/s390x/css.c | 22 ++++++++++++++++++----
include/hw/s390x/css.h | 1 +
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 8fc9e35ba5d3..6ee31cc2e08f 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -830,8 +830,12 @@ static int ccw_dstream_rw_noflags(CcwDataStream *cds, void *buff, int len,
if (op == CDS_OP_A) {
goto incr;
}
- ret = address_space_rw(&address_space_memory, cds->cda,
- MEMTXATTRS_UNSPECIFIED, buff, len, op);
+ if (!cds->do_skip) {
+ ret = address_space_rw(&address_space_memory, cds->cda,
+ MEMTXATTRS_UNSPECIFIED, buff, len, op);
+ } else {
+ ret = 0;
+ }
if (ret != MEMTX_OK) {
cds->flags |= CDS_F_STREAM_BROKEN;
return -EINVAL;
@@ -928,8 +932,13 @@ static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,
do {
iter_len = MIN(len, cont_left);
if (op != CDS_OP_A) {
- ret = address_space_rw(&address_space_memory, cds->cda,
- MEMTXATTRS_UNSPECIFIED, buff, iter_len, op);
+ if (!cds->do_skip) {
+ ret = address_space_rw(&address_space_memory, cds->cda,
+ MEMTXATTRS_UNSPECIFIED, buff, iter_len,
+ op);
+ } else {
+ ret = 0;
+ }
if (ret != MEMTX_OK) {
/* assume inaccessible address */
ret = -EINVAL; /* channel program check */
@@ -968,6 +977,11 @@ void ccw_dstream_init(CcwDataStream *cds, CCW1 const *ccw, ORB const *orb)
cds->count = ccw->count;
cds->cda_orig = ccw->cda;
+ /* skip is only effective for read, read backwards, or sense commands */
+ cds->do_skip = (ccw->flags & CCW_FLAG_SKIP) &&
+ (ccw->cmd_code & CCW_CMD_BASIC_SENSE ||
+ ccw->cmd_code & 0x02 /* read */ ||
+ ccw->cmd_code & 0x0c /* read backwards */);
ccw_dstream_rewind(cds);
if (!(cds->flags & CDS_F_IDA)) {
cds->op_handler = ccw_dstream_rw_noflags;
diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
index aae19c427229..7cc183ef4366 100644
--- a/include/hw/s390x/css.h
+++ b/include/hw/s390x/css.h
@@ -97,6 +97,7 @@ typedef struct CcwDataStream {
int (*op_handler)(struct CcwDataStream *cds, void *buff, int len,
CcwDataStreamOp op);
hwaddr cda;
+ bool do_skip;
} CcwDataStream;
/*
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH RFC] s390/css: handle CCW_FLAG_SKIP
2019-05-06 17:17 [Qemu-devel] [PATCH RFC] s390/css: handle CCW_FLAG_SKIP Cornelia Huck
@ 2019-05-06 20:58 ` Eric Farman
2019-05-07 7:34 ` Cornelia Huck
0 siblings, 1 reply; 3+ messages in thread
From: Eric Farman @ 2019-05-06 20:58 UTC (permalink / raw)
To: Cornelia Huck, Halil Pasic, Christian Borntraeger; +Cc: qemu-s390x, qemu-devel
On 5/6/19 1:17 PM, Cornelia Huck wrote:
> If a ccw has CCW_FLAG_SKIP set, and the command is of type
> read, read backwards, or sense, no data should be written
> to the guest for that command.
>
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
>
> Only extremely lightly tested (i.e., can boot a guest.)
>
> ---
> hw/s390x/css.c | 22 ++++++++++++++++++----
> include/hw/s390x/css.h | 1 +
> 2 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/hw/s390x/css.c b/hw/s390x/css.c
> index 8fc9e35ba5d3..6ee31cc2e08f 100644
> --- a/hw/s390x/css.c
> +++ b/hw/s390x/css.c
> @@ -830,8 +830,12 @@ static int ccw_dstream_rw_noflags(CcwDataStream *cds, void *buff, int len,
> if (op == CDS_OP_A) {
> goto incr;
> }
> - ret = address_space_rw(&address_space_memory, cds->cda,
> - MEMTXATTRS_UNSPECIFIED, buff, len, op);
> + if (!cds->do_skip) {
> + ret = address_space_rw(&address_space_memory, cds->cda,
> + MEMTXATTRS_UNSPECIFIED, buff, len, op);
> + } else {
> + ret = 0;
> + }
> if (ret != MEMTX_OK) {
> cds->flags |= CDS_F_STREAM_BROKEN;
> return -EINVAL;
> @@ -928,8 +932,13 @@ static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,
> do {
> iter_len = MIN(len, cont_left);
> if (op != CDS_OP_A) {
> - ret = address_space_rw(&address_space_memory, cds->cda,
> - MEMTXATTRS_UNSPECIFIED, buff, iter_len, op);
> + if (!cds->do_skip) {
> + ret = address_space_rw(&address_space_memory, cds->cda,
> + MEMTXATTRS_UNSPECIFIED, buff, iter_len,
> + op);
> + } else {
> + ret = 0;
> + }
> if (ret != MEMTX_OK) {
> /* assume inaccessible address */
> ret = -EINVAL; /* channel program check */
> @@ -968,6 +977,11 @@ void ccw_dstream_init(CcwDataStream *cds, CCW1 const *ccw, ORB const *orb)
>
> cds->count = ccw->count;
> cds->cda_orig = ccw->cda;
> + /* skip is only effective for read, read backwards, or sense commands */
> + cds->do_skip = (ccw->flags & CCW_FLAG_SKIP) &&
> + (ccw->cmd_code & CCW_CMD_BASIC_SENSE ||
> + ccw->cmd_code & 0x02 /* read */ ||
> + ccw->cmd_code & 0x0c /* read backwards */);
I wish so badly that these checks work, since it'd simplify the vfio-ccw
code, but I don't think this lets you tell the difference between a READ
(x02) and a NOP (x03) or any other control-type CCW. Ditto
read-backward versus TIC. :-(
> ccw_dstream_rewind(cds);
> if (!(cds->flags & CDS_F_IDA)) {
> cds->op_handler = ccw_dstream_rw_noflags;
> diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
> index aae19c427229..7cc183ef4366 100644
> --- a/include/hw/s390x/css.h
> +++ b/include/hw/s390x/css.h
> @@ -97,6 +97,7 @@ typedef struct CcwDataStream {
> int (*op_handler)(struct CcwDataStream *cds, void *buff, int len,
> CcwDataStreamOp op);
> hwaddr cda;
> + bool do_skip;
> } CcwDataStream;
>
> /*
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH RFC] s390/css: handle CCW_FLAG_SKIP
2019-05-06 20:58 ` Eric Farman
@ 2019-05-07 7:34 ` Cornelia Huck
0 siblings, 0 replies; 3+ messages in thread
From: Cornelia Huck @ 2019-05-07 7:34 UTC (permalink / raw)
To: Eric Farman; +Cc: Halil Pasic, Christian Borntraeger, qemu-s390x, qemu-devel
On Mon, 6 May 2019 16:58:03 -0400
Eric Farman <farman@linux.ibm.com> wrote:
> On 5/6/19 1:17 PM, Cornelia Huck wrote:
> > If a ccw has CCW_FLAG_SKIP set, and the command is of type
> > read, read backwards, or sense, no data should be written
> > to the guest for that command.
> >
> > Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> > ---
> >
> > Only extremely lightly tested (i.e., can boot a guest.)
> >
> > ---
> > hw/s390x/css.c | 22 ++++++++++++++++++----
> > include/hw/s390x/css.h | 1 +
> > 2 files changed, 19 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/s390x/css.c b/hw/s390x/css.c
> > index 8fc9e35ba5d3..6ee31cc2e08f 100644
> > --- a/hw/s390x/css.c
> > +++ b/hw/s390x/css.c
> > @@ -830,8 +830,12 @@ static int ccw_dstream_rw_noflags(CcwDataStream *cds, void *buff, int len,
> > if (op == CDS_OP_A) {
> > goto incr;
> > }
> > - ret = address_space_rw(&address_space_memory, cds->cda,
> > - MEMTXATTRS_UNSPECIFIED, buff, len, op);
> > + if (!cds->do_skip) {
> > + ret = address_space_rw(&address_space_memory, cds->cda,
> > + MEMTXATTRS_UNSPECIFIED, buff, len, op);
> > + } else {
> > + ret = 0;
> > + }
> > if (ret != MEMTX_OK) {
> > cds->flags |= CDS_F_STREAM_BROKEN;
> > return -EINVAL;
> > @@ -928,8 +932,13 @@ static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,
> > do {
> > iter_len = MIN(len, cont_left);
> > if (op != CDS_OP_A) {
> > - ret = address_space_rw(&address_space_memory, cds->cda,
> > - MEMTXATTRS_UNSPECIFIED, buff, iter_len, op);
> > + if (!cds->do_skip) {
> > + ret = address_space_rw(&address_space_memory, cds->cda,
> > + MEMTXATTRS_UNSPECIFIED, buff, iter_len,
> > + op);
> > + } else {
> > + ret = 0;
> > + }
> > if (ret != MEMTX_OK) {
> > /* assume inaccessible address */
> > ret = -EINVAL; /* channel program check */
> > @@ -968,6 +977,11 @@ void ccw_dstream_init(CcwDataStream *cds, CCW1 const *ccw, ORB const *orb)
> >
> > cds->count = ccw->count;
> > cds->cda_orig = ccw->cda;
> > + /* skip is only effective for read, read backwards, or sense commands */
> > + cds->do_skip = (ccw->flags & CCW_FLAG_SKIP) &&
> > + (ccw->cmd_code & CCW_CMD_BASIC_SENSE ||
> > + ccw->cmd_code & 0x02 /* read */ ||
> > + ccw->cmd_code & 0x0c /* read backwards */);
>
> I wish so badly that these checks work, since it'd simplify the vfio-ccw
> code, but I don't think this lets you tell the difference between a READ
> (x02) and a NOP (x03) or any other control-type CCW. Ditto
> read-backward versus TIC. :-(
Drat, why is that never easy... I'll rework this check.
>
> > ccw_dstream_rewind(cds);
> > if (!(cds->flags & CDS_F_IDA)) {
> > cds->op_handler = ccw_dstream_rw_noflags;
> > diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
> > index aae19c427229..7cc183ef4366 100644
> > --- a/include/hw/s390x/css.h
> > +++ b/include/hw/s390x/css.h
> > @@ -97,6 +97,7 @@ typedef struct CcwDataStream {
> > int (*op_handler)(struct CcwDataStream *cds, void *buff, int len,
> > CcwDataStreamOp op);
> > hwaddr cda;
> > + bool do_skip;
> > } CcwDataStream;
> >
> > /*
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-07 7:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-06 17:17 [Qemu-devel] [PATCH RFC] s390/css: handle CCW_FLAG_SKIP Cornelia Huck
2019-05-06 20:58 ` Eric Farman
2019-05-07 7:34 ` Cornelia Huck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.