mbox series

[0/7] Retrieve zPCI hardware information from VFIO

Message ID 1600529672-10243-1-git-send-email-mjrosato@linux.ibm.com
Headers show
Series Retrieve zPCI hardware information from VFIO | expand

Message

Matthew Rosato Sept. 19, 2020, 3:34 p.m. UTC
This patchset exploits the VFIO ZPCI CLP region, which provides hardware
information about passed-through s390 PCI devices that can be shared with
the guest.

The retrieval of this information is done once per function (and for a
subset of data, once per function group) and is performed at time of device
plug.  Some elements provided in the CLP region must still be forced to
default values for now to reflect what QEMU actually provides support for.

The original work for this feature was done by Pierre Morel.

Note: This patchset will overlap with "s390x/pci: Accomodate vfio DMA
limiting" because they both add hw/s390x/s390-pci-vfio.* - This is
intentional as both patchsets add functionality that belongs in these new
files.  Once one set is taken, I'll rebase the other on top of it.

Associated kernel patchset:
https://marc.info/?l=kvm&m=160052933112238&w=2

Matthew Rosato (4):
  update-linux-headers: Add vfio_zdev.h
  linux-headers: update against 5.9-rc5
  s390x/pci: clean up s390 PCI groups
  s390x/pci: get zPCI function info from host

Pierre Morel (3):
  s390x/pci: create a header dedicated to PCI CLP
  s390x/pci: use a PCI Group structure
  s390x/pci: use a PCI Function structure

 hw/s390x/meson.build                               |   1 +
 hw/s390x/s390-pci-bus.c                            |  82 ++++++-
 hw/s390x/s390-pci-bus.h                            |  13 ++
 hw/s390x/s390-pci-clp.h                            | 215 +++++++++++++++++++
 hw/s390x/s390-pci-inst.c                           |  28 +--
 hw/s390x/s390-pci-inst.h                           | 196 -----------------
 hw/s390x/s390-pci-vfio.c                           | 235 +++++++++++++++++++++
 hw/s390x/s390-pci-vfio.h                           |  19 ++
 include/standard-headers/drm/drm_fourcc.h          | 140 ++++++++++++
 include/standard-headers/linux/ethtool.h           |  87 ++++++++
 include/standard-headers/linux/input-event-codes.h |   3 +-
 include/standard-headers/linux/vhost_types.h       |  11 +
 include/standard-headers/linux/virtio_9p.h         |   4 +-
 include/standard-headers/linux/virtio_blk.h        |  26 +--
 include/standard-headers/linux/virtio_config.h     |   8 +-
 include/standard-headers/linux/virtio_console.h    |   8 +-
 include/standard-headers/linux/virtio_net.h        |   6 +-
 include/standard-headers/linux/virtio_scsi.h       |  20 +-
 linux-headers/asm-generic/unistd.h                 |   6 +-
 linux-headers/asm-mips/unistd_n32.h                |   1 +
 linux-headers/asm-mips/unistd_n64.h                |   1 +
 linux-headers/asm-mips/unistd_o32.h                |   1 +
 linux-headers/asm-powerpc/kvm.h                    |   5 +
 linux-headers/asm-powerpc/unistd_32.h              |   1 +
 linux-headers/asm-powerpc/unistd_64.h              |   1 +
 linux-headers/asm-s390/kvm.h                       |   7 +-
 linux-headers/asm-s390/unistd_32.h                 |   1 +
 linux-headers/asm-s390/unistd_64.h                 |   1 +
 linux-headers/asm-x86/unistd_32.h                  |   1 +
 linux-headers/asm-x86/unistd_64.h                  |   1 +
 linux-headers/asm-x86/unistd_x32.h                 |   1 +
 linux-headers/linux/kvm.h                          |  10 +-
 linux-headers/linux/vfio.h                         |   7 +-
 linux-headers/linux/vfio_zdev.h                    | 116 ++++++++++
 linux-headers/linux/vhost.h                        |   2 +
 scripts/update-linux-headers.sh                    |   2 +-
 36 files changed, 1007 insertions(+), 260 deletions(-)
 create mode 100644 hw/s390x/s390-pci-clp.h
 create mode 100644 hw/s390x/s390-pci-vfio.c
 create mode 100644 hw/s390x/s390-pci-vfio.h
 create mode 100644 linux-headers/linux/vfio_zdev.h

Comments

