1. 28 1月, 2015 1 次提交
  2. 23 9月, 2014 1 次提交
  3. 30 7月, 2014 1 次提交
    • D
      x86/xen: safely map and unmap grant frames when in atomic context · b7dd0e35
      David Vrabel 提交于
      arch_gnttab_map_frames() and arch_gnttab_unmap_frames() are called in
      atomic context but were calling alloc_vm_area() which might sleep.
      
      Also, if a driver attempts to allocate a grant ref from an interrupt
      and the table needs expanding, then the CPU may already by in lazy MMU
      mode and apply_to_page_range() will BUG when it tries to re-enable
      lazy MMU mode.
      
      These two functions are only used in PV guests.
      
      Introduce arch_gnttab_init() to allocates the virtual address space in
      advance.
      
      Avoid the use of apply_to_page_range() by using saving and using the
      array of PTE addresses from the alloc_vm_area() call (which ensures
      that the required page tables are pre-allocated).
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      b7dd0e35
  4. 15 7月, 2014 2 次提交
  5. 18 6月, 2014 1 次提交
  6. 18 3月, 2014 1 次提交
  7. 03 2月, 2014 1 次提交
  8. 31 1月, 2014 1 次提交
    • Z
      xen/grant-table: Avoid m2p_override during mapping · 08ece5bb
      Zoltan Kiss 提交于
      The grant mapping API does m2p_override unnecessarily: only gntdev needs it,
      for blkback and future netback patches it just cause a lock contention, as
      those pages never go to userspace. Therefore this series does the following:
      - the original functions were renamed to __gnttab_[un]map_refs, with a new
        parameter m2p_override
      - based on m2p_override either they follow the original behaviour, or just set
        the private flag and call set_phys_to_machine
      - gnttab_[un]map_refs are now a wrapper to call __gnttab_[un]map_refs with
        m2p_override false
      - a new function gnttab_[un]map_refs_userspace provides the old behaviour
      
      It also removes a stray space from page.h and change ret to 0 if
      XENFEAT_auto_translated_physmap, as that is the only possible return value
      there.
      
      v2:
      - move the storing of the old mfn in page->index to gnttab_map_refs
      - move the function header update to a separate patch
      
      v3:
      - a new approach to retain old behaviour where it needed
      - squash the patches into one
      
      v4:
      - move out the common bits from m2p* functions, and pass pfn/mfn as parameter
      - clear page->private before doing anything with the page, so m2p_find_override
        won't race with this
      
      v5:
      - change return value handling in __gnttab_[un]map_refs
      - remove a stray space in page.h
      - add detail why ret = 0 now at some places
      
      v6:
      - don't pass pfn to m2p* functions, just get it locally
      Signed-off-by: NZoltan Kiss <zoltan.kiss@citrix.com>
      Suggested-by: NDavid Vrabel <david.vrabel@citrix.com>
      Acked-by: NDavid Vrabel <david.vrabel@citrix.com>
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      08ece5bb
  9. 30 1月, 2014 1 次提交
  10. 06 1月, 2014 5 次提交
    • K
      xen/grant-table: Force to use v1 of grants. · 11c7ff17
      Konrad Rzeszutek Wilk 提交于
      We have the framework to use v2, but there are no backends that
      actually use it. The end result is that on PV we use v2 grants
      and on PVHVM v1. The v1 has a capacity of 512 grants per page while
      the v2 has 256 grants per page. This means we lose about 50%
      capacity - and if we want more than 16 VIFs (each VIF takes
      512 grants), then we are hitting the max per guest of 32.
      
      Oracle-bug: 16039922
      CC: annie.li@oracle.com
      CC: msw@amazon.com
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: NDavid Vrabel <david.vrabel@citrix.com>
      11c7ff17
    • K
      xen/pvh: Piggyback on PVHVM for grant driver (v4) · 6926f6d6
      Konrad Rzeszutek Wilk 提交于
      In PVH the shared grant frame is the PFN and not MFN,
      hence its mapped via the same code path as HVM.
      
      The allocation of the grant frame is done differently - we
      do not use the early platform-pci driver and have an
      ioremap area - instead we use balloon memory and stitch
      all of the non-contingous pages in a virtualized area.
      
      That means when we call the hypervisor to replace the GMFN
      with a XENMAPSPACE_grant_table type, we need to lookup the
      old PFN for every iteration instead of assuming a flat
      contingous PFN allocation.
      
      Lastly, we only use v1 for grants. This is because PVHVM
      is not able to use v2 due to no XENMEM_add_to_physmap
      calls on the error status page (see commit
      69e8f430
       xen/granttable: Disable grant v2 for HVM domains.)
      
      Until that is implemented this workaround has to
      be in place.
      
      Also per suggestions by Stefano utilize the PVHVM paths
      as they share common functionality.
      
      v2 of this patch moves most of the PVH code out in the
      arch/x86/xen/grant-table driver and touches only minimally
      the generic driver.
      
      v3, v4: fixes us some of the code due to earlier patches.
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      6926f6d6
    • K
      xen/grant: Implement an grant frame array struct (v3). · efaf30a3
      Konrad Rzeszutek Wilk 提交于
      The 'xen_hvm_resume_frames' used to be an 'unsigned long'
      and contain the virtual address of the grants. That was OK
      for most architectures (PVHVM, ARM) were the grants are contiguous
      in memory. That however is not the case for PVH - in which case
      we will have to do a lookup for each virtual address for the PFN.
      
      Instead of doing that, lets make it a structure which will contain
      the array of PFNs, the virtual address and the count of said PFNs.
      
      Also provide a generic functions: gnttab_setup_auto_xlat_frames and
      gnttab_free_auto_xlat_frames to populate said structure with
      appropriate values for PVHVM and ARM.
      
      To round it off, change the name from 'xen_hvm_resume_frames' to
      a more descriptive one - 'xen_auto_xlat_grant_frames'.
      
      For PVH, in patch "xen/pvh: Piggyback on PVHVM for grant driver"
      we will populate the 'xen_auto_xlat_grant_frames' by ourselves.
      
      v2 moves the xen_remap in the gnttab_setup_auto_xlat_frames
      and also introduces xen_unmap for gnttab_free_auto_xlat_frames.
      Suggested-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      [v3: Based on top of 'asm/xen/page.h: remove redundant semicolon']
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      efaf30a3
    • K
      xen/grant-table: Refactor gnttab_init · 45684753
      Konrad Rzeszutek Wilk 提交于
      We have this odd scenario of where for PV paths we take a shortcut
      but for the HVM paths we first ioremap xen_hvm_resume_frames, then
      assign it to gnttab_shared.addr. This is needed because gnttab_map
      uses gnttab_shared.addr.
      
      Instead of having:
      	if (pv)
      		return gnttab_map
      	if (hvm)
      		...
      
      	gnttab_map
      
      Lets move the HVM part before the gnttab_map and remove the
      first call to gnttab_map.
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: NDavid Vrabel <david.vrabel@citrix.com>
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      45684753
    • K
      xen/grants: Remove gnttab_max_grant_frames dependency on gnttab_init. · 7f256020
      Konrad Rzeszutek Wilk 提交于
      The function gnttab_max_grant_frames() returns the maximum amount
      of frames (pages) of grants we can have. Unfortunatly it was
      dependent on gnttab_init() having been run before to initialize
      the boot max value (boot_max_nr_grant_frames).
      
      This meant that users of gnttab_max_grant_frames would always
      get a zero value if they called before gnttab_init() - such as
      'platform_pci_init' (drivers/xen/platform-pci.c).
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: NDavid Vrabel <david.vrabel@citrix.com>
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      7f256020
  11. 04 12月, 2013 1 次提交
  12. 27 11月, 2013 1 次提交
  13. 25 10月, 2013 1 次提交
  14. 09 8月, 2013 1 次提交
  15. 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
  16. 20 2月, 2013 1 次提交
  17. 16 1月, 2013 1 次提交
    • M
      xen/grant-table: correctly initialize grant table version 1 · d0b4d64a
      Matt Wilson 提交于
      Commit 85ff6acb (xen/granttable: Grant
      tables V2 implementation) changed the GREFS_PER_GRANT_FRAME macro from
      a constant to a conditional expression. The expression depends on
      grant_table_version being appropriately set. Unfortunately, at init
      time grant_table_version will be 0. The GREFS_PER_GRANT_FRAME
      conditional expression checks for "grant_table_version == 1", and
      therefore returns the number of grant references per frame for v2.
      
      This causes gnttab_init() to allocate fewer pages for gnttab_list, as
      a frame can old half the number of v2 entries than v1 entries. After
      gnttab_resume() is called, grant_table_version is appropriately
      set. nr_init_grefs will then be miscalculated and gnttab_free_count
      will hold a value larger than the actual number of free gref entries.
      
      If a guest is heavily utilizing improperly initialized v1 grant
      tables, memory corruption can occur. One common manifestation is
      corruption of the vmalloc list, resulting in a poisoned pointer
      derefrence when accessing /proc/meminfo or /proc/vmallocinfo:
      
      [   40.770064] BUG: unable to handle kernel paging request at 0000200200001407
      [   40.770083] IP: [<ffffffff811a6fb0>] get_vmalloc_info+0x70/0x110
      [   40.770102] PGD 0
      [   40.770107] Oops: 0000 [#1] SMP
      [   40.770114] CPU 10
      
      This patch introduces a static variable, grefs_per_grant_frame, to
      cache the calculated value. gnttab_init() now calls
      gnttab_request_version() early so that grant_table_version and
      grefs_per_grant_frame can be appropriately set. A few BUG_ON()s have
      been added to prevent this type of bug from reoccurring in the future.
      Signed-off-by: NMatt Wilson <msw@amazon.com>
      Reviewed-and-Tested-by: NSteven Noonan <snoonan@amazon.com>
      Acked-by: NIan Campbell <Ian.Campbell@citrix.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Annie Li <annie.li@oracle.com>
      Cc: xen-devel@lists.xen.org
      Cc: linux-kernel@vger.kernel.org
      Cc: stable@vger.kernel.org # v3.3 and newer
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      d0b4d64a
  18. 04 1月, 2013 1 次提交
    • G
      Drivers: xen: remove __dev* attributes. · 345a5255
      Greg Kroah-Hartman 提交于
      CONFIG_HOTPLUG is going away as an option.  As a result, the __dev*
      markings need to be removed.
      
      This change removes the use of __devinit, and __devinitdata from these
      drivers.
      
      Based on patches originally written by Bill Pemberton, but redone by me
      in order to handle some of the coding style issues better, by hand.
      
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Jeremy Fitzhardinge <jeremy@goop.org>
      Cc: Jan Beulich <jbeulich@suse.com>
      Cc: Stephen Hemminger <shemminger@vyatta.com>
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Bill Pemberton <wfp5p@virginia.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      345a5255
  19. 20 10月, 2012 1 次提交
  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. 12 9月, 2012 1 次提交
    • S
      xen/m2p: do not reuse kmap_op->dev_bus_addr · 2fc136ee
      Stefano Stabellini 提交于
      If the caller passes a valid kmap_op to m2p_add_override, we use
      kmap_op->dev_bus_addr to store the original mfn, but dev_bus_addr is
      part of the interface with Xen and if we are batching the hypercalls it
      might not have been written by the hypervisor yet. That means that later
      on Xen will write to it and we'll think that the original mfn is
      actually what Xen has written to it.
      
      Rather than "stealing" struct members from kmap_op, keep using
      page->index to store the original mfn and add another parameter to
      m2p_remove_override to get the corresponding kmap_op instead.
      It is now responsibility of the caller to keep track of which kmap_op
      corresponds to a particular page in the m2p_override (gntdev, the only
      user of this interface that passes a valid kmap_op, is already doing that).
      
      CC: stable@kernel.org
      Reported-and-Tested-By: NSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      2fc136ee
  22. 22 8月, 2012 2 次提交
  23. 08 5月, 2012 1 次提交
    • S
      xen: enter/exit lazy_mmu_mode around m2p_override calls · f62805f1
      Stefano Stabellini 提交于
      This patch is a significant performance improvement for the
      m2p_override: about 6% using the gntdev device.
      
      Each m2p_add/remove_override call issues a MULTI_grant_table_op and a
      __flush_tlb_single if kmap_op != NULL.  Batching all the calls together
      is a great performance benefit because it means issuing one hypercall
      total rather than two hypercall per page.
      If paravirt_lazy_mode is set PARAVIRT_LAZY_MMU, all these calls are
      going to be batched together, otherwise they are issued one at a time.
      
      Adding arch_enter_lazy_mmu_mode/arch_leave_lazy_mmu_mode around the
      m2p_add/remove_override calls forces paravirt_lazy_mode to
      PARAVIRT_LAZY_MMU, therefore makes sure that they are always batched.
      
      However it is not safe to call arch_enter_lazy_mmu_mode if we are in
      interrupt context or if we are already in PARAVIRT_LAZY_MMU mode, so
      check for both conditions before doing so.
      
      Changes in v4:
      - rebased on 3.4-rc4: all the m2p_override users call gnttab_unmap_refs
      and gnttab_map_refs;
      - check whether we are in interrupt context and the lazy_mode we are in
      before calling arch_enter/leave_lazy_mmu_mode.
      
      Changes in v3:
      - do not call arch_enter/leave_lazy_mmu_mode in xen_blkbk_unmap, that
      can be called in interrupt context.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      [v5: s/int lazy/bool lazy/]
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      f62805f1
  24. 18 4月, 2012 1 次提交
  25. 17 4月, 2012 1 次提交
  26. 28 1月, 2012 1 次提交
    • K
      xen/granttable: Disable grant v2 for HVM domains. · 69e8f430
      Konrad Rzeszutek Wilk 提交于
      As proper scaffolding for supporting error status is not yet
      implemented.
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000400
      IP: [<ffffffff81375ae9>] gnttab_end_foreign_access_ref_v2+0x29/0x40
      PGD 32aa3067 PUD 32a87067 PMD 0
      Oops: 0000 [#1] PREEMPT SMP
      CPU 0
      Modules linked in: sg sr_mod cdrom ata_generic ata_piix libata scsi_mod xen_blkfront xen_netfront fb_sys_fops sysimgblt sysfillrect syscopyarea xen_kbdfront
      cmd
      
      Pid: 2307, comm: ip Not tainted 3.3.0-rc1 #1 Xen HVM domU
      RIP: 0010:[<ffffffff81375ae9>]  [<ffffffff81375ae9>] gnttab_end_foreign_access_ref_v2+0x29/0x40
      RSP: 0018:ffff88003be03d38  EFLAGS: 00010206
      RAX: 0000000000000000 RBX: ffff880033210640 RCX: 0000000000000040
      RDX: 0000000000002000 RSI: 0000000000000000 RDI: 0000000000000200
      RBP: ffff88003be03d38 R08: 0000000000000101 R09: 0000000000000000
      R10: dead000000100100 R11: 0000000000000000 R12: ffff88003be03e48
      R13: 0000000000000001 R14: ffff880039461c00 R15: 0000000000000200
      FS:  00007fb1f84ec700(0000) GS:ffff88003be00000(0000) knlGS:0000000000000000
      ...
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      69e8f430
  27. 21 12月, 2011 1 次提交
  28. 17 12月, 2011 3 次提交
  29. 22 11月, 2011 4 次提交