qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: P J P <ppandit@redhat.com>
Cc: Qemu Developers <qemu-devel@nongnu.org>,
	Dmitry Fleytman <dmitry@daynix.com>, Li Qiang <liqiang6-s@360.cn>
Subject: Re: [Qemu-devel] [PATCH] scsi: pvscsi: request descriptor data_length to 32 bit
Date: Mon, 5 Sep 2016 15:02:21 +0200	[thread overview]
Message-ID: <d115ae37-d7fe-4351-f802-5dec1c23422b@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.20.1609051824140.16376@wniryva>



On 05/09/2016 14:58, P J P wrote:
> +-- On Mon, 5 Sep 2016, Paolo Bonzini wrote --+
> | Without a public spec it's hard, but I guess 2048 is more than enough.
> 
> ===
> diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
> index 4245c15..4823b9d 100644
> --- a/hw/scsi/vmw_pvscsi.c
> +++ b/hw/scsi/vmw_pvscsi.c
> @@ -628,17 +628,16 @@ pvscsi_queue_pending_descriptor(PVSCSIState *s, SCSIDevice **d,
>  static void
>  pvscsi_convert_sglist(PVSCSIRequest *r)
>  {
> -    int chunk_size;
> +    int chunk_size, n = 0;

chunk_size should be uint32_t.

>      uint64_t data_length = r->req.dataLen;
>      PVSCSISGState sg = r->sg;
> -    while (data_length) {
> -        while (!sg.resid) {
> +    while (data_length && n < 2048) {
> +        while (!sg.resid && n++ < 2048) {
>              pvscsi_get_next_sg_elem(&sg);
>              trace_pvscsi_convert_sglist(r->req.context, r->sg.dataAddr,
>                                          r->sg.resid);
>          }
> -        assert(data_length > 0);
> -        chunk_size = MIN((unsigned) data_length, sg.resid);
> +        chunk_size = MIN(data_length, sg.resid);
>          if (chunk_size) {
>              qemu_sglist_add(&r->sgl, sg.dataAddr, chunk_size);
>          }
> ===
> 
> Does this look okay?

Yes, just change 2048 to a #define PVSCSI_MAX_SG_ELEM.

Paolo

> --
> Prasad J Pandit / Red Hat Product Security Team
> 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F
> 

  reply	other threads:[~2016-09-05 13:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03  6:33 [Qemu-devel] [PATCH] scsi: pvscsi: request descriptor data_length to 32 bit P J P
2016-09-05  9:04 ` Paolo Bonzini
2016-09-05  9:50   ` P J P
2016-09-05 10:00     ` Paolo Bonzini
2016-09-05 11:13       ` P J P
2016-09-05 11:39         ` Paolo Bonzini
2016-09-05 12:58           ` P J P
2016-09-05 13:02             ` Paolo Bonzini [this message]
2016-09-05 20:52               ` P J P

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=d115ae37-d7fe-4351-f802-5dec1c23422b@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dmitry@daynix.com \
    --cc=liqiang6-s@360.cn \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).