1. 23 10月, 2015 5 次提交
  2. 09 9月, 2015 3 次提交
    • J
      xen: Use correctly the Xen memory terminologies · 0df4f266
      Julien Grall 提交于
      Based on include/xen/mm.h [1], Linux is mistakenly using MFN when GFN
      is meant, I suspect this is because the first support for Xen was for
      PV. This resulted in some misimplementation of helpers on ARM and
      confused developers about the expected behavior.
      
      For instance, with pfn_to_mfn, we expect to get an MFN based on the name.
      Although, if we look at the implementation on x86, it's returning a GFN.
      
      For clarity and avoid new confusion, replace any reference to mfn with
      gfn in any helpers used by PV drivers. The x86 code will still keep some
      reference of pfn_to_mfn which may be used by all kind of guests
      No changes as been made in the hypercall field, even
      though they may be invalid, in order to keep the same as the defintion
      in xen repo.
      
      Note that page_to_mfn has been renamed to xen_page_to_gfn to avoid a
      name to close to the KVM function gfn_to_page.
      
      Take also the opportunity to simplify simple construction such
      as pfn_to_mfn(page_to_pfn(page)) into xen_page_to_gfn. More complex clean up
      will come in follow-up patches.
      
      [1] http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=e758ed14f390342513405dd766e874934573e6cbSigned-off-by: NJulien Grall <julien.grall@citrix.com>
      Reviewed-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Acked-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Acked-by: NWei Liu <wei.liu2@citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      0df4f266
    • J
      arm/xen: implement correctly pfn_to_mfn · 5192b35d
      Julien Grall 提交于
      After the commit introducing convertion between DMA and guest addresses,
      all the callers of pfn_to_mfn are expecting to get a GFN (Guest Frame
      Number). On ARM, all the guests are auto-translated so the GFN is equal
      to the Linux PFN (Pseudo-physical Frame Number).
      
      The current implementation may return an MFN if the caller is passing a
      PFN associated to a mapped foreign grant. In pratice, I haven't seen
      the problem on running guest but we should fix it for the sake of
      correctness.
      
      Correct the implementation by always returning the pfn passed in parameter.
      
      A follow-up patch will take care to rename pfn_to_mfn to a suitable
      name.
      Signed-off-by: NJulien Grall <julien.grall@citrix.com>
      Reviewed-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      5192b35d
    • J
      xen: Make clear that swiotlb and biomerge are dealing with DMA address · 32e09870
      Julien Grall 提交于
      The swiotlb is required when programming a DMA address on ARM when a
      device is not protected by an IOMMU.
      
      In this case, the DMA address should always be equal to the machine address.
      For DOM0 memory, Xen ensure it by have an identity mapping between the
      guest address and host address. However, when mapping a foreign grant
      reference, the 1:1 model doesn't work.
      
      For ARM guest, most of the callers of pfn_to_mfn expects to get a GFN
      (Guest Frame Number), i.e a PFN (Page Frame Number) from the Linux point
      of view given that all ARM guest are auto-translated.
      
      Even though the name pfn_to_mfn is misleading, we need to ensure that
      those caller get a GFN and not by mistake a MFN. In pratical, I haven't
      seen error related to this but we should fix it for the sake of
      correctness.
      
      In order to fix the implementation of pfn_to_mfn on ARM in a follow-up
      patch, we have to introduce new helpers to return the DMA from a PFN and
      the invert.
      
      On x86, the new helpers will be an alias of pfn_to_mfn and mfn_to_pfn.
      
      The helpers will be used in swiotlb and xen_biovec_phys_mergeable.
      
      This is necessary in the latter because we have to ensure that the
      biovec code will not try to merge a biovec using foreign page and
      another using Linux memory.
      
      Lastly, the helper mfn_to_local_pfn has been renamed to bfn_to_local_pfn
      given that the only usage was in swiotlb.
      Signed-off-by: NJulien Grall <julien.grall@citrix.com>
      Reviewed-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      32e09870
  3. 20 8月, 2015 2 次提交
    • J
      arm/xen: Remove helpers which are PV specific · 724afaea
      Julien Grall 提交于
      ARM guests are always HVM. The current implementation is assuming a 1:1
      mapping which is only true for DOM0 and may not be at all in the future.
      
      Furthermore, all the helpers but arbitrary_virt_to_machine are used in
      x86 specific code (or only compiled for).
      
      The helper arbitrary_virt_to_machine is only used in PV specific code.
      Therefore we should never call the function.
      
      Add a BUG() in this helper and drop all the others.
      Signed-off-by: NJulien Grall <julien.grall@citrix.com>
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      724afaea
    • J
      xen/events: Support event channel rebind on ARM · 4a5b6946
      Julien Grall 提交于
      Currently, the event channel rebind code is gated with the presence of
      the vector callback.
      
      The virtual interrupt controller on ARM has the concept of per-CPU
      interrupt (PPI) which allow us to support per-VCPU event channel.
      Therefore there is no need of vector callback for ARM.
      
      Xen is already using a free PPI to notify the guest VCPU of an event.
      Furthermore, the xen code initialization in Linux (see
      arch/arm/xen/enlighten.c) is requesting correctly a per-CPU IRQ.
      
      Introduce new helper xen_support_evtchn_rebind to allow architecture
      decide whether rebind an event is support or not. It will always return
      true on ARM and keep the same behavior on x86.
      
      This is also allow us to drop the usage of xen_have_vector_callback
      entirely in the ARM code.
      Signed-off-by: NJulien Grall <julien.grall@citrix.com>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      4a5b6946
  4. 17 6月, 2015 1 次提交
  5. 28 5月, 2015 1 次提交
  6. 06 5月, 2015 1 次提交
  7. 28 1月, 2015 1 次提交
  8. 04 12月, 2014 4 次提交
  9. 12 9月, 2014 2 次提交
    • 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
  10. 13 5月, 2014 1 次提交
  11. 28 4月, 2014 1 次提交
    • J
      arm/xen: Remove definiition of virt_to_pfn in asm/xen/page.h · 063aa8e6
      Julien Grall 提交于
      virt_to_pfn has been defined in asm/memory.h by the commit e26a9e00 "ARM: Better
      virt_to_page() handling"
      
      This will result of a compilation warning when CONFIG_XEN is enabled.
      
      arch/arm/include/asm/xen/page.h:80:0: warning: "virt_to_pfn" redefined [enabled by default]
       #define virt_to_pfn(v)          (PFN_DOWN(__pa(v)))
       ^
      In file included from arch/arm/include/asm/page.h:163:0,
                       from arch/arm/include/asm/xen/page.h:4,
                       from include/xen/page.h:4,
                       from arch/arm/xen/grant-table.c:33:
      
      The definition in memory.h is nearly the same (it directly expand PFN_DOWN),
      so we can safely drop virt_to_pfn in xen include.
      Signed-off-by: NJulien Grall <julien.grall@linaro.org>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      063aa8e6
  12. 24 4月, 2014 2 次提交
    • J
      arm/xen: Remove definiition of virt_to_pfn in asm/xen/page.h · adc01864
      Julien Grall 提交于
      virt_to_pfn has been defined in asm/memory.h by the commit e26a9e00 "ARM: Better
      virt_to_page() handling"
      
      This will result of a compilation warning when CONFIG_XEN is enabled.
      
      arch/arm/include/asm/xen/page.h:80:0: warning: "virt_to_pfn" redefined [enabled by default]
       #define virt_to_pfn(v)          (PFN_DOWN(__pa(v)))
       ^
      In file included from arch/arm/include/asm/page.h:163:0,
                       from arch/arm/include/asm/xen/page.h:4,
                       from include/xen/page.h:4,
                       from arch/arm/xen/grant-table.c:33:
      
      The definition in memory.h is nearly the same (it directly expand PFN_DOWN),
      so we can safely drop virt_to_pfn in xen include.
      Signed-off-by: NJulien Grall <julien.grall@linaro.org>
      Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
      adc01864
    • 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
  13. 18 3月, 2014 1 次提交
  14. 06 1月, 2014 2 次提交
  15. 05 1月, 2014 1 次提交
  16. 29 12月, 2013 1 次提交
    • R
      ARM: 7896/1: rename ioremap_cached to ioremap_cache · 92341c83
      Rob Herring 提交于
      ioremap_cache is more aligned with other architectures. There are only
      2 users of this in the kernel: pxa2xx-flash and Xen.
      
      This fixes Xen build failures on arm64 caused by commit c04e8e2f (arm64:
      allow ioremap_cache() to use existing RAM mappings)
      
      drivers/tty/hvc/hvc_xen.c:233:2: error: implicit declaration of function 'ioremap_cached' [-Werror=implicit-function-declaration]
      drivers/xen/grant-table.c:1174:3: error: implicit declaration of function 'ioremap_cached' [-Werror=implicit-function-declaration]
      drivers/xen/xenbus/xenbus_probe.c:778:4: error: implicit declaration of function 'ioremap_cached' [-Werror=implicit-function-declaration]
      Signed-off-by: NRob Herring <rob.herring@calxeda.com>
      Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
      Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      92341c83
  17. 12 11月, 2013 1 次提交
  18. 25 10月, 2013 1 次提交
  19. 10 10月, 2013 2 次提交
    • S
      xen: introduce xen_alloc/free_coherent_pages · d6fe76c5
      Stefano Stabellini 提交于
      xen_swiotlb_alloc_coherent needs to allocate a coherent buffer for cpu
      and devices. On native x86 is sufficient to call __get_free_pages in
      order to get a coherent buffer, while on ARM (and potentially ARM64) we
      need to call the native dma_ops->alloc implementation.
      
      Introduce xen_alloc_coherent_pages to abstract the arch specific buffer
      allocation.
      
      Similarly introduce xen_free_coherent_pages to free a coherent buffer:
      on x86 is simply a call to free_pages while on ARM and ARM64 is
      arm_dma_ops.free.
      Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      
      
      Changes in v7:
      - rename __get_dma_ops to __generic_dma_ops;
      - call __generic_dma_ops(hwdev)->alloc/free on arm64 too.
      
      Changes in v6:
      - call __get_dma_ops to get the native dma_ops pointer on arm.
      d6fe76c5
    • 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
  20. 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
  21. 04 7月, 2013 1 次提交
  22. 05 6月, 2013 1 次提交
  23. 26 4月, 2013 1 次提交
  24. 12 3月, 2013 1 次提交
    • I
      xen: arm: mandate EABI and use generic atomic operations. · 85323a99
      Ian Campbell 提交于
      Rob Herring has observed that c81611c4 "xen: event channel arrays are
      xen_ulong_t and not unsigned long" introduced a compile failure when building
      without CONFIG_AEABI:
      
      /tmp/ccJaIZOW.s: Assembler messages:
      /tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'
      
      Will Deacon pointed out that this is because OABI does not require even base
      registers for 64-bit values. We can avoid this by simply using the existing
      atomic64_xchg operation and the same containerof trick as used by the cmpxchg
      macros. However since this code is used on memory which is shared with the
      hypervisor we require proper atomic instructions and cannot use the generic
      atomic64 callbacks (which are based on spinlocks), therefore add a dependency
      on !GENERIC_ATOMIC64. Since we already depend on !CPU_V6 there isn't much
      downside to this.
      
      While thinking about this we also observed that OABI has different struct
      alignment requirements to EABI, which is a problem for hypercall argument
      structs which are shared with the hypervisor and which must be in EABI layout.
      Since I don't expect people to want to run OABI kernels on Xen depend on
      CONFIG_AEABI explicitly too (although it also happens to be enforced by the
      !GENERIC_ATOMIC64 requirement too).
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Rob Herring <robherring2@gmail.com>
      Acked-by: NStefano Stabellini <Stefano.Stabellini@eu.citrix.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      85323a99
  25. 20 2月, 2013 2 次提交