Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1954155ybk; Thu, 21 May 2020 20:56:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVSSuEui+N+587iw9Mk0AjPMzq1YfokThojpvga8CxZqQTzb+O4zA3injCb3rGAskd4YQU X-Received: by 2002:a17:906:6893:: with SMTP id n19mr6903462ejr.354.1590119798128; Thu, 21 May 2020 20:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590119798; cv=none; d=google.com; s=arc-20160816; b=Qw9BeirccTle7mFDtRIX61XcL/i3H2Na8sBqk+UVrvH1R2DDwNj8ByyQR0BezdKc+k ppuvx3BSkuGvSj86p4DIqf1nkcNq6ClydJeHtbx7VaXCqjevKdqWkShdjrSIp/Qw6c6+ tVVuBsk1hgvJztPP0f7lU7Y0WvxGImi1buoa11ZZzDrvniUZtNqtcfHSb1SkHvaAtCAq FdYgDDMo7RsVHhohdoR11zJ6BLa3exsw38bkTxkaD+URmmW843pvC1tVJovTWgSN+n/a LLPybWJ/CajEjbMlN0lVkdaLGxllf3xS26oSOqhJjx/M8ygB6QRSQMSh+uz+DAWKyYSw kmRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=MlsdD2LqQsDmgyNKsSrwDmjflhH1dpDFBl4/E2G2E7o=; b=0xgaKHWbeGMz/ryZ98VzwUuakpySVLsAjRCp7GZ2t7TLyyRWFC3f+wu1DYLGlgEvnK t72a9ErNR7Nv/SnHCNDxbYFaun7qRQ0iIHRBNzk5KrfRgy6iQHUBXA90/Sfq+oXRBDSZ mVGeiCz2I2Bs5i6V/MXqBq+lHalN9PFOOlqN5DHNdiKYX+Q3WoMLALWtisuZOPrNUNYf 3BgSaars4Su6A3dm/TXKJknNxPzp2Km/aZziPz3+RNX3LxrV1gwcKeOj1MriMj6KA1is WLWLgVMZ6evTWcLIDUX0w95IMAXUSIyfatV/XxoSVviNTEpJF8ZM5ihZoS6vVCFuj7rk tWEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aR+s4YbN; 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 k19si4474165edj.455.2020.05.21.20.56.15; Thu, 21 May 2020 20:56:38 -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=aR+s4YbN; 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 S1728288AbgEVDyt (ORCPT + 99 others); Thu, 21 May 2020 23:54:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:49788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727924AbgEVDyt (ORCPT ); Thu, 21 May 2020 23:54:49 -0400 Received: from localhost (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7733F20759; Fri, 22 May 2020 03:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590119688; bh=IOb0RQXn20mPjLvcXrm5g1uV8k0WGkYBZ/xCUkJOpgs=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=aR+s4YbN4WY3+tkkj48KZxEgCx1VjrO1vm0r1wNMQmzemwTf89enT66INgI5pVVER PKJNzG8Jq6pwsmDp7EOMvvfRmjTrWjeT/QV0ZXVda0Uz4aJBL5l9u4Yl1wGvrTnwnx 0IQQAfkPycuEiV4Dv9WiJbM49iZE8D+vPYKqCvhA= Date: Thu, 21 May 2020 20:54:47 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Julien Grall cc: Stefano Stabellini , jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Stefano Stabellini Subject: Re: [PATCH 01/10] swiotlb-xen: use vmalloc_to_page on vmalloc virt addresses In-Reply-To: <23e5b6d8-c5d9-b43f-41cd-9d02d8ec0a7f@xen.org> Message-ID: References: <20200520234520.22563-1-sstabellini@kernel.org> <23e5b6d8-c5d9-b43f-41cd-9d02d8ec0a7f@xen.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 May 2020, Julien Grall wrote: > Hi, > > On 21/05/2020 00:45, Stefano Stabellini wrote: > > 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. > > Can you provide an example where swiotlb is used with vmalloc()? The issue was reported here happening on the Rasperry Pi 4: https://marc.info/?l=xen-devel&m=158862573216800 If you are asking where in the Linux codebase the vmalloc is happening specifically, I don't know for sure, my information is limited to the stack trace that you see in the link (I don't have a Rasperry Pi 4 yet but I shall have one soon.) > > 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); > > Common DMA code seems to protect this check with CONFIG_DMA_REMAP. Is it > something we want to do it here as well? Or is there any other condition where > vmalloc can happen? I can see it in dma_direct_free_pages: if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr)) vunmap(cpu_addr); I wonder why the common DMA code does that. is_vmalloc_addr should work regardless of CONFIG_DMA_REMAP. Maybe just for efficiency?