virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: open list <linux-kernel@vger.kernel.org>,
	"open list:VIRTIO CORE,
	NET..." <virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH v2] virtio-pci: alloc only resources actually used.
Date: Thu, 18 Jun 2015 12:33:20 +0200	[thread overview]
Message-ID: <1434623600.4968.29.camel@redhat.com> (raw)
In-Reply-To: <20150618115029-mutt-send-email-mst@redhat.com>

  Hi,

> > +	if (offset + length < offset ||
> > +	    offset + length > pci_resource_len(dev, bar)) {
> > +		dev_err(&dev->dev,
> > +			"virtio_pci: virtio capability %u@%u "
> > +			"out of range on bar %i length %lu\n",
> > +			length, offset, bar,
> > +			(unsigned long)pci_resource_len(dev, bar));
> > +		return NULL;
> > +	}
> > +
> > +	if (limit && length > limit)
> > +		length = limit;
> > +
> 
> I'll have to review the above carefully. Hopefully next week.
> Any reason you didn't just move code out map_capability to a helper,
> without changes?  Would have made review easier.

Doesn't work that easily as there are different things to check.
request_capability verifies the capability itself only, map_capability
has a bunch of additional range checks because it supports partial maps.

> I don't see reasons to request regions that we aren't going to
> claim ...

I had it that way first, simply calling request_mem_region from
map_capability.  But then you get tons of notify entries in /proc/iomem,
and keeping track of the requested regions (for cleanup in
virtio_pci_modern_remove) also is more complicated than with a simple
set of 4 fixed regions.

> > +	return request_mem_region(pci_resource_start(dev, bar) + offset,
> > +				  length, name);
> 
> Hmm this seems wrong, resource can be IO, not just memory.

Right (not the case in the current qemu implementation, but still ...).

> > +	vp_dev->res_common = request_capability(pci_dev, common, 0,
> 
> Please make limit = sizeof(struct virtio_pci_common_cfg) and not 0.
> 
> > +						"virtio-pci-common");
> > +	vp_dev->res_isr = request_capability(pci_dev, isr, 0,
> > +						"virtio-pci-isr");
> 
> And here, 1.
> 
> > +	vp_dev->res_notify = request_capability(pci_dev, notify, 0,
> > +						"virtio-pci-notify");
> > +	if (device) {
> > +		vp_dev->res_device = request_capability(pci_dev, device,
> > +							PAGE_SIZE,
> > +							"virtio-pci-device");
> > +	}
> 
> Please drop {} around a single statement.

I'll fix them for the next version.

cheers,
  Gerd

  parent reply	other threads:[~2015-06-18 10:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  9:27 [PATCH v2] virtio-pci: alloc only resources actually used Gerd Hoffmann
2015-06-18  9:58 ` Michael S. Tsirkin
     [not found] ` <20150618115029-mutt-send-email-mst@redhat.com>
2015-06-18 10:33   ` Gerd Hoffmann [this message]
2015-06-18 13:27     ` Michael S. Tsirkin

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=1434623600.4968.29.camel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.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).