Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp781404ima; Wed, 24 Oct 2018 09:07:16 -0700 (PDT) X-Google-Smtp-Source: AJdET5cSqo5ZkKOMi7nAJuck/+zUY8lQ2YE1UJWKHZfQTUD4nsgLpDL9GGflhN+z4RgcaTqzgfXE X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr2570757plo.175.1540397236060; Wed, 24 Oct 2018 09:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540397236; cv=none; d=google.com; s=arc-20160816; b=QtL198iwjhXcIrsLIuPgj/7b76xFhf3PXckAXzdjG6t2sMR2OWVhnBie/ds/JCVtFg 8ASbl29IIv6AKCEagto/BGz8a8fH0kejhxIQody7J1J66W6tQXXeF6ePpGxlpRzraHMD C24dYuEAy/eZrVoFpvm24T+mZ2iu0/GveMe49iqzEOb7OU3gvVFYv9V/djhJGmg6U4kJ jZJ6o9W5UzfSV2aaLz631H1kZ56iHqFWYgz45J7k30CiljZ/ykht8KTHVNyDKL65Ay/g j+7ZKFUBkn99TL2l1JJctAXEJph53l/KWr7PlLON41yg9ZpC8SfRXYbrm7z8hoSF6i2X a/2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=6agoU7alTHiWAx6DoRytImdcajTbjXamv5ky2Y6SWPo=; b=OSfbT5FSi9eg3fwTi5AxUOosRcvMP7LNKD18ZMLyA17Q8ZQJ7ZouFygAm6S5tcpuHw SDPOO2qZQI2v1AvjyIsL7wTMtiwI/pDMnEVUVyk7hE47uNWdq6OjgZr3kl7bpe7UZGSf MzT+jR6UxcrxLYEkMszD5rqamHZMS7aW1QgLPdrK4t3bvbHtBhW7D3I5u6rUPqdcbJdZ HpNSq5UNfYnerMU2w7HwMMw5oZE3DgysuqSyWzv/B/rxuX6jhCHIjyx0F5wD3azHbi76 JXgtwsFD9wCz5iZqEJkqP10IHvMyJm/jjc6Om4Jts2d90Z1VcTFtIYzWkIc+ktDryoL3 7gzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=3RQ3YDzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6-v6si4852991plk.304.2018.10.24.09.07.00; Wed, 24 Oct 2018 09:07:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=3RQ3YDzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727133AbeJYAeS (ORCPT + 99 others); Wed, 24 Oct 2018 20:34:18 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55974 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbeJYAeS (ORCPT ); Wed, 24 Oct 2018 20:34:18 -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 w9OG4R6a117844; Wed, 24 Oct 2018 16:05:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=6agoU7alTHiWAx6DoRytImdcajTbjXamv5ky2Y6SWPo=; b=3RQ3YDzoAet0rdMxjVjg4C5rNQlYw+RxnHMUJA95BohzFjq5FWgfTWcXsQK4j2kBMBrK E3EfZzYKnOpNGUYfMVfg5x90VKMKfv5ehd/B/2KACEtFo3EDhh63y3dKROIBXy27AzK7 NIgb/yYqOovZf/MJmAjxwbdLVkMOrTJrjJK9r3L16RHUZ+c31zWqkqU3wpgp1UCnx1zi O+Z4Z2Nn90DaN771Xdf9kmVUiJcAQsUVLi3uHSCy9NCSklRHVC8dM30Bya5wB/7cTGeb jprEN4tAI6J3Av8ZbcFLlyfmMENY9VBSp+mdgmbJ90I51KQYQfGbXs6xJL++UiibtmZJ Ng== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2n7vaq4kj0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Oct 2018 16:05:32 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9OG5VUo007121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Oct 2018 16:05:31 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9OG5V1S007440; Wed, 24 Oct 2018 16:05:31 GMT Received: from [10.211.46.5] (/10.211.46.5) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Oct 2018 09:05:31 -0700 Subject: Re: [PATCH] xen-swiotlb: exchange memory with Xen only when pages are contiguous To: Konrad Rzeszutek Wilk Cc: "DONGLI.ZHANG" , konrad@kernel.org, Christoph Helwig , John Sobecki , Boris Ostrovsky , "xen-devel@lists.xenproject.org" , "linux-kernel@vger.kernel.org\"" References: <20181024130246.GA22616@localhost.localdomain> From: Joe Jin Message-ID: Date: Wed, 24 Oct 2018 09:05:30 -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 In-Reply-To: <20181024130246.GA22616@localhost.localdomain> 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-1810240137 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/24/18 6:02 AM, Konrad Rzeszutek Wilk wrote: > On Tue, Oct 23, 2018 at 08:09:04PM -0700, Joe Jin wrote: >> 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. > > s/it will lead/which lead to/? > >> >> The correct check condition should be memory is in DMA area and >> physically contiguous. > > "The correct check condition to make Xen hypercall to revert the > memory back from its 32-bit pool is if it is: > 1) Above its DMA bit mask (for example 32-bit devices can only address > up to 4GB, and we may want 4GB+2K), and > 2) If it not physically contingous Here should be physically contiguous? on allocating, it asked physically contiguous memory for DMA, if not contiguous, it can not do DMA, am I right? Andy range_straddles_page_boundary() return 0 means is physically contiguous, is that correct? Thanks, Joe > > N.B. The logic in the code is inverted, which leads to all sorts of > confusions." > > Does that sound correct? > >> >> Thank you Boris for pointing it out. >> > > Fixes: 4855c92dbb7 ("xen-sw..") ? > >> Signed-off-by: Joe Jin >> Cc: Konrad Rzeszutek Wilk >> Cc: Boris Ostrovsky > > Reported-by: Boris Ostrovs... ? >> 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) >>