aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorIgor Druzhinin <igor.druzhinin@citrix.com>2018-11-27 15:58:21 -0500
committerJuergen Gross <jgross@suse.com>2018-11-29 11:53:31 -0500
commit123664101aa2156d05251704fc63f9bcbf77741a (patch)
tree0e64c51976e70e1e01702e6d6646633427da5f44 /drivers/xen
parent72791ac854fea36034fa7976b748fde585008e78 (diff)
Revert "xen/balloon: Mark unallocated host memory as UNUSABLE"
This reverts commit b3cf8528bb21febb650a7ecbf080d0647be40b9f. That commit unintentionally broke Xen balloon memory hotplug with "hotplug_unpopulated" set to 1. As long as "System RAM" resource got assigned under a new "Unusable memory" resource in IO/Mem tree any attempt to online this memory would fail due to general kernel restrictions on having "System RAM" resources as 1st level only. The original issue that commit has tried to workaround fa564ad96366 ("x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 00-1f, 30-3f, 60-7f)") also got amended by the following 03a551734 ("x86/PCI: Move and shrink AMD 64-bit window to avoid conflict") which made the original fix to Xen ballooning unnecessary. Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/balloon.c65
1 files changed, 9 insertions, 56 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index e12bb256036f..7ab6caef599c 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -251,25 +251,10 @@ static void release_memory_resource(struct resource *resource)
251 kfree(resource); 251 kfree(resource);
252} 252}
253 253
254/*
255 * Host memory not allocated to dom0. We can use this range for hotplug-based
256 * ballooning.
257 *
258 * It's a type-less resource. Setting IORESOURCE_MEM will make resource
259 * management algorithms (arch_remove_reservations()) look into guest e820,
260 * which we don't want.
261 */
262static struct resource hostmem_resource = {
263 .name = "Host RAM",
264};
265
266void __attribute__((weak)) __init arch_xen_balloon_init(struct resource *res)
267{}
268
269static struct resource *additional_memory_resource(phys_addr_t size) 254static struct resource *additional_memory_resource(phys_addr_t size)
270{ 255{
271 struct resource *res, *res_hostmem; 256 struct resource *res;
272 int ret = -ENOMEM; 257 int ret;
273 258
274 res = kzalloc(sizeof(*res), GFP_KERNEL); 259 res = kzalloc(sizeof(*res), GFP_KERNEL);
275 if (!res) 260 if (!res)
@@ -278,42 +263,13 @@ static struct resource *additional_memory_resource(phys_addr_t size)
278 res->name = "System RAM"; 263 res->name = "System RAM";
279 res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; 264 res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
280 265
281 res_hostmem = kzalloc(sizeof(*res), GFP_KERNEL); 266 ret = allocate_resource(&iomem_resource, res,
282 if (res_hostmem) { 267 size, 0, -1,
283 /* Try to grab a range from hostmem */ 268 PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
284 res_hostmem->name = "Host memory"; 269 if (ret < 0) {
285 ret = allocate_resource(&hostmem_resource, res_hostmem, 270 pr_err("Cannot allocate new System RAM resource\n");
286 size, 0, -1, 271 kfree(res);
287 PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL); 272 return NULL;
288 }
289
290 if (!ret) {
291 /*
292 * Insert this resource into iomem. Because hostmem_resource
293 * tracks portion of guest e820 marked as UNUSABLE noone else
294 * should try to use it.
295 */
296 res->start = res_hostmem->start;
297 res->end = res_hostmem->end;
298 ret = insert_resource(&iomem_resource, res);
299 if (ret < 0) {
300 pr_err("Can't insert iomem_resource [%llx - %llx]\n",
301 res->start, res->end);
302 release_memory_resource(res_hostmem);
303 res_hostmem = NULL;
304 res->start = res->end = 0;
305 }
306 }
307
308 if (ret) {
309 ret = allocate_resource(&iomem_resource, res,
310 size, 0, -1,
311 PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
312 if (ret < 0) {
313 pr_err("Cannot allocate new System RAM resource\n");
314 kfree(res);
315 return NULL;
316 }
317 } 273 }
318 274
319#ifdef CONFIG_SPARSEMEM 275#ifdef CONFIG_SPARSEMEM
@@ -325,7 +281,6 @@ static struct resource *additional_memory_resource(phys_addr_t size)
325 pr_err("New System RAM resource outside addressable RAM (%lu > %lu)\n", 281 pr_err("New System RAM resource outside addressable RAM (%lu > %lu)\n",
326 pfn, limit); 282 pfn, limit);
327 release_memory_resource(res); 283 release_memory_resource(res);
328 release_memory_resource(res_hostmem);
329 return NULL; 284 return NULL;
330 } 285 }
331 } 286 }
@@ -747,8 +702,6 @@ static int __init balloon_init(void)
747 set_online_page_callback(&xen_online_page); 702 set_online_page_callback(&xen_online_page);
748 register_memory_notifier(&xen_memory_nb); 703 register_memory_notifier(&xen_memory_nb);
749 register_sysctl_table(xen_root); 704 register_sysctl_table(xen_root);
750
751 arch_xen_balloon_init(&hostmem_resource);
752#endif 705#endif
753 706
754#ifdef CONFIG_XEN_PV 707#ifdef CONFIG_XEN_PV