[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] PCI: don't allow "pci-phantom=" to mark real devices as phantom functions


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 5 May 2022 17:00:42 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FkqHBJ5xv1vnilhPFpsMb3IdDKmG89ejqa/ekVJMMig=; b=NkgYwi+6+ZDvb2cAvcb/eAkgCbIKR7FZv7gswAnemGRcSywt0PC9Sp+hJC9l+P9scviTkmp1yGlXeRNn9/mWCVfK+zn5ZqxVUvGRYLt75bUQMS1X5eFpt9FzxuZ/7tKG/FVllMPVwpxoHGOkE/JOO8RmTxatry++QMWSpdKZ8LbaSGCl9gQBxZlI7PaLXbnZzxsUylPEJxK3ECgFI25DsEeuzvwXX80QLhsMMh0k9xMc4xFRALJyM5vNBegaxZMHwXcN4RBLH44zwXdUAHREYxUAQOf79MZ37CVKXlU0iaZuo531px2L6WwRvMiRaWmec15sLumXnoqgLhkmz72dvw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J2l7GNhTWLFWbmuSryazfD7s0qNConYowvwmGcysdr2j41M3Dm1qgexN3RjQU0qwMBk2VpcDTlZP1EhjsQJ/NJVYc7DdghmZIBZjBDddZoE5ghvgHTB4HwfHg205zMzrSn5WkBNLUCCMR+QqZeENu/0Yr8c6te7M2S4c52UNZuyPpEsp3uY4jFiuq+nDMdOB9Rulkv/CeAj8nUVLQadG1uGyS8O13t7tyXG1C3i4+87GF5VCWh18lWpktXyqHkFRBvLeHI/y8gZH5KtqXrOyceuqGZGzCFkRoOrMpdRwa4OVL+lP99+wdodFhIbYvM2wok96FUuVA0wEOrUfOS8Wxg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 05 May 2022 15:01:12 +0000
  • Ironport-data: A9a23:7zOOpqgEXx6x2L9TXvvKKnRZX161FxEKZh0ujC45NGQN5FlHY01je htvCj3UaaqOZWqnfooiaYyy9RsOvZbcmtcyTwNv+yoxRn4b9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M68wIFqtQw24LhXlvQ4 YmaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YQUwFILnhtQNaDZdHTBME4hG5e7eM2fq5KR/z2WeG5ft69NHKRhseKgnoKNwC2wI8 uEEIjcQaBzFn/ix3L+wVuhrgIIkMdXvO4Qc/HpnyFk1D95/GcyFH/qMu4EegGhYasNmRJ4yY +IDbjVidlLYagBnMVYLEpMu2uyvgxETdhUH8wvJ//ZuuQA/yiR204bnIoT1f+XNQJ0JsG+8/ T/ZxTX2V0Ry2Nu3jGDtHmiXru3FkD7/WYkSPKal7fMsi1qWrkQDBRtTWValrP2Rjk+lR8kZO 0ES4jApr6U56AqsVNaVdwWxvXqsrhMaHd1KHIUHBBqlz6PV50OcGTICRzsYMtg+7pdqGnoty 0ODmM7vCXp3qrqJRHmB97CS6zSvJSwSKmxEbigBJecY3+TeTEgIpkqnZr5e/GSd1bUZxRmYL +i2kRUD
  • Ironport-hdrordr: A9a23:GH1c8akbpSrnJ4aT9PRMlkHj4FbpDfOlimdD5ihNYBxZY6Wkfp +V8cjzhCWftN9OYhodcLC7V5Voj0mskKKdxbNhRYtKOzOWw1dATbsSlLcKpgeNJ8SQzI5gPM tbAstD4ZjLfCJHZKXBkXaF+rQbsb66GcmT7I+xrkuFDzsaDZ2Ihz0JdjpzeXcGIDWua6BJdq Z1saF81kedkDksH4yGL0hAe9KGi8zAlZrgbxJDLxk76DOWhTftzLLhCRCX0joXTjsKmN4ZgC L4uj28wp/mn+Cwyxfa2WOWx5NKmOH5wt8GIMCXkMAaJhjllw7tToV8XL+puiwzvYiUmR0Xue iJhy1lE9V46nvXcG3wiRzx2zP42DJr0HPmwU/wuwqVnSRULAhKePZptMZ8SF/0+kAgtNZz3O ZgxGSCradaChvGgWDU+8XIfwsCrDv7nVMS1cooy1BPW4oXb7Fc6aYF+llOLZsGFCXmrKg6De hVCt3G7vo+SyLUU5nghBgu/DWQZAVxIv/fKXJy+PB9kgIm0EyR9nFohfD2xRw7hdcAo5ot3Z WxDk0nrsALciYsV9MNOA4we7rINoXze2O9DIuzGyWQKEhVAQOFl3bIiI9Flt2CSdgv8KYYvq jnfRdxiVMSEniefPFmmqc7vyzwfA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Apr 29, 2022 at 03:05:32PM +0200, Jan Beulich wrote:
> [CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments 
> unless you have verified the sender and know the content is safe.
> 
> IOMMU code mapping / unmapping devices and interrupts will misbehave if
> a wrong command line option declared a function "phantom" when there's a
> real device at that position. Warn about this and adjust the specified
> stride (in the worst case ignoring the option altogether).
> 
> Requested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

FWIW, I would be fine with just discarding the stride option if one of
the phantom devices happen to report vendor/device IDs on the config
space.

> --- a/xen/drivers/passthrough/pci.c
> +++ b/xen/drivers/passthrough/pci.c
> @@ -451,7 +451,24 @@ static struct pci_dev *alloc_pdev(struct
>                           phantom_devs[i].slot == PCI_SLOT(devfn) &&
>                           phantom_devs[i].stride > PCI_FUNC(devfn) )
>                      {
> -                        pdev->phantom_stride = phantom_devs[i].stride;
> +                        pci_sbdf_t sbdf = pdev->sbdf;
> +                        unsigned int stride = phantom_devs[i].stride;
> +
> +                        while ( (sbdf.fn += stride) > PCI_FUNC(devfn) )
> +                        {
> +                            if ( pci_conf_read16(sbdf, PCI_VENDOR_ID) == 
> 0xffff &&
> +                                 pci_conf_read16(sbdf, PCI_DEVICE_ID) == 
> 0xffff )
> +                                continue;
> +                            stride <<= 1;
> +                            printk(XENLOG_WARNING
> +                                   "%pp looks to be a real device; bumping 
> %04x:%02x:%02x stride to %u\n",
> +                                   &sbdf, phantom_devs[i].seg,
> +                                   phantom_devs[i].bus, phantom_devs[i].slot,

Can't you use pdev->sbdf here?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.