Merge tag 'for-linus-4.20a-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 2 Dec 2018 20:15:55 +0000 (12:15 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 2 Dec 2018 20:15:55 +0000 (12:15 -0800)
Pull xen fixes from Juergen Gross:

 - A revert of a previous commit as it is no longer necessary and has
   shown to cause problems in some memory hotplug cases.

 - Some small fixes and a minor cleanup.

 - A patch for adding better diagnostic data in a very rare failure
   case.

* tag 'for-linus-4.20a-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  pvcalls-front: fixes incorrect error handling
  Revert "xen/balloon: Mark unallocated host memory as UNUSABLE"
  xen: xlate_mmu: add missing header to fix 'W=1' warning
  xen/x86: add diagnostic printout to xen_mc_flush() in case of error
  x86/xen: cleanup includes in arch/x86/xen/spinlock.c

1  2 
arch/x86/xen/enlighten.c
drivers/xen/balloon.c

diff --combined arch/x86/xen/enlighten.c
index e996e8e744cbab90ecaca0ea17f07048465e208b,aa1cc483bd2a228c6b1f872314516b14720ef847..750f46ad018a0e0e500bf5dd60da2f7901a54f89
@@@ -1,7 -1,7 +1,7 @@@
  // SPDX-License-Identifier: GPL-2.0
  
  #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
 -#include <linux/bootmem.h>
 +#include <linux/memblock.h>
  #endif
  #include <linux/cpu.h>
  #include <linux/kexec.h>
@@@ -10,7 -10,6 +10,6 @@@
  #include <xen/xen.h>
  #include <xen/features.h>
  #include <xen/page.h>
- #include <xen/interface/memory.h>
  
  #include <asm/xen/hypercall.h>
  #include <asm/xen/hypervisor.h>
@@@ -346,80 -345,3 +345,3 @@@ void xen_arch_unregister_cpu(int num
  }
  EXPORT_SYMBOL(xen_arch_unregister_cpu);
  #endif
- #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
- void __init arch_xen_balloon_init(struct resource *hostmem_resource)
- {
-       struct xen_memory_map memmap;
-       int rc;
-       unsigned int i, last_guest_ram;
-       phys_addr_t max_addr = PFN_PHYS(max_pfn);
-       struct e820_table *xen_e820_table;
-       const struct e820_entry *entry;
-       struct resource *res;
-       if (!xen_initial_domain())
-               return;
-       xen_e820_table = kmalloc(sizeof(*xen_e820_table), GFP_KERNEL);
-       if (!xen_e820_table)
-               return;
-       memmap.nr_entries = ARRAY_SIZE(xen_e820_table->entries);
-       set_xen_guest_handle(memmap.buffer, xen_e820_table->entries);
-       rc = HYPERVISOR_memory_op(XENMEM_machine_memory_map, &memmap);
-       if (rc) {
-               pr_warn("%s: Can't read host e820 (%d)\n", __func__, rc);
-               goto out;
-       }
-       last_guest_ram = 0;
-       for (i = 0; i < memmap.nr_entries; i++) {
-               if (xen_e820_table->entries[i].addr >= max_addr)
-                       break;
-               if (xen_e820_table->entries[i].type == E820_TYPE_RAM)
-                       last_guest_ram = i;
-       }
-       entry = &xen_e820_table->entries[last_guest_ram];
-       if (max_addr >= entry->addr + entry->size)
-               goto out; /* No unallocated host RAM. */
-       hostmem_resource->start = max_addr;
-       hostmem_resource->end = entry->addr + entry->size;
-       /*
-        * Mark non-RAM regions between the end of dom0 RAM and end of host RAM
-        * as unavailable. The rest of that region can be used for hotplug-based
-        * ballooning.
-        */
-       for (; i < memmap.nr_entries; i++) {
-               entry = &xen_e820_table->entries[i];
-               if (entry->type == E820_TYPE_RAM)
-                       continue;
-               if (entry->addr >= hostmem_resource->end)
-                       break;
-               res = kzalloc(sizeof(*res), GFP_KERNEL);
-               if (!res)
-                       goto out;
-               res->name = "Unavailable host RAM";
-               res->start = entry->addr;
-               res->end = (entry->addr + entry->size < hostmem_resource->end) ?
-                           entry->addr + entry->size : hostmem_resource->end;
-               rc = insert_resource(hostmem_resource, res);
-               if (rc) {
-                       pr_warn("%s: Can't insert [%llx - %llx) (%d)\n",
-                               __func__, res->start, res->end, rc);
-                       kfree(res);
-                       goto  out;
-               }
-       }
-  out:
-       kfree(xen_e820_table);
- }
- #endif /* CONFIG_XEN_BALLOON_MEMORY_HOTPLUG */
diff --combined drivers/xen/balloon.c
index fdfc64f5aceaa807e392b887d278daf466de3eae,7ab6caef599c59c57e1de6e25b03a073652472c7..221b7333d067bc95c262a3eee4913ea70dfde1bd
@@@ -44,7 -44,7 +44,7 @@@
  #include <linux/cred.h>
  #include <linux/errno.h>
  #include <linux/mm.h>
 -#include <linux/bootmem.h>
 +#include <linux/memblock.h>
  #include <linux/pagemap.h>
  #include <linux/highmem.h>
  #include <linux/mutex.h>
