public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] pci: config space bounds check and correction
@ 2011-07-20 23:46 Donald Dutile
  2011-07-20 23:49 ` [PATCH 1/2] pci: bounds check offsets into config_map Donald Dutile
  2011-07-20 23:51 ` [PATCH 2/2] pci: correct pci config size default for cap version 2 endpoints Donald Dutile
  0 siblings, 2 replies; 7+ messages in thread
From: Donald Dutile @ 2011-07-20 23:46 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, mst

Doing device assignement using a PCIe device with it's
PCI Cap structure at offset 0xcc showed a problem in
the default size mapped for this cap-id.

The failure caused a corruption which might have gone unnoticed
otherwise.

So, add a bounds check in pci_add_capability() & fprintf()
to detail which device & cap structure.  While there, adjust
overlap check to prefix output with '0x' so it's clear in output.
Note: bounds check a bit odd looking, but that's because offset & size
      are uint8's and comparing to greater than 256.

Next, fix assigned_device_pci_cap_init() to set the default
size of PCIe Cap structure (cap-id 0x10) to 0x34 instead of 0x3c.
0x34 is default, min, for endpoint device with a cap version of 2.
Algorithm will have to get a bit more complicated if 
non-endpoint (mriov-based switches?) are ever device-assigned.

Signed-off-by: Donald Dutile <ddutile@redhat.com>
cc: Alex Williamson <alex.williamson@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>

---

Donald Dutile (2):
      pci: correct pci config size default for cap version 2 endpoints
      pci: bounds check offsets into config_map


 hw/device-assignment.c |    4 +++-
 hw/pci.c               |   16 ++++++++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-07-21 15:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-20 23:46 [PATCH 0/2] pci: config space bounds check and correction Donald Dutile
2011-07-20 23:49 ` [PATCH 1/2] pci: bounds check offsets into config_map Donald Dutile
2011-07-21  8:11   ` Michael S. Tsirkin
2011-07-21 15:52     ` Don Dutile
2011-07-20 23:51 ` [PATCH 2/2] pci: correct pci config size default for cap version 2 endpoints Donald Dutile
2011-07-21  2:43   ` Alex Williamson
2011-07-21 15:52     ` Don Dutile

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox