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] virtio-pci: alloc only resources actually used.
Date: Thu, 18 Jun 2015 10:14:40 +0200	[thread overview]
Message-ID: <1434615280.4968.14.camel@redhat.com> (raw)
In-Reply-To: <20150616160052-mutt-send-email-mst@redhat.com>

  Hi,

> > +static struct resource *request_capability(struct pci_dev *dev, int off,
> > +					   const char *name)
> > +{
> > +	u8 bar;
> > +	u32 offset, length;
> > +
> > +	pci_read_config_byte(dev, off + offsetof(struct virtio_pci_cap,
> > +						 bar),
> > +			     &bar);
> > +	pci_read_config_dword(dev, off + offsetof(struct virtio_pci_cap, offset),
> > +			     &offset);
> > +	pci_read_config_dword(dev, off + offsetof(struct virtio_pci_cap, length),
> > +			      &length);
> > +
> > +	return request_mem_region(pci_resource_start(dev, bar) + offset,
> > +				  length, name);
> > +}
> > +
> 
> For device config, this might request too much. The spec says:
> 	The drivers SHOULD only map part of configuration structure large enough
> 	for device operation.

We don't map it here though.  We just reserve what belongs to virtio
according to the capabilities.

> I think you should limit this to PAGE_SIZE like we do for map_capability.

notify is much larger than PAGE_SIZE.

> >  	err = -EINVAL;
> >  	vp_dev->common = map_capability(pci_dev, common,
> >  					sizeof(struct virtio_pci_common_cfg), 4,
> 
> map_capability has a bunch of checks in place to validate the capability
> structure. With request_capability called earlier, they are now done too
> late.

Hmm, lets move the checks to find_capability then?

cheers,
  Gerd

  reply	other threads:[~2015-06-18  8:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-16 13:57 [PATCH] virtio-pci: alloc only resources actually used Gerd Hoffmann
2015-06-16 14:11 ` Michael S. Tsirkin
2015-06-18  8:14   ` Gerd Hoffmann [this message]
2015-06-18  8:56     ` Michael S. Tsirkin
  -- strict thread matches above, loose matches on Subject: below --
2015-06-23 13:54 Gerd Hoffmann
2015-06-23 14:21 ` Michael S. Tsirkin
2015-06-24  5:54 Gerd Hoffmann
2015-06-24  6:14 ` 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=1434615280.4968.14.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).