From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18E97C46475 for ; Wed, 24 Oct 2018 03:09:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D02462075D for ; Wed, 24 Oct 2018 03:09:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="xx6gb4vs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D02462075D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726773AbeJXLfR (ORCPT ); Wed, 24 Oct 2018 07:35:17 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:40292 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbeJXLfR (ORCPT ); Wed, 24 Oct 2018 07:35:17 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9O34jhd144681; Wed, 24 Oct 2018 03:09:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : subject : to : cc : message-id : date : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=9RH60/NOSzW/L8qgWr1HN6/FqkHjt8Ho+au4JYlAEVg=; b=xx6gb4vsJPzoYNmsT4G7btRdM27vGBxE7CBYC1IVTRyPNQTpyOSY/wPlrPKIAIit0LeA IBm2bZ3ZioCSexd+Gp6WxvEN848F9NtAxGJI+qxXR/j87y2+XAaLXEd6iYYGzq1NwIOB b0qWwUT9ek4x7RoCgz8NiOKxrU5GxxZGmYksCJonRDir24McvcfcTaWbxSXON9wMrKaQ 4UDuLVGGJ8+yHkQZcuo8R7UE8cAeJeWHI5O1hSXd+Cp9Z+RfnhT6Pn31XgqTemXfI8j0 bSGeE9dAOLiHCX+c+HP2hU1yVXHy+5pWvd6fkU12zs+irg2XgihYYT/L/ZdvE/hEB8GJ Aw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2n7vaq0u5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Oct 2018 03:09:07 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9O396NU016001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Oct 2018 03:09:06 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9O395aV025072; Wed, 24 Oct 2018 03:09:06 GMT Received: from [10.159.228.48] (/10.159.228.48) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 23 Oct 2018 20:09:05 -0700 From: Joe Jin Subject: [PATCH] xen-swiotlb: exchange memory with Xen only when pages are contiguous To: Konrad Rzeszutek Wilk , "DONGLI.ZHANG" , konrad@kernel.org, Christoph Helwig , John Sobecki , Boris Ostrovsky Cc: "xen-devel@lists.xenproject.org" , "linux-kernel@vger.kernel.org\"" Message-ID: Date: Tue, 23 Oct 2018 20:09:04 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9055 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810240025 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 4855c92dbb7 "xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent" only fixed memory address check condition on xen_swiotlb_free_coherent(), when memory was not physically contiguous and tried to exchanged with Xen via xen_destroy_contiguous_region it will lead kernel panic. The correct check condition should be memory is in DMA area and physically contiguous. Thank you Boris for pointing it out. Signed-off-by: Joe Jin Cc: Konrad Rzeszutek Wilk Cc: Boris Ostrovsky Cc: Christoph Helwig Cc: Dongli Zhang Cc: John Sobecki --- drivers/xen/swiotlb-xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index f5c1af4ce9ab..aed92fa019f9 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -357,8 +357,8 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, /* 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)) + if ((dev_addr + size - 1 <= dma_mask) && + !range_straddles_page_boundary(phys, size)) xen_destroy_contiguous_region(phys, order); xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs); -- 2.17.1 (Apple Git-112)