Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1174363pxk; Mon, 31 Aug 2020 11:50:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxPW5w+ChMGoN0MY/ogxay9vDwlKg41INUFtq/k03ihDCC2HMjIYTEVJWQPK241eSm6dOn X-Received: by 2002:a17:907:270d:: with SMTP id w13mr2160276ejk.191.1598899857320; Mon, 31 Aug 2020 11:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598899857; cv=none; d=google.com; s=arc-20160816; b=Q9T36V8CMx2sOLecCrA2JLLprwAmgX2buuJj21VZqoMIR/oXUsQZpwW3NIBU6idXPy DghnuiONJ6miHt+oSBNhA2h15IXpzwcoXKsy4yoiym+vinsXMeTIHGDkLIJK0Bi8Hm6W 9Tm9Miskl00DcyXFhzGcj6XoLoOVeHAM/IHSEh0J3dWeDF0WVNfBupo/GXnSZCr+Mhse EPKJYr8OWfA7eJTbfQybApVKisLbXzL3O5W2WbWmXDPke//xcCCeFRxmbBfoZcfd6VkB W+fyLJ5QL5JGxKhbvotVG1LzKSv6lsw5SCAwl3dIWBafMFkLornjrndIStfBYyD4UlOj 1d9Q== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Lai6b/mhormZIgHDNWddZMuOaRz/crPnQ6WAkO23afU=; b=zDQvhEND1c2iLVWv3VSZy8pes2tV56ik5SAUJRkXPpSQJUTNRooMvNeTCBdU3Ppvbg L+eIe1PKQSOt0iEQHoula78XC4SKEQPZq8pHwukvM8n5pAaBJfzw+GE3u86XqlrvZurG IGgxRBpvqbb9avXuEbfvOEQruPKlgDTFng2ryjd4a5hd784C8k9IgR+VHFaC46zk+8BC Hg6ibOkpvgjtl3CnLS57SM5EkfO8PfnGpqdioLTwZ2cBQAIYnPm73q8mRx/zT1FejRF1 fDwNi2weoBOyUtHrWt1KS8e+SIS8aoC5ZNlPxPU4zZtBMgunDHh2+5UaPW/F/JvnPwPp duDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q9hLf9Qs; 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 s18si5973049eja.139.2020.08.31.11.50.34; Mon, 31 Aug 2020 11:50:57 -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=Q9hLf9Qs; 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 S1728725AbgHaPaq (ORCPT + 99 others); Mon, 31 Aug 2020 11:30:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:40332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728681AbgHaPag (ORCPT ); Mon, 31 Aug 2020 11:30:36 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 69372214D8; Mon, 31 Aug 2020 15:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598887836; bh=UqqMPAtWDqzA6uUdK9GV+TVqxsDEdKr1IAB3nfSBPuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q9hLf9QsynLtpUQttfgx4RwjoCIhoqOHFiIEucCON7lXCaoldpFKfE0v4CQa+sjWO J/SRnl1XEf1yqUxCsOAie84w6uAS0iHDLgtlNCKXlhb9inigCbDRtxjl0DWAxh6bi0 OpJA/xO5raSAWiiPfDGk+u5vLN0IWkkVhwJIZcOE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Simon Leiner , Stefano Stabellini , Juergen Gross , Sasha Levin , xen-devel@lists.xenproject.org Subject: [PATCH AUTOSEL 5.8 41/42] xen/xenbus: Fix granting of vmalloc'd memory Date: Mon, 31 Aug 2020 11:29:33 -0400 Message-Id: <20200831152934.1023912-41-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831152934.1023912-1-sashal@kernel.org> References: <20200831152934.1023912-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Simon Leiner [ Upstream commit d742db70033c745e410523e00522ee0cfe2aa416 ] On some architectures (like ARM), virt_to_gfn cannot be used for vmalloc'd memory because of its reliance on virt_to_phys. This patch introduces a check for vmalloc'd addresses and obtains the PFN using vmalloc_to_pfn in that case. Signed-off-by: Simon Leiner Reviewed-by: Stefano Stabellini Link: https://lore.kernel.org/r/20200825093153.35500-1-simon@leiner.me Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- drivers/xen/xenbus/xenbus_client.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 786fbb7d8be06..907bcbb93afbf 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -379,8 +379,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, int i, j; for (i = 0; i < nr_pages; i++) { - err = gnttab_grant_foreign_access(dev->otherend_id, - virt_to_gfn(vaddr), 0); + unsigned long gfn; + + if (is_vmalloc_addr(vaddr)) + gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr)); + else + gfn = virt_to_gfn(vaddr); + + err = gnttab_grant_foreign_access(dev->otherend_id, gfn, 0); if (err < 0) { xenbus_dev_fatal(dev, err, "granting access to ring page"); -- 2.25.1