Cornelia Huck Sept. 25, 2020, 9:17 a.m. UTC | #1
On Sat, 19 Sep 2020 11:34:28 -0400
Matthew Rosato <mjrosato@linux.ibm.com> wrote:

> From: Pierre Morel <pmorel@linux.ibm.com>
> 
> To have a clean separation between s390-pci-bus.h and s390-pci-inst.h
> headers we export the PCI CLP instructions in a dedicated header.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
>  hw/s390x/s390-pci-bus.h  |   1 +
>  hw/s390x/s390-pci-clp.h  | 211 +++++++++++++++++++++++++++++++++++++++++++++++
>  hw/s390x/s390-pci-inst.h | 196 -------------------------------------------
>  3 files changed, 212 insertions(+), 196 deletions(-)
>  create mode 100644 hw/s390x/s390-pci-clp.h

Looks sane; but I wonder whether we should move the stuff under
include/hw/s390x/.
Cornelia Huck Sept. 25, 2020, 9:41 a.m. UTC | #2
On Sat, 19 Sep 2020 11:34:29 -0400
Matthew Rosato <mjrosato@linux.ibm.com> wrote:

> From: Pierre Morel <pmorel@linux.ibm.com>
> 
> We use a S390PCIGroup structure to hold the information related to a
> zPCI Function group.
> 
> This allows us to be ready to support multiple groups and to retrieve
> the group information from the host.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
>  hw/s390x/s390-pci-bus.c  | 42 ++++++++++++++++++++++++++++++++++++++++++
>  hw/s390x/s390-pci-bus.h  | 10 ++++++++++
>  hw/s390x/s390-pci-inst.c | 22 +++++++++++++---------
>  3 files changed, 65 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index 92146a2..3015d86 100644
> --- a/hw/s390x/s390-pci-bus.c
> +++ b/hw/s390x/s390-pci-bus.c
> @@ -737,6 +737,46 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus *bus, int32_t devfn)
>      object_unref(OBJECT(iommu));
>  }
>  
> +static S390PCIGroup *s390_grp_create(int ug)

I think you made the identifiers a bit too compact :)
s390_group_create() is not that long, and I have no idea what the 'ug'
(ugh :) parameter is supposed to mean.

> +{
> +    S390PCIGroup *grp;

group?

> +    S390pciState *s = s390_get_phb();
> +
> +    grp = g_new0(S390PCIGroup, 1);
> +    grp->ug = ug;
> +    QTAILQ_INSERT_TAIL(&s->zpci_grps, grp, link);

zpci_groups? I think you get the idea :)

> +    return grp;
> +}

(...)

No objection to the patch in general.
Matthew Rosato Sept. 25, 2020, 2:10 p.m. UTC | #3
On 9/25/20 5:17 AM, Cornelia Huck wrote:
> On Sat, 19 Sep 2020 11:34:28 -0400
> Matthew Rosato <mjrosato@linux.ibm.com> wrote:
> 
>> From: Pierre Morel <pmorel@linux.ibm.com>
>>
>> To have a clean separation between s390-pci-bus.h and s390-pci-inst.h
>> headers we export the PCI CLP instructions in a dedicated header.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
>> ---
>>   hw/s390x/s390-pci-bus.h  |   1 +
>>   hw/s390x/s390-pci-clp.h  | 211 +++++++++++++++++++++++++++++++++++++++++++++++
>>   hw/s390x/s390-pci-inst.h | 196 -------------------------------------------
>>   3 files changed, 212 insertions(+), 196 deletions(-)
>>   create mode 100644 hw/s390x/s390-pci-clp.h
> 
> Looks sane; but I wonder whether we should move the stuff under
> include/hw/s390x/.
> 

Probably.  I'd be fine with creating this file under include, but if 
we're going to do that we should plan to move the other s390-pci* ones 
too.  For this patchset, I can change this patch to put the new header 
in include/hw/s390x, easy enough.

I'll plan to do a separate cleanup patchset to move s390-pci-bus.h and 
s390-pci-inst.h.

