Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp955202ybk; Wed, 20 May 2020 16:50:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE+Uy2X6cOLl0l80TPL1i9HNunkdCX89sX3wpaDWzB8dJV+3cUsvDPV1YY2nq4DGs/autM X-Received: by 2002:a17:907:2142:: with SMTP id rk2mr1340581ejb.225.1590018656104; Wed, 20 May 2020 16:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590018656; cv=none; d=google.com; s=arc-20160816; b=tpXFTNj02bnHnHutvK3Hk5iYE3F47Fu157TfLwNvuyMrSgSA1ic0can90zlxmbTFEW LwVsDACgA8V4u6HbxQhRHOEZs0vS7O2pB75WiHTyqfd9UH0XIszGImSLbRH40LONcPUx fgLeUxUlmJIb0o9KhK4gII/BqEqChNRXyNcSnZp/9vDE9YqsIRik6G9kbj1QcPG0xnCl EQd1p9joqpvQezTTQCgAuUIbRkk4GHb8F6F5Yuc6Ku4FEWM5B4JjFnpGaJKNqqRAphAh l6hkRrBcMnA5bLjwqa4G51+1rgn+um24v36iqY4RO10Q+jSPBu+KnaFeXFN2aKCA2Hrq ajkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=DW4KtEv4gVnNT5GbGXK9y6UZhKFkKz6YseUoFnJFxaM=; b=YAA7kX8jUCDx18YK7CJz0M3Allo/azaBeJblpRlMAZwKUfHryNSzw9dsijbmYebZqx yFmC7H3bCScf9Sydwt9+Xzqm+EY7APZi4Rvw1VBh8JGu5XH3nnj4uHJMB5o/ToKeBAcJ DtSyKCeeBAoLHja3D38GZO08V9f5atMz0N97kaSuPJYH2vpZ4ntxEc6Kg6kWiHssRJrX WirAcc2Oaj9s6Lbl/h8fuTzKN6wFEZhJPQnfMkAtJrh3mtTsEvar2Sl9Ghd9uUDM+2jm SypxlTxR0DpMgw4qU/P5b7KK/lgYxr352cphK9lUDQpTV5Oo9GzpoezfZYca6IggRu+w ftCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Z/XEnES7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc10si2558642ejb.156.2020.05.20.16.50.33; Wed, 20 May 2020 16:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Z/XEnES7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbgETXpW (ORCPT + 99 others); Wed, 20 May 2020 19:45:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:36890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbgETXpW (ORCPT ); Wed, 20 May 2020 19:45:22 -0400 Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1812920748; Wed, 20 May 2020 23:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590018322; bh=2rJi6KfJ7cKpdb3KgYosM8AG09eJiSBLH85aYQo6tfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z/XEnES7H/3TARKOmkB1qbDupxUWdE2Iq1shY3iRXvUvUqgWMI9JC8cDHfeS8Yl+u +HcspWBrKeLpETCuygnY/0/UPeXGziAinuXs3JHNLhNZdDIMXyospJd0iz+iNx4WVf DXuaL5c43gHfkKb/gZV0rdGZ8hqWUrfcfPK0H0bI= From: Stefano Stabellini To: jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Cc: sstabellini@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Stefano Stabellini Subject: [PATCH 01/10] swiotlb-xen: use vmalloc_to_page on vmalloc virt addresses Date: Wed, 20 May 2020 16:45:11 -0700 Message-Id: <20200520234520.22563-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris Ostrovsky Don't just assume that virt_to_page works on all virtual addresses. Instead add a is_vmalloc_addr check and use vmalloc_to_page on vmalloc virt addresses. Signed-off-by: Boris Ostrovsky Signed-off-by: Stefano Stabellini --- drivers/xen/swiotlb-xen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index b6d27762c6f8..a42129cba36e 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -335,6 +335,7 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, int order = get_order(size); phys_addr_t phys; u64 dma_mask = DMA_BIT_MASK(32); + struct page *pg; if (hwdev && hwdev->coherent_dma_mask) dma_mask = hwdev->coherent_dma_mask; @@ -346,9 +347,11 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, /* Convert the size to actually allocated. */ size = 1UL << (order + XEN_PAGE_SHIFT); + pg = is_vmalloc_addr(vaddr) ? vmalloc_to_page(vaddr) : + virt_to_page(vaddr); if (!WARN_ON((dev_addr + size - 1 > dma_mask) || range_straddles_page_boundary(phys, size)) && - TestClearPageXenRemapped(virt_to_page(vaddr))) + TestClearPageXenRemapped(pg)) xen_destroy_contiguous_region(phys, order); xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs); -- 2.17.1