Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6743784ybi; Mon, 22 Jul 2019 00:49:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSad6eyujjMK3oYwK2xzQKVrKOwGoFJULvP4ZIn1aHC9yiqxDX8dmwiOl9jQtJAjNUjuO8 X-Received: by 2002:a17:902:820c:: with SMTP id x12mr74440790pln.216.1563781769598; Mon, 22 Jul 2019 00:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563781769; cv=none; d=google.com; s=arc-20160816; b=LBr+wqCXCCyhDZRh3Omyiebh821czLDT8O0xhYzZTwpEs1YluU87f9SRyzSj8BiO3u eXBseoy3y7DGsqhHVl81+3SF62aZVTdc5RusahdymvP/9erFLa4vx5YTmL+qJKGvrK/k DvQl26H6CmXFUPxCMusdGiAzUAs18rAfbiaVvhYsiaCrLSnRW8w6bqG9rQf3Y1G6wxIn 9wtxPTX9xYzbrPkSgPVCrNPEN8ZVkO7+ptmMWdeEyWLilg2VJbgKtv1/CjLet8/4HdDp xER0cPSqnv11H5XpRZSGCiyvzRLloV9uUPj5t40Tc2gWExy3wdpZoSJQlr7oD2+dGRkk kj3Q== 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=WEEHIRy5I1HVkdmEwxd+XWBILCIrQExy0XGMxVROOx8=; b=skincNse4HxTaFZ/GpqQ73Srt+Lo8u/fW508CQ7Iyzgx5fpqfR/yu6wUko9h0Jjmxq /KuYiwsLo6+9rupp8baI3x8vXfTIKY2zxTwS7ztNwU/2FC+k3tPr8ToSGJM+nK1/LbFI /DSkS5s6UpbjNa0j+PIjbiV+D+I+b6Vw/lNMkv/x7RqYlW985CxjbdyDYQ5ETVm0kMo8 GePW/8EQ5tdQGNdocfJ7xTZJYdUHd4zVFy9s8E9SvALubLvTRpVcRgHMB50F6nnjMpW7 eYTRaHiakmpm4RLEu1Ddig/veLeaeCL3WRB7mxoKKPsgTXMbRBSKDrcfV/0MOVXonOC7 XZ/g== 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 a63si8199314pge.113.2019.07.22.00.49.13; Mon, 22 Jul 2019 00:49:29 -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; 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 S1727699AbfGVHrz (ORCPT + 99 others); Mon, 22 Jul 2019 03:47:55 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:60781 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727164AbfGVHrz (ORCPT ); Mon, 22 Jul 2019 03:47:55 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MSbov-1i04vK0nhx-00T03d; Mon, 22 Jul 2019 09:47:07 +0200 From: Arnd Bergmann To: Boris Ostrovsky , Juergen Gross Cc: Arnd Bergmann , Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v3] xen: avoid link error on ARM Date: Mon, 22 Jul 2019 09:46:29 +0200 Message-Id: <20190722074705.2082153-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:3EdOY3EUnlUpz1I3SU7SExGgM9Np4XJCmPkMfsKvDxZfzJkaD2X f9IRekbqSDJcE1EVqjNOA9BdXcMErvJxelu1521l2QAetrl5ETmalOPD0QL4Zcvom9mSXyc uRLbnfLZv+hDj2noZweapQyB7LLryFnru7t9yiXOb1r6C6biY4aLRZtuZ9KBYat1oJPr5p+ RDIU7ZjihuLGcHKObaqdg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:oeVD7OeF3dY=:wxlNhsi0rCLsy/PPJPNYuB w26Lnf05qvb2AdLALuGE2FvIUZkDZtgpoU6R8YB9hoqyzcezCEjXqZfCtnWSxB7Xd5r0zYrGV vQgqb+8zmFG973E4Xn/5KB9dzReifXqBPS9DwprfNIaxW952EkjWCZWkJiv9mZ53kuyXupCYu BH4Z2Yazmzn+S9axnkq6V+//UJLH62xLvYX5HrecVy9r11BIMk4AhFwVxRT74f+ABJos42aR4 c0KR9ItikEembbodxyYbGQKk6LU1xlZ+nRLqT0JZwWpcuNAHYFBTMjJieq+mM2AC1m3bZ+S7/ lW2FOeUhQhrfktt/vryAYwEmU2pR7Iv7GbFhZPXZgMvuxqKEyTj4WOPWg1bTn/32HA4xVd8Ks XezYmPel78/F1PXEN5U9XaXolkKia3orRT+Gw6MVhHpBiyYFFiC5jNifG7bchp0bVtujzRDgT gaE3Mf7ImSTATrDw2BHDOY9qSJsP3mHXnRJiHiTlQwweOHI0pQK1ylxvqEeq1iOsxlh3Bc8us GMbXaRMYAe/sK2ZmmNyPlc2pmfJCkvQK/L+NAKGJNrzHD5VmQlTsHDEW0py9v/jtxEX7ftRuX Hs9gFyNnwJxyktB+BwksaAfS2L9CeavlqqyuA736zO4tju9QTXgDzzE5rmY4ZNmOpixszww+5 Jpy+8fuI3MnGH4RWdSGmk9RaFDzxdeI5PVYLYa7nQYum1fWu+P4eg7xG/CqH74ZYUJOd26EHa XMLWYPQ8+CG6T24kqI6rhBECg/v+6XhkuUwLSQ== 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 that is always built in when Xen is enabled, as suggested by Juergen Gross and Boris Ostrovsky. Signed-off-by: Arnd Bergmann --- v2: rename mm.o to xen-builtin.o, make it unconditional v3: move new code into xlate_mmu as suggested by Boris Ostrovsky. sorry for the long delay since v2, I lost track of this. --- drivers/xen/privcmd.c | 35 +++++------------------------------ drivers/xen/xlate_mmu.c | 32 ++++++++++++++++++++++++++++++++ include/xen/xen-ops.h | 3 +++ 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 2f5ce7230a43..c6070e70dd73 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -724,25 +724,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, 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; @@ -774,7 +755,8 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata) goto out; } - if (xen_feature(XENFEAT_auto_translated_physmap)) { + if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && + xen_feature(XENFEAT_auto_translated_physmap)) { unsigned int nr = DIV_ROUND_UP(kdata.num, XEN_PFN_PER_PAGE); struct page **pages; unsigned int i; @@ -808,16 +790,9 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata) if (rc) 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); + if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && + xen_feature(XENFEAT_auto_translated_physmap)) { + 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/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c index ba883a80b3c0..7b1077f0abcb 100644 --- a/drivers/xen/xlate_mmu.c +++ b/drivers/xen/xlate_mmu.c @@ -262,3 +262,35 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt, return 0; } EXPORT_SYMBOL_GPL(xen_xlate_map_ballooned_pages); + +struct remap_pfn { + struct mm_struct *mm; + struct page **pages; + pgprot_t prot; + unsigned long i; +}; + +static int remap_pfn_fn(pte_t *ptep, 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/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 -- 2.20.0