How would you like me to handle s390-pci-vfio.h (this is a new file 
added by both this patch set and 's390x/pci: Accomodate vfio DMA 
limiting') --  It seems likely that the latter patch set will merge 
first, so my thought would be to avoid a cleanup on this one and just 
re-send 's390x/pci: Accomodate vfio DMA limiting' once the kernel part 
hits mainline (it's currently in linux-next via Alex) with 
s390-pci-vfio.h also created in include/hw/s390x (and I guess the 
MAINTAINERS hit for it too). Sound OK?
Matthew Rosato Sept. 25, 2020, 2:17 p.m. UTC | #4
On 9/25/20 5:41 AM, Cornelia Huck wrote:
> On Sat, 19 Sep 2020 11:34:29 -0400

> Matthew Rosato <mjrosato@linux.ibm.com> wrote:

> 

>> From: Pierre Morel <pmorel@linux.ibm.com>

>>

>> We use a S390PCIGroup structure to hold the information related to a

>> zPCI Function group.

>>

>> This allows us to be ready to support multiple groups and to retrieve

>> the group information from the host.

>>

>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>

>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>

>> ---

>>   hw/s390x/s390-pci-bus.c  | 42 ++++++++++++++++++++++++++++++++++++++++++

>>   hw/s390x/s390-pci-bus.h  | 10 ++++++++++

>>   hw/s390x/s390-pci-inst.c | 22 +++++++++++++---------

>>   3 files changed, 65 insertions(+), 9 deletions(-)

>>

>> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c

>> index 92146a2..3015d86 100644

>> --- a/hw/s390x/s390-pci-bus.c

>> +++ b/hw/s390x/s390-pci-bus.c

>> @@ -737,6 +737,46 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus *bus, int32_t devfn)

>>       object_unref(OBJECT(iommu));

>>   }

>>   

>> +static S390PCIGroup *s390_grp_create(int ug)

> 

> I think you made the identifiers a bit too compact :)

> s390_group_create() is not that long, and I have no idea what the 'ug'

> (ugh :) parameter is supposed to mean.

> 


Ha :)  Message received, something like s390_group_create(int id) is 
probably more appropriate.

>> +{

>> +    S390PCIGroup *grp;

> 

> group?

> 

>> +    S390pciState *s = s390_get_phb();

>> +

>> +    grp = g_new0(S390PCIGroup, 1);

>> +    grp->ug = ug;

>> +    QTAILQ_INSERT_TAIL(&s->zpci_grps, grp, link);

> 

> zpci_groups? I think you get the idea :)

> 


Yep, thanks!

>> +    return grp;

>> +}

> 

> (...)

> 

> No objection to the patch in general.

>
Cornelia Huck Sept. 25, 2020, 3:03 p.m. UTC | #5
On Fri, 25 Sep 2020 10:10:12 -0400
Matthew Rosato <mjrosato@linux.ibm.com> wrote:

> On 9/25/20 5:17 AM, Cornelia Huck wrote:

> > On Sat, 19 Sep 2020 11:34:28 -0400

> > Matthew Rosato <mjrosato@linux.ibm.com> wrote:

> >   

> >> From: Pierre Morel <pmorel@linux.ibm.com>

> >>

> >> To have a clean separation between s390-pci-bus.h and s390-pci-inst.h

> >> headers we export the PCI CLP instructions in a dedicated header.

> >>

> >> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>

> >> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>

> >> ---

> >>   hw/s390x/s390-pci-bus.h  |   1 +

> >>   hw/s390x/s390-pci-clp.h  | 211 +++++++++++++++++++++++++++++++++++++++++++++++

> >>   hw/s390x/s390-pci-inst.h | 196 -------------------------------------------

> >>   3 files changed, 212 insertions(+), 196 deletions(-)

> >>   create mode 100644 hw/s390x/s390-pci-clp.h  

> > 

> > Looks sane; but I wonder whether we should move the stuff under

> > include/hw/s390x/.

> >   

> 

> Probably.  I'd be fine with creating this file under include, but if 

> we're going to do that we should plan to move the other s390-pci* ones 

> too.  For this patchset, I can change this patch to put the new header 

> in include/hw/s390x, easy enough.

> 

> I'll plan to do a separate cleanup patchset to move s390-pci-bus.h and 

> s390-pci-inst.h.

> 

> How would you like me to handle s390-pci-vfio.h (this is a new file 

> added by both this patch set and 's390x/pci: Accomodate vfio DMA 

> limiting') --  It seems likely that the latter patch set will merge 

> first, so my thought would be to avoid a cleanup on this one and just 

> re-send 's390x/pci: Accomodate vfio DMA limiting' once the kernel part 

> hits mainline (it's currently in linux-next via Alex) with 

> s390-pci-vfio.h also created in include/hw/s390x (and I guess the 

> MAINTAINERS hit for it too). Sound OK?


Yes, I guess that would be best.