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

On Thu, Jun 18, 2015 at 10:14:40AM +0200, Gerd Hoffmann wrote:
>   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.

Yes - I mean for the device config.

> > >  	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:57 UTC|newest]

Thread overview: 16+ 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 13:57 ` Gerd Hoffmann
2015-06-16 14:11 ` Michael S. Tsirkin
2015-06-16 14:11   ` Michael S. Tsirkin
2015-06-18  8:14   ` Gerd Hoffmann
2015-06-18  8:14     ` Gerd Hoffmann
2015-06-18  8:56     ` Michael S. Tsirkin [this message]
2015-06-18  8:56     ` Michael S. Tsirkin
2015-06-23 13:54 Gerd Hoffmann
2015-06-23 13:54 ` Gerd Hoffmann
2015-06-23 14:21 ` Michael S. Tsirkin
2015-06-23 14:21   ` Michael S. Tsirkin
2015-06-24  5:54 Gerd Hoffmann
2015-06-24  5:54 ` Gerd Hoffmann
2015-06-24  6:14 ` Michael S. Tsirkin
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=20150618105628-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 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.