Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2419955pxb; Mon, 19 Apr 2021 05:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXHthYF8Dv/af92Us4EfCiwaV7recI5/XJTaWMlkR6s1w1jNVTV9UsM3y0wl5k10A3Emrn X-Received: by 2002:a17:906:b2cf:: with SMTP id cf15mr21629595ejb.233.1618835290357; Mon, 19 Apr 2021 05:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618835290; cv=none; d=google.com; s=arc-20160816; b=09B7PhY52fh8RqCJvPc4Z4Y66EXrVPL0jnQ+4ce9HPmgRgcDUTnz6D+WFfbo5obxJy M77LOTBWWlXpR995ePqbOQ2gE/Pd6Hlom6NthmX12aFt/lCT4fis8YoPJEzURsD1lbxx qTgkY6J1X/KlanHimO+C7Syz8hj7duAjQEiuvOeZblMaqBqxcpWb5X1/PYunIm6R905Z Mw4iAtNbLSlnBy+ZwOZXflJhzqjLFrZzG8shAmNTRuK1VcRe3TWvIjw63XzUmOFIo9WX bkhBv00cKSlgCPDePjbzZtNsGMoEPOGFbJVQtl8s3fN0xEPQEz4K+T3f+ZkW2iPTtIov deYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=vIbKY5/H6Cl/oeXWBZNJljrigR37eStblNyNzMwRYI8=; b=QhpcNp8TC62bhQYhJklfNEbhvSvoWBoCOQkx5gEMlbpZO8G1BS/Jfhv/4/Efch7WiH u3pFR7CrrS+7o9JE5tq+4IdIv8TQlCUZsFTPL0sd7u3bCZ4M5qNcRH3cqs+g1vBXsVXz 80nGNsNRbpXC4lKyDdJifZ/R80DtA6xw6Wju0behqupBZ2/5Jg+M3F8UjGnvbeElHPm+ rINR9TI+jMj4/yxF3Iia38TpiZXbbOuMsyvR6gU2EEqBKNOVxRpkhDofcPidhOr49bRf vrEVaZVXpRxDe8jA9WrZ4G2fmTAWJNxL7RkUho6UlphVaFC5lFm2OHVU+XWlDAjrNDXF phnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz20si7881607ejb.307.2021.04.19.05.27.46; Mon, 19 Apr 2021 05:28:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239071AbhDSMZR (ORCPT + 99 others); Mon, 19 Apr 2021 08:25:17 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16602 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229790AbhDSMZQ (ORCPT ); Mon, 19 Apr 2021 08:25:16 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FP5YD4sSjz1BGPw; Mon, 19 Apr 2021 20:22:24 +0800 (CST) Received: from [10.67.102.118] (10.67.102.118) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Mon, 19 Apr 2021 20:24:40 +0800 Subject: Re: [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio To: Jason Gunthorpe CC: , , , References: <1618284983-55581-1-git-send-email-liulongfang@huawei.com> <1618284983-55581-3-git-send-email-liulongfang@huawei.com> <20210415220137.GA1672608@nvidia.com> From: liulongfang Message-ID: <10d53c5d-e6d5-a165-84b2-eaf8a3b7dcce@huawei.com> Date: Mon, 19 Apr 2021 20:24:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20210415220137.GA1672608@nvidia.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.118] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> 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.