1. 21 1月, 2015 1 次提交
  2. 04 12月, 2014 8 次提交
  3. 12 9月, 2014 3 次提交
    • S
      xen/arm: remove mach_to_phys rbtree · d50582e0
      Stefano Stabellini 提交于
      Remove the rbtree used to keep track of machine to physical mappings:
      the frontend can grant the same page multiple times, leading to errors
      inserting or removing entries from the mach_to_phys tree.
      
      Linux only needed to know the physical address corresponding to a given
      machine address in swiotlb-xen. Now that swiotlb-xen can call the
      xen_dma_* functions passing the machine address directly, we can remove
      it.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Tested-by: NDenis Schneider <v1ne2go@gmail.com>
      d50582e0
    • S
      xen/arm: reimplement xen_dma_unmap_page & friends · 340720be
      Stefano Stabellini 提交于
      xen_dma_unmap_page, xen_dma_sync_single_for_cpu and
      xen_dma_sync_single_for_device are currently implemented by calling into
      the corresponding generic ARM implementation of these functions. In
      order to do this, firstly the dma_addr_t handle, that on Xen is a
      machine address, needs to be translated into a physical address.  The
      operation is expensive and inaccurate, given that a single machine
      address can correspond to multiple physical addresses in one domain,
      because the same page can be granted multiple times by the frontend.
      
      To avoid this problem, we introduce a Xen specific implementation of
      xen_dma_unmap_page, xen_dma_sync_single_for_cpu and
      xen_dma_sync_single_for_device, that can operate on machine addresses
      directly.
      
      The new implementation relies on the fact that the hypervisor creates a
      second p2m mapping of any grant pages at physical address == machine
      address of the page for dom0. Therefore we can access memory at physical
      address == dma_addr_r handle and perform the cache flushing there. Some
      cache maintenance operations require a virtual address. Instead of using
      ioremap_cache, that is not safe in interrupt context, we allocate a
      per-cpu PAGE_KERNEL scratch page and we manually update the pte for it.
      
      arm64 doesn't need cache maintenance operations on unmap for now.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Tested-by: NDenis Schneider <v1ne2go@gmail.com>
      340720be
    • S
      xen/arm: introduce XENFEAT_grant_map_identity · 5ebc77de
      Stefano Stabellini 提交于
      The flag tells us that the hypervisor maps a grant page to guest
      physical address == machine address of the page in addition to the
      normal grant mapping address. It is needed to properly issue cache
      maintenance operation at the completion of a DMA operation involving a
      foreign grant.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Tested-by: NDenis Schneider <v1ne2go@gmail.com>
      5ebc77de
  4. 11 8月, 2014 1 次提交
  5. 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
  6. 26 7月, 2014 1 次提交
  7. 18 7月, 2014 1 次提交
    • R
      ARM: convert all "mov.* pc, reg" to "bx reg" for ARMv6+ · 6ebbf2ce
      Russell King 提交于
      ARMv6 and greater introduced a new instruction ("bx") which can be used
      to return from function calls.  Recent CPUs perform better when the
      "bx lr" instruction is used rather than the "mov pc, lr" instruction,
      and this sequence is strongly recommended to be used by the ARM
      architecture manual (section A.4.1.1).
      
      We provide a new macro "ret" with all its variants for the condition
      code which will resolve to the appropriate instruction.
      
      Rather than doing this piecemeal, and miss some instances, change all
      the "mov pc" instances to use the new macro, with the exception of
      the "movs" instruction and the kprobes code.  This allows us to detect
      the "mov pc, lr" case and fix it up - and also gives us the possibility
      of deploying this for other registers depending on the CPU selection.
      Reported-by: NWill Deacon <will.deacon@arm.com>
      Tested-by: Stephen Warren <swarren@nvidia.com> # Tegra Jetson TK1
      Tested-by: Robert Jarzmik <robert.jarzmik@free.fr> # mioa701_bootresume.S
      Tested-by: Andrew Lunn <andrew@lunn.ch> # Kirkwood
      Tested-by: NShawn Guo <shawn.guo@freescale.com>
      Tested-by: Tony Lindgren <tony@atomide.com> # OMAPs
      Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com> # Armada XP, 375, 385
      Acked-by: Sekhar Nori <nsekhar@ti.com> # DaVinci
      Acked-by: Christoffer Dall <christoffer.dall@linaro.org> # kvm/hyp
      Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com> # PXA3xx
      Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> # Xen
      Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> # ARMv7M
      Tested-by: Simon Horman <horms+renesas@verge.net.au> # Shmobile
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      6ebbf2ce
  8. 15 7月, 2014 2 次提交
  9. 13 5月, 2014 1 次提交
  10. 10 5月, 2014 1 次提交
  11. 24 4月, 2014 1 次提交
    • I
      arm: xen: implement multicall hypercall support. · 5e40704e
      Ian Campbell 提交于
      As part of this make the usual change to xen_ulong_t in place of unsigned long.
      This change has no impact on x86.
      
      The Linux definition of struct multicall_entry.result differs from the Xen
      definition, I think for good reasons, and used a long rather than an unsigned
      long. Therefore introduce a xen_long_t, which is a long on x86 architectures
      and a signed 64-bit integer on ARM.
      
      Use uint32_t nr_calls on x86 for consistency with the ARM definition.
      
      Build tested on amd64 and i386 builds. Runtime tested on ARM.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      5e40704e
  12. 18 3月, 2014 1 次提交
  13. 30 1月, 2014 2 次提交
  14. 06 1月, 2014 1 次提交
    • 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
  15. 12 12月, 2013 1 次提交
    • I
      arm: xen: foreign mapping PTEs are special. · a7892f32
      Ian Campbell 提交于
      These mappings are in fact special and require special handling in privcmd,
      which already exists. Failure to mark the PTE as special on arm64 causes all
      sorts of bad PTE fun. e.g.
      
      e.g.:
      
      BUG: Bad page map in process xl  pte:e0004077b33f53 pmd:4079575003
      page:ffffffbce1a2f328 count:1 mapcount:-1 mapping:          (null) index:0x0
      page flags: 0x4000000000000014(referenced|dirty)
      addr:0000007fb5259000 vm_flags:040644fa anon_vma:          (null) mapping:ffffffc03a6fda58 index:0
      vma->vm_ops->fault: privcmd_fault+0x0/0x38
      vma->vm_file->f_op->mmap: privcmd_mmap+0x0/0x2c
      CPU: 0 PID: 2657 Comm: xl Not tainted 3.12.0+ #102
      Call trace:
      [<ffffffc0000880f8>] dump_backtrace+0x0/0x12c
      [<ffffffc000088238>] show_stack+0x14/0x1c
      [<ffffffc0004b67e0>] dump_stack+0x70/0x90
      [<ffffffc000125690>] print_bad_pte+0x12c/0x1bc
      [<ffffffc0001268f4>] unmap_single_vma+0x4cc/0x700
      [<ffffffc0001273b4>] unmap_vmas+0x68/0xb4
      [<ffffffc00012c050>] unmap_region+0xcc/0x1d4
      [<ffffffc00012df20>] do_munmap+0x218/0x314
      [<ffffffc00012e060>] vm_munmap+0x44/0x64
      [<ffffffc00012ed78>] SyS_munmap+0x24/0x34
      
      Where unmap_single_vma contains inlined -> unmap_page_range -> zap_pud_range
      -> zap_pmd_range -> zap_pte_range -> print_bad_pte.
      
      Or:
      
      BUG: Bad page state in process xl  pfn:4077b4d
      page:ffffffbce1a2f8d8 count:0 mapcount:-1 mapping:          (null) index:0x0
      page flags: 0x4000000000000014(referenced|dirty)
      Modules linked in:
      CPU: 0 PID: 2657 Comm: xl Tainted: G    B        3.12.0+ #102
      Call trace:
      [<ffffffc0000880f8>] dump_backtrace+0x0/0x12c
      [<ffffffc000088238>] show_stack+0x14/0x1c
      [<ffffffc0004b67e0>] dump_stack+0x70/0x90
      [<ffffffc00010f798>] bad_page+0xc4/0x110
      [<ffffffc00010f8b4>] free_pages_prepare+0xd0/0xd8
      [<ffffffc000110e94>] free_hot_cold_page+0x28/0x178
      [<ffffffc000111460>] free_hot_cold_page_list+0x38/0x60
      [<ffffffc000114cf0>] release_pages+0x190/0x1dc
      [<ffffffc00012c0e0>] unmap_region+0x15c/0x1d4
      [<ffffffc00012df20>] do_munmap+0x218/0x314
      [<ffffffc00012e060>] vm_munmap+0x44/0x64
      [<ffffffc00012ed78>] SyS_munmap+0x24/0x34
      
      x86 already gets this correct. 32-bit arm gets away with this because there is
      not PTE_SPECIAL bit in the PTE there and the vm_normal_page fallback path does
      the right thing.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      a7892f32
  16. 04 12月, 2013 1 次提交
  17. 18 11月, 2013 2 次提交
  18. 10 10月, 2013 3 次提交
    • S
      swiotlb-xen: use xen_alloc/free_coherent_pages · 1b65c4e5
      Stefano Stabellini 提交于
      Use xen_alloc_coherent_pages and xen_free_coherent_pages to allocate or
      free coherent pages.
      
      We need to be careful handling the pointer returned by
      xen_alloc_coherent_pages, because on ARM the pointer is not equal to
      phys_to_virt(*dma_handle). In fact virt_to_phys only works for kernel
      direct mapped RAM memory.
      In ARM case the pointer could be an ioremap address, therefore passing
      it to virt_to_phys would give you another physical address that doesn't
      correspond to it.
      
      Make xen_create_contiguous_region take a phys_addr_t as start parameter to
      avoid the virt_to_phys calls which would be incorrect.
      
      Changes in v6:
      - remove extra spaces.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Reviewed-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      1b65c4e5
    • S
      swiotlb-xen: introduce xen_swiotlb_set_dma_mask · eb1ddc00
      Stefano Stabellini 提交于
      Implement xen_swiotlb_set_dma_mask, use it for set_dma_mask on arm.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      eb1ddc00
    • S
      xen/arm,arm64: enable SWIOTLB_XEN · 83862ccf
      Stefano Stabellini 提交于
      Xen on arm and arm64 needs SWIOTLB_XEN: when running on Xen we need to
      program the hardware with mfns rather than pfns for dma addresses.
      Remove SWIOTLB_XEN dependency on X86 and PCI and make XEN select
      SWIOTLB_XEN on arm and arm64.
      
      At the moment always rely on swiotlb-xen, but when Xen starts supporting
      hardware IOMMUs we'll be able to avoid it conditionally on the presence
      of an IOMMU on the platform.
      
      Implement xen_create_contiguous_region on arm and arm64: for the moment
      we assume that dom0 has been mapped 1:1 (physical addresses == machine
      addresses) therefore we don't need to call XENMEM_exchange. Simply
      return the physical address as dma address.
      
      Initialize the xen-swiotlb from xen_early_init (before the native
      dma_ops are initialized), set xen_dma_ops to &xen_swiotlb_dma_ops.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      
      
      Changes in v8:
      - assume dom0 is mapped 1:1, no need to call XENMEM_exchange.
      
      Changes in v7:
      - call __set_phys_to_machine_multi from xen_create_contiguous_region and
      xen_destroy_contiguous_region to update the P2M;
      - don't call XENMEM_unpin, it has been removed;
      - call XENMEM_exchange instead of XENMEM_exchange_and_pin;
      - set nr_exchanged to 0 before calling the hypercall.
      
      Changes in v6:
      - introduce and export xen_dma_ops;
      - call xen_mm_init from as arch_initcall.
      
      Changes in v4:
      - remove redefinition of DMA_ERROR_CODE;
      - update the code to use XENMEM_exchange_and_pin and XENMEM_unpin;
      - add a note about hardware IOMMU in the commit message.
      
      Changes in v3:
      - code style changes;
      - warn on XENMEM_put_dma_buf failures.
      83862ccf
  19. 18 10月, 2013 1 次提交
    • S
      arm/xen,arm64/xen: introduce p2m · 4a19138c
      Stefano Stabellini 提交于
      Introduce physical to machine and machine to physical tracking
      mechanisms based on rbtrees for arm/xen and arm64/xen.
      
      We need it because any guests on ARM are an autotranslate guests,
      therefore a physical address is potentially different from a machine
      address. When programming a device to do DMA, we need to be
      extra-careful to use machine addresses rather than physical addresses to
      program the device. Therefore we need to know the physical to machine
      mappings.
      
      For the moment we assume that dom0 starts with a 1:1 physical to machine
      mapping, in other words physical addresses correspond to machine
      addresses. However when mapping a foreign grant reference, obviously the
      1:1 model doesn't work anymore. So at the very least we need to be able
      to track grant mappings.
      
      We need locking to protect accesses to the two trees.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      
      Changes in v8:
      - move pfn_to_mfn and mfn_to_pfn to page.h as static inline functions;
      - no need to walk the tree if phys_to_mach.rb_node is NULL;
      - correctly handle multipage p2m entries;
      - substitute the spin_lock with a rwlock.
      4a19138c
  20. 09 9月, 2013 2 次提交
  21. 05 8月, 2013 1 次提交
  22. 23 7月, 2013 1 次提交
  23. 04 7月, 2013 1 次提交
  24. 14 5月, 2013 2 次提交