qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Christian Borntraeger <borntraeger@de.ibm.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Jens Freimann <jfrei@linux.vnet.ibm.com>,
	Richard Henderson <rth@twiddle.net>,
	qemu-devel <qemu-devel@nongnu.org>,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PULL 3/3] s390x/css: catch ccw sequence errors
Date: Fri, 26 Sep 2014 12:36:38 +0200	[thread overview]
Message-ID: <542541B6.1000009@suse.de> (raw)
In-Reply-To: <1411474456-12226-4-git-send-email-borntraeger@de.ibm.com>

Christian, Conny,

Am 23.09.2014 um 14:14 schrieb Christian Borntraeger:
> From: Cornelia Huck <cornelia.huck@de.ibm.com>
> 
> We must not allow chains of more than 255 ccws without data transfer.
> 
> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  hw/s390x/css.c | 10 ++++++++++
>  hw/s390x/css.h |  1 +
>  2 files changed, 11 insertions(+)
> 
> diff --git a/hw/s390x/css.c b/hw/s390x/css.c
> index 34637cb..b67c039 100644
> --- a/hw/s390x/css.c
> +++ b/hw/s390x/css.c
> @@ -294,6 +294,13 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr)
>  
>      check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));
>  
> +    if (!ccw.cda) {
> +        if (sch->ccw_no_data_cnt == 255) {
> +            return -EINVAL;
> +        }
> +        sch->ccw_no_data_cnt++;
> +    }
> +
>      /* Look at the command. */
>      switch (ccw.cmd_code) {
>      case CCW_CMD_NOOP:
> @@ -396,6 +403,7 @@ static void sch_handle_start_func(SubchDev *sch, ORB *orb)
>              return;
>          }
>          sch->ccw_fmt_1 = !!(orb->ctrl0 & ORB_CTRL0_MASK_FMT);
> +        sch->ccw_no_data_cnt = 0;
>      } else {
>          s->ctrl &= ~(SCSW_ACTL_SUSP | SCSW_ACTL_RESUME_PEND);
>      }
> @@ -1358,6 +1366,7 @@ void subch_device_save(SubchDev *s, QEMUFile *f)
>          qemu_put_be16(f, s->id.ciw[i].count);
>      }
>      qemu_put_byte(f, s->ccw_fmt_1);
> +    qemu_put_byte(f, s->ccw_no_data_cnt);
>      return;
>  }
>  
> @@ -1414,6 +1423,7 @@ int subch_device_load(SubchDev *s, QEMUFile *f)
>          s->id.ciw[i].count = qemu_get_be16(f);
>      }
>      s->ccw_fmt_1 = qemu_get_byte(f);
> +    s->ccw_no_data_cnt = qemu_get_byte(f);
>      return 0;
>  }
>  

You need to bump the version saved if you add fields (same as VMState),
and on load you need to check the version for whether to load the field
(or deny loading).

Regards,
Andreas

> diff --git a/hw/s390x/css.h b/hw/s390x/css.h
> index 384a455..33104ac 100644
> --- a/hw/s390x/css.h
> +++ b/hw/s390x/css.h
> @@ -78,6 +78,7 @@ struct SubchDev {
>      bool last_cmd_valid;
>      bool ccw_fmt_1;
>      bool thinint_active;
> +    uint8_t ccw_no_data_cnt;
>      /* transport-provided data: */
>      int (*ccw_cb) (SubchDev *, CCW1);
>      SenseId id;

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2014-09-26 10:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 12:14 [Qemu-devel] [PULL 0/3] s390x/kvm: some fixes and cleanups Christian Borntraeger
2014-09-23 12:14 ` [Qemu-devel] [PULL 1/3] s390x: remove duplicate defines in SCLP code Christian Borntraeger
2014-09-23 12:14 ` [Qemu-devel] [PULL 2/3] s390x/css: support format-0 ccws Christian Borntraeger
2014-09-26 10:41   ` Andreas Färber
2014-09-23 12:14 ` [Qemu-devel] [PULL 3/3] s390x/css: catch ccw sequence errors Christian Borntraeger
2014-09-26 10:36   ` Andreas Färber [this message]
2014-09-26 10:49     ` Christian Borntraeger
2014-09-26 11:18       ` Andreas Färber
2014-09-23 13:42 ` [Qemu-devel] [PULL 0/3] s390x/kvm: some fixes and cleanups Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=542541B6.1000009@suse.de \
    --to=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).