From patchwork Mon Mar 4 20:47:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 159622 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4195461jad; Mon, 4 Mar 2019 12:49:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzIkQYgWqNXkLEdz6W5dlZI/bW9swg3XNSE0KLwkDPSjK09rF9yS40XIJCwS5VmNJo3fhM3 X-Received: by 2002:a62:5959:: with SMTP id n86mr21647025pfb.237.1551732540326; Mon, 04 Mar 2019 12:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551732540; cv=none; d=google.com; s=arc-20160816; b=KXFZpGHGAjQfL4IjpjUZ7hN1XPVoGuoORhUWDyg5hb0ab3f4xHUEx5vGlQNiz4bXMm hEtZYRcQ5gcm21V6uKV6+6Qi46fRAmYv1A+BSOzATv4I24mqAhZEb99ASwL8JAb5Zzks /jOMoghbfniWrJe2VP7bBgv1qW4LnqL4Jl3qlYrDe0xLFmJdSrSEjqt4LIfJ7ToAD1Kb SxXP3+wrOBonvGMvdvCMYuIQ4gDDjpIN+5D8FS9PEICgEkeNzDVGNgSxmcxLo4/DADKq CEicHExqGrbhUP6jXEkLSRDxedp1ymErZZ/ztUoihQjAKyP/UQa/R3+r2NEHjyo3mecW wyKQ== 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 :message-id:date:subject:cc:to:from; bh=MbJEonyU8nsJNT8EGpr7ie25BcAbkRiLkFkqNP41wIE=; b=E7UGTHPSBvjRvJv8RiuM7/lKsxwSM4ri59V8Rw/oEhrpkYSTpBHLxuHedn/CLkVu9a MN9sWVZrvoADE7OpBbP3u2eKP1zHuep6DmPMcaY1c+6pDQDkbs0ETqt0qoYiLAhQ3R2p Sqq+Og5O3jMfTMzVHBNhBz6nIUJ6y6kmD4zvalLPGDE867rOEB45G+/DonTLA8U8mLul hw4Q8Y6bI4Uy37TUNEeiGvS+m7fPaxeAaGzLdYGfK+KJGiPZc6fLNQned84u8rjNSric NXsD8Iwe+HUsxK+OnBkMmC/tBTOvg5X1JOmkBtyEzwYZUuK+jclEdBj9Mxyv1CPSBLPN iRDw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si6382058plr.136.2019.03.04.12.49.00; Mon, 04 Mar 2019 12:49:00 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726552AbfCDUs6 (ORCPT + 31 others); Mon, 4 Mar 2019 15:48:58 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:41307 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726409AbfCDUs6 (ORCPT ); Mon, 4 Mar 2019 15:48:58 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MTzrW-1gbACN1ZvG-00R2qt; Mon, 04 Mar 2019 21:48:29 +0100 From: Arnd Bergmann To: Boris Ostrovsky , Juergen Gross Cc: Arnd Bergmann , Stefano Stabellini , Oleksandr Andrushchenko , Matthew Wilcox , Paul Durrant , Souptick Joarder , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [PATCH] xen: avoid link error on ARM Date: Mon, 4 Mar 2019 21:47:52 +0100 Message-Id: <20190304204826.2414365-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:zD/cWwO0hmB7+ie+bIHG6Mz/lAutIvzcy8D6QjKzWARBd/P32aF rsTMDRqh6OUDcVVQPzF+L5jXTYSioKas+yeqfZWQKLiAOvMzNWEAv9EogAvn4K8jU+33xYB Wk3e2kkxL+qCUA8Xu2Td9NO/sQJk2Y+7X3B8U9hkX1y7Zd9e1uFhu+GWhKRcQfvOkvyxT34 3M0pxTPZkH89IKTFJZXTw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Kbree5Ra92E=:H7qcgrKdCxdCK995jkpgDg 2rHz5QpHsXfxFHji8tmH/9Y5gUCIS1ZGDzlL2E57E4R9344wc5zzpmn9zJhbbi6zzZ/3mCo7Z 41zyE+SsEy7KdtYY4c1C3+i2aaRiBKufiBZHcF9sxnUfaqSVxeiLsaF6YdVtZBMgYinyyuJXo 7YcunWzlAvGF73kIgNHDgZ3y6U5rlftgbBsR/jPGYYhU1G+diXRzBKt/7gjVyALi0Cu3kUHRo y/fDm7+CMEuqdarn1wdyoauSeN+jWZZH6jfuio/2iFziZ9UNW1yYP6UGx6A6zDu6YJNP6ui4K g4H8YZCcDSQjhyXlFGqDXOgOijUo8454xEXnZQR2N/3f5iJaOay0GFPNNtapNEpQa34BETTfZ KDwF9eWHmF4oObsLKv4hpZd+9MkPndwX8gq0QwfWKafHEw9ZWoZCut9HCW5jVRBgwMA6ot4sw y2FSCtiYcAhQ09q7c0qjmtoU2vw8gXdSAHM/qW8JkAlq9o7X62PfuLSTlguGWzr+OhwRWQAf+ 8QyrJkmht5BKTX54jLvU1JwFit1M9BMqMfFuBKGXCpi9ZIa6lndyaHrt3kwWEIP67akTQPyvb fVdBQ5lYT+O7ItkcALE7XdPrljWVoBzwPC8GL7il4LpTGrWJi+zqiXQ6qvkZSqGA/vs+Z9NB2 +mLdETZtfyDzLTHFgW9GEDlyFzfECYDK8gxcwE6dN0QjaiHVMfAIIQqfbUUZCtxWy8QlzG9db +jiByblkreU7zCty6lDyeESQfYSvQrbN+uwKTg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Building the privcmd code as a loadable module on ARM, we get a link error due to the private cache management functions: ERROR: "__sync_icache_dcache" [drivers/xen/xen-privcmd.ko] undefined! Move the code into a new file that is built along with privcmd.o but is always built-in, even when the latter is a loadable module. xen_remap_vma_range() may not be the best name here, if someone comes up with a better one, let me know. Signed-off-by: Arnd Bergmann --- drivers/xen/Makefile | 3 +++ drivers/xen/mm.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/xen/privcmd.c | 30 +----------------------------- include/xen/xen-ops.h | 3 +++ 4 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 drivers/xen/mm.c -- 2.20.0 diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile index ad3844d9f876..7124f9e749b4 100644 --- a/drivers/xen/Makefile +++ b/drivers/xen/Makefile @@ -29,6 +29,9 @@ obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o obj-$(CONFIG_XEN_MCE_LOG) += mcelog.o obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/ obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o +ifdef CONFIG_XEN_PRIVCMD +obj-y += mm.o +endif obj-$(CONFIG_XEN_STUB) += xen-stub.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o diff --git a/drivers/xen/mm.c b/drivers/xen/mm.c new file mode 100644 index 000000000000..8ad0d4900588 --- /dev/null +++ b/drivers/xen/mm.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Architecture independent helper functions for memory management + * + * Written by Paul Durrant + */ +#include +#include + +struct remap_pfn { + struct mm_struct *mm; + struct page **pages; + pgprot_t prot; + unsigned long i; +}; + +static int remap_pfn_fn(pte_t *ptep, pgtable_t token, unsigned long addr, + void *data) +{ + struct remap_pfn *r = data; + struct page *page = r->pages[r->i]; + pte_t pte = pte_mkspecial(pfn_pte(page_to_pfn(page), r->prot)); + + set_pte_at(r->mm, addr, ptep, pte); + r->i++; + + return 0; +} + +/* Used by the privcmd module, but has to be built-in on ARM */ +int xen_remap_vma_range(struct vm_area_struct *vma, unsigned long addr, unsigned long len) +{ + struct remap_pfn r = { + .mm = vma->vm_mm, + .pages = vma->vm_private_data, + .prot = vma->vm_page_prot, + }; + + return apply_to_page_range(vma->vm_mm, addr, len, remap_pfn_fn, &r); +} +EXPORT_SYMBOL_GPL(xen_remap_vma_range); diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index b24ddac1604b..290b6aca7e1d 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -723,26 +723,6 @@ static long privcmd_ioctl_restrict(struct file *file, void __user *udata) return 0; } -struct remap_pfn { - struct mm_struct *mm; - struct page **pages; - pgprot_t prot; - unsigned long i; -}; - -static int remap_pfn_fn(pte_t *ptep, pgtable_t token, unsigned long addr, - void *data) -{ - struct remap_pfn *r = data; - struct page *page = r->pages[r->i]; - pte_t pte = pte_mkspecial(pfn_pte(page_to_pfn(page), r->prot)); - - set_pte_at(r->mm, addr, ptep, pte); - r->i++; - - return 0; -} - static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata) { struct privcmd_data *data = file->private_data; @@ -809,15 +789,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata) goto out; if (xen_feature(XENFEAT_auto_translated_physmap)) { - struct remap_pfn r = { - .mm = vma->vm_mm, - .pages = vma->vm_private_data, - .prot = vma->vm_page_prot, - }; - - rc = apply_to_page_range(r.mm, kdata.addr, - kdata.num << PAGE_SHIFT, - remap_pfn_fn, &r); + rc = xen_remap_vma_range(vma, kdata.addr, kdata.num << PAGE_SHIFT); } else { unsigned int domid = (xdata.flags & XENMEM_rsrc_acq_caller_owned) ? diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h index 4969817124a8..98b30c1613b2 100644 --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h @@ -109,6 +109,9 @@ static inline int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma, } #endif +int xen_remap_vma_range(struct vm_area_struct *vma, unsigned long addr, + unsigned long len); + /* * xen_remap_domain_gfn_array() - map an array of foreign frames by gfn * @vma: VMA to map the pages into