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

Re: [PATCH] xen/xenbus: fix xenbus_setup_ring()


  • To: Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>
  • From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
  • Date: Thu, 15 Sep 2022 14:47:10 +0000
  • Accept-language: en-US, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=XmhH4OHAj83WUaq1+htPXu31XFk9cLRFSxiLf8O+Fcg=; b=J5v+D9ivMPnBfcge7t56EZBk/Dat8rw/FqFgEGZOeRIftzJD2b+lzKbWHI81TfZS2dc9wOJLi+wRjzG5rlQoar+FEae5VYxHnPxedBbGzqyvJuSrNtLOQbf5HiWUkccDzm+S0zuE/0Rwxz/YT97TN37BZB1ht74CNb44L5IhrpOUAmWWgSE/vKG13yLz7goc/Elxvow5XjQ4WVGq+NDBSeZsAKJXsCLAR5AenaVlRJY0+kaS7BEoE372Bm1Hrq8Fs7fyT+tVMAow1q+xtfRc7hagNRmp2HwXuaDGTjMYEEdAN5ndtKhTIgVpc7571zaJIt4oVbL9jIL7h5ubCo4drQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ag9hfkh5xvF6oxz72nXeMBI61H8uLDAf6qgc0qdlY64Ay0qVVxU787UD1TwKErDZkZZvlXyag1SKvicC/fWpeDzcKhANFQJLNhJKcMp84hcVurTZMnUXoo/K+5kxcpOYxrG9rxkU6+6kZH81zGaNjwpEe80YQMIIvvNIsMwZr/xrR1rEJ4lXpbJHaCjikkMjMI1jQygSoV2ylHsFUcw5VRZzTYrdHP+lVFd5ahguX0Y8I7ZKyfv7/fn1egNcihdbS5IcLr+2Nagr5uVDrav6ao+riDE7PpIQVJ2HdFN2FtlzOBY3blRlG7Ly0kPU4G4DTb1DEcWKDeqpofEfk7RsEg==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, "stable@xxxxxxxxxxxxxxx" <stable@xxxxxxxxxxxxxxx>, Sander Eikelenboom <linux@xxxxxxxxxxxxxx>
  • Delivery-date: Thu, 15 Sep 2022 14:47:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYyQ/iPv5e34GuQU2mfPtgOqQE7q3gkeuA
  • Thread-topic: [PATCH] xen/xenbus: fix xenbus_setup_ring()

On 15.09.22 17:31, Juergen Gross wrote:

Hello Juergen

> Commit 4573240f0764 ("xen/xenbus: eliminate xenbus_grant_ring()")
> introduced an error for initialization of multi-page rings.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 4573240f0764 ("xen/xenbus: eliminate xenbus_grant_ring()")
> Reported-by: Sander Eikelenboom <linux@xxxxxxxxxxxxxx>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
> ---
>   drivers/xen/xenbus/xenbus_client.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/xen/xenbus/xenbus_client.c 
> b/drivers/xen/xenbus/xenbus_client.c
> index d5f3f763717e..caa5c5c32f8e 100644
> --- a/drivers/xen/xenbus/xenbus_client.c
> +++ b/drivers/xen/xenbus/xenbus_client.c
> @@ -382,9 +382,10 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t 
> gfp, void **vaddr,
>       unsigned long ring_size = nr_pages * XEN_PAGE_SIZE;
>       grant_ref_t gref_head;
>       unsigned int i;
> +     void *addr;
>       int ret;
>   
> -     *vaddr = alloc_pages_exact(ring_size, gfp | __GFP_ZERO);
> +     addr = *vaddr = alloc_pages_exact(ring_size, gfp | __GFP_ZERO);
>       if (!*vaddr) {
>               ret = -ENOMEM;
>               goto err;
> @@ -401,13 +402,15 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t 
> gfp, void **vaddr,
>               unsigned long gfn;
>   
>               if (is_vmalloc_addr(*vaddr))
> -                     gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr[i]));
> +                     gfn = pfn_to_gfn(vmalloc_to_pfn(addr));
>               else
> -                     gfn = virt_to_gfn(vaddr[i]);
> +                     gfn = virt_to_gfn(addr);
>   
>               grefs[i] = gnttab_claim_grant_reference(&gref_head);
>               gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id,
>                                               gfn, 0);
> +
> +             addr += PAGE_SIZE;

XEN_PAGE_SIZE?


Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>


P.S.

I wondered why I didn't face the similar issue(s) as I used Linux 
v6.0.0-rc1 and several PV drivers including PV block device.

The answer is that the single-page ring is being used for all of them in 
my environment.


root@salvator-x-h3-4x2g-xt-domu:~# dmesg | grep xenbus_setup_ring
[    0.332449] vdispl vdispl-0: 0 xenbus_setup_ring: 1 pages
[    0.333464] vdispl vdispl-0: 0 xenbus_setup_ring: 1 pages
[    0.341350] vbd vbd-51713: 0 xenbus_setup_ring: 1 pages
[    0.342750] vbd vbd-51713: 0 xenbus_setup_ring: 1 pages
[    0.343261] vbd vbd-51713: 0 xenbus_setup_ring: 1 pages
[    0.343798] vbd vbd-51713: 0 xenbus_setup_ring: 1 pages
[    0.392969] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.518733] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.519198] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.519501] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.519948] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.520371] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.520805] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.521070] vif vif-0: 0 xenbus_setup_ring: 1 pages
[    0.575451] vsnd vsnd-0: 0 xenbus_setup_ring: 1 pages
[    0.576855] vsnd vsnd-0: 0 xenbus_setup_ring: 1 pages


>       }
>   
>       return 0;

-- 
Regards,

Oleksandr Tyshchenko

 


Rackspace

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