lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <104bb7a4-68e7-adb1-91f4-d6fce09b99e7@linux.ibm.com>
Date:   Tue, 18 Jan 2022 13:37:16 -0500
From:   Matthew Rosato <mjrosato@...ux.ibm.com>
To:     Pierre Morel <pmorel@...ux.ibm.com>, linux-s390@...r.kernel.org
Cc:     alex.williamson@...hat.com, cohuck@...hat.com,
        schnelle@...ux.ibm.com, farman@...ux.ibm.com,
        borntraeger@...ux.ibm.com, hca@...ux.ibm.com, gor@...ux.ibm.com,
        gerald.schaefer@...ux.ibm.com, agordeev@...ux.ibm.com,
        frankja@...ux.ibm.com, david@...hat.com, imbrenda@...ux.ibm.com,
        vneethv@...ux.ibm.com, oberpar@...ux.ibm.com, freude@...ux.ibm.com,
        thuth@...hat.com, pasic@...ux.ibm.com, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 24/30] vfio-pci/zdev: wire up group notifier

On 1/18/22 12:34 PM, Pierre Morel wrote:
> 
> 
> On 1/14/22 21:31, Matthew Rosato wrote:
>> KVM zPCI passthrough device logic will need a reference to the associated
>> kvm guest that has access to the device.  Let's register a group notifier
>> for VFIO_GROUP_NOTIFY_SET_KVM to catch this information in order to 
>> create
>> an association between a kvm guest and the host zdev.
>>
>> Signed-off-by: Matthew Rosato <mjrosato@...ux.ibm.com>
>> ---
>>   arch/s390/include/asm/kvm_pci.h  |  2 ++
>>   drivers/vfio/pci/vfio_pci_core.c |  2 ++
>>   drivers/vfio/pci/vfio_pci_zdev.c | 46 ++++++++++++++++++++++++++++++++
>>   include/linux/vfio_pci_core.h    | 10 +++++++
>>   4 files changed, 60 insertions(+)
>>
>> diff --git a/arch/s390/include/asm/kvm_pci.h 
>> b/arch/s390/include/asm/kvm_pci.h
>> index fa90729a35cf..97a90b37c87d 100644
>> --- a/arch/s390/include/asm/kvm_pci.h
>> +++ b/arch/s390/include/asm/kvm_pci.h
>> @@ -17,6 +17,7 @@
>>   #include <linux/kvm.h>
>>   #include <linux/pci.h>
>>   #include <linux/mutex.h>
>> +#include <linux/notifier.h>
>>   #include <asm/pci_insn.h>
>>   #include <asm/pci_dma.h>
>> @@ -33,6 +34,7 @@ struct kvm_zdev {
>>       u64 rpcit_count;
>>       struct kvm_zdev_ioat ioat;
>>       struct zpci_fib fib;
>> +    struct notifier_block nb;
>>   };
>>   int kvm_s390_pci_dev_open(struct zpci_dev *zdev);
>> diff --git a/drivers/vfio/pci/vfio_pci_core.c 
>> b/drivers/vfio/pci/vfio_pci_core.c
>> index f948e6cd2993..fc57d4d0abbe 100644
>> --- a/drivers/vfio/pci/vfio_pci_core.c
>> +++ b/drivers/vfio/pci/vfio_pci_core.c
>> @@ -452,6 +452,7 @@ void vfio_pci_core_close_device(struct vfio_device 
>> *core_vdev)
>>       vfio_pci_vf_token_user_add(vdev, -1);
>>       vfio_spapr_pci_eeh_release(vdev->pdev);
>> +    vfio_pci_zdev_release(vdev);
>>       vfio_pci_core_disable(vdev);
>>       mutex_lock(&vdev->igate);
>> @@ -470,6 +471,7 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_close_device);
>>   void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev)
>>   {
>>       vfio_pci_probe_mmaps(vdev);
>> +    vfio_pci_zdev_open(vdev);
>>       vfio_spapr_pci_eeh_open(vdev->pdev);
>>       vfio_pci_vf_token_user_add(vdev, 1);
>>   }
>> diff --git a/drivers/vfio/pci/vfio_pci_zdev.c 
>> b/drivers/vfio/pci/vfio_pci_zdev.c
>> index ea4c0d2b0663..5c2bddc57b39 100644
>> --- a/drivers/vfio/pci/vfio_pci_zdev.c
>> +++ b/drivers/vfio/pci/vfio_pci_zdev.c
>> @@ -13,6 +13,7 @@
>>   #include <linux/vfio_zdev.h>
>>   #include <asm/pci_clp.h>
>>   #include <asm/pci_io.h>
>> +#include <asm/kvm_pci.h>
>>   #include <linux/vfio_pci_core.h>
>> @@ -136,3 +137,48 @@ int vfio_pci_info_zdev_add_caps(struct 
>> vfio_pci_core_device *vdev,
>>       return ret;
>>   }
>> +
>> +static int vfio_pci_zdev_group_notifier(struct notifier_block *nb,
>> +                    unsigned long action, void *data)
>> +{
>> +    struct kvm_zdev *kzdev = container_of(nb, struct kvm_zdev, nb);
>> +
>> +    if (action == VFIO_GROUP_NOTIFY_SET_KVM) {
>> +        if (!data || !kzdev->zdev)
>> +            return NOTIFY_DONE;
>> +        kvm_s390_pci_attach_kvm(kzdev->zdev, data);
> 
> Why not just set kzdev->kvm = data ?
> 
> alternatively, define kvm_s390_pci_attach_kvm() as an inline instead of 
> a global function.
> 
> otherwise LGTM

At some point in the past this function did more than just set a 
pointer...  You are correct there's no need for this abstraction now, 
let's just set kzdev->kvm = data directly here and drop the 
kvm_s390_pci_attach_kvm function.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