aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/xen
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 17:29:16 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 17:29:16 -0500
commit896ea17d3da5f44b2625c9cda9874d7dfe447393 (patch)
tree089f00dd300a49c81f042e9b52ef32cd1333bdbc /arch/arm/xen
parentc7708fac5a878d6e0f2de0aa19f9749cff4f707f (diff)
parent6a7ed405114b2a53ccd99631b0636aaeabf71b3e (diff)
Merge tag 'stable/for-linus-3.8-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
Pull Xen updates from Konrad Rzeszutek Wilk: - Add necessary infrastructure to make balloon driver work under ARM. - Add /dev/xen/privcmd interfaces to work with ARM and PVH. - Improve Xen PCIBack wild-card parsing. - Add Xen ACPI PAD (Processor Aggregator) support - so can offline/ online sockets depending on the power consumption. - PVHVM + kexec = use an E820_RESV region for the shared region so we don't overwrite said region during kexec reboot. - Cleanups, compile fixes. Fix up some trivial conflicts due to the balloon driver now working on ARM, and there were changes next to the previous work-arounds that are now gone. * tag 'stable/for-linus-3.8-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: xen/PVonHVM: fix compile warning in init_hvm_pv_info xen: arm: implement remap interfaces needed for privcmd mappings. xen: correctly use xen_pfn_t in remap_domain_mfn_range. xen: arm: enable balloon driver xen: balloon: allow PVMMU interfaces to be compiled out xen: privcmd: support autotranslated physmap guests. xen: add pages parameter to xen_remap_domain_mfn_range xen/acpi: Move the xen_running_on_version_or_later function. xen/xenbus: Remove duplicate inclusion of asm/xen/hypervisor.h xen/acpi: Fix compile error by missing decleration for xen_domain. xen/acpi: revert pad config check in xen_check_mwait xen/acpi: ACPI PAD driver xen-pciback: reject out of range inputs xen-pciback: simplify and tighten parsing of device IDs xen PVonHVM: use E820_Reserved area for shared_info
Diffstat (limited to 'arch/arm/xen')
-rw-r--r--arch/arm/xen/enlighten.c123
1 files changed, 102 insertions, 21 deletions
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index f57609275449..7a32976fa2a3 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -8,6 +8,8 @@
8#include <xen/features.h> 8#include <xen/features.h>
9#include <xen/platform_pci.h> 9#include <xen/platform_pci.h>
10#include <xen/xenbus.h> 10#include <xen/xenbus.h>
11#include <xen/page.h>
12#include <xen/xen-ops.h>
11#include <asm/xen/hypervisor.h> 13#include <asm/xen/hypervisor.h>
12#include <asm/xen/hypercall.h> 14#include <asm/xen/hypercall.h>
13#include <linux/interrupt.h> 15#include <linux/interrupt.h>
@@ -17,6 +19,8 @@
17#include <linux/of_irq.h> 19#include <linux/of_irq.h>
18#include <linux/of_address.h> 20#include <linux/of_address.h>
19 21
22#include <linux/mm.h>
23
20struct start_info _xen_start_info; 24struct start_info _xen_start_info;
21struct start_info *xen_start_info = &_xen_start_info; 25struct start_info *xen_start_info = &_xen_start_info;
22EXPORT_SYMBOL_GPL(xen_start_info); 26EXPORT_SYMBOL_GPL(xen_start_info);
@@ -29,6 +33,10 @@ struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
29 33
30DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); 34DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
31 35
36/* These are unused until we support booting "pre-ballooned" */
37unsigned long xen_released_pages;
38struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
39
32/* TODO: to be removed */ 40/* TODO: to be removed */
33__read_mostly int xen_have_vector_callback; 41__read_mostly int xen_have_vector_callback;
34EXPORT_SYMBOL_GPL(xen_have_vector_callback); 42EXPORT_SYMBOL_GPL(xen_have_vector_callback);
@@ -38,15 +46,106 @@ EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
38 46
39static __read_mostly int xen_events_irq = -1; 47static __read_mostly int xen_events_irq = -1;
40 48
49/* map fgmfn of domid to lpfn in the current domain */
50static int map_foreign_page(unsigned long lpfn, unsigned long fgmfn,
51 unsigned int domid)
52{
53 int rc;
54 struct xen_add_to_physmap_range xatp = {
55 .domid = DOMID_SELF,
56 .foreign_domid = domid,
57 .size = 1,
58 .space = XENMAPSPACE_gmfn_foreign,
59 };
60 xen_ulong_t idx = fgmfn;
61 xen_pfn_t gpfn = lpfn;
62
63 set_xen_guest_handle(xatp.idxs, &idx);
64 set_xen_guest_handle(xatp.gpfns, &gpfn);
65
66 rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
67 if (rc) {
68 pr_warn("Failed to map pfn to mfn rc:%d pfn:%lx mfn:%lx\n",
69 rc, lpfn, fgmfn);
70 return 1;
71 }
72 return 0;
73}
74
75struct remap_data {
76 xen_pfn_t fgmfn; /* foreign domain's gmfn */
77 pgprot_t prot;
78 domid_t domid;
79 struct vm_area_struct *vma;
80 int index;
81 struct page **pages;
82 struct xen_remap_mfn_info *info;
83};
84
85static int remap_pte_fn(pte_t *ptep, pgtable_t token, unsigned long addr,
86 void *data)
87{
88 struct remap_data *info = data;
89 struct page *page = info->pages[info->index++];
90 unsigned long pfn = page_to_pfn(page);
91 pte_t pte = pfn_pte(pfn, info->prot);
92
93 if (map_foreign_page(pfn, info->fgmfn, info->domid))
94 return -EFAULT;
95 set_pte_at(info->vma->vm_mm, addr, ptep, pte);
96
97 return 0;
98}
99
41int xen_remap_domain_mfn_range(struct vm_area_struct *vma, 100int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
42 unsigned long addr, 101 unsigned long addr,
43 unsigned long mfn, int nr, 102 xen_pfn_t mfn, int nr,
44 pgprot_t prot, unsigned domid) 103 pgprot_t prot, unsigned domid,
104 struct page **pages)
45{ 105{
46 return -ENOSYS; 106 int err;
107 struct remap_data data;
108
109 /* TBD: Batching, current sole caller only does page at a time */
110 if (nr > 1)
111 return -EINVAL;
112
113 data.fgmfn = mfn;
114 data.prot = prot;
115 data.domid = domid;
116 data.vma = vma;
117 data.index = 0;
118 data.pages = pages;
119 err = apply_to_page_range(vma->vm_mm, addr, nr << PAGE_SHIFT,
120 remap_pte_fn, &data);
121 return err;
47} 122}
48EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range); 123EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
49 124
125int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
126 int nr, struct page **pages)
127{
128 int i;
129
130 for (i = 0; i < nr; i++) {
131 struct xen_remove_from_physmap xrp;
132 unsigned long rc, pfn;
133
134 pfn = page_to_pfn(pages[i]);
135
136 xrp.domid = DOMID_SELF;
137 xrp.gpfn = pfn;
138 rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrp);
139 if (rc) {
140 pr_warn("Failed to unmap pfn:%lx rc:%ld\n",
141 pfn, rc);
142 return rc;
143 }
144 }
145 return 0;
146}
147EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
148
50/* 149/*
51 * see Documentation/devicetree/bindings/arm/xen.txt for the 150 * see Documentation/devicetree/bindings/arm/xen.txt for the
52 * documentation of the Xen Device Tree format. 151 * documentation of the Xen Device Tree format.
@@ -149,24 +248,6 @@ static int __init xen_init_events(void)
149} 248}
150postcore_initcall(xen_init_events); 249postcore_initcall(xen_init_events);
151 250
152/* XXX: only until balloon is properly working */
153int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem)
154{
155 *pages = alloc_pages(highmem ? GFP_HIGHUSER : GFP_KERNEL,
156 get_order(nr_pages));
157 if (*pages == NULL)
158 return -ENOMEM;
159 return 0;
160}
161EXPORT_SYMBOL_GPL(alloc_xenballooned_pages);
162
163void free_xenballooned_pages(int nr_pages, struct page **pages)
164{
165 kfree(*pages);
166 *pages = NULL;
167}
168EXPORT_SYMBOL_GPL(free_xenballooned_pages);
169
170/* In the hypervisor.S file. */ 251/* In the hypervisor.S file. */
171EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op); 252EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op);
172EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op); 253EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op);