Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp308911ima; Thu, 25 Oct 2018 21:18:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5elWBloAm5+vgs6MFCxHmoge5bwca9xdQftUTKZr2yXQ1hgDMjT5IXyhvwe7nBfnF3KM/Rs X-Received: by 2002:a63:4243:: with SMTP id p64-v6mr1975751pga.127.1540527483096; Thu, 25 Oct 2018 21:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540527483; cv=none; d=google.com; s=arc-20160816; b=1A6hCQCEZQV/NB9YJrdGb4PKg211jTJ/W3pW45VplyZJ1s95lcKa5fAaPTRx6KXy5E S7cRJldUz1fHNqc2CeJW/WI38X55jtWSZL+ECNpPgO3W2Bg1iyj0gfjCYvO6Tt/dNrXT mVeR94gYSETkhxbxOMHrpY55NIuJIUSqcrFmhkV8ximMSDtcCrZ/5qjA9nr1FSVSnuaf 9cC2+z+ygyFqtvky4gJN+uq9IDL1gEjU4HQhVYy0nD6sRYpM3daBfAQInB1jOtTJXsgP N6Skz82qfeUCcTDgtEHoifwQ3Z47ScmyWmbcaJaXVExKFetC3YEBRMI73ZtAZnFQE4De oScg== 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=Aj4OeuSFoQcmJZ1fRFOMjUgqrvUepn7096+IooR002k=; b=v0Z05Fy7ET5fOEuJ+sy+Am4JT169zMwyEmpMLpIiFPkEIxN1GLkm60VRjnIuJCdMjl KOs95uw6SO1+zQX/x05vpeAnb9zBlXUKZsyy0mU0sZVKYQwqbUGwRGkebJlfHBFVNn5V Khew9HH2VwxS6KI0yibId5WmpWprXQjulmtaj5Pczh6gTHmC44y+26cUSwflhtiay2Rb QEDxjduc4P6pTnLQEOfkO6WyJDdeB6hqhGaNr0e77pRwayr0qU0846lpqt5RA78YGt8n hR7fHUqVyIXVR0XUrEhbtZDauH/JBa56yJFsgiVxsWhBTT7g8EPLlSwHPd/+S0xLcwoP j4qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=s01QnAHv; 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 g11-v6si767791pgd.26.2018.10.25.21.17.45; Thu, 25 Oct 2018 21:18:03 -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=s01QnAHv; 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 S1726013AbeJZMwo (ORCPT + 99 others); Fri, 26 Oct 2018 08:52:44 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55012 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725849AbeJZMwo (ORCPT ); Fri, 26 Oct 2018 08:52:44 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9Q49Tf9170092; Fri, 26 Oct 2018 04:17:18 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=Aj4OeuSFoQcmJZ1fRFOMjUgqrvUepn7096+IooR002k=; b=s01QnAHvOlKhYLIQ17Y2Hwpl10oLi8f5GZQvr2Q1spm3hulQERz2mDtTwjY0rbwkJkt0 hwDFiotSI4CkduBqo8qD/uzIoU6ivxkshy9/Hx6ZfB1+yUIxpOiKighX1HiKsL2gJ2i7 1yRJzr40RtOBDsdUdtLPJIN0rkYKVQZP1wy/M/jEeele5n3Y/7Zx+jA9k+p8g28e8eL+ H4rD/gqULNZH4WBrSY0FkYoEb339IA6L1zE+RqXsWtKQRZznqPIQJIr7OdVvldqGXOTf H08+TJjYESmXVAEsgftzTqUKyts5E9x0DY6hXTGaU5ZyXGTPyFYHNn6cY1k5R6DP/BqZ pw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2n7w0r506v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Oct 2018 04:17:17 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9Q4HC3k026620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Oct 2018 04:17:12 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9Q4HBYH008020; Fri, 26 Oct 2018 04:17:12 GMT Received: from [10.0.0.83] (/73.231.240.86) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Oct 2018 21:17:11 -0700 Subject: Re: [PATCH] x86/xen: add physically contiguous check to xen_destroy_contiguous_region To: Boris Ostrovsky , Konrad Rzeszutek Wilk , Juergen Gross , "DONGLI.ZHANG" , John Sobecki Cc: "xen-devel@lists.xenproject.org" , "linux-kernel@vger.kernel.org" , konrad@kernel.org References: <210fa20d-4abb-413f-7e58-d8079cf3c589@oracle.com> From: Joe Jin Message-ID: Date: Thu, 25 Oct 2018 21:17:10 -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: <210fa20d-4abb-413f-7e58-d8079cf3c589@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9057 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-1810260036 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I did not realized range_straddles_page_boundary() only available on xen-swiotlb, please ignore this patch. Sorry for the bother. Thanks, Joe On 10/25/18 5:16 PM, Joe Jin wrote: > xen_destroy_contiguous_region() used to exchange physically > contiguous memory with hypervisor, but it does not verify > that the memory is physically contiguous or no, passing > non-contiguous memory to xen_destroy_contiguous_region() > will lead kernel panic. > > Signed-off-by: Joe Jin > Cc: Konrad Rzeszutek Wilk > Cc: Boris Ostrovsky > Cc: Juergen Gross > --- > arch/x86/xen/mmu_pv.c | 3 +++ > drivers/xen/swiotlb-xen.c | 3 +-- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c > index 70ea598a37d2..c2f081f8ebe3 100644 > --- a/arch/x86/xen/mmu_pv.c > +++ b/arch/x86/xen/mmu_pv.c > @@ -2649,6 +2649,9 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order) > if (unlikely(order > MAX_CONTIG_ORDER)) > return; > > + if (range_straddles_page_boundary(pstart, PAGE_SIZE << order)) > + return; > + > vstart = (unsigned long)phys_to_virt(pstart); > memset((void *) vstart, 0, PAGE_SIZE << order); > > diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c > index f5c1af4ce9ab..432eeae02d7d 100644 > --- a/drivers/xen/swiotlb-xen.c > +++ b/drivers/xen/swiotlb-xen.c > @@ -357,8 +357,7 @@ 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) > xen_destroy_contiguous_region(phys, order); > > xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs); >