Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Alexey Kardashevskiy
On 12/08/16 04:52, Alexander Duyck wrote: > On Wed, Aug 10, 2016 at 4:54 PM, Benjamin Herrenschmidt > wrote: >> On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: >>> >>> The problem is if we don't do this it becomes possible for a guest to >>> essentially cripple

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Alexey Kardashevskiy
On 12/08/16 04:52, Alexander Duyck wrote: > On Wed, Aug 10, 2016 at 4:54 PM, Benjamin Herrenschmidt > wrote: >> On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: >>> >>> The problem is if we don't do this it becomes possible for a guest to >>> essentially cripple a device on the host by

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Benjamin Herrenschmidt
On Mon, 2016-08-15 at 23:16 +, Rustad, Mark D wrote: > > Bugs in existing guests is an interesting case, but I have been focused on   > getting acceptable behavior from a properly functioning guest, in the face   > of hardware issues that can only be resolved in a single place. > > I agree

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Benjamin Herrenschmidt
On Mon, 2016-08-15 at 23:16 +, Rustad, Mark D wrote: > > Bugs in existing guests is an interesting case, but I have been focused on   > getting acceptable behavior from a properly functioning guest, in the face   > of hardware issues that can only be resolved in a single place. > > I agree

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Rustad, Mark D
Benjamin Herrenschmidt wrote: Filtering things to work around bugs in existing guests to avoid crashes is a different kettle of fish and could be justified but keep in mind that in most cases a malicious guest will be able to exploit those HW flaws. Bugs in existing

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Rustad, Mark D
Benjamin Herrenschmidt wrote: Filtering things to work around bugs in existing guests to avoid crashes is a different kettle of fish and could be justified but keep in mind that in most cases a malicious guest will be able to exploit those HW flaws. Bugs in existing guests is an interesting

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Benjamin Herrenschmidt
On Tue, 2016-08-16 at 08:23 +1000, Benjamin Herrenschmidt wrote: > > I don't think desktop users appreciate hangs any more than anyone else, and  > >   > > that is one of the symptoms that can arise here without the vfio   > > coordination. > > And can happen with it as well  Oh and your

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Benjamin Herrenschmidt
On Tue, 2016-08-16 at 08:23 +1000, Benjamin Herrenschmidt wrote: > > I don't think desktop users appreciate hangs any more than anyone else, and  > >   > > that is one of the symptoms that can arise here without the vfio   > > coordination. > > And can happen with it as well  Oh and your

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Benjamin Herrenschmidt
On Mon, 2016-08-15 at 17:59 +, Rustad, Mark D wrote: > > Benjamin Herrenschmidt wrote: > > > > > We may want some kind of "strict" vs. "relaxed" model here to > > differenciate the desktop user wanting to give a function to his/her > > windows partition and doesn't

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Benjamin Herrenschmidt
On Mon, 2016-08-15 at 17:59 +, Rustad, Mark D wrote: > > Benjamin Herrenschmidt wrote: > > > > > We may want some kind of "strict" vs. "relaxed" model here to > > differenciate the desktop user wanting to give a function to his/her > > windows partition and doesn't care about strict

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Rustad, Mark D
Benjamin Herrenschmidt wrote: We may want some kind of "strict" vs. "relaxed" model here to differenciate the desktop user wanting to give a function to his/her windows partition and doesn't care about strict isolation vs. the cloud data center. I don't think

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-15 Thread Rustad, Mark D
Benjamin Herrenschmidt wrote: We may want some kind of "strict" vs. "relaxed" model here to differenciate the desktop user wanting to give a function to his/her windows partition and doesn't care about strict isolation vs. the cloud data center. I don't think desktop users appreciate hangs

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-11 Thread Benjamin Herrenschmidt
On Thu, 2016-08-11 at 14:17 -0600, Alex Williamson wrote: > > vfio isn't playing nanny here for the fun of it, part of the reason we > have vpd access functions is because folks have discovered that vpd > registers between PCI functions on multi-function devices may be > shared.  So pounding on

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-11 Thread Benjamin Herrenschmidt
On Thu, 2016-08-11 at 14:17 -0600, Alex Williamson wrote: > > vfio isn't playing nanny here for the fun of it, part of the reason we > have vpd access functions is because folks have discovered that vpd > registers between PCI functions on multi-function devices may be > shared.  So pounding on

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-11 Thread Alex Williamson
On Thu, 11 Aug 2016 11:52:02 -0700 Alexander Duyck wrote: > On Wed, Aug 10, 2016 at 4:54 PM, Benjamin Herrenschmidt > wrote: > > On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: > >> > >> The problem is if we don't do this it

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-11 Thread Alex Williamson
On Thu, 11 Aug 2016 11:52:02 -0700 Alexander Duyck wrote: > On Wed, Aug 10, 2016 at 4:54 PM, Benjamin Herrenschmidt > wrote: > > On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: > >> > >> The problem is if we don't do this it becomes possible for a guest to > >> essentially cripple a

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-11 Thread Alexander Duyck
On Wed, Aug 10, 2016 at 4:54 PM, Benjamin Herrenschmidt wrote: > On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: >> >> The problem is if we don't do this it becomes possible for a guest to >> essentially cripple a device on the host by just accessing VPD >>

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-11 Thread Alexander Duyck
On Wed, Aug 10, 2016 at 4:54 PM, Benjamin Herrenschmidt wrote: > On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: >> >> The problem is if we don't do this it becomes possible for a guest to >> essentially cripple a device on the host by just accessing VPD >> regions that aren't actually

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-10 Thread Benjamin Herrenschmidt
On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: > > The problem is if we don't do this it becomes possible for a guest to > essentially cripple a device on the host by just accessing VPD > regions that aren't actually viable on many devices.  And ? We already can cripple the device in

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-10 Thread Benjamin Herrenschmidt
On Wed, 2016-08-10 at 08:47 -0700, Alexander Duyck wrote: > > The problem is if we don't do this it becomes possible for a guest to > essentially cripple a device on the host by just accessing VPD > regions that aren't actually viable on many devices.  And ? We already can cripple the device in

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-10 Thread Hannes Reinecke
On 08/09/2016 08:12 PM, Alexander Duyck wrote: > On Tue, Aug 9, 2016 at 5:54 AM, Alexey Kardashevskiy wrote: >> On 10/02/16 08:04, Bjorn Helgaas wrote: >>> On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: PCI-2.2 VPD entries have a maximum size of 32k, but

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-10 Thread Hannes Reinecke
On 08/09/2016 08:12 PM, Alexander Duyck wrote: > On Tue, Aug 9, 2016 at 5:54 AM, Alexey Kardashevskiy wrote: >> On 10/02/16 08:04, Bjorn Helgaas wrote: >>> On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: PCI-2.2 VPD entries have a maximum size of 32k, but might actually

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-10 Thread Alexander Duyck
On Tue, Aug 9, 2016 at 5:03 PM, Benjamin Herrenschmidt wrote: > On Tue, 2016-08-09 at 11:12 -0700, Alexander Duyck wrote: >> >> The PCI spec is what essentially assumes that there is only one block. >> If I am not mistaken in the case of this device the second block here

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-10 Thread Alexander Duyck
On Tue, Aug 9, 2016 at 5:03 PM, Benjamin Herrenschmidt wrote: > On Tue, 2016-08-09 at 11:12 -0700, Alexander Duyck wrote: >> >> The PCI spec is what essentially assumes that there is only one block. >> If I am not mistaken in the case of this device the second block here >> actually contains

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Benjamin Herrenschmidt
On Tue, 2016-08-09 at 11:12 -0700, Alexander Duyck wrote: > > The PCI spec is what essentially assumes that there is only one block. > If I am not mistaken in the case of this device the second block here > actually contains device configuration data, not actual VPD data.  The > issue here is

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Benjamin Herrenschmidt
On Tue, 2016-08-09 at 11:12 -0700, Alexander Duyck wrote: > > The PCI spec is what essentially assumes that there is only one block. > If I am not mistaken in the case of this device the second block here > actually contains device configuration data, not actual VPD data.  The > issue here is

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Benjamin Herrenschmidt
> On Tue, 2016-08-09 at 22:54 +1000, Alexey Kardashevskiy wrote: > The cxgb3 driver is reading the second bit starting from 0xc00 but since > the size is wrongly detected as 0x7c, VFIO blocks access beyond it and the > guest driver fails to probe. > > I also cannot find a clause in the PCI 3.0

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Benjamin Herrenschmidt
> On Tue, 2016-08-09 at 22:54 +1000, Alexey Kardashevskiy wrote: > The cxgb3 driver is reading the second bit starting from 0xc00 but since > the size is wrongly detected as 0x7c, VFIO blocks access beyond it and the > guest driver fails to probe. > > I also cannot find a clause in the PCI 3.0

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Alexander Duyck
On Tue, Aug 9, 2016 at 5:54 AM, Alexey Kardashevskiy wrote: > On 10/02/16 08:04, Bjorn Helgaas wrote: >> On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: >>> PCI-2.2 VPD entries have a maximum size of 32k, but might actually >>> be smaller than that. To figure out

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Alexander Duyck
On Tue, Aug 9, 2016 at 5:54 AM, Alexey Kardashevskiy wrote: > On 10/02/16 08:04, Bjorn Helgaas wrote: >> On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: >>> PCI-2.2 VPD entries have a maximum size of 32k, but might actually >>> be smaller than that. To figure out the actual size

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Alexey Kardashevskiy
On 10/02/16 08:04, Bjorn Helgaas wrote: > On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: >> PCI-2.2 VPD entries have a maximum size of 32k, but might actually >> be smaller than that. To figure out the actual size one has to read >> the VPD area until the 'end marker' is reached.

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-08-09 Thread Alexey Kardashevskiy
On 10/02/16 08:04, Bjorn Helgaas wrote: > On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: >> PCI-2.2 VPD entries have a maximum size of 32k, but might actually >> be smaller than that. To figure out the actual size one has to read >> the VPD area until the 'end marker' is reached.

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-02-09 Thread Hannes Reinecke
On 02/09/2016 10:04 PM, Bjorn Helgaas wrote: > On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: >> PCI-2.2 VPD entries have a maximum size of 32k, but might actually >> be smaller than that. To figure out the actual size one has to read >> the VPD area until the 'end marker' is

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-02-09 Thread Bjorn Helgaas
On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: > PCI-2.2 VPD entries have a maximum size of 32k, but might actually > be smaller than that. To figure out the actual size one has to read > the VPD area until the 'end marker' is reached. > Trying to read VPD data beyond that marker

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-02-09 Thread Bjorn Helgaas
On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: > PCI-2.2 VPD entries have a maximum size of 32k, but might actually > be smaller than that. To figure out the actual size one has to read > the VPD area until the 'end marker' is reached. > Trying to read VPD data beyond that marker

Re: [PATCHv2 3/4] pci: Determine actual VPD size on first access

2016-02-09 Thread Hannes Reinecke
On 02/09/2016 10:04 PM, Bjorn Helgaas wrote: > On Wed, Jan 13, 2016 at 12:25:34PM +0100, Hannes Reinecke wrote: >> PCI-2.2 VPD entries have a maximum size of 32k, but might actually >> be smaller than that. To figure out the actual size one has to read >> the VPD area until the 'end marker' is