Merge tag 'for-linus-4.6-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2016 19:55:17 +0000 (12:55 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2016 19:55:17 +0000 (12:55 -0700)
Pull xen updates from David Vrabel:
 "Features and fixes for 4.6:

  - Make earlyprintk=xen work for HVM guests

  - Remove module support for things never built as modules"

* tag 'for-linus-4.6-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  drivers/xen: make platform-pci.c explicitly non-modular
  drivers/xen: make sys-hypervisor.c explicitly non-modular
  drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular
  drivers/xen: make [xen-]ballon explicitly non-modular
  xen: audit usages of module.h ; remove unnecessary instances
  xen/x86: Drop mode-selecting ifdefs in startup_xen()
  xen/x86: Zero out .bss for PV guests
  hvc_xen: make early_printk work with HVM guests
  hvc_xen: fix xenboot for DomUs
  hvc_xen: add earlycon support

1  2 
drivers/tty/hvc/hvc_xen.c
drivers/xen/balloon.c
drivers/xen/events/events_2l.c
drivers/xen/xen-pciback/pciback_ops.c
drivers/xen/xenbus/xenbus_dev_frontend.c

index f417fa1ee47cb7f2b9ed3c53f7887ee4a4263d15,71784950048fc8934fc092f0c73cabbeac46b9bc..5e87e4866bcb7b71c75d835d16b65335c4613f3e
@@@ -25,6 -25,7 +25,7 @@@
  #include <linux/init.h>
  #include <linux/types.h>
  #include <linux/list.h>
+ #include <linux/serial_core.h>
  
  #include <asm/io.h>
  #include <asm/xen/hypervisor.h>
@@@ -162,7 -163,7 +163,7 @@@ static int domU_read_console(uint32_t v
        return recv;
  }
  
 -static struct hv_ops domU_hvc_ops = {
 +static const struct hv_ops domU_hvc_ops = {
        .get_chars = domU_read_console,
        .put_chars = domU_write_console,
        .notifier_add = notifier_add_irq,
@@@ -188,7 -189,7 +189,7 @@@ static int dom0_write_console(uint32_t 
        return len;
  }
  
 -static struct hv_ops dom0_hvc_ops = {
 +static const struct hv_ops dom0_hvc_ops = {
        .get_chars = dom0_read_console,
        .put_chars = dom0_write_console,
        .notifier_add = notifier_add_irq,
@@@ -245,6 -246,18 +246,18 @@@ err
        return -ENODEV;
  }
  
+ static int xencons_info_pv_init(struct xencons_info *info, int vtermno)
+ {
+       info->evtchn = xen_start_info->console.domU.evtchn;
+       /* GFN == MFN for PV guest */
+       info->intf = gfn_to_virt(xen_start_info->console.domU.mfn);
+       info->vtermno = vtermno;
+       list_add_tail(&info->list, &xenconsoles);
+       return 0;
+ }
  static int xen_pv_console_init(void)
  {
        struct xencons_info *info;
                /* already configured */
                return 0;
        }
-       info->evtchn = xen_start_info->console.domU.evtchn;
-       /* GFN == MFN for PV guest */
-       info->intf = gfn_to_virt(xen_start_info->console.domU.mfn);
-       info->vtermno = HVC_COOKIE;
        spin_lock(&xencons_lock);
-       list_add_tail(&info->list, &xenconsoles);
+       xencons_info_pv_init(info, HVC_COOKIE);
        spin_unlock(&xencons_lock);
  
        return 0;
@@@ -323,7 -331,6 +331,7 @@@ void xen_console_resume(void
        }
  }
  
 +#ifdef CONFIG_HVC_XEN_FRONTEND
  static void xencons_disconnect_backend(struct xencons_info *info)
  {
        if (info->irq > 0)
@@@ -364,6 -371,7 +372,6 @@@ static int xen_console_remove(struct xe
        return 0;
  }
  
 -#ifdef CONFIG_HVC_XEN_FRONTEND
  static int xencons_remove(struct xenbus_device *dev)
  {
        return xen_console_remove(dev_get_drvdata(&dev->dev));
@@@ -597,15 -605,39 +605,39 @@@ static int xen_cons_init(void
  }
  console_initcall(xen_cons_init);
  
+ #ifdef CONFIG_X86
+ static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len)
+ {
+       if (xen_cpuid_base())
+               outsb(0xe9, str, len);
+ }
+ #else
+ static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) { }
+ #endif
  #ifdef CONFIG_EARLY_PRINTK
+ static int __init xenboot_setup_console(struct console *console, char *string)
+ {
+       static struct xencons_info xenboot;
+       if (xen_initial_domain())
+               return 0;
+       if (!xen_pv_domain())
+               return -ENODEV;
+       return xencons_info_pv_init(&xenboot, 0);
+ }
  static void xenboot_write_console(struct console *console, const char *string,
                                  unsigned len)
  {
        unsigned int linelen, off = 0;
        const char *pos;
  
-       if (!xen_pv_domain())
+       if (!xen_pv_domain()) {
+               xen_hvm_early_write(0, string, len);
                return;
+       }
  
        dom0_write_console(0, string, len);
  
  struct console xenboot_console = {
        .name           = "xenboot",
        .write          = xenboot_write_console,
+       .setup          = xenboot_setup_console,
        .flags          = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
        .index          = -1,
  };
@@@ -640,17 -673,10 +673,10 @@@ void xen_raw_console_write(const char *
  
        if (xen_domain()) {
                rc = dom0_write_console(0, str, len);
- #ifdef CONFIG_X86
-               if (rc == -ENOSYS && xen_hvm_domain())
-                       goto outb_print;
-       } else if (xen_cpuid_base()) {
-               int i;
- outb_print:
-               for (i = 0; i < len; i++)
-                       outb(str[i], 0xe9);
- #endif
+               if (rc != -ENOSYS || !xen_hvm_domain())
+                       return;
        }
+       xen_hvm_early_write(0, str, len);
  }
  
  void xen_raw_printk(const char *fmt, ...)
  
        xen_raw_console_write(buf);
  }
+ static void xenboot_earlycon_write(struct console *console,
+                                 const char *string,
+                                 unsigned len)
+ {
+       dom0_write_console(0, string, len);
+ }
+ static int __init xenboot_earlycon_setup(struct earlycon_device *device,
+                                           const char *opt)
+ {
+       device->con->write = xenboot_earlycon_write;
+       return 0;
+ }
+ EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup);
diff --combined drivers/xen/balloon.c
index 7c8a2cf16f58b440bd4a7f23053fd6dea199f810,481c3f86033a82f433bd5cf9b7c23f80039c5589..9781e0dd59d6fc6a1b02da5e51e516e27ccafad1
@@@ -42,7 -42,6 +42,6 @@@
  #include <linux/kernel.h>
  #include <linux/sched.h>
  #include <linux/errno.h>
- #include <linux/module.h>
  #include <linux/mm.h>
  #include <linux/bootmem.h>
  #include <linux/pagemap.h>
@@@ -257,7 -256,7 +256,7 @@@ static struct resource *additional_memo
                return NULL;
  
        res->name = "System RAM";
 -      res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 +      res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
  
        ret = allocate_resource(&iomem_resource, res,
                                size, 0, -1,
@@@ -338,16 -337,7 +337,16 @@@ static enum bp_state reserve_additional
        }
  #endif
  
 -      rc = add_memory_resource(nid, resource);
 +      /*
 +       * add_memory_resource() will call online_pages() which in its turn
 +       * will call xen_online_page() callback causing deadlock if we don't
 +       * release balloon_mutex here. Unlocking here is safe because the
 +       * callers drop the mutex before trying again.
 +       */
 +      mutex_unlock(&balloon_mutex);
 +      rc = add_memory_resource(nid, resource, memhp_auto_online);
 +      mutex_lock(&balloon_mutex);
 +
        if (rc) {
                pr_warn("Cannot add additional memory (%i)\n", rc);
                goto err;
@@@ -760,7 -750,4 +759,4 @@@ static int __init balloon_init(void
  
        return 0;
  }
  subsys_initcall(balloon_init);
- MODULE_LICENSE("GPL");
index 403fe395539308431eecad718d5e613a94d2ad98,51b488f5bfe95ec4951a6dd72293c4121340d5f8..bdff01095f5496069036b7b684609731ba4b8cde
@@@ -9,7 -9,6 +9,6 @@@
  #include <linux/linkage.h>
  #include <linux/interrupt.h>
  #include <linux/irq.h>
- #include <linux/module.h>
  
  #include <asm/sync_bitops.h>
  #include <asm/xen/hypercall.h>
@@@ -38,9 -37,8 +37,9 @@@
  /* Find the first set bit in a evtchn mask */
  #define EVTCHN_FIRST_BIT(w) find_first_bit(BM(&(w)), BITS_PER_EVTCHN_WORD)
  
 -static DEFINE_PER_CPU(xen_ulong_t [EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD],
 -                    cpu_evtchn_mask);
 +#define EVTCHN_MASK_SIZE (EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD)
 +
 +static DEFINE_PER_CPU(xen_ulong_t [EVTCHN_MASK_SIZE], cpu_evtchn_mask);
  
  static unsigned evtchn_2l_max_channels(void)
  {
index fb0221434f814aa49eef41f6aea7a60c86a4c817,5ad01f9c24fcbce6bb27b43586fd0f282c24d848..2f19dd7553e6922218f5296985b564625a8e4c70
@@@ -6,7 -6,7 +6,7 @@@
  
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  
- #include <linux/module.h>
+ #include <linux/moduleparam.h>
  #include <linux/wait.h>
  #include <linux/bitops.h>
  #include <xen/events.h>
@@@ -227,9 -227,8 +227,9 @@@ int xen_pcibk_enable_msix(struct xen_pc
        /*
         * PCI_COMMAND_MEMORY must be enabled, otherwise we may not be able
         * to access the BARs where the MSI-X entries reside.
 +       * But VF devices are unique in which the PF needs to be checked.
         */
 -      pci_read_config_word(dev, PCI_COMMAND, &cmd);
 +      pci_read_config_word(pci_physfn(dev), PCI_COMMAND, &cmd);
        if (dev->msi_enabled || !(cmd & PCI_COMMAND_MEMORY))
                return -ENXIO;
  
@@@ -333,9 -332,6 +333,9 @@@ void xen_pcibk_do_op(struct work_struc
        struct xen_pcibk_dev_data *dev_data = NULL;
        struct xen_pci_op *op = &pdev->op;
        int test_intx = 0;
 +#ifdef CONFIG_PCI_MSI
 +      unsigned int nr = 0;
 +#endif
  
        *op = pdev->sh_info->op;
        barrier();
                        op->err = xen_pcibk_disable_msi(pdev, dev, op);
                        break;
                case XEN_PCI_OP_enable_msix:
 +                      nr = op->value;
                        op->err = xen_pcibk_enable_msix(pdev, dev, op);
                        break;
                case XEN_PCI_OP_disable_msix:
        if (op->cmd == XEN_PCI_OP_enable_msix && op->err == 0) {
                unsigned int i;
  
 -              for (i = 0; i < op->value; i++)
 +              for (i = 0; i < nr; i++)
                        pdev->sh_info->op.msix_entries[i].vector =
                                op->msix_entries[i].vector;
        }
index 912b64edb42b4a016201b4e7d1a695ca25056610,8c0a359ab4a8620ae8343294acd77d6be4c8deb6..cacf30d14747baa20d5f2d8a6a999ebdcba14018
@@@ -55,7 -55,7 +55,7 @@@
  #include <linux/string.h>
  #include <linux/slab.h>
  #include <linux/miscdevice.h>
- #include <linux/module.h>
+ #include <linux/init.h>
  
  #include "xenbus_comms.h"
  
@@@ -63,8 -63,6 +63,6 @@@
  #include <xen/xen.h>
  #include <asm/xen/hypervisor.h>
  
- MODULE_LICENSE("GPL");
  /*
   * An element of a list of outstanding transactions, for which we're
   * still waiting a reply.
@@@ -188,8 -186,6 +186,8 @@@ static int queue_reply(struct list_hea
  
        if (len == 0)
                return 0;
 +      if (len > XENSTORE_PAYLOAD_MAX)
 +              return -EINVAL;
  
        rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
        if (rb == NULL)
@@@ -626,11 -622,4 +624,4 @@@ static int __init xenbus_init(void
                pr_err("Could not register xenbus frontend device\n");
        return err;
  }
- static void __exit xenbus_exit(void)
- {
-       misc_deregister(&xenbus_dev);
- }
- module_init(xenbus_init);
- module_exit(xenbus_exit);
+ device_initcall(xenbus_init);