diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-27 14:35:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-27 14:35:37 -0400 |
commit | 08fd8c17686c6b09fa410a26d516548dd80ff147 (patch) | |
tree | 0d8c17e70a94518a301e85fc7b23fbc09311068c /drivers/xen | |
parent | e831101a73fbc8339ef1d1909dad3ef64f089e70 (diff) | |
parent | d34c30cc1fa80f509500ff192ea6bc7d30671061 (diff) |
Merge tag 'for-linus-4.8-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from David Vrabel:
"Features and fixes for 4.8-rc0:
- ACPI support for guests on ARM platforms.
- Generic steal time support for arm and x86.
- Support cases where kernel cpu is not Xen VCPU number (e.g., if
in-guest kexec is used).
- Use the system workqueue instead of a custom workqueue in various
places"
* tag 'for-linus-4.8-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: (47 commits)
xen: add static initialization of steal_clock op to xen_time_ops
xen/pvhvm: run xen_vcpu_setup() for the boot CPU
xen/evtchn: use xen_vcpu_id mapping
xen/events: fifo: use xen_vcpu_id mapping
xen/events: use xen_vcpu_id mapping in events_base
x86/xen: use xen_vcpu_id mapping when pointing vcpu_info to shared_info
x86/xen: use xen_vcpu_id mapping for HYPERVISOR_vcpu_op
xen: introduce xen_vcpu_id mapping
x86/acpi: store ACPI ids from MADT for future usage
x86/xen: update cpuid.h from Xen-4.7
xen/evtchn: add IOCTL_EVTCHN_RESTRICT
xen-blkback: really don't leak mode property
xen-blkback: constify instance of "struct attribute_group"
xen-blkfront: prefer xenbus_scanf() over xenbus_gather()
xen-blkback: prefer xenbus_scanf() over xenbus_gather()
xen: support runqueue steal time on xen
arm/xen: add support for vm_assist hypercall
xen: update xen headers
xen-pciback: drop superfluous variables
xen-pciback: short-circuit read path used for merging write values
...
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/Kconfig | 2 | ||||
-rw-r--r-- | drivers/xen/Makefile | 1 | ||||
-rw-r--r-- | drivers/xen/arm-device.c | 196 | ||||
-rw-r--r-- | drivers/xen/efi.c | 173 | ||||
-rw-r--r-- | drivers/xen/events/events_base.c | 13 | ||||
-rw-r--r-- | drivers/xen/events/events_fifo.c | 2 | ||||
-rw-r--r-- | drivers/xen/evtchn.c | 43 | ||||
-rw-r--r-- | drivers/xen/gntalloc.c | 2 | ||||
-rw-r--r-- | drivers/xen/gntdev.c | 2 | ||||
-rw-r--r-- | drivers/xen/privcmd.c | 2 | ||||
-rw-r--r-- | drivers/xen/time.c | 50 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/conf_space.c | 22 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/conf_space_header.c | 57 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/pciback.h | 1 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/pciback_ops.c | 2 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/xenbus.c | 10 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe_frontend.c | 15 | ||||
-rw-r--r-- | drivers/xen/xlate_mmu.c | 77 |
18 files changed, 428 insertions, 242 deletions
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index 979a8317204f..f15bb3b789d5 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig | |||
@@ -275,7 +275,7 @@ config XEN_HAVE_PVMMU | |||
275 | 275 | ||
276 | config XEN_EFI | 276 | config XEN_EFI |
277 | def_bool y | 277 | def_bool y |
278 | depends on X86_64 && EFI | 278 | depends on (ARM || ARM64 || X86_64) && EFI |
279 | 279 | ||
280 | config XEN_AUTO_XLATE | 280 | config XEN_AUTO_XLATE |
281 | def_bool y | 281 | def_bool y |
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile index 030e91b38e32..8feab810aed9 100644 --- a/drivers/xen/Makefile +++ b/drivers/xen/Makefile | |||
@@ -10,6 +10,7 @@ CFLAGS_features.o := $(nostackp) | |||
10 | CFLAGS_efi.o += -fshort-wchar | 10 | CFLAGS_efi.o += -fshort-wchar |
11 | LDFLAGS += $(call ld-option, --no-wchar-size-warning) | 11 | LDFLAGS += $(call ld-option, --no-wchar-size-warning) |
12 | 12 | ||
13 | dom0-$(CONFIG_ARM64) += arm-device.o | ||
13 | dom0-$(CONFIG_PCI) += pci.o | 14 | dom0-$(CONFIG_PCI) += pci.o |
14 | dom0-$(CONFIG_USB_SUPPORT) += dbgp.o | 15 | dom0-$(CONFIG_USB_SUPPORT) += dbgp.o |
15 | dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y) | 16 | dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y) |
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c new file mode 100644 index 000000000000..778acf80aacb --- /dev/null +++ b/drivers/xen/arm-device.c | |||
@@ -0,0 +1,196 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2015, Linaro Limited, Shannon Zhao | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/acpi.h> | ||
19 | #include <xen/xen.h> | ||
20 | #include <xen/page.h> | ||
21 | #include <xen/interface/memory.h> | ||
22 | #include <asm/xen/hypervisor.h> | ||
23 | #include <asm/xen/hypercall.h> | ||
24 | |||
25 | static int xen_unmap_device_mmio(const struct resource *resources, | ||
26 | unsigned int count) | ||
27 | { | ||
28 | unsigned int i, j, nr; | ||
29 | int rc = 0; | ||
30 | const struct resource *r; | ||
31 | struct xen_remove_from_physmap xrp; | ||
32 | |||
33 | for (i = 0; i < count; i++) { | ||
34 | r = &resources[i]; | ||
35 | nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE); | ||
36 | if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0)) | ||
37 | continue; | ||
38 | |||
39 | for (j = 0; j < nr; j++) { | ||
40 | xrp.domid = DOMID_SELF; | ||
41 | xrp.gpfn = XEN_PFN_DOWN(r->start) + j; | ||
42 | rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap, | ||
43 | &xrp); | ||
44 | if (rc) | ||
45 | return rc; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | return rc; | ||
50 | } | ||
51 | |||
52 | static int xen_map_device_mmio(const struct resource *resources, | ||
53 | unsigned int count) | ||
54 | { | ||
55 | unsigned int i, j, nr; | ||
56 | int rc = 0; | ||
57 | const struct resource *r; | ||
58 | xen_pfn_t *gpfns; | ||
59 | xen_ulong_t *idxs; | ||
60 | int *errs; | ||
61 | struct xen_add_to_physmap_range xatp; | ||
62 | |||
63 | for (i = 0; i < count; i++) { | ||
64 | r = &resources[i]; | ||
65 | nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE); | ||
66 | if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0)) | ||
67 | continue; | ||
68 | |||
69 | gpfns = kzalloc(sizeof(xen_pfn_t) * nr, GFP_KERNEL); | ||
70 | idxs = kzalloc(sizeof(xen_ulong_t) * nr, GFP_KERNEL); | ||
71 | errs = kzalloc(sizeof(int) * nr, GFP_KERNEL); | ||
72 | if (!gpfns || !idxs || !errs) { | ||
73 | kfree(gpfns); | ||
74 | kfree(idxs); | ||
75 | kfree(errs); | ||
76 | rc = -ENOMEM; | ||
77 | goto unmap; | ||
78 | } | ||
79 | |||
80 | for (j = 0; j < nr; j++) { | ||
81 | /* | ||
82 | * The regions are always mapped 1:1 to DOM0 and this is | ||
83 | * fine because the memory map for DOM0 is the same as | ||
84 | * the host (except for the RAM). | ||
85 | */ | ||
86 | gpfns[j] = XEN_PFN_DOWN(r->start) + j; | ||
87 | idxs[j] = XEN_PFN_DOWN(r->start) + j; | ||
88 | } | ||
89 | |||
90 | xatp.domid = DOMID_SELF; | ||
91 | xatp.size = nr; | ||
92 | xatp.space = XENMAPSPACE_dev_mmio; | ||
93 | |||
94 | set_xen_guest_handle(xatp.gpfns, gpfns); | ||
95 | set_xen_guest_handle(xatp.idxs, idxs); | ||
96 | set_xen_guest_handle(xatp.errs, errs); | ||
97 | |||
98 | rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp); | ||
99 | kfree(gpfns); | ||
100 | kfree(idxs); | ||
101 | kfree(errs); | ||
102 | if (rc) | ||
103 | goto unmap; | ||
104 | } | ||
105 | |||
106 | return rc; | ||
107 | |||
108 | unmap: | ||
109 | xen_unmap_device_mmio(resources, i); | ||
110 | return rc; | ||
111 | } | ||
112 | |||
113 | static int xen_platform_notifier(struct notifier_block *nb, | ||
114 | unsigned long action, void *data) | ||
115 | { | ||
116 | struct platform_device *pdev = to_platform_device(data); | ||
117 | int r = 0; | ||
118 | |||
119 | if (pdev->num_resources == 0 || pdev->resource == NULL) | ||
120 | return NOTIFY_OK; | ||
121 | |||
122 | switch (action) { | ||
123 | case BUS_NOTIFY_ADD_DEVICE: | ||
124 | r = xen_map_device_mmio(pdev->resource, pdev->num_resources); | ||
125 | break; | ||
126 | case BUS_NOTIFY_DEL_DEVICE: | ||
127 | r = xen_unmap_device_mmio(pdev->resource, pdev->num_resources); | ||
128 | break; | ||
129 | default: | ||
130 | return NOTIFY_DONE; | ||
131 | } | ||
132 | if (r) | ||
133 | dev_err(&pdev->dev, "Platform: Failed to %s device %s MMIO!\n", | ||
134 | action == BUS_NOTIFY_ADD_DEVICE ? "map" : | ||
135 | (action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"), | ||
136 | pdev->name); | ||
137 | |||
138 | return NOTIFY_OK; | ||
139 | } | ||
140 | |||
141 | static struct notifier_block platform_device_nb = { | ||
142 | .notifier_call = xen_platform_notifier, | ||
143 | }; | ||
144 | |||
145 | static int __init register_xen_platform_notifier(void) | ||
146 | { | ||
147 | if (!xen_initial_domain() || acpi_disabled) | ||
148 | return 0; | ||
149 | |||
150 | return bus_register_notifier(&platform_bus_type, &platform_device_nb); | ||
151 | } | ||
152 | |||
153 | arch_initcall(register_xen_platform_notifier); | ||
154 | |||
155 | #ifdef CONFIG_ARM_AMBA | ||
156 | #include <linux/amba/bus.h> | ||
157 | |||
158 | static int xen_amba_notifier(struct notifier_block *nb, | ||
159 | unsigned long action, void *data) | ||
160 | { | ||
161 | struct amba_device *adev = to_amba_device(data); | ||
162 | int r = 0; | ||
163 | |||
164 | switch (action) { | ||
165 | case BUS_NOTIFY_ADD_DEVICE: | ||
166 | r = xen_map_device_mmio(&adev->res, 1); | ||
167 | break; | ||
168 | case BUS_NOTIFY_DEL_DEVICE: | ||
169 | r = xen_unmap_device_mmio(&adev->res, 1); | ||
170 | break; | ||
171 | default: | ||
172 | return NOTIFY_DONE; | ||
173 | } | ||
174 | if (r) | ||
175 | dev_err(&adev->dev, "AMBA: Failed to %s device %s MMIO!\n", | ||
176 | action == BUS_NOTIFY_ADD_DEVICE ? "map" : | ||
177 | (action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"), | ||
178 | adev->dev.init_name); | ||
179 | |||
180 | return NOTIFY_OK; | ||
181 | } | ||
182 | |||
183 | static struct notifier_block amba_device_nb = { | ||
184 | .notifier_call = xen_amba_notifier, | ||
185 | }; | ||
186 | |||
187 | static int __init register_xen_amba_notifier(void) | ||
188 | { | ||
189 | if (!xen_initial_domain() || acpi_disabled) | ||
190 | return 0; | ||
191 | |||
192 | return bus_register_notifier(&amba_bustype, &amba_device_nb); | ||
193 | } | ||
194 | |||
195 | arch_initcall(register_xen_amba_notifier); | ||
196 | #endif | ||
diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c index e9d2135445c1..22f71ffd3406 100644 --- a/drivers/xen/efi.c +++ b/drivers/xen/efi.c | |||
@@ -38,7 +38,7 @@ | |||
38 | 38 | ||
39 | #define efi_data(op) (op.u.efi_runtime_call) | 39 | #define efi_data(op) (op.u.efi_runtime_call) |
40 | 40 | ||
41 | static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) | 41 | efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) |
42 | { | 42 | { |
43 | struct xen_platform_op op = INIT_EFI_OP(get_time); | 43 | struct xen_platform_op op = INIT_EFI_OP(get_time); |
44 | 44 | ||
@@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) | |||
59 | 59 | ||
60 | return efi_data(op).status; | 60 | return efi_data(op).status; |
61 | } | 61 | } |
62 | EXPORT_SYMBOL_GPL(xen_efi_get_time); | ||
62 | 63 | ||
63 | static efi_status_t xen_efi_set_time(efi_time_t *tm) | 64 | efi_status_t xen_efi_set_time(efi_time_t *tm) |
64 | { | 65 | { |
65 | struct xen_platform_op op = INIT_EFI_OP(set_time); | 66 | struct xen_platform_op op = INIT_EFI_OP(set_time); |
66 | 67 | ||
@@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm) | |||
72 | 73 | ||
73 | return efi_data(op).status; | 74 | return efi_data(op).status; |
74 | } | 75 | } |
76 | EXPORT_SYMBOL_GPL(xen_efi_set_time); | ||
75 | 77 | ||
76 | static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, | 78 | efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending, |
77 | efi_bool_t *pending, | 79 | efi_time_t *tm) |
78 | efi_time_t *tm) | ||
79 | { | 80 | { |
80 | struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time); | 81 | struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time); |
81 | 82 | ||
@@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, | |||
95 | 96 | ||
96 | return efi_data(op).status; | 97 | return efi_data(op).status; |
97 | } | 98 | } |
99 | EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time); | ||
98 | 100 | ||
99 | static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) | 101 | efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) |
100 | { | 102 | { |
101 | struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time); | 103 | struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time); |
102 | 104 | ||
@@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) | |||
113 | 115 | ||
114 | return efi_data(op).status; | 116 | return efi_data(op).status; |
115 | } | 117 | } |
118 | EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time); | ||
116 | 119 | ||
117 | static efi_status_t xen_efi_get_variable(efi_char16_t *name, | 120 | efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor, |
118 | efi_guid_t *vendor, | 121 | u32 *attr, unsigned long *data_size, |
119 | u32 *attr, | 122 | void *data) |
120 | unsigned long *data_size, | ||
121 | void *data) | ||
122 | { | 123 | { |
123 | struct xen_platform_op op = INIT_EFI_OP(get_variable); | 124 | struct xen_platform_op op = INIT_EFI_OP(get_variable); |
124 | 125 | ||
@@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name, | |||
138 | 139 | ||
139 | return efi_data(op).status; | 140 | return efi_data(op).status; |
140 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(xen_efi_get_variable); | ||
141 | 143 | ||
142 | static efi_status_t xen_efi_get_next_variable(unsigned long *name_size, | 144 | efi_status_t xen_efi_get_next_variable(unsigned long *name_size, |
143 | efi_char16_t *name, | 145 | efi_char16_t *name, |
144 | efi_guid_t *vendor) | 146 | efi_guid_t *vendor) |
145 | { | 147 | { |
146 | struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name); | 148 | struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name); |
147 | 149 | ||
@@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size, | |||
161 | 163 | ||
162 | return efi_data(op).status; | 164 | return efi_data(op).status; |
163 | } | 165 | } |
166 | EXPORT_SYMBOL_GPL(xen_efi_get_next_variable); | ||
164 | 167 | ||
165 | static efi_status_t xen_efi_set_variable(efi_char16_t *name, | 168 | efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor, |
166 | efi_guid_t *vendor, | 169 | u32 attr, unsigned long data_size, |
167 | u32 attr, | 170 | void *data) |
168 | unsigned long data_size, | ||
169 | void *data) | ||
170 | { | 171 | { |
171 | struct xen_platform_op op = INIT_EFI_OP(set_variable); | 172 | struct xen_platform_op op = INIT_EFI_OP(set_variable); |
172 | 173 | ||
@@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name, | |||
183 | 184 | ||
184 | return efi_data(op).status; | 185 | return efi_data(op).status; |
185 | } | 186 | } |
187 | EXPORT_SYMBOL_GPL(xen_efi_set_variable); | ||
186 | 188 | ||
187 | static efi_status_t xen_efi_query_variable_info(u32 attr, | 189 | efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space, |
188 | u64 *storage_space, | 190 | u64 *remaining_space, |
189 | u64 *remaining_space, | 191 | u64 *max_variable_size) |
190 | u64 *max_variable_size) | ||
191 | { | 192 | { |
192 | struct xen_platform_op op = INIT_EFI_OP(query_variable_info); | 193 | struct xen_platform_op op = INIT_EFI_OP(query_variable_info); |
193 | 194 | ||
@@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr, | |||
205 | 206 | ||
206 | return efi_data(op).status; | 207 | return efi_data(op).status; |
207 | } | 208 | } |
209 | EXPORT_SYMBOL_GPL(xen_efi_query_variable_info); | ||
208 | 210 | ||
209 | static efi_status_t xen_efi_get_next_high_mono_count(u32 *count) | 211 | efi_status_t xen_efi_get_next_high_mono_count(u32 *count) |
210 | { | 212 | { |
211 | struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count); | 213 | struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count); |
212 | 214 | ||
@@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count) | |||
217 | 219 | ||
218 | return efi_data(op).status; | 220 | return efi_data(op).status; |
219 | } | 221 | } |
222 | EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count); | ||
220 | 223 | ||
221 | static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules, | 224 | efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules, |
222 | unsigned long count, | 225 | unsigned long count, unsigned long sg_list) |
223 | unsigned long sg_list) | ||
224 | { | 226 | { |
225 | struct xen_platform_op op = INIT_EFI_OP(update_capsule); | 227 | struct xen_platform_op op = INIT_EFI_OP(update_capsule); |
226 | 228 | ||
@@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules, | |||
237 | 239 | ||
238 | return efi_data(op).status; | 240 | return efi_data(op).status; |
239 | } | 241 | } |
242 | EXPORT_SYMBOL_GPL(xen_efi_update_capsule); | ||
240 | 243 | ||
241 | static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules, | 244 | efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules, |
242 | unsigned long count, | 245 | unsigned long count, u64 *max_size, |
243 | u64 *max_size, | 246 | int *reset_type) |
244 | int *reset_type) | ||
245 | { | 247 | { |
246 | struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities); | 248 | struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities); |
247 | 249 | ||
@@ -260,111 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules, | |||
260 | 262 | ||
261 | return efi_data(op).status; | 263 | return efi_data(op).status; |
262 | } | 264 | } |
263 | 265 | EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps); | |
264 | static efi_char16_t vendor[100] __initdata; | ||
265 | |||
266 | static efi_system_table_t efi_systab_xen __initdata = { | ||
267 | .hdr = { | ||
268 | .signature = EFI_SYSTEM_TABLE_SIGNATURE, | ||
269 | .revision = 0, /* Initialized later. */ | ||
270 | .headersize = 0, /* Ignored by Linux Kernel. */ | ||
271 | .crc32 = 0, /* Ignored by Linux Kernel. */ | ||
272 | .reserved = 0 | ||
273 | }, | ||
274 | .fw_vendor = EFI_INVALID_TABLE_ADDR, /* Initialized later. */ | ||
275 | .fw_revision = 0, /* Initialized later. */ | ||
276 | .con_in_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ | ||
277 | .con_in = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ | ||
278 | .con_out_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ | ||
279 | .con_out = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ | ||
280 | .stderr_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ | ||
281 | .stderr = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ | ||
282 | .runtime = (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR, | ||
283 | /* Not used under Xen. */ | ||
284 | .boottime = (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR, | ||
285 | /* Not used under Xen. */ | ||
286 | .nr_tables = 0, /* Initialized later. */ | ||
287 | .tables = EFI_INVALID_TABLE_ADDR /* Initialized later. */ | ||
288 | }; | ||
289 | |||
290 | static const struct efi efi_xen __initconst = { | ||
291 | .systab = NULL, /* Initialized later. */ | ||
292 | .runtime_version = 0, /* Initialized later. */ | ||
293 | .mps = EFI_INVALID_TABLE_ADDR, | ||
294 | .acpi = EFI_INVALID_TABLE_ADDR, | ||
295 | .acpi20 = EFI_INVALID_TABLE_ADDR, | ||
296 | .smbios = EFI_INVALID_TABLE_ADDR, | ||
297 | .smbios3 = EFI_INVALID_TABLE_ADDR, | ||
298 | .sal_systab = EFI_INVALID_TABLE_ADDR, | ||
299 | .boot_info = EFI_INVALID_TABLE_ADDR, | ||
300 | .hcdp = EFI_INVALID_TABLE_ADDR, | ||
301 | .uga = EFI_INVALID_TABLE_ADDR, | ||
302 | .uv_systab = EFI_INVALID_TABLE_ADDR, | ||
303 | .fw_vendor = EFI_INVALID_TABLE_ADDR, | ||
304 | .runtime = EFI_INVALID_TABLE_ADDR, | ||
305 | .config_table = EFI_INVALID_TABLE_ADDR, | ||
306 | .get_time = xen_efi_get_time, | ||
307 | .set_time = xen_efi_set_time, | ||
308 | .get_wakeup_time = xen_efi_get_wakeup_time, | ||
309 | .set_wakeup_time = xen_efi_set_wakeup_time, | ||
310 | .get_variable = xen_efi_get_variable, | ||
311 | .get_next_variable = xen_efi_get_next_variable, | ||
312 | .set_variable = xen_efi_set_variable, | ||
313 | .query_variable_info = xen_efi_query_variable_info, | ||
314 | .update_capsule = xen_efi_update_capsule, | ||
315 | .query_capsule_caps = xen_efi_query_capsule_caps, | ||
316 | .get_next_high_mono_count = xen_efi_get_next_high_mono_count, | ||
317 | .reset_system = NULL, /* Functionality provided by Xen. */ | ||
318 | .set_virtual_address_map = NULL, /* Not used under Xen. */ | ||
319 | .flags = 0 /* Initialized later. */ | ||
320 | }; | ||
321 | |||
322 | efi_system_table_t __init *xen_efi_probe(void) | ||
323 | { | ||
324 | struct xen_platform_op op = { | ||
325 | .cmd = XENPF_firmware_info, | ||
326 | .u.firmware_info = { | ||
327 | .type = XEN_FW_EFI_INFO, | ||
328 | .index = XEN_FW_EFI_CONFIG_TABLE | ||
329 | } | ||
330 | }; | ||
331 | union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info; | ||
332 | |||
333 | if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0) | ||
334 | return NULL; | ||
335 | |||
336 | /* Here we know that Xen runs on EFI platform. */ | ||
337 | |||
338 | efi = efi_xen; | ||
339 | |||
340 | efi_systab_xen.tables = info->cfg.addr; | ||
341 | efi_systab_xen.nr_tables = info->cfg.nent; | ||
342 | |||
343 | op.cmd = XENPF_firmware_info; | ||
344 | op.u.firmware_info.type = XEN_FW_EFI_INFO; | ||
345 | op.u.firmware_info.index = XEN_FW_EFI_VENDOR; | ||
346 | info->vendor.bufsz = sizeof(vendor); | ||
347 | set_xen_guest_handle(info->vendor.name, vendor); | ||
348 | |||
349 | if (HYPERVISOR_platform_op(&op) == 0) { | ||
350 | efi_systab_xen.fw_vendor = __pa_symbol(vendor); | ||
351 | efi_systab_xen.fw_revision = info->vendor.revision; | ||
352 | } else | ||
353 | efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN"); | ||
354 | |||
355 | op.cmd = XENPF_firmware_info; | ||
356 | op.u.firmware_info.type = XEN_FW_EFI_INFO; | ||
357 | op.u.firmware_info.index = XEN_FW_EFI_VERSION; | ||
358 | |||
359 | if (HYPERVISOR_platform_op(&op) == 0) | ||
360 | efi_systab_xen.hdr.revision = info->version; | ||
361 | |||
362 | op.cmd = XENPF_firmware_info; | ||
363 | op.u.firmware_info.type = XEN_FW_EFI_INFO; | ||
364 | op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION; | ||
365 | |||
366 | if (HYPERVISOR_platform_op(&op) == 0) | ||
367 | efi.runtime_version = info->version; | ||
368 | |||
369 | return &efi_systab_xen; | ||
370 | } | ||
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 71d49a95f8c0..d5dbdb9d24d8 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c | |||
@@ -895,7 +895,7 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu) | |||
895 | irq_set_chip_and_handler_name(irq, &xen_percpu_chip, | 895 | irq_set_chip_and_handler_name(irq, &xen_percpu_chip, |
896 | handle_percpu_irq, "ipi"); | 896 | handle_percpu_irq, "ipi"); |
897 | 897 | ||
898 | bind_ipi.vcpu = cpu; | 898 | bind_ipi.vcpu = xen_vcpu_nr(cpu); |
899 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, | 899 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, |
900 | &bind_ipi) != 0) | 900 | &bind_ipi) != 0) |
901 | BUG(); | 901 | BUG(); |
@@ -991,7 +991,7 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu) | |||
991 | handle_edge_irq, "virq"); | 991 | handle_edge_irq, "virq"); |
992 | 992 | ||
993 | bind_virq.virq = virq; | 993 | bind_virq.virq = virq; |
994 | bind_virq.vcpu = cpu; | 994 | bind_virq.vcpu = xen_vcpu_nr(cpu); |
995 | ret = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, | 995 | ret = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, |
996 | &bind_virq); | 996 | &bind_virq); |
997 | if (ret == 0) | 997 | if (ret == 0) |
@@ -1211,7 +1211,8 @@ void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector) | |||
1211 | 1211 | ||
1212 | #ifdef CONFIG_X86 | 1212 | #ifdef CONFIG_X86 |
1213 | if (unlikely(vector == XEN_NMI_VECTOR)) { | 1213 | if (unlikely(vector == XEN_NMI_VECTOR)) { |
1214 | int rc = HYPERVISOR_vcpu_op(VCPUOP_send_nmi, cpu, NULL); | 1214 | int rc = HYPERVISOR_vcpu_op(VCPUOP_send_nmi, xen_vcpu_nr(cpu), |
1215 | NULL); | ||
1215 | if (rc < 0) | 1216 | if (rc < 0) |
1216 | printk(KERN_WARNING "Sending nmi to CPU%d failed (rc:%d)\n", cpu, rc); | 1217 | printk(KERN_WARNING "Sending nmi to CPU%d failed (rc:%d)\n", cpu, rc); |
1217 | return; | 1218 | return; |
@@ -1318,7 +1319,7 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu) | |||
1318 | 1319 | ||
1319 | /* Send future instances of this interrupt to other vcpu. */ | 1320 | /* Send future instances of this interrupt to other vcpu. */ |
1320 | bind_vcpu.port = evtchn; | 1321 | bind_vcpu.port = evtchn; |
1321 | bind_vcpu.vcpu = tcpu; | 1322 | bind_vcpu.vcpu = xen_vcpu_nr(tcpu); |
1322 | 1323 | ||
1323 | /* | 1324 | /* |
1324 | * Mask the event while changing the VCPU binding to prevent | 1325 | * Mask the event while changing the VCPU binding to prevent |
@@ -1458,7 +1459,7 @@ static void restore_cpu_virqs(unsigned int cpu) | |||
1458 | 1459 | ||
1459 | /* Get a new binding from Xen. */ | 1460 | /* Get a new binding from Xen. */ |
1460 | bind_virq.virq = virq; | 1461 | bind_virq.virq = virq; |
1461 | bind_virq.vcpu = cpu; | 1462 | bind_virq.vcpu = xen_vcpu_nr(cpu); |
1462 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, | 1463 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, |
1463 | &bind_virq) != 0) | 1464 | &bind_virq) != 0) |
1464 | BUG(); | 1465 | BUG(); |
@@ -1482,7 +1483,7 @@ static void restore_cpu_ipis(unsigned int cpu) | |||
1482 | BUG_ON(ipi_from_irq(irq) != ipi); | 1483 | BUG_ON(ipi_from_irq(irq) != ipi); |
1483 | 1484 | ||
1484 | /* Get a new binding from Xen. */ | 1485 | /* Get a new binding from Xen. */ |
1485 | bind_ipi.vcpu = cpu; | 1486 | bind_ipi.vcpu = xen_vcpu_nr(cpu); |
1486 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, | 1487 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, |
1487 | &bind_ipi) != 0) | 1488 | &bind_ipi) != 0) |
1488 | BUG(); | 1489 | BUG(); |
diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c index 9289a17712e2..266c2c733039 100644 --- a/drivers/xen/events/events_fifo.c +++ b/drivers/xen/events/events_fifo.c | |||
@@ -113,7 +113,7 @@ static int init_control_block(int cpu, | |||
113 | 113 | ||
114 | init_control.control_gfn = virt_to_gfn(control_block); | 114 | init_control.control_gfn = virt_to_gfn(control_block); |
115 | init_control.offset = 0; | 115 | init_control.offset = 0; |
116 | init_control.vcpu = cpu; | 116 | init_control.vcpu = xen_vcpu_nr(cpu); |
117 | 117 | ||
118 | return HYPERVISOR_event_channel_op(EVTCHNOP_init_control, &init_control); | 118 | return HYPERVISOR_event_channel_op(EVTCHNOP_init_control, &init_control); |
119 | } | 119 | } |
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c index f4edd6df3df2..e8c7f09d01be 100644 --- a/drivers/xen/evtchn.c +++ b/drivers/xen/evtchn.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <xen/xen.h> | 55 | #include <xen/xen.h> |
56 | #include <xen/events.h> | 56 | #include <xen/events.h> |
57 | #include <xen/evtchn.h> | 57 | #include <xen/evtchn.h> |
58 | #include <xen/xen-ops.h> | ||
58 | #include <asm/xen/hypervisor.h> | 59 | #include <asm/xen/hypervisor.h> |
59 | 60 | ||
60 | struct per_user_data { | 61 | struct per_user_data { |
@@ -73,8 +74,12 @@ struct per_user_data { | |||
73 | wait_queue_head_t evtchn_wait; | 74 | wait_queue_head_t evtchn_wait; |
74 | struct fasync_struct *evtchn_async_queue; | 75 | struct fasync_struct *evtchn_async_queue; |
75 | const char *name; | 76 | const char *name; |
77 | |||
78 | domid_t restrict_domid; | ||
76 | }; | 79 | }; |
77 | 80 | ||
81 | #define UNRESTRICTED_DOMID ((domid_t)-1) | ||
82 | |||
78 | struct user_evtchn { | 83 | struct user_evtchn { |
79 | struct rb_node node; | 84 | struct rb_node node; |
80 | struct per_user_data *user; | 85 | struct per_user_data *user; |
@@ -443,12 +448,16 @@ static long evtchn_ioctl(struct file *file, | |||
443 | struct ioctl_evtchn_bind_virq bind; | 448 | struct ioctl_evtchn_bind_virq bind; |
444 | struct evtchn_bind_virq bind_virq; | 449 | struct evtchn_bind_virq bind_virq; |
445 | 450 | ||
451 | rc = -EACCES; | ||
452 | if (u->restrict_domid != UNRESTRICTED_DOMID) | ||
453 | break; | ||
454 | |||
446 | rc = -EFAULT; | 455 | rc = -EFAULT; |
447 | if (copy_from_user(&bind, uarg, sizeof(bind))) | 456 | if (copy_from_user(&bind, uarg, sizeof(bind))) |
448 | break; | 457 | break; |
449 | 458 | ||
450 | bind_virq.virq = bind.virq; | 459 | bind_virq.virq = bind.virq; |
451 | bind_virq.vcpu = 0; | 460 | bind_virq.vcpu = xen_vcpu_nr(0); |
452 | rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, | 461 | rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, |
453 | &bind_virq); | 462 | &bind_virq); |
454 | if (rc != 0) | 463 | if (rc != 0) |
@@ -468,6 +477,11 @@ static long evtchn_ioctl(struct file *file, | |||
468 | if (copy_from_user(&bind, uarg, sizeof(bind))) | 477 | if (copy_from_user(&bind, uarg, sizeof(bind))) |
469 | break; | 478 | break; |
470 | 479 | ||
480 | rc = -EACCES; | ||
481 | if (u->restrict_domid != UNRESTRICTED_DOMID && | ||
482 | u->restrict_domid != bind.remote_domain) | ||
483 | break; | ||
484 | |||
471 | bind_interdomain.remote_dom = bind.remote_domain; | 485 | bind_interdomain.remote_dom = bind.remote_domain; |
472 | bind_interdomain.remote_port = bind.remote_port; | 486 | bind_interdomain.remote_port = bind.remote_port; |
473 | rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, | 487 | rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, |
@@ -485,6 +499,10 @@ static long evtchn_ioctl(struct file *file, | |||
485 | struct ioctl_evtchn_bind_unbound_port bind; | 499 | struct ioctl_evtchn_bind_unbound_port bind; |
486 | struct evtchn_alloc_unbound alloc_unbound; | 500 | struct evtchn_alloc_unbound alloc_unbound; |
487 | 501 | ||
502 | rc = -EACCES; | ||
503 | if (u->restrict_domid != UNRESTRICTED_DOMID) | ||
504 | break; | ||
505 | |||
488 | rc = -EFAULT; | 506 | rc = -EFAULT; |
489 | if (copy_from_user(&bind, uarg, sizeof(bind))) | 507 | if (copy_from_user(&bind, uarg, sizeof(bind))) |
490 | break; | 508 | break; |
@@ -553,6 +571,27 @@ static long evtchn_ioctl(struct file *file, | |||
553 | break; | 571 | break; |
554 | } | 572 | } |
555 | 573 | ||
574 | case IOCTL_EVTCHN_RESTRICT_DOMID: { | ||
575 | struct ioctl_evtchn_restrict_domid ierd; | ||
576 | |||
577 | rc = -EACCES; | ||
578 | if (u->restrict_domid != UNRESTRICTED_DOMID) | ||
579 | break; | ||
580 | |||
581 | rc = -EFAULT; | ||
582 | if (copy_from_user(&ierd, uarg, sizeof(ierd))) | ||
583 | break; | ||
584 | |||
585 | rc = -EINVAL; | ||
586 | if (ierd.domid == 0 || ierd.domid >= DOMID_FIRST_RESERVED) | ||
587 | break; | ||
588 | |||
589 | u->restrict_domid = ierd.domid; | ||
590 | rc = 0; | ||
591 | |||
592 | break; | ||
593 | } | ||
594 | |||
556 | default: | 595 | default: |
557 | rc = -ENOSYS; | 596 | rc = -ENOSYS; |
558 | break; | 597 | break; |
@@ -601,6 +640,8 @@ static int evtchn_open(struct inode *inode, struct file *filp) | |||
601 | mutex_init(&u->ring_cons_mutex); | 640 | mutex_init(&u->ring_cons_mutex); |
602 | spin_lock_init(&u->ring_prod_lock); | 641 | spin_lock_init(&u->ring_prod_lock); |
603 | 642 | ||
643 | u->restrict_domid = UNRESTRICTED_DOMID; | ||
644 | |||
604 | filp->private_data = u; | 645 | filp->private_data = u; |
605 | 646 | ||
606 | return nonseekable_open(inode, filp); | 647 | return nonseekable_open(inode, filp); |
diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c index 4547a91bca67..7a47c4c9fb1b 100644 --- a/drivers/xen/gntalloc.c +++ b/drivers/xen/gntalloc.c | |||
@@ -504,7 +504,7 @@ static int gntalloc_mmap(struct file *filp, struct vm_area_struct *vma) | |||
504 | struct gntalloc_file_private_data *priv = filp->private_data; | 504 | struct gntalloc_file_private_data *priv = filp->private_data; |
505 | struct gntalloc_vma_private_data *vm_priv; | 505 | struct gntalloc_vma_private_data *vm_priv; |
506 | struct gntalloc_gref *gref; | 506 | struct gntalloc_gref *gref; |
507 | int count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 507 | int count = vma_pages(vma); |
508 | int rv, i; | 508 | int rv, i; |
509 | 509 | ||
510 | if (!(vma->vm_flags & VM_SHARED)) { | 510 | if (!(vma->vm_flags & VM_SHARED)) { |
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 67939578cd6d..bb952121ea94 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c | |||
@@ -982,7 +982,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) | |||
982 | { | 982 | { |
983 | struct gntdev_priv *priv = flip->private_data; | 983 | struct gntdev_priv *priv = flip->private_data; |
984 | int index = vma->vm_pgoff; | 984 | int index = vma->vm_pgoff; |
985 | int count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 985 | int count = vma_pages(vma); |
986 | struct grant_map *map; | 986 | struct grant_map *map; |
987 | int i, err = -EINVAL; | 987 | int i, err = -EINVAL; |
988 | 988 | ||
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index df2e6f783318..702040fe2001 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c | |||
@@ -582,7 +582,7 @@ static long privcmd_ioctl(struct file *file, | |||
582 | static void privcmd_close(struct vm_area_struct *vma) | 582 | static void privcmd_close(struct vm_area_struct *vma) |
583 | { | 583 | { |
584 | struct page **pages = vma->vm_private_data; | 584 | struct page **pages = vma->vm_private_data; |
585 | int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 585 | int numpgs = vma_pages(vma); |
586 | int numgfns = (vma->vm_end - vma->vm_start) >> XEN_PAGE_SHIFT; | 586 | int numgfns = (vma->vm_end - vma->vm_start) >> XEN_PAGE_SHIFT; |
587 | int rc; | 587 | int rc; |
588 | 588 | ||
diff --git a/drivers/xen/time.c b/drivers/xen/time.c index 71078425c9ea..ac5f23fcafc2 100644 --- a/drivers/xen/time.c +++ b/drivers/xen/time.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/math64.h> | 6 | #include <linux/math64.h> |
7 | #include <linux/gfp.h> | 7 | #include <linux/gfp.h> |
8 | 8 | ||
9 | #include <asm/paravirt.h> | ||
9 | #include <asm/xen/hypervisor.h> | 10 | #include <asm/xen/hypervisor.h> |
10 | #include <asm/xen/hypercall.h> | 11 | #include <asm/xen/hypercall.h> |
11 | 12 | ||
@@ -46,27 +47,31 @@ static u64 get64(const u64 *p) | |||
46 | return ret; | 47 | return ret; |
47 | } | 48 | } |
48 | 49 | ||
49 | /* | 50 | static void xen_get_runstate_snapshot_cpu(struct vcpu_runstate_info *res, |
50 | * Runstate accounting | 51 | unsigned int cpu) |
51 | */ | ||
52 | void xen_get_runstate_snapshot(struct vcpu_runstate_info *res) | ||
53 | { | 52 | { |
54 | u64 state_time; | 53 | u64 state_time; |
55 | struct vcpu_runstate_info *state; | 54 | struct vcpu_runstate_info *state; |
56 | 55 | ||
57 | BUG_ON(preemptible()); | 56 | BUG_ON(preemptible()); |
58 | 57 | ||
59 | state = this_cpu_ptr(&xen_runstate); | 58 | state = per_cpu_ptr(&xen_runstate, cpu); |
60 | 59 | ||
61 | /* | ||
62 | * The runstate info is always updated by the hypervisor on | ||
63 | * the current CPU, so there's no need to use anything | ||
64 | * stronger than a compiler barrier when fetching it. | ||
65 | */ | ||
66 | do { | 60 | do { |
67 | state_time = get64(&state->state_entry_time); | 61 | state_time = get64(&state->state_entry_time); |
62 | rmb(); /* Hypervisor might update data. */ | ||
68 | *res = READ_ONCE(*state); | 63 | *res = READ_ONCE(*state); |
69 | } while (get64(&state->state_entry_time) != state_time); | 64 | rmb(); /* Hypervisor might update data. */ |
65 | } while (get64(&state->state_entry_time) != state_time || | ||
66 | (state_time & XEN_RUNSTATE_UPDATE)); | ||
67 | } | ||
68 | |||
69 | /* | ||
70 | * Runstate accounting | ||
71 | */ | ||
72 | void xen_get_runstate_snapshot(struct vcpu_runstate_info *res) | ||
73 | { | ||
74 | xen_get_runstate_snapshot_cpu(res, smp_processor_id()); | ||
70 | } | 75 | } |
71 | 76 | ||
72 | /* return true when a vcpu could run but has no real cpu to run on */ | 77 | /* return true when a vcpu could run but has no real cpu to run on */ |
@@ -75,6 +80,14 @@ bool xen_vcpu_stolen(int vcpu) | |||
75 | return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable; | 80 | return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable; |
76 | } | 81 | } |
77 | 82 | ||
83 | u64 xen_steal_clock(int cpu) | ||
84 | { | ||
85 | struct vcpu_runstate_info state; | ||
86 | |||
87 | xen_get_runstate_snapshot_cpu(&state, cpu); | ||
88 | return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline]; | ||
89 | } | ||
90 | |||
78 | void xen_setup_runstate_info(int cpu) | 91 | void xen_setup_runstate_info(int cpu) |
79 | { | 92 | { |
80 | struct vcpu_register_runstate_memory_area area; | 93 | struct vcpu_register_runstate_memory_area area; |
@@ -82,7 +95,20 @@ void xen_setup_runstate_info(int cpu) | |||
82 | area.addr.v = &per_cpu(xen_runstate, cpu); | 95 | area.addr.v = &per_cpu(xen_runstate, cpu); |
83 | 96 | ||
84 | if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, | 97 | if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, |
85 | cpu, &area)) | 98 | xen_vcpu_nr(cpu), &area)) |
86 | BUG(); | 99 | BUG(); |
87 | } | 100 | } |
88 | 101 | ||
102 | void __init xen_time_setup_guest(void) | ||
103 | { | ||
104 | bool xen_runstate_remote; | ||
105 | |||
106 | xen_runstate_remote = !HYPERVISOR_vm_assist(VMASST_CMD_enable, | ||
107 | VMASST_TYPE_runstate_update_flag); | ||
108 | |||
109 | pv_time_ops.steal_clock = xen_steal_clock; | ||
110 | |||
111 | static_key_slow_inc(¶virt_steal_enabled); | ||
112 | if (xen_runstate_remote) | ||
113 | static_key_slow_inc(¶virt_steal_rq_enabled); | ||
114 | } | ||
diff --git a/drivers/xen/xen-pciback/conf_space.c b/drivers/xen/xen-pciback/conf_space.c index 6a25533da237..9e9286d0872e 100644 --- a/drivers/xen/xen-pciback/conf_space.c +++ b/drivers/xen/xen-pciback/conf_space.c | |||
@@ -148,7 +148,7 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size, | |||
148 | struct xen_pcibk_dev_data *dev_data = pci_get_drvdata(dev); | 148 | struct xen_pcibk_dev_data *dev_data = pci_get_drvdata(dev); |
149 | const struct config_field_entry *cfg_entry; | 149 | const struct config_field_entry *cfg_entry; |
150 | const struct config_field *field; | 150 | const struct config_field *field; |
151 | int req_start, req_end, field_start, field_end; | 151 | int field_start, field_end; |
152 | /* if read fails for any reason, return 0 | 152 | /* if read fails for any reason, return 0 |
153 | * (as if device didn't respond) */ | 153 | * (as if device didn't respond) */ |
154 | u32 value = 0, tmp_val; | 154 | u32 value = 0, tmp_val; |
@@ -178,12 +178,10 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size, | |||
178 | list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { | 178 | list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { |
179 | field = cfg_entry->field; | 179 | field = cfg_entry->field; |
180 | 180 | ||
181 | req_start = offset; | ||
182 | req_end = offset + size; | ||
183 | field_start = OFFSET(cfg_entry); | 181 | field_start = OFFSET(cfg_entry); |
184 | field_end = OFFSET(cfg_entry) + field->size; | 182 | field_end = OFFSET(cfg_entry) + field->size; |
185 | 183 | ||
186 | if (req_end > field_start && field_end > req_start) { | 184 | if (offset + size > field_start && field_end > offset) { |
187 | err = conf_space_read(dev, cfg_entry, field_start, | 185 | err = conf_space_read(dev, cfg_entry, field_start, |
188 | &tmp_val); | 186 | &tmp_val); |
189 | if (err) | 187 | if (err) |
@@ -191,7 +189,7 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size, | |||
191 | 189 | ||
192 | value = merge_value(value, tmp_val, | 190 | value = merge_value(value, tmp_val, |
193 | get_mask(field->size), | 191 | get_mask(field->size), |
194 | field_start - req_start); | 192 | field_start - offset); |
195 | } | 193 | } |
196 | } | 194 | } |
197 | 195 | ||
@@ -211,7 +209,7 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value) | |||
211 | const struct config_field_entry *cfg_entry; | 209 | const struct config_field_entry *cfg_entry; |
212 | const struct config_field *field; | 210 | const struct config_field *field; |
213 | u32 tmp_val; | 211 | u32 tmp_val; |
214 | int req_start, req_end, field_start, field_end; | 212 | int field_start, field_end; |
215 | 213 | ||
216 | if (unlikely(verbose_request)) | 214 | if (unlikely(verbose_request)) |
217 | printk(KERN_DEBUG | 215 | printk(KERN_DEBUG |
@@ -224,21 +222,17 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value) | |||
224 | list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { | 222 | list_for_each_entry(cfg_entry, &dev_data->config_fields, list) { |
225 | field = cfg_entry->field; | 223 | field = cfg_entry->field; |
226 | 224 | ||
227 | req_start = offset; | ||
228 | req_end = offset + size; | ||
229 | field_start = OFFSET(cfg_entry); | 225 | field_start = OFFSET(cfg_entry); |
230 | field_end = OFFSET(cfg_entry) + field->size; | 226 | field_end = OFFSET(cfg_entry) + field->size; |
231 | 227 | ||
232 | if (req_end > field_start && field_end > req_start) { | 228 | if (offset + size > field_start && field_end > offset) { |
233 | tmp_val = 0; | 229 | err = conf_space_read(dev, cfg_entry, field_start, |
234 | 230 | &tmp_val); | |
235 | err = xen_pcibk_config_read(dev, field_start, | ||
236 | field->size, &tmp_val); | ||
237 | if (err) | 231 | if (err) |
238 | break; | 232 | break; |
239 | 233 | ||
240 | tmp_val = merge_value(tmp_val, value, get_mask(size), | 234 | tmp_val = merge_value(tmp_val, value, get_mask(size), |
241 | req_start - field_start); | 235 | offset - field_start); |
242 | 236 | ||
243 | err = conf_space_write(dev, cfg_entry, field_start, | 237 | err = conf_space_write(dev, cfg_entry, field_start, |
244 | tmp_val); | 238 | tmp_val); |
diff --git a/drivers/xen/xen-pciback/conf_space_header.c b/drivers/xen/xen-pciback/conf_space_header.c index 9ead1c2ff1dd..5fbfd9cfb6d6 100644 --- a/drivers/xen/xen-pciback/conf_space_header.c +++ b/drivers/xen/xen-pciback/conf_space_header.c | |||
@@ -209,58 +209,35 @@ static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data) | |||
209 | return 0; | 209 | return 0; |
210 | } | 210 | } |
211 | 211 | ||
212 | static inline void read_dev_bar(struct pci_dev *dev, | 212 | static void *bar_init(struct pci_dev *dev, int offset) |
213 | struct pci_bar_info *bar_info, int offset, | ||
214 | u32 len_mask) | ||
215 | { | 213 | { |
216 | int pos; | 214 | unsigned int pos; |
217 | struct resource *res = dev->resource; | 215 | const struct resource *res = dev->resource; |
216 | struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL); | ||
217 | |||
218 | if (!bar) | ||
219 | return ERR_PTR(-ENOMEM); | ||
218 | 220 | ||
219 | if (offset == PCI_ROM_ADDRESS || offset == PCI_ROM_ADDRESS1) | 221 | if (offset == PCI_ROM_ADDRESS || offset == PCI_ROM_ADDRESS1) |
220 | pos = PCI_ROM_RESOURCE; | 222 | pos = PCI_ROM_RESOURCE; |
221 | else { | 223 | else { |
222 | pos = (offset - PCI_BASE_ADDRESS_0) / 4; | 224 | pos = (offset - PCI_BASE_ADDRESS_0) / 4; |
223 | if (pos && ((res[pos - 1].flags & (PCI_BASE_ADDRESS_SPACE | | 225 | if (pos && (res[pos - 1].flags & IORESOURCE_MEM_64)) { |
224 | PCI_BASE_ADDRESS_MEM_TYPE_MASK)) == | 226 | bar->val = res[pos - 1].start >> 32; |
225 | (PCI_BASE_ADDRESS_SPACE_MEMORY | | 227 | bar->len_val = -resource_size(&res[pos - 1]) >> 32; |
226 | PCI_BASE_ADDRESS_MEM_TYPE_64))) { | 228 | return bar; |
227 | bar_info->val = res[pos - 1].start >> 32; | ||
228 | bar_info->len_val = -resource_size(&res[pos - 1]) >> 32; | ||
229 | return; | ||
230 | } | 229 | } |
231 | } | 230 | } |
232 | 231 | ||
233 | if (!res[pos].flags || | 232 | if (!res[pos].flags || |
234 | (res[pos].flags & (IORESOURCE_DISABLED | IORESOURCE_UNSET | | 233 | (res[pos].flags & (IORESOURCE_DISABLED | IORESOURCE_UNSET | |
235 | IORESOURCE_BUSY))) | 234 | IORESOURCE_BUSY))) |
236 | return; | 235 | return bar; |
237 | |||
238 | bar_info->val = res[pos].start | | ||
239 | (res[pos].flags & PCI_REGION_FLAG_MASK); | ||
240 | bar_info->len_val = -resource_size(&res[pos]) | | ||
241 | (res[pos].flags & PCI_REGION_FLAG_MASK); | ||
242 | } | ||
243 | 236 | ||
244 | static void *bar_init(struct pci_dev *dev, int offset) | 237 | bar->val = res[pos].start | |
245 | { | 238 | (res[pos].flags & PCI_REGION_FLAG_MASK); |
246 | struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL); | 239 | bar->len_val = -resource_size(&res[pos]) | |
247 | 240 | (res[pos].flags & PCI_REGION_FLAG_MASK); | |
248 | if (!bar) | ||
249 | return ERR_PTR(-ENOMEM); | ||
250 | |||
251 | read_dev_bar(dev, bar, offset, ~0); | ||
252 | |||
253 | return bar; | ||
254 | } | ||
255 | |||
256 | static void *rom_init(struct pci_dev *dev, int offset) | ||
257 | { | ||
258 | struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL); | ||
259 | |||
260 | if (!bar) | ||
261 | return ERR_PTR(-ENOMEM); | ||
262 | |||
263 | read_dev_bar(dev, bar, offset, ~PCI_ROM_ADDRESS_ENABLE); | ||
264 | 241 | ||
265 | return bar; | 242 | return bar; |
266 | } | 243 | } |
@@ -383,7 +360,7 @@ static const struct config_field header_common[] = { | |||
383 | { \ | 360 | { \ |
384 | .offset = reg_offset, \ | 361 | .offset = reg_offset, \ |
385 | .size = 4, \ | 362 | .size = 4, \ |
386 | .init = rom_init, \ | 363 | .init = bar_init, \ |
387 | .reset = bar_reset, \ | 364 | .reset = bar_reset, \ |
388 | .release = bar_release, \ | 365 | .release = bar_release, \ |
389 | .u.dw.read = bar_read, \ | 366 | .u.dw.read = bar_read, \ |
diff --git a/drivers/xen/xen-pciback/pciback.h b/drivers/xen/xen-pciback/pciback.h index 4d529f3e40df..7af369b6aaa2 100644 --- a/drivers/xen/xen-pciback/pciback.h +++ b/drivers/xen/xen-pciback/pciback.h | |||
@@ -55,7 +55,6 @@ struct xen_pcibk_dev_data { | |||
55 | 55 | ||
56 | /* Used by XenBus and xen_pcibk_ops.c */ | 56 | /* Used by XenBus and xen_pcibk_ops.c */ |
57 | extern wait_queue_head_t xen_pcibk_aer_wait_queue; | 57 | extern wait_queue_head_t xen_pcibk_aer_wait_queue; |
58 | extern struct workqueue_struct *xen_pcibk_wq; | ||
59 | /* Used by pcistub.c and conf_space_quirks.c */ | 58 | /* Used by pcistub.c and conf_space_quirks.c */ |
60 | extern struct list_head xen_pcibk_quirks; | 59 | extern struct list_head xen_pcibk_quirks; |
61 | 60 | ||
diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c index 2f19dd7553e6..f8c77751f330 100644 --- a/drivers/xen/xen-pciback/pciback_ops.c +++ b/drivers/xen/xen-pciback/pciback_ops.c | |||
@@ -310,7 +310,7 @@ void xen_pcibk_test_and_schedule_op(struct xen_pcibk_device *pdev) | |||
310 | * already processing a request */ | 310 | * already processing a request */ |
311 | if (test_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags) | 311 | if (test_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags) |
312 | && !test_and_set_bit(_PDEVF_op_active, &pdev->flags)) { | 312 | && !test_and_set_bit(_PDEVF_op_active, &pdev->flags)) { |
313 | queue_work(xen_pcibk_wq, &pdev->op_work); | 313 | schedule_work(&pdev->op_work); |
314 | } | 314 | } |
315 | /*_XEN_PCIB_active should have been cleared by pcifront. And also make | 315 | /*_XEN_PCIB_active should have been cleared by pcifront. And also make |
316 | sure xen_pcibk is waiting for ack by checking _PCIB_op_pending*/ | 316 | sure xen_pcibk is waiting for ack by checking _PCIB_op_pending*/ |
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c index c252eb3f0176..5ce878c51d03 100644 --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include "pciback.h" | 17 | #include "pciback.h" |
18 | 18 | ||
19 | #define INVALID_EVTCHN_IRQ (-1) | 19 | #define INVALID_EVTCHN_IRQ (-1) |
20 | struct workqueue_struct *xen_pcibk_wq; | ||
21 | 20 | ||
22 | static bool __read_mostly passthrough; | 21 | static bool __read_mostly passthrough; |
23 | module_param(passthrough, bool, S_IRUGO); | 22 | module_param(passthrough, bool, S_IRUGO); |
@@ -76,8 +75,7 @@ static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev) | |||
76 | /* If the driver domain started an op, make sure we complete it | 75 | /* If the driver domain started an op, make sure we complete it |
77 | * before releasing the shared memory */ | 76 | * before releasing the shared memory */ |
78 | 77 | ||
79 | /* Note, the workqueue does not use spinlocks at all.*/ | 78 | flush_work(&pdev->op_work); |
80 | flush_workqueue(xen_pcibk_wq); | ||
81 | 79 | ||
82 | if (pdev->sh_info != NULL) { | 80 | if (pdev->sh_info != NULL) { |
83 | xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info); | 81 | xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info); |
@@ -733,11 +731,6 @@ const struct xen_pcibk_backend *__read_mostly xen_pcibk_backend; | |||
733 | 731 | ||
734 | int __init xen_pcibk_xenbus_register(void) | 732 | int __init xen_pcibk_xenbus_register(void) |
735 | { | 733 | { |
736 | xen_pcibk_wq = create_workqueue("xen_pciback_workqueue"); | ||
737 | if (!xen_pcibk_wq) { | ||
738 | pr_err("%s: create xen_pciback_workqueue failed\n", __func__); | ||
739 | return -EFAULT; | ||
740 | } | ||
741 | xen_pcibk_backend = &xen_pcibk_vpci_backend; | 734 | xen_pcibk_backend = &xen_pcibk_vpci_backend; |
742 | if (passthrough) | 735 | if (passthrough) |
743 | xen_pcibk_backend = &xen_pcibk_passthrough_backend; | 736 | xen_pcibk_backend = &xen_pcibk_passthrough_backend; |
@@ -747,6 +740,5 @@ int __init xen_pcibk_xenbus_register(void) | |||
747 | 740 | ||
748 | void __exit xen_pcibk_xenbus_unregister(void) | 741 | void __exit xen_pcibk_xenbus_unregister(void) |
749 | { | 742 | { |
750 | destroy_workqueue(xen_pcibk_wq); | ||
751 | xenbus_unregister_driver(&xen_pcibk_driver); | 743 | xenbus_unregister_driver(&xen_pcibk_driver); |
752 | } | 744 | } |
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c index bcb53bdc469c..611a23119675 100644 --- a/drivers/xen/xenbus/xenbus_probe_frontend.c +++ b/drivers/xen/xenbus/xenbus_probe_frontend.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include "xenbus_probe.h" | 31 | #include "xenbus_probe.h" |
32 | 32 | ||
33 | 33 | ||
34 | static struct workqueue_struct *xenbus_frontend_wq; | ||
35 | 34 | ||
36 | /* device/<type>/<id> => <type>-<id> */ | 35 | /* device/<type>/<id> => <type>-<id> */ |
37 | static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename) | 36 | static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename) |
@@ -109,13 +108,7 @@ static int xenbus_frontend_dev_resume(struct device *dev) | |||
109 | if (xen_store_domain_type == XS_LOCAL) { | 108 | if (xen_store_domain_type == XS_LOCAL) { |
110 | struct xenbus_device *xdev = to_xenbus_device(dev); | 109 | struct xenbus_device *xdev = to_xenbus_device(dev); |
111 | 110 | ||
112 | if (!xenbus_frontend_wq) { | 111 | schedule_work(&xdev->work); |
113 | pr_err("%s: no workqueue to process delayed resume\n", | ||
114 | xdev->nodename); | ||
115 | return -EFAULT; | ||
116 | } | ||
117 | |||
118 | queue_work(xenbus_frontend_wq, &xdev->work); | ||
119 | 112 | ||
120 | return 0; | 113 | return 0; |
121 | } | 114 | } |
@@ -485,12 +478,6 @@ static int __init xenbus_probe_frontend_init(void) | |||
485 | 478 | ||
486 | register_xenstore_notifier(&xenstore_notifier); | 479 | register_xenstore_notifier(&xenstore_notifier); |
487 | 480 | ||
488 | if (xen_store_domain_type == XS_LOCAL) { | ||
489 | xenbus_frontend_wq = create_workqueue("xenbus_frontend"); | ||
490 | if (!xenbus_frontend_wq) | ||
491 | pr_warn("create xenbus frontend workqueue failed, S3 resume is likely to fail\n"); | ||
492 | } | ||
493 | |||
494 | return 0; | 481 | return 0; |
495 | } | 482 | } |
496 | subsys_initcall(xenbus_probe_frontend_init); | 483 | subsys_initcall(xenbus_probe_frontend_init); |
diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c index 5063c5e796b7..23f1387b3ef7 100644 --- a/drivers/xen/xlate_mmu.c +++ b/drivers/xen/xlate_mmu.c | |||
@@ -29,6 +29,8 @@ | |||
29 | */ | 29 | */ |
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | #include <linux/mm.h> | 31 | #include <linux/mm.h> |
32 | #include <linux/slab.h> | ||
33 | #include <linux/vmalloc.h> | ||
32 | 34 | ||
33 | #include <asm/xen/hypercall.h> | 35 | #include <asm/xen/hypercall.h> |
34 | #include <asm/xen/hypervisor.h> | 36 | #include <asm/xen/hypervisor.h> |
@@ -37,6 +39,7 @@ | |||
37 | #include <xen/page.h> | 39 | #include <xen/page.h> |
38 | #include <xen/interface/xen.h> | 40 | #include <xen/interface/xen.h> |
39 | #include <xen/interface/memory.h> | 41 | #include <xen/interface/memory.h> |
42 | #include <xen/balloon.h> | ||
40 | 43 | ||
41 | typedef void (*xen_gfn_fn_t)(unsigned long gfn, void *data); | 44 | typedef void (*xen_gfn_fn_t)(unsigned long gfn, void *data); |
42 | 45 | ||
@@ -185,3 +188,77 @@ int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma, | |||
185 | return 0; | 188 | return 0; |
186 | } | 189 | } |
187 | EXPORT_SYMBOL_GPL(xen_xlate_unmap_gfn_range); | 190 | EXPORT_SYMBOL_GPL(xen_xlate_unmap_gfn_range); |
191 | |||
192 | struct map_balloon_pages { | ||
193 | xen_pfn_t *pfns; | ||
194 | unsigned int idx; | ||
195 | }; | ||
196 | |||
197 | static void setup_balloon_gfn(unsigned long gfn, void *data) | ||
198 | { | ||
199 | struct map_balloon_pages *info = data; | ||
200 | |||
201 | info->pfns[info->idx++] = gfn; | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * xen_xlate_map_ballooned_pages - map a new set of ballooned pages | ||
206 | * @gfns: returns the array of corresponding GFNs | ||
207 | * @virt: returns the virtual address of the mapped region | ||
208 | * @nr_grant_frames: number of GFNs | ||
209 | * @return 0 on success, error otherwise | ||
210 | * | ||
211 | * This allocates a set of ballooned pages and maps them into the | ||
212 | * kernel's address space. | ||
213 | */ | ||
214 | int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt, | ||
215 | unsigned long nr_grant_frames) | ||
216 | { | ||
217 | struct page **pages; | ||
218 | xen_pfn_t *pfns; | ||
219 | void *vaddr; | ||
220 | struct map_balloon_pages data; | ||
221 | int rc; | ||
222 | unsigned long nr_pages; | ||
223 | |||
224 | BUG_ON(nr_grant_frames == 0); | ||
225 | nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE); | ||
226 | pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL); | ||
227 | if (!pages) | ||
228 | return -ENOMEM; | ||
229 | |||
230 | pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL); | ||
231 | if (!pfns) { | ||
232 | kfree(pages); | ||
233 | return -ENOMEM; | ||
234 | } | ||
235 | rc = alloc_xenballooned_pages(nr_pages, pages); | ||
236 | if (rc) { | ||
237 | pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__, | ||
238 | nr_pages, rc); | ||
239 | kfree(pages); | ||
240 | kfree(pfns); | ||
241 | return rc; | ||
242 | } | ||
243 | |||
244 | data.pfns = pfns; | ||
245 | data.idx = 0; | ||
246 | xen_for_each_gfn(pages, nr_grant_frames, setup_balloon_gfn, &data); | ||
247 | |||
248 | vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL); | ||
249 | if (!vaddr) { | ||
250 | pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__, | ||
251 | nr_pages, rc); | ||
252 | free_xenballooned_pages(nr_pages, pages); | ||
253 | kfree(pages); | ||
254 | kfree(pfns); | ||
255 | return -ENOMEM; | ||
256 | } | ||
257 | kfree(pages); | ||
258 | |||
259 | *gfns = pfns; | ||
260 | *virt = vaddr; | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | EXPORT_SYMBOL_GPL(xen_xlate_map_ballooned_pages); | ||