@@@ -251,25 -251,10 +251,10 @@@ static void release_memory_resource(str
        kfree(resource);
  }
  
- /*
-  * Host memory not allocated to dom0. We can use this range for hotplug-based
-  * ballooning.
-  *
-  * It's a type-less resource. Setting IORESOURCE_MEM will make resource
-  * management algorithms (arch_remove_reservations()) look into guest e820,
-  * which we don't want.
-  */
- static struct resource hostmem_resource = {
-       .name   = "Host RAM",
- };
- void __attribute__((weak)) __init arch_xen_balloon_init(struct resource *res)
- {}
  static struct resource *additional_memory_resource(phys_addr_t size)
  {
-       struct resource *res, *res_hostmem;
-       int ret = -ENOMEM;
+       struct resource *res;
+       int ret;
  
        res = kzalloc(sizeof(*res), GFP_KERNEL);
        if (!res)
        res->name = "System RAM";
        res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
  
-       res_hostmem = kzalloc(sizeof(*res), GFP_KERNEL);
-       if (res_hostmem) {
-               /* Try to grab a range from hostmem */
-               res_hostmem->name = "Host memory";
-               ret = allocate_resource(&hostmem_resource, res_hostmem,
-                                       size, 0, -1,
-                                       PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
-       }
-       if (!ret) {
-               /*
-                * Insert this resource into iomem. Because hostmem_resource
-                * tracks portion of guest e820 marked as UNUSABLE noone else
-                * should try to use it.
-                */
-               res->start = res_hostmem->start;
-               res->end = res_hostmem->end;
-               ret = insert_resource(&iomem_resource, res);
-               if (ret < 0) {
-                       pr_err("Can't insert iomem_resource [%llx - %llx]\n",
-                               res->start, res->end);
-                       release_memory_resource(res_hostmem);
-                       res_hostmem = NULL;
-                       res->start = res->end = 0;
-               }
-       }
-       if (ret) {
-               ret = allocate_resource(&iomem_resource, res,
-                                       size, 0, -1,
-                                       PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
-               if (ret < 0) {
-                       pr_err("Cannot allocate new System RAM resource\n");
-                       kfree(res);
-                       return NULL;
-               }
+       ret = allocate_resource(&iomem_resource, res,
+                               size, 0, -1,
+                               PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
+       if (ret < 0) {
+               pr_err("Cannot allocate new System RAM resource\n");
+               kfree(res);
+               return NULL;
        }
  
  #ifdef CONFIG_SPARSEMEM
                        pr_err("New System RAM resource outside addressable RAM (%lu > %lu)\n",
                               pfn, limit);
                        release_memory_resource(res);
-                       release_memory_resource(res_hostmem);
                        return NULL;
                }
        }
@@@ -395,10 -350,7 +350,10 @@@ static enum bp_state reserve_additional
         * callers drop the mutex before trying again.
         */
        mutex_unlock(&balloon_mutex);
 +      /* add_memory_resource() requires the device_hotplug lock */
 +      lock_device_hotplug();
        rc = add_memory_resource(nid, resource, memhp_auto_online);
 +      unlock_device_hotplug();
        mutex_lock(&balloon_mutex);
  
        if (rc) {
@@@ -750,8 -702,6 +705,6 @@@ static int __init balloon_init(void
        set_online_page_callback(&xen_online_page);
        register_memory_notifier(&xen_memory_nb);
        register_sysctl_table(xen_root);
-       arch_xen_balloon_init(&hostmem_resource);
  #endif
  
  #ifdef CONFIG_XEN_PV