1. 05 2月, 2015 1 次提交
  2. 06 10月, 2014 3 次提交
  3. 16 4月, 2014 1 次提交
    • K
      xen/xenbus: Avoid synchronous wait on XenBus stalling shutdown/restart. · 027bd7e8
      Konrad Rzeszutek Wilk 提交于
      The 'read_reply' works with 'process_msg' to read of a reply in XenBus.
      'process_msg' is running from within the 'xenbus' thread. Whenever
      a message shows up in XenBus it is put on a xs_state.reply_list list
      and 'read_reply' picks it up.
      
      The problem is if the backend domain or the xenstored process is killed.
      In which case 'xenbus' is still awaiting - and 'read_reply' if called -
      stuck forever waiting for the reply_list to have some contents.
      
      This is normally not a problem - as the backend domain can come back
      or the xenstored process can be restarted. However if the domain
      is in process of being powered off/restarted/halted - there is no
      point of waiting on it coming back - as we are effectively being
      terminated and should not impede the progress.
      
      This patch solves this problem by checking whether the guest is the
      right domain. If it is an initial domain and hurtling towards death -
      there is no point of continuing the wait. All other type of guests
      continue with their behavior (as Xenstore is expected to still be
      running in another domain).
      
      Fixes-Bug: http://bugs.xenproject.org/xen/bug/8Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: NBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Reviewed-by: NDavid Vrabel <david.vrabel@citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      027bd7e8
  4. 01 3月, 2014 1 次提交
  5. 06 1月, 2014 1 次提交
  6. 04 1月, 2014 1 次提交
    • K
      xen/pvhvm: If xen_platform_pci=0 is set don't blow up (v4). · 51c71a3b
      Konrad Rzeszutek Wilk 提交于
      The user has the option of disabling the platform driver:
      00:02.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)
      
      which is used to unplug the emulated drivers (IDE, Realtek 8169, etc)
      and allow the PV drivers to take over. If the user wishes
      to disable that they can set:
      
        xen_platform_pci=0
        (in the guest config file)
      
      or
        xen_emul_unplug=never
        (on the Linux command line)
      
      except it does not work properly. The PV drivers still try to
      load and since the Xen platform driver is not run - and it
      has not initialized the grant tables, most of the PV drivers
      stumble upon:
      
      input: Xen Virtual Keyboard as /devices/virtual/input/input5
      input: Xen Virtual Pointer as /devices/virtual/input/input6M
      ------------[ cut here ]------------
      kernel BUG at /home/konrad/ssd/konrad/linux/drivers/xen/grant-table.c:1206!
      invalid opcode: 0000 [#1] SMP
      Modules linked in: xen_kbdfront(+) xenfs xen_privcmd
      CPU: 6 PID: 1389 Comm: modprobe Not tainted 3.13.0-rc1upstream-00021-ga6c892b-dirty #1
      Hardware name: Xen HVM domU, BIOS 4.4-unstable 11/26/2013
      RIP: 0010:[<ffffffff813ddc40>]  [<ffffffff813ddc40>] get_free_entries+0x2e0/0x300
      Call Trace:
       [<ffffffff8150d9a3>] ? evdev_connect+0x1e3/0x240
       [<ffffffff813ddd0e>] gnttab_grant_foreign_access+0x2e/0x70
       [<ffffffffa0010081>] xenkbd_connect_backend+0x41/0x290 [xen_kbdfront]
       [<ffffffffa0010a12>] xenkbd_probe+0x2f2/0x324 [xen_kbdfront]
       [<ffffffff813e5757>] xenbus_dev_probe+0x77/0x130
       [<ffffffff813e7217>] xenbus_frontend_dev_probe+0x47/0x50
       [<ffffffff8145e9a9>] driver_probe_device+0x89/0x230
       [<ffffffff8145ebeb>] __driver_attach+0x9b/0xa0
       [<ffffffff8145eb50>] ? driver_probe_device+0x230/0x230
       [<ffffffff8145eb50>] ? driver_probe_device+0x230/0x230
       [<ffffffff8145cf1c>] bus_for_each_dev+0x8c/0xb0
       [<ffffffff8145e7d9>] driver_attach+0x19/0x20
       [<ffffffff8145e260>] bus_add_driver+0x1a0/0x220
       [<ffffffff8145f1ff>] driver_register+0x5f/0xf0
       [<ffffffff813e55c5>] xenbus_register_driver_common+0x15/0x20
       [<ffffffff813e76b3>] xenbus_register_frontend+0x23/0x40
       [<ffffffffa0015000>] ? 0xffffffffa0014fff
       [<ffffffffa001502b>] xenkbd_init+0x2b/0x1000 [xen_kbdfront]
       [<ffffffff81002049>] do_one_initcall+0x49/0x170
      
      .. snip..
      
      which is hardly nice. This patch fixes this by having each
      PV driver check for:
       - if running in PV, then it is fine to execute (as that is their
         native environment).
       - if running in HVM, check if user wanted 'xen_emul_unplug=never',
         in which case bail out and don't load any PV drivers.
       - if running in HVM, and if PCI device 5853:0001 (xen_platform_pci)
         does not exist, then bail out and not load PV drivers.
       - (v2) if running in HVM, and if the user wanted 'xen_emul_unplug=ide-disks',
         then bail out for all PV devices _except_ the block one.
         Ditto for the network one ('nics').
       - (v2) if running in HVM, and if the user wanted 'xen_emul_unplug=unnecessary'
         then load block PV driver, and also setup the legacy IDE paths.
         In (v3) make it actually load PV drivers.
      
      Reported-by: Sander Eikelenboom <linux@eikelenboom.it
      Reported-by: NAnthony PERARD <anthony.perard@citrix.com>
      Reported-and-Tested-by: NFabio Fantoni <fabio.fantoni@m2r.biz>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      [v2: Add extra logic to handle the myrid ways 'xen_emul_unplug'
      can be used per Ian and Stefano suggestion]
      [v3: Make the unnecessary case work properly]
      [v4: s/disks/ide-disks/ spotted by Fabio]
      Reviewed-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Acked-by: Bjorn Helgaas <bhelgaas@google.com> [for PCI parts]
      CC: stable@vger.kernel.org
      51c71a3b
  7. 17 10月, 2013 1 次提交
  8. 29 7月, 2013 1 次提交
  9. 04 7月, 2013 1 次提交
  10. 28 6月, 2013 1 次提交
    • J
      xen: Convert printks to pr_<level> · 283c0972
      Joe Perches 提交于
      Convert printks to pr_<level> (excludes printk(KERN_DEBUG...)
      to be more consistent throughout the xen subsystem.
      
      Add pr_fmt with KBUILD_MODNAME or "xen:" KBUILD_MODNAME
      Coalesce formats and add missing word spaces
      Add missing newlines
      Align arguments and reflow to 80 columns
      Remove DRV_NAME from formats as pr_fmt adds the same content
      
      This does change some of the prefixes of these messages
      but it also does make them more consistent.
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      283c0972
  11. 30 5月, 2013 1 次提交
  12. 29 5月, 2013 2 次提交
  13. 21 5月, 2013 2 次提交
  14. 01 3月, 2013 1 次提交
  15. 20 2月, 2013 1 次提交
  16. 29 11月, 2012 1 次提交
  17. 30 10月, 2012 1 次提交
  18. 20 10月, 2012 3 次提交
  19. 12 10月, 2012 1 次提交
    • K
      xen/pv-on-hvm kexec: add quirk for Xen 3.4 and shutdown watches. · cb6b6df1
      Konrad Rzeszutek Wilk 提交于
      The commit 254d1a3f, titled
      "xen/pv-on-hvm kexec: shutdown watches from old kernel" assumes that the
      XenBus backend can deal with reading of values from:
       "control/platform-feature-xs_reset_watches":
      
          ... a patch for xenstored is required so that it
          accepts the XS_RESET_WATCHES request from a client (see changeset
          23839:42a45baf037d in xen-unstable.hg). Without the patch for xenstored
          the registration of watches will fail and some features of a PVonHVM
          guest are not available. The guest is still able to boot, but repeated
          kexec boots will fail."
      
      Sadly this is not true when using a Xen 3.4 hypervisor and booting a PVHVM
      guest. We end up hanging at:
      
        err = xenbus_scanf(XBT_NIL, "control",
                              "platform-feature-xs_reset_watches", "%d", &supported);
      
      This can easily be seen with guests hanging at xenbus_init:
      
      NX (Execute Disable) protection: active
      SMBIOS 2.4 present.
      DMI: Xen HVM domU, BIOS 3.4.0 05/13/2011
      Hypervisor detected: Xen HVM
      Xen version 3.4.
      Xen Platform PCI: I/O protocol version 1
      ... snip ..
      calling  xenbus_init+0x0/0x27e @ 1
      
      Reverting the commit or using the attached patch fixes the issue. This fix
      checks whether the hypervisor is older than 4.0 and if so does not try to
      perform the read.
      
      Fixes-Oracle-Bug: 14708233
      CC: stable@vger.kernel.org
      Acked-by: NOlaf Hering <olaf@aepfle.de>
      [v2: Added a comment in the source code]
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      cb6b6df1
  20. 21 9月, 2012 1 次提交
    • A
      xen/gndev: Xen backend support for paged out grant targets V4. · c571898f
      Andres Lagar-Cavilla 提交于
      Since Xen-4.2, hvm domains may have portions of their memory paged out. When a
      foreign domain (such as dom0) attempts to map these frames, the map will
      initially fail. The hypervisor returns a suitable errno, and kicks an
      asynchronous page-in operation carried out by a helper. The foreign domain is
      expected to retry the mapping operation until it eventually succeeds. The
      foreign domain is not put to sleep because itself could be the one running the
      pager assist (typical scenario for dom0).
      
      This patch adds support for this mechanism for backend drivers using grant
      mapping and copying operations. Specifically, this covers the blkback and
      gntdev drivers (which map foreign grants), and the netback driver (which copies
      foreign grants).
      
      * Add a retry method for grants that fail with GNTST_eagain (i.e. because the
        target foreign frame is paged out).
      * Insert hooks with appropriate wrappers in the aforementioned drivers.
      
      The retry loop is only invoked if the grant operation status is GNTST_eagain.
      It guarantees to leave a new status code different from GNTST_eagain. Any other
      status code results in identical code execution as before.
      
      The retry loop performs 256 attempts with increasing time intervals through a
      32 second period. It uses msleep to yield while waiting for the next retry.
      
      V2 after feedback from David Vrabel:
      * Explicit MAX_DELAY instead of wrap-around delay into zero
      * Abstract GNTST_eagain check into core grant table code for netback module.
      
      V3 after feedback from Ian Campbell:
      * Add placeholder in array of grant table error descriptions for unrelated
        error code we jump over.
      * Eliminate single map and retry macro in favor of a generic batch flavor.
      * Some renaming.
      * Bury most implementation in grant_table.c, cleaner interface.
      
      V4 rebased on top of sync of Xen grant table interface headers.
      Signed-off-by: NAndres Lagar-Cavilla <andres@lagarcavilla.org>
      Acked-by: NIan Campbell <ian.campbell@citrix.com>
      [v5: Fixed whitespace issues]
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      c571898f
  21. 17 9月, 2012 1 次提交
  22. 22 8月, 2012 2 次提交
  23. 20 7月, 2012 1 次提交
    • O
      xen/pv-on-hvm kexec: shutdown watches from old kernel · 254d1a3f
      Olaf Hering 提交于
      Add xs_reset_watches function to shutdown watches from old kernel after
      kexec boot.  The old kernel does not unregister all watches in the
      shutdown path.  They are still active, the double registration can not
      be detected by the new kernel.  When the watches fire, unexpected events
      will arrive and the xenwatch thread will crash (jumps to NULL).  An
      orderly reboot of a hvm guest will destroy the entire guest with all its
      resources (including the watches) before it is rebuilt from scratch, so
      the missing unregister is not an issue in that case.
      
      With this change the xenstored is instructed to wipe all active watches
      for the guest.  However, a patch for xenstored is required so that it
      accepts the XS_RESET_WATCHES request from a client (see changeset
      23839:42a45baf037d in xen-unstable.hg). Without the patch for xenstored
      the registration of watches will fail and some features of a PVonHVM
      guest are not available. The guest is still able to boot, but repeated
      kexec boots will fail.
      Signed-off-by: NOlaf Hering <olaf@aepfle.de>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      254d1a3f
  24. 21 5月, 2012 1 次提交
  25. 20 4月, 2012 1 次提交
    • K
      xen/xenbus: Add quirk to deal with misconfigured backends. · 3066616c
      Konrad Rzeszutek Wilk 提交于
      A rather annoying and common case is when booting a PVonHVM guest
      and exposing the PV KBD and PV VFB - as broken toolstacks don't
      always initialize the backends correctly.
      
      Normally The HVM guest is using the VGA driver and the emulated
      keyboard for this (though upstream version of QEMU implements
      PV KBD, but still uses a VGA driver). We provide a very basic
      two-stage wait mechanism - where we wait for 30 seconds for all
      devices, and then for 270 for all them except the two mentioned.
      
      That allows us to wait for the essential devices, like network
      or disk for the full 6 minutes.
      
      To trigger this, put this in your guest config:
      
      vfb = [ 'vnc=1, vnclisten=0.0.0.0 ,vncunused=1']
      
      instead of this:
      vnc=1
      vnclisten="0.0.0.0"
      
      CC: stable@kernel.org
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      [v3: Split delay in non-essential (30 seconds) and essential
       devices per Ian and Stefano suggestion]
      [v4: Added comments per Stefano suggestion]
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      3066616c
  26. 14 3月, 2012 2 次提交
  27. 27 2月, 2012 1 次提交
  28. 04 2月, 2012 1 次提交
  29. 05 1月, 2012 4 次提交
    • I
      xen/xenbus: don't reimplement kvasprintf via a fixed size buffer · a800651e
      Ian Campbell 提交于
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Cc: Haogang Chen <haogangchen@gmail.com>
      Acked-by: NJan Beulich <JBeulich@suse.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      a800651e
    • I
      xenbus: maximum buffer size is XENSTORE_PAYLOAD_MAX · 50bf7379
      Ian Campbell 提交于
      Use this now that it is defined even though it happens to be == PAGE_SIZE.
      
      The code which takes requests from userspace already validates against the size
      of this buffer so no further checks are required to ensure that userspace
      requests comply with the protocol in this respect.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Cc: Haogang Chen <haogangchen@gmail.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      50bf7379
    • I
      xen/xenbus: Reject replies with payload > XENSTORE_PAYLOAD_MAX. · 9e7860ce
      Ian Campbell 提交于
      Haogang Chen found out that:
      
       There is a potential integer overflow in process_msg() that could result
       in cross-domain attack.
      
       	body = kmalloc(msg->hdr.len + 1, GFP_NOIO | __GFP_HIGH);
      
       When a malicious guest passes 0xffffffff in msg->hdr.len, the subsequent
       call to xb_read() would write to a zero-length buffer.
      
       The other end of this connection is always the xenstore backend daemon
       so there is no guest (malicious or otherwise) which can do this. The
       xenstore daemon is a trusted component in the system.
      
       However this seem like a reasonable robustness improvement so we should
       have it.
      
      And Ian when read the API docs found that:
              The payload length (len field of the header) is limited to 4096
              (XENSTORE_PAYLOAD_MAX) in both directions.  If a client exceeds the
              limit, its xenstored connection will be immediately killed by
              xenstored, which is usually catastrophic from the client's point of
              view.  Clients (particularly domains, which cannot just reconnect)
              should avoid this.
      
      so this patch checks against that instead.
      
      This also avoids a potential integer overflow pointed out by Haogang Chen.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Cc: Haogang Chen <haogangchen@gmail.com>
      CC: stable@kernel.org
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      9e7860ce
    • J
      Xen: consolidate and simplify struct xenbus_driver instantiation · 73db144b
      Jan Beulich 提交于
      The 'name', 'owner', and 'mod_name' members are redundant with the
      identically named fields in the 'driver' sub-structure. Rather than
      switching each instance to specify these fields explicitly, introduce
      a macro to simplify this.
      
      Eliminate further redundancy by allowing the drvname argument to
      DEFINE_XENBUS_DRIVER() to be blank (in which case the first entry from
      the ID table will be used for .driver.name).
      
      Also eliminate the questionable xenbus_register_{back,front}end()
      wrappers - their sole remaining purpose was the checking of the
      'owner' field, proper setting of which shouldn't be an issue anymore
      when the macro gets used.
      
      v2: Restore DRV_NAME for the driver name in xen-pciback.
      Signed-off-by: NJan Beulich <jbeulich@suse.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Cc: David S. Miller <davem@davemloft.net>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      73db144b