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

Re: [PATCH v2 2/3] x86/hvm: Allow writes to registers on the same page as MSI-X table


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 27 Mar 2023 11:47:34 +0100
  • 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=y0tta+3gd+Qbjy7buj0oN2bF8xS/bZ0jMcrsNxM5LU4=; b=VZTqE4xAQzenA3VdParJZnOt25OkUWRO9O7UoUKtziYXCpDhNUUYNCoX5JpFndOX403ap2P8b5GmuqJU2zjKtkFJUeASkOGhjVc8U0KZMCwphZWkbE0LVzVuBg0Jy/pMIoPb449kpLNNgZushuCA8R/WCRjmvqnsW4YYq8R5K2Z+5tBh3r+uDSkH7TkQA/74PulAxLvYVEF1bJMf15qn2+KdI4+UrsLa3EEgpHFi0jEEUaZoTT7dYfa/12X3WCCjq0SLh2zjiSgAuO0zbKEBlFpKR/pWYRKbaaup7chVtYwTvx1x0MKXp+fK7W8YRGpwCsel60mwy3WaggAGLmBEzg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E2sexa1/o2i/7aXqrTagfrUHoKixbnHcTcSrCBbHzaxK1y7daaLrunM7EAGJrjxiFGg8UFsLrMwkfI+1Fxg4bVdgWetkN/cEUH7pBOJHfKHgS3hUNEJJKydwVUNoH7X5X6lzA9Dx738I/1qYv0vYNaMwdHMJihAETVpATGw51KIjjgIpRSNhROFn8bpe9ZshQVm+la8JDGBWmXwEK99S6W4DwNbRyUnBBibc6131uwxaoLL071u3lYis3DL3h3CKJlJ7xPi1ZmuoxBU2W9NbSWsUYvG65PAkFUouirA6YPdzTUv0OKmIgnW9zR1gKATrBBYFIAXXlXYf84cE3Zeqzg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jason Andryuk <jandryuk@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 27 Mar 2023 10:48:12 +0000
  • Ironport-data: A9a23:U1nyCq/5dGjhTH6mmLX9DrUDWH+TJUtcMsCJ2f8bNWPcYEJGY0x3z mNNUG3UOvreZ2r3Ko0laYri9ksD6MLRzIJkT1Fr+yo8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kI/1BjOkGlA5AdmPqoU5Aa2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkle9 /83JmlKMSrbqLuwmJScd7JJnZU8eZyD0IM34hmMzBn/JNN/GdXvZvuP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWDilUpjtABM/KMEjCObexTklyVu STt+GPhDwtBHNee1SCE4jSngeqncSbTAdpPT+Pgq6E06LGV7kcwKiA5akernamS0USBd8liD nE4+DV7+MDe82TuFLERRSaQpXeeuxcGVtl4Eusk6RqMwK7Z/waYAGcfSjdLLtchsaceVTEsk 1OEgd7tLThuq6GOD2KQ8K+OqjG/MjRTKnUNDQcGRA0J+cj+o6k8ixvOSpBoF6vdpt//FCz0w juKhDMjnLhVhskOv42k+XjXjjTqoYLGJjPZ/S3SV2Ohqw98OoisYtXw7UCBtK4eaoGEUlOGo X4I3dCE6/wDBo2MkyrLR/gRGLau5LCONzi0bUNTIqTNPg+FoxaLFb28KhknTKu1Gq7ooQPUX XI=
  • Ironport-hdrordr: A9a23:BXhwNa+sJa5MbWkGDQtuk+AfI+orL9Y04lQ7vn2YSXRuA6qlfq GV/MjzsCWetN9/YhAdcLy7Scy9qBDnhOdICOsqTM+ftWDd0QPGQr2KhbGSuAEIcBeOktK1u5 0QFJRWOZncN3U/q+DQiTPVLz8n+rO62ZHtv8vli11Kai5LRZ1axzpYLCHeKGFKLTM2ZqYRJd 6S5s9KvTqydW5/VKmGL3MYRfXEo9HRtL+OW29lOyIa
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25/03/2023 2:49 am, Marek Marczykowski-Górecki wrote:
> diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
> index 9c82bf9b4ec2..9293009a4075 100644
> --- a/xen/arch/x86/hvm/vmsi.c
> +++ b/xen/arch/x86/hvm/vmsi.c
> @@ -438,6 +438,152 @@ static const struct hvm_io_ops msixtbl_mmio_ops = {
>      .write = _msixtbl_write,
>  };
>  
> +static void __iomem *msixtbl_page_handler_get_hwaddr(
> +    const struct domain *d,
> +    uint64_t address,
> +    bool write)
> +{
> +    const struct pci_dev *pdev = NULL;
> +    const struct msixtbl_entry *entry;
> +    int adj_type;
> +
> +    rcu_read_lock(&msixtbl_rcu_lock);
> +    /*
> +     * Check if it's on the same page as the end of the MSI-X table, but
> +     * outside of the table itself.
> +     */
> +    list_for_each_entry( entry, &d->arch.hvm.msixtbl_list, list )
> +    {
> +        if ( PFN_DOWN(address) == PFN_DOWN(entry->gtable) &&
> +             address < entry->gtable )
> +        {
> +            adj_type = ADJ_IDX_FIRST;
> +            pdev = entry->pdev;
> +            break;
> +        }
> +        if ( PFN_DOWN(address) == PFN_DOWN(entry->gtable + entry->table_len) 
> &&
> +             address >= entry->gtable + entry->table_len )
> +        {
> +            adj_type = ADJ_IDX_LAST;
> +            pdev = entry->pdev;
> +            break;
> +        }
> +    }
> +    rcu_read_unlock(&msixtbl_rcu_lock);
> +
> +    if ( !pdev )
> +        return NULL;
> +
> +    ASSERT(pdev->msix);
> +
> +    if ( !pdev->msix->adj_access_table_idx[adj_type] )
> +    {
> +        gdprintk(XENLOG_WARNING,
> +                 "Page for adjacent MSI-X table access not initialized for 
> %pp\n",
> +                 pdev);

One minor observation.   &pdev->sbdf

Otherwise things will go wrong if sbdf ever moves from being the first
element in a pdev.

~Andrew



 


Rackspace

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