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

Re: [PATCH v3] vpci/msix: handle accesses adjacent to the MSI-X table


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 22 Mar 2023 16:14:54 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=7oOoc6GOlwSrWGbCnU9hAo7XnLCdXIRikZtBzrCOlIg=; b=XDAJn4pXVCM3Y8FUd2/Blye/PFfLde7fvzgVlAHl3A6zUUKAHX4XUFue7Pp3KNzFuLw8qRIH4OIqOmaAwnopMISWZcF8/MA+AikPUw5ynawarVjkMckkxzabiL7d57UOVSZ3M075RqTXV67yoFxktdHQE5drl8t0WvJPh+6cRp6kQPxWhWrBmD5MKVTZ7neBsY/uKZZwnDcr6xFEvl+sZKBro/3+XIDOLYal4FtPQ5l8H3JcdN4ImM+T/moMddvO0BygjlQ/wXlHkkrd9tT+tJu3YRKXf6bPKbW09FNGbZODWeObV2WOZfhKW1v7P1/Kmeo8InMyrjV6sMehrkI2ag==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PLS16tGmJGAYIPYTYQjZ2a4Mkp2xUddKT0gcYSiCsj9UGFNj+ZG+JBdywFLMIKDY1Kvsj1BL9ORYEv2CEMyn4lRw9dT4931C8svFIJVedgl7rRm0XFgUaPz43J/6JjZY3KGKQzUFw0mrpxLxcuMoEHDpLFr4QtNAdtIj97mD8GSo0ljxEbVHyf1NegXCpsTp6sz56itDkwDheJ7ngCW1nPIIghfkNHaxluWHrKVZQqqiPK1r+xK/nk+irhD1Me4hCe+bvivPqmtRUoSUKBsu5nMQMkQM+YbxPsGKYLjo8uddY1YiCDTmp1yWw39gd7r9alM8uZBn+OJDosTesMg7vg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 22 Mar 2023 15:15:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.03.2023 15:30, Roger Pau Monne wrote:
> Changes since v2:
>  - Slightly adjust VMSIX_ADDR_SAME_PAGE().
>  - Use IS_ALIGNED and unlikely for the non-aligned access checking.
>  - Move the check for the page mapped before the aligned one.
>  - Remove cast of data to uint8_t and instead use a mask in order to
>    avoid undefined behaviour when shifting.
>  - Remove Xen maps of the MSIX related regions when memory decoding
>    for the device is enabled by dom0, in order to purge stale maps.

I'm glad you thought of this. The new code has issues, though:

> @@ -182,93 +187,201 @@ static struct vpci_msix_entry *get_entry(struct 
> vpci_msix *msix,
>      return &msix->entries[(addr - start) / PCI_MSIX_ENTRY_SIZE];
>  }
>  
> -static void __iomem *get_pba(struct vpci *vpci)
> +static void __iomem *get_table(struct vpci *vpci, unsigned int slot)
>  {
>      struct vpci_msix *msix = vpci->msix;
>      /*
> -     * PBA will only be unmapped when the device is deassigned, so access it
> -     * without holding the vpci lock.
> +     * Regions will only be unmapped when the device is deassigned, so access
> +     * them without holding the vpci lock.

The first part of the sentence is now stale, and the second part is in
conflict ...

> @@ -482,6 +641,26 @@ int vpci_make_msix_hole(const struct pci_dev *pdev)
>          }
>      }
>  
> +    if ( is_hardware_domain(d) )
> +    {
> +        unsigned int i;
> +
> +        /*
> +         * For the hardware domain only remove any hypervisor mappings of the
> +         * MSIX or PBA related areas, as dom0 is capable of moving the 
> position
> +         * of the BARs in the host address space.
> +         *
> +         * We rely on being called with the vPCI lock held in order to not 
> race
> +         * with get_table().

... with what you say (and utilize) here. Furthermore this comment also wants
clarifying that apply_map() -> modify_decoding() not (afaics) holding the lock
when calling here is not a problem, as no mapping can exist yet that may need
tearing down. (I first wondered whether you wouldn't want to assert that the
lock is being held. You actually could, but only after finding a non-NULL
table entry.)

Jan



 


Rackspace

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