From: liulongfang <liulongfang@huawei.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <alex.williamson@redhat.com>, <cohuck@redhat.com>,
<linux-kernel@vger.kernel.org>, <linuxarm@openeuler.org>
Subject: Re: [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio
Date: Mon, 19 Apr 2021 20:24:40 +0800 [thread overview]
Message-ID: <10d53c5d-e6d5-a165-84b2-eaf8a3b7dcce@huawei.com> (raw)
In-Reply-To: <20210415220137.GA1672608@nvidia.com>
On 2021/4/16 6:01, Jason Gunthorpe wrote:
> On Tue, Apr 13, 2021 at 11:36:22AM +0800, Longfang Liu wrote:
>> Register the live migration driver of the accelerator module to vfio
>>
>> Signed-off-by: Longfang Liu <liulongfang@huawei.com>
>> drivers/vfio/pci/vfio_pci.c | 11 +++++++++++
>> drivers/vfio/pci/vfio_pci_private.h | 9 +++++++++
>> 2 files changed, 20 insertions(+)
>>
>> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
>> index 65e7e6b..e1b0e37 100644
>> +++ b/drivers/vfio/pci/vfio_pci.c
>> @@ -407,6 +407,17 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
>> }
>> }
>>
>> + if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
>> + IS_ENABLED(CONFIG_VFIO_PCI_HISI_MIGRATION)) {
>> + ret = vfio_pci_hisilicon_acc_init(vdev);
>
> This is exactly what we want to avoid with the work we are doing on
> the vfio-pci modularity.
>
> It is a complete mess to just keep adding more stuff here, and as
> we've discussed to death really ugly to have such a ridiculously wide
> ID match.
>
> You should be working with us on that project and base your work on
> top of Max's series.. Alex given the interest here I think we should
> find some way forward while we work on completed version of the mlx5
> pci vfio driver..
>
> I'm also confused how this works securely at all, as a general rule a
> VFIO PCI driver cannot access the MMIO memory of the function it is
> planning to assign to the guest. There is a lot of danger that the
> guest could access that MMIO space one way or another.
>
VF's MMIO memory is divided into two parts, one is the guest part,
and the other is the live migration part. They do not affect each other,
so there is no security problem.
> Here I see the driver obtaining a devm_ioremap() of the same pdev it
> is going to assign (and I really wonder why pci_release_mem_regions()
> exists at all..)
>
The driver here obtains the VF's MMIO memory address through devm_ioremap(),
and adding pci_release_mem_regions() is to get the MMIO memory address
in the guest after the driver here obtains the MMIO memory address.
If pci_release_mem_regions() is not added here,
The guests using pci_request_mem_regions() will return an error.
Then, the guest will not be able to obtain the MMIO address of the VF.
> This is why the mlx5 RFC was showing how to juggle two PCI devices via
> the aux device connector.
>
I also noticed the mlx5 RFC, but it will take some time to analyze it. If the analysis
process goes well. I will import the mlx5 RFC into our driver and use this solution
to test and verify our live migration function.
If we use the mlx5 RFC, what should we pay attention to?
> Jason
> .
>
Thanks.
Longfang.
next prev parent reply other threads:[~2021-04-19 12:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 3:36 [RFC PATCH 0/3] vfio/hisilicon: add acc live migration driver Longfang Liu
2021-04-13 3:36 ` [RFC PATCH 1/3] " Longfang Liu
2021-04-13 3:36 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
2021-04-15 22:01 ` Jason Gunthorpe
2021-04-19 12:24 ` liulongfang [this message]
2021-04-19 12:33 ` Jason Gunthorpe
2021-04-20 12:50 ` liulongfang
2021-04-20 12:59 ` Jason Gunthorpe
2021-04-20 13:28 ` liulongfang
2021-04-20 14:55 ` Jason Gunthorpe
2021-04-20 22:04 ` Alex Williamson
2021-04-20 23:18 ` Jason Gunthorpe
2021-04-21 9:59 ` liulongfang
2021-04-21 9:59 ` liulongfang
2021-04-21 18:12 ` Alex Williamson
2021-04-26 11:49 ` liulongfang
2021-05-12 8:39 ` liulongfang
2021-05-12 12:10 ` Jason Gunthorpe
2021-05-13 2:08 ` liulongfang
2021-05-13 13:44 ` Jason Gunthorpe
2021-05-13 15:49 ` [Linuxarm] " Shameerali Kolothum Thodi
2021-05-13 17:03 ` Alex Williamson
2021-05-13 17:52 ` Shameerali Kolothum Thodi
2021-05-13 18:22 ` Alex Williamson
2021-05-13 18:31 ` Shameerali Kolothum Thodi
2021-05-13 18:34 ` Jason Gunthorpe
2021-05-13 18:24 ` Jason Gunthorpe
2021-05-13 18:35 ` Shameerali Kolothum Thodi
2021-05-27 10:11 ` Shameerali Kolothum Thodi
2021-05-27 10:30 ` Max Gurtovoy
2021-04-13 3:36 ` [RFC PATCH 3/3] vfio/hisilicom: add debugfs for driver Longfang Liu
2021-04-15 21:35 ` [RFC PATCH 0/3] vfio/hisilicon: add acc live migration driver Alex Williamson
-- strict thread matches above, loose matches on Subject: below --
2021-04-13 1:20 [RFC PATCH v3 " Longfang Liu
2021-04-13 1:20 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
2021-04-12 8:53 [RFC PATCH v3 0/3] vfio/hisilicon: add acc live migration driver Longfang Liu
2021-04-12 8:53 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
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=10d53c5d-e6d5-a165-84b2-eaf8a3b7dcce@huawei.com \
--to=liulongfang@huawei.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@openeuler.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox