[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5bb5e41f-ed6c-87d0-a1b1-d053c191a8d5@oracle.com>
Date: Fri, 7 Sep 2018 15:47:50 -0700
From: Joe Jin <joe.jin@...cle.com>
To: Dongli Zhang <dongli.zhang@...cle.com>,
"xen-devel@...ts.xenproject.org" <xen-devel@...ts.xenproject.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
John Sobecki <john.sobecki@...cle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [Xen-devel] [PATCH] xen-swiotlb: use actually allocated size on
check physical contiguous
Anybody would like to help review this patch?
Thanks,
Joe
On 09/05/2018 02:16 AM, Joe Jin wrote
> xen_swiotlb_{alloc,free}_coherent() actually allocate/free size by order
> but used the required size to check if address is physical contiguous,
> if first pages are physical contiguous also passed
> range_straddles_page_boundary() check, but others were not it will
> lead kernel panic.
>
> Signed-off-by: Joe Jin <joe.jin@...cle.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
> ---
> drivers/xen/swiotlb-xen.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
> index a6f9ba85dc4b..aa081f806728 100644
> --- a/drivers/xen/swiotlb-xen.c
> +++ b/drivers/xen/swiotlb-xen.c
> @@ -303,6 +303,9 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
> */
> flags &= ~(__GFP_DMA | __GFP_HIGHMEM);
>
> + /* Convert the size to actually allocated. */
> + size = 1UL << (order + XEN_PAGE_SHIFT);
> +
> /* On ARM this function returns an ioremap'ped virtual address for
> * which virt_to_phys doesn't return the corresponding physical
> * address. In fact on ARM virt_to_phys only works for kernel direct
> @@ -351,6 +354,9 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
> * physical address */
> phys = xen_bus_to_phys(dev_addr);
>
> + /* Convert the size to actually allocated. */
> + size = 1UL << (order + XEN_PAGE_SHIFT);
> +
> if (((dev_addr + size - 1 <= dma_mask)) ||
> range_straddles_page_boundary(phys, size))
> xen_destroy_contiguous_region(phys, order);
>
Powered by blists - more mailing lists