27 Oct, 2017

1 commit

  • rwlock.h should not be included directly. Instead linux/splinlock.h
    should be included. One thing it does is to break the RT build.

    Cc: Stefano Stabellini
    Cc: xen-devel@lists.xenproject.org
    Cc: linux-arm-kernel@lists.infradead.org
    Signed-off-by: Sebastian Andrzej Siewior
    Reviewed-by: Stefano Stabellini
    Signed-off-by: Boris Ostrovsky

    Sebastian Andrzej Siewior
     

07 Jul, 2017

1 commit

  • Pull dma-mapping infrastructure from Christoph Hellwig:
    "This is the first pull request for the new dma-mapping subsystem

    In this new subsystem we'll try to properly maintain all the generic
    code related to dma-mapping, and will further consolidate arch code
    into common helpers.

    This pull request contains:

    - removal of the DMA_ERROR_CODE macro, replacing it with calls to
    ->mapping_error so that the dma_map_ops instances are more self
    contained and can be shared across architectures (me)

    - removal of the ->set_dma_mask method, which duplicates the
    ->dma_capable one in terms of functionality, but requires more
    duplicate code.

    - various updates for the coherent dma pool and related arm code
    (Vladimir)

    - various smaller cleanups (me)"

    * tag 'dma-mapping-4.13' of git://git.infradead.org/users/hch/dma-mapping: (56 commits)
    ARM: dma-mapping: Remove traces of NOMMU code
    ARM: NOMMU: Set ARM_DMA_MEM_BUFFERABLE for M-class cpus
    ARM: NOMMU: Introduce dma operations for noMMU
    drivers: dma-mapping: allow dma_common_mmap() for NOMMU
    drivers: dma-coherent: Introduce default DMA pool
    drivers: dma-coherent: Account dma_pfn_offset when used with device tree
    dma: Take into account dma_pfn_offset
    dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs
    dma-mapping: remove dmam_free_noncoherent
    crypto: qat - avoid an uninitialized variable warning
    au1100fb: remove a bogus dma_free_nonconsistent call
    MAINTAINERS: add entry for dma mapping helpers
    powerpc: merge __dma_set_mask into dma_set_mask
    dma-mapping: remove the set_dma_mask method
    powerpc/cell: use the dma_supported method for ops switching
    powerpc/cell: clean up fixed mapping dma_ops initialization
    tile: remove dma_supported and mapping_error methods
    xen-swiotlb: remove xen_swiotlb_set_dma_mask
    arm: implement ->dma_supported instead of ->set_dma_mask
    mips/loongson64: implement ->dma_supported instead of ->set_dma_mask
    ...

    Linus Torvalds
     

20 Jun, 2017

1 commit

  • ARM and x86 had duplicated versions of the dma_ops structure, the
    only difference is that x86 hasn't wired up the set_dma_mask,
    mmap, and get_sgtable ops yet. On x86 all of them are identical
    to the generic version, so they aren't needed but harmless.

    All the symbols used only for xen_swiotlb_dma_ops can now be marked
    static as well.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Konrad Rzeszutek Wilk

    Christoph Hellwig
     

06 Jun, 2017

3 commits


02 May, 2017

2 commits

  • When rebooting DOM0 with ACPI on ARM64, the kernel is crashing with the stack
    trace [1].

    This is happening because when EFI runtimes are enabled, the reset code
    (see machine_restart) will first try to use EFI restart method.

    However, the EFI restart code is expecting the reset_system callback to
    be always set. This is not the case for Xen and will lead to crash.

    The EFI restart helper is used in multiple places and some of them don't
    not have fallback (see machine_power_off). So implement reset_system
    callback as a call to xen_reboot when using EFI Xen.

    [ 36.999270] reboot: Restarting system
    [ 37.002921] Internal error: Attempting to execute userspace memory: 86000004 [#1] PREEMPT SMP
    [ 37.011460] Modules linked in:
    [ 37.014598] CPU: 0 PID: 1 Comm: systemd-shutdow Not tainted 4.11.0-rc1-00003-g1e248b60a39b-dirty #506
    [ 37.023903] Hardware name: (null) (DT)
    [ 37.027734] task: ffff800902068000 task.stack: ffff800902064000
    [ 37.033739] PC is at 0x0
    [ 37.036359] LR is at efi_reboot+0x94/0xd0
    [ 37.040438] pc : [] lr : [] pstate: 404001c5
    [ 37.047920] sp : ffff800902067cf0
    [ 37.051314] x29: ffff800902067cf0 x28: ffff800902068000
    [ 37.056709] x27: ffff000008992000 x26: 000000000000008e
    [ 37.062104] x25: 0000000000000123 x24: 0000000000000015
    [ 37.067499] x23: 0000000000000000 x22: ffff000008e6e250
    [ 37.072894] x21: ffff000008e6e000 x20: 0000000000000000
    [ 37.078289] x19: ffff000008e5d4c8 x18: 0000000000000010
    [ 37.083684] x17: 0000ffffa7c27470 x16: 00000000deadbeef
    [ 37.089079] x15: 0000000000000006 x14: ffff000088f42bef
    [ 37.094474] x13: ffff000008f42bfd x12: ffff000008e706c0
    [ 37.099870] x11: ffff000008e70000 x10: 0000000005f5e0ff
    [ 37.105265] x9 : ffff800902067a50 x8 : 6974726174736552
    [ 37.110660] x7 : ffff000008cc6fb8 x6 : ffff000008cc6fb0
    [ 37.116055] x5 : ffff000008c97dd8 x4 : 0000000000000000
    [ 37.121453] x3 : 0000000000000000 x2 : 0000000000000000
    [ 37.126845] x1 : 0000000000000000 x0 : 0000000000000000
    [ 37.132239]
    [ 37.133808] Process systemd-shutdow (pid: 1, stack limit = 0xffff800902064000)
    [ 37.141118] Stack: (0xffff800902067cf0 to 0xffff800902068000)
    [ 37.146949] 7ce0: ffff800902067d40 ffff000008085334
    [ 37.154869] 7d00: 0000000000000000 ffff000008f3b000 ffff800902067d40 ffff0000080852e0
    [ 37.162787] 7d20: ffff000008cc6fb0 ffff000008cc6fb8 ffff000008c7f580 ffff000008c97dd8
    [ 37.170706] 7d40: ffff800902067d60 ffff0000080e2c2c 0000000000000000 0000000001234567
    [ 37.178624] 7d60: ffff800902067d80 ffff0000080e2ee8 0000000000000000 ffff0000080e2df4
    [ 37.186544] 7d80: 0000000000000000 ffff0000080830f0 0000000000000000 00008008ff1c1000
    [ 37.194462] 7da0: ffffffffffffffff 0000ffffa7c4b1cc 0000000000000000 0000000000000024
    [ 37.202380] 7dc0: ffff800902067dd0 0000000000000005 0000fffff24743c8 0000000000000004
    [ 37.210299] 7de0: 0000fffff2475f03 0000000000000010 0000fffff2474418 0000000000000005
    [ 37.218218] 7e00: 0000fffff2474578 000000000000000a 0000aaaad6b722c0 0000000000000001
    [ 37.226136] 7e20: 0000000000000123 0000000000000038 ffff800902067e50 ffff0000081e7294
    [ 37.234055] 7e40: ffff800902067e60 ffff0000081e935c ffff800902067e60 ffff0000081e9388
    [ 37.241973] 7e60: ffff800902067eb0 ffff0000081ea388 0000000000000000 00008008ff1c1000
    [ 37.249892] 7e80: ffffffffffffffff 0000ffffa7c4a79c 0000000000000000 ffff000000020000
    [ 37.257810] 7ea0: 0000010000000004 0000000000000000 0000000000000000 ffff0000080830f0
    [ 37.265729] 7ec0: fffffffffee1dead 0000000028121969 0000000001234567 0000000000000000
    [ 37.273651] 7ee0: ffffffffffffffff 8080000000800000 0000800000008080 feffa9a9d4ff2d66
    [ 37.281567] 7f00: 000000000000008e feffa9a9d5b60e0f 7f7fffffffff7f7f 0101010101010101
    [ 37.289485] 7f20: 0000000000000010 0000000000000008 000000000000003a 0000ffffa7ccf588
    [ 37.297404] 7f40: 0000aaaad6b87d00 0000ffffa7c4b1b0 0000fffff2474be0 0000aaaad6b88000
    [ 37.305326] 7f60: 0000fffff2474fb0 0000000001234567 0000000000000000 0000000000000000
    [ 37.313240] 7f80: 0000000000000000 0000000000000001 0000aaaad6b70d4d 0000000000000000
    [ 37.321159] 7fa0: 0000000000000001 0000fffff2474ea0 0000aaaad6b5e2e0 0000fffff2474e80
    [ 37.329078] 7fc0: 0000ffffa7c4b1cc 0000000000000000 fffffffffee1dead 000000000000008e
    [ 37.336997] 7fe0: 0000000000000000 0000000000000000 9ce839cffee77eab fafdbf9f7ed57f2f
    [ 37.344911] Call trace:
    [ 37.347437] Exception stack(0xffff800902067b20 to 0xffff800902067c50)
    [ 37.353970] 7b20: ffff000008e5d4c8 0001000000000000 0000000080f82000 0000000000000000
    [ 37.361883] 7b40: ffff800902067b60 ffff000008e17000 ffff000008f44c68 00000001081081b4
    [ 37.369802] 7b60: ffff800902067bf0 ffff000008108478 0000000000000000 ffff000008c235b0
    [ 37.377721] 7b80: ffff800902067ce0 0000000000000000 0000000000000000 0000000000000015
    [ 37.385643] 7ba0: 0000000000000123 000000000000008e ffff000008992000 ffff800902068000
    [ 37.393557] 7bc0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    [ 37.401477] 7be0: 0000000000000000 ffff000008c97dd8 ffff000008cc6fb0 ffff000008cc6fb8
    [ 37.409396] 7c00: 6974726174736552 ffff800902067a50 0000000005f5e0ff ffff000008e70000
    [ 37.417318] 7c20: ffff000008e706c0 ffff000008f42bfd ffff000088f42bef 0000000000000006
    [ 37.425234] 7c40: 00000000deadbeef 0000ffffa7c27470
    [ 37.430190] [< (null)>] (null)
    [ 37.434982] [] machine_restart+0x6c/0x70
    [ 37.440550] [] kernel_restart+0x6c/0x78
    [ 37.446030] [] SyS_reboot+0x130/0x228
    [ 37.451337] [] el0_svc_naked+0x24/0x28
    [ 37.456737] Code: bad PC value
    [ 37.459891] ---[ end trace 76e2fc17e050aecd ]---

    Signed-off-by: Julien Grall

    --

    Cc: Boris Ostrovsky
    Cc: Juergen Gross
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: x86@kernel.org

    The x86 code has theoritically a similar issue, altought EFI does not
    seem to be the preferred method. I have only built test it on x86.

    This should also probably be fixed in stable tree.

    Changes in v2:
    - Implement xen_efi_reset_system using xen_reboot
    - Move xen_efi_reset_system in drivers/xen/efi.c
    Signed-off-by: Juergen Gross

    Julien Grall
     
  • Signed-off-by: Julien Grall
    Signed-off-by: Juergen Gross

    Julien Grall
     

08 Mar, 2017

1 commit


26 Feb, 2017

1 commit

  • Pull rdma DMA mapping updates from Doug Ledford:
    "Drop IB DMA mapping code and use core DMA code instead.

    Bart Van Assche noted that the ib DMA mapping code was significantly
    similar enough to the core DMA mapping code that with a few changes it
    was possible to remove the IB DMA mapping code entirely and switch the
    RDMA stack to use the core DMA mapping code.

    This resulted in a nice set of cleanups, but touched the entire tree
    and has been kept separate for that reason."

    * tag 'for-next-dma_ops' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (37 commits)
    IB/rxe, IB/rdmavt: Use dma_virt_ops instead of duplicating it
    IB/core: Remove ib_device.dma_device
    nvme-rdma: Switch from dma_device to dev.parent
    RDS: net: Switch from dma_device to dev.parent
    IB/srpt: Modify a debug statement
    IB/srp: Switch from dma_device to dev.parent
    IB/iser: Switch from dma_device to dev.parent
    IB/IPoIB: Switch from dma_device to dev.parent
    IB/rxe: Switch from dma_device to dev.parent
    IB/vmw_pvrdma: Switch from dma_device to dev.parent
    IB/usnic: Switch from dma_device to dev.parent
    IB/qib: Switch from dma_device to dev.parent
    IB/qedr: Switch from dma_device to dev.parent
    IB/ocrdma: Switch from dma_device to dev.parent
    IB/nes: Remove a superfluous assignment statement
    IB/mthca: Switch from dma_device to dev.parent
    IB/mlx5: Switch from dma_device to dev.parent
    IB/mlx4: Switch from dma_device to dev.parent
    IB/i40iw: Remove a superfluous assignment statement
    IB/hns: Switch from dma_device to dev.parent
    ...

    Linus Torvalds
     

15 Feb, 2017

1 commit

  • Recently a new dm_op[1] hypercall was added to Xen to provide a mechanism
    for restricting device emulators (such as QEMU) to a limited set of
    hypervisor operations, and being able to audit those operations in the
    kernel of the domain in which they run.

    This patch adds IOCTL_PRIVCMD_DM_OP as gateway for __HYPERVISOR_dm_op.

    NOTE: There is no requirement for user-space code to bounce data through
    locked memory buffers (as with IOCTL_PRIVCMD_HYPERCALL) since
    privcmd has enough information to lock the original buffers
    directly.

    [1] http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=524a98c2

    Signed-off-by: Paul Durrant
    Acked-by: Stefano Stabellini
    Signed-off-by: Boris Ostrovsky

    Paul Durrant
     

14 Feb, 2017

2 commits


25 Jan, 2017

1 commit

  • Most dma_map_ops structures are never modified. Constify these
    structures such that these can be write-protected. This patch
    has been generated as follows:

    git grep -l 'struct dma_map_ops' |
    xargs -d\\n sed -i \
    -e 's/struct dma_map_ops/const struct dma_map_ops/g' \
    -e 's/const struct dma_map_ops {/struct dma_map_ops {/g' \
    -e 's/^const struct dma_map_ops;$/struct dma_map_ops;/' \
    -e 's/const const struct dma_map_ops /const struct dma_map_ops /g';
    sed -i -e 's/const \(struct dma_map_ops intel_dma_ops\)/\1/' \
    $(git grep -l 'struct dma_map_ops intel_dma_ops');
    sed -i -e 's/const \(struct dma_map_ops dma_iommu_ops\)/\1/' \
    $(git grep -l 'struct dma_map_ops' | grep ^arch/powerpc);
    sed -i -e '/^struct vmd_dev {$/,/^};$/ s/const \(struct dma_map_ops[[:blank:]]dma_ops;\)/\1/' \
    -e '/^static void vmd_setup_dma_ops/,/^}$/ s/const \(struct dma_map_ops \*dest\)/\1/' \
    -e 's/const \(struct dma_map_ops \*dest = \&vmd->dma_ops\)/\1/' \
    drivers/pci/host/*.c
    sed -i -e '/^void __init pci_iommu_alloc(void)$/,/^}$/ s/dma_ops->/intel_dma_ops./' arch/ia64/kernel/pci-dma.c
    sed -i -e 's/static const struct dma_map_ops sn_dma_ops/static struct dma_map_ops sn_dma_ops/' arch/ia64/sn/pci/pci_dma.c
    sed -i -e 's/(const struct dma_map_ops \*)//' drivers/misc/mic/bus/vop_bus.c

    Signed-off-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Cc: Benjamin Herrenschmidt
    Cc: Boris Ostrovsky
    Cc: David Woodhouse
    Cc: Juergen Gross
    Cc: H. Peter Anvin
    Cc: Ingo Molnar
    Cc: linux-arch@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: Russell King
    Cc: x86@kernel.org
    Signed-off-by: Doug Ledford

    Bart Van Assche
     

25 Dec, 2016

1 commit

  • When the state names got added a script was used to add the extra argument
    to the calls. The script basically converted the state constant to a
    string, but the cleanup to convert these strings into meaningful ones did
    not happen.

    Replace all the useless strings with 'subsys/xxx/yyy:state' strings which
    are used in all the other places already.

    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Link: http://lkml.kernel.org/r/20161221192112.085444152@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

14 Dec, 2016

1 commit

  • Pull xen updates from Juergen Gross:
    "Xen features and fixes for 4.10

    These are some fixes, a move of some arm related headers to share them
    between arm and arm64 and a series introducing a helper to make code
    more readable.

    The most notable change is David stepping down as maintainer of the
    Xen hypervisor interface. This results in me sending you the pull
    requests for Xen related code from now on"

    * tag 'for-linus-4.10-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: (29 commits)
    xen/balloon: Only mark a page as managed when it is released
    xenbus: fix deadlock on writes to /proc/xen/xenbus
    xen/scsifront: don't request a slot on the ring until request is ready
    xen/x86: Increase xen_e820_map to E820_X_MAX possible entries
    x86: Make E820_X_MAX unconditionally larger than E820MAX
    xen/pci: Bubble up error and fix description.
    xen: xenbus: set error code on failure
    xen: set error code on failures
    arm/xen: Use alloc_percpu rather than __alloc_percpu
    arm/arm64: xen: Move shared architecture headers to include/xen/arm
    xen/events: use xen_vcpu_id mapping for EVTCHNOP_status
    xen/gntdev: Use VM_MIXEDMAP instead of VM_IO to avoid NUMA balancing
    xen-scsifront: Add a missing call to kfree
    MAINTAINERS: update XEN HYPERVISOR INTERFACE
    xenfs: Use proc_create_mount_point() to create /proc/xen
    xen-platform: use builtin_pci_driver
    xen-netback: fix error handling output
    xen: make use of xenbus_read_unsigned() in xenbus
    xen: make use of xenbus_read_unsigned() in xen-pciback
    xen: make use of xenbus_read_unsigned() in xen-fbfront
    ...

    Linus Torvalds
     

08 Dec, 2016

1 commit

  • The function xen_guest_init is using __alloc_percpu with an alignment
    which are not power of two.

    However, the percpu allocator never supported alignments which are not power
    of two and has always behaved incorectly in thise case.

    Commit 3ca45a4 "percpu: ensure requested alignment is power of two"
    introduced a check which trigger a warning [1] when booting linux-next
    on Xen. But in reality this bug was always present.

    This can be fixed by replacing the call to __alloc_percpu with
    alloc_percpu. The latter will use an alignment which are a power of two.

    [1]

    [ 0.023921] illegal size (48) or align (48) for percpu allocation
    [ 0.024167] ------------[ cut here ]------------
    [ 0.024344] WARNING: CPU: 0 PID: 1 at linux/mm/percpu.c:892 pcpu_alloc+0x88/0x6c0
    [ 0.024584] Modules linked in:
    [ 0.024708]
    [ 0.024804] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
    4.9.0-rc7-next-20161128 #473
    [ 0.025012] Hardware name: Foundation-v8A (DT)
    [ 0.025162] task: ffff80003d870000 task.stack: ffff80003d844000
    [ 0.025351] PC is at pcpu_alloc+0x88/0x6c0
    [ 0.025490] LR is at pcpu_alloc+0x88/0x6c0
    [ 0.025624] pc : [] lr : []
    pstate: 60000045
    [ 0.025830] sp : ffff80003d847cd0
    [ 0.025946] x29: ffff80003d847cd0 x28: 0000000000000000
    [ 0.026147] x27: 0000000000000000 x26: 0000000000000000
    [ 0.026348] x25: 0000000000000000 x24: 0000000000000000
    [ 0.026549] x23: 0000000000000000 x22: 00000000024000c0
    [ 0.026752] x21: ffff000008e97000 x20: 0000000000000000
    [ 0.026953] x19: 0000000000000030 x18: 0000000000000010
    [ 0.027155] x17: 0000000000000a3f x16: 00000000deadbeef
    [ 0.027357] x15: 0000000000000006 x14: ffff000088f79c3f
    [ 0.027573] x13: ffff000008f79c4d x12: 0000000000000041
    [ 0.027782] x11: 0000000000000006 x10: 0000000000000042
    [ 0.027995] x9 : ffff80003d847a40 x8 : 6f697461636f6c6c
    [ 0.028208] x7 : 6120757063726570 x6 : ffff000008f79c84
    [ 0.028419] x5 : 0000000000000005 x4 : 0000000000000000
    [ 0.028628] x3 : 0000000000000000 x2 : 000000000000017f
    [ 0.028840] x1 : ffff80003d870000 x0 : 0000000000000035
    [ 0.029056]
    [ 0.029152] ---[ end trace 0000000000000000 ]---
    [ 0.029297] Call trace:
    [ 0.029403] Exception stack(0xffff80003d847b00 to
    0xffff80003d847c30)
    [ 0.029621] 7b00: 0000000000000030 0001000000000000
    ffff80003d847cd0 ffff00000818e678
    [ 0.029901] 7b20: 0000000000000002 0000000000000004
    ffff000008f7c060 0000000000000035
    [ 0.030153] 7b40: ffff000008f79000 ffff000008c4cd88
    ffff80003d847bf0 ffff000008101778
    [ 0.030402] 7b60: 0000000000000030 0000000000000000
    ffff000008e97000 00000000024000c0
    [ 0.030647] 7b80: 0000000000000000 0000000000000000
    0000000000000000 0000000000000000
    [ 0.030895] 7ba0: 0000000000000035 ffff80003d870000
    000000000000017f 0000000000000000
    [ 0.031144] 7bc0: 0000000000000000 0000000000000005
    ffff000008f79c84 6120757063726570
    [ 0.031394] 7be0: 6f697461636f6c6c ffff80003d847a40
    0000000000000042 0000000000000006
    [ 0.031643] 7c00: 0000000000000041 ffff000008f79c4d
    ffff000088f79c3f 0000000000000006
    [ 0.031877] 7c20: 00000000deadbeef 0000000000000a3f
    [ 0.032051] [] pcpu_alloc+0x88/0x6c0
    [ 0.032229] [] __alloc_percpu+0x18/0x20
    [ 0.032409] [] xen_guest_init+0x174/0x2f4
    [ 0.032591] [] do_one_initcall+0x38/0x130
    [ 0.032783] [] kernel_init_freeable+0xe0/0x248
    [ 0.032995] [] kernel_init+0x10/0x100
    [ 0.033172] [] ret_from_fork+0x10/0x50

    Reported-by: Wei Chen
    Link: https://lkml.org/lkml/2016/11/28/669
    Signed-off-by: Julien Grall
    Signed-off-by: Stefano Stabellini
    Reviewed-by: Stefano Stabellini
    Cc: stable@vger.kernel.org

    Julien Grall
     

08 Nov, 2016

1 commit

  • The mapping function should always return DMA_ERROR_CODE when a mapping has
    failed as this is what the DMA API expects when a DMA error has occurred.
    The current function for mapping a page in Xen was returning either
    DMA_ERROR_CODE or 0 depending on where it failed.

    On x86 DMA_ERROR_CODE is 0, but on other architectures such as ARM it is
    ~0. We need to make sure we return the same error value if either the
    mapping failed or the device is not capable of accessing the mapping.

    If we are returning DMA_ERROR_CODE as our error value we can drop the
    function for checking the error code as the default is to compare the
    return value against DMA_ERROR_CODE if no function is defined.

    Cc: Konrad Rzeszutek Wilk
    Signed-off-by: Alexander Duyck
    Signed-off-by: Konrad Rzeszutek Wilk

    Alexander Duyck
     

14 Sep, 2016

1 commit

  • Commit 88e957d6e47f ("xen: introduce xen_vcpu_id mapping") broke SMP
    ARM guests on Xen. When FIFO-based event channels are in use (this is
    the default), evtchn_fifo_alloc_control_block() is called on
    CPU_UP_PREPARE event and this happens before we set up xen_vcpu_id
    mapping in xen_starting_cpu. Temporary fix the issue by setting direct
    Linux CPU id Xen vCPU id mapping for all possible CPUs at boot. We
    don't currently support kexec/kdump on Xen/ARM so these ids always
    match.

    In future, we have several ways to solve the issue, e.g.:

    - Eliminate all hypercalls from CPU_UP_PREPARE, do them from the
    starting CPU. This can probably be done for both x86 and ARM and, if
    done, will allow us to get Xen's idea of vCPU id from CPUID/MPIDR on
    the starting CPU directly, no messing with ACPI/device tree
    required.

    - Save vCPU id information from ACPI/device tree on ARM and use it to
    initialize xen_vcpu_id mapping. This is the same trick we currently
    do on x86.

    Reported-by: Julien Grall
    Tested-by: Wei Chen
    Signed-off-by: Vitaly Kuznetsov
    Acked-by: Stefano Stabellini
    Signed-off-by: David Vrabel

    Vitaly Kuznetsov
     

25 Aug, 2016

1 commit

  • We pass xen_vcpu_id mapping information to hypercalls which require
    uint32_t type so it would be cleaner to have it as uint32_t. The
    initializer to -1 can be dropped as we always do the mapping before using
    it and we never check the 'not set' value anyway.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: David Vrabel

    Vitaly Kuznetsov
     

04 Aug, 2016

1 commit

  • The dma-mapping core and the implementations do not change the DMA
    attributes passed by pointer. Thus the pointer can point to const data.
    However the attributes do not have to be a bitfield. Instead unsigned
    long will do fine:

    1. This is just simpler. Both in terms of reading the code and setting
    attributes. Instead of initializing local attributes on the stack
    and passing pointer to it to dma_set_attr(), just set the bits.

    2. It brings safeness and checking for const correctness because the
    attributes are passed by value.

    Semantic patches for this change (at least most of them):

    virtual patch
    virtual context

    @r@
    identifier f, attrs;

    @@
    f(...,
    - struct dma_attrs *attrs
    + unsigned long attrs
    , ...)
    {
    ...
    }

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
    )

    and

    // Options: --all-includes
    virtual patch
    virtual context

    @r@
    identifier f, attrs;
    type t;

    @@
    t f(..., struct dma_attrs *attrs);

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
    )

    Link: http://lkml.kernel.org/r/1468399300-5399-2-git-send-email-k.kozlowski@samsung.com
    Signed-off-by: Krzysztof Kozlowski
    Acked-by: Vineet Gupta
    Acked-by: Robin Murphy
    Acked-by: Hans-Christian Noren Egtvedt
    Acked-by: Mark Salter [c6x]
    Acked-by: Jesper Nilsson [cris]
    Acked-by: Daniel Vetter [drm]
    Reviewed-by: Bart Van Assche
    Acked-by: Joerg Roedel [iommu]
    Acked-by: Fabien Dessenne [bdisp]
    Reviewed-by: Marek Szyprowski [vb2-core]
    Acked-by: David Vrabel [xen]
    Acked-by: Konrad Rzeszutek Wilk [xen swiotlb]
    Acked-by: Joerg Roedel [iommu]
    Acked-by: Richard Kuo [hexagon]
    Acked-by: Geert Uytterhoeven [m68k]
    Acked-by: Gerald Schaefer [s390]
    Acked-by: Bjorn Andersson
    Acked-by: Hans-Christian Noren Egtvedt [avr32]
    Acked-by: Vineet Gupta [arc]
    Acked-by: Robin Murphy [arm64 and dma-iommu]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Krzysztof Kozlowski
     

30 Jul, 2016

1 commit

  • Pull smp hotplug updates from Thomas Gleixner:
    "This is the next part of the hotplug rework.

    - Convert all notifiers with a priority assigned

    - Convert all CPU_STARTING/DYING notifiers

    The final removal of the STARTING/DYING infrastructure will happen
    when the merge window closes.

    Another 700 hundred line of unpenetrable maze gone :)"

    * 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (70 commits)
    timers/core: Correct callback order during CPU hot plug
    leds/trigger/cpu: Move from CPU_STARTING to ONLINE level
    powerpc/numa: Convert to hotplug state machine
    arm/perf: Fix hotplug state machine conversion
    irqchip/armada: Avoid unused function warnings
    ARC/time: Convert to hotplug state machine
    clocksource/atlas7: Convert to hotplug state machine
    clocksource/armada-370-xp: Convert to hotplug state machine
    clocksource/exynos_mct: Convert to hotplug state machine
    clocksource/arm_global_timer: Convert to hotplug state machine
    rcu: Convert rcutree to hotplug state machine
    KVM/arm/arm64/vgic-new: Convert to hotplug state machine
    smp/cfd: Convert core to hotplug state machine
    x86/x2apic: Convert to CPU hotplug state machine
    profile: Convert to hotplug state machine
    timers/core: Convert to hotplug state machine
    hrtimer: Convert to hotplug state machine
    x86/tboot: Convert to hotplug state machine
    arm64/armv8 deprecated: Convert to hotplug state machine
    hwtracing/coresight-etm4x: Convert to hotplug state machine
    ...

    Linus Torvalds
     

25 Jul, 2016

2 commits

  • HYPERVISOR_vcpu_op() passes Linux's idea of vCPU id as a parameter
    while Xen's idea is expected. In some cases these ideas diverge so we
    need to do remapping.

    Convert all callers of HYPERVISOR_vcpu_op() to use xen_vcpu_nr().

    Leave xen_fill_possible_map() and xen_filter_cpu_maps() intact as
    they're only being called by PV guests before perpu areas are
    initialized. While the issue could be solved by switching to
    early_percpu for xen_vcpu_id I think it's not worth it: PV guests will
    probably never get to the point where their idea of vCPU id diverges
    from Xen's.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: David Vrabel

    Vitaly Kuznetsov
     
  • It may happen that Xen's and Linux's ideas of vCPU id diverge. In
    particular, when we crash on a secondary vCPU we may want to do kdump
    and unlike plain kexec where we do migrate_to_reboot_cpu() we try
    booting on the vCPU which crashed. This doesn't work very well for
    PVHVM guests as we have a number of hypercalls where we pass vCPU id
    as a parameter. These hypercalls either fail or do something
    unexpected.

    To solve the issue introduce percpu xen_vcpu_id mapping. ARM and PV
    guests get direct mapping for now. Boot CPU for PVHVM guest gets its
    id from CPUID. With secondary CPUs it is a bit more
    trickier. Currently, we initialize IPI vectors before these CPUs boot
    so we can't use CPUID. Use ACPI ids from MADT instead.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: David Vrabel

    Vitaly Kuznetsov
     

15 Jul, 2016

1 commit

  • Install the callbacks via the state machine and let the core invoke
    the callbacks on the already online CPUs.

    The get_cpu() in xen_starting_cpu() boils down to preempt_disable() since
    we already know the CPU we run on. Disabling preemption shouldn't be required
    here from what I see since it we don't switch CPUs while invoking the function.

    Signed-off-by: Richard Cochran
    Signed-off-by: Anna-Maria Gleixner
    Reviewed-by: Sebastian Andrzej Siewior
    Reviewed-by: Stefano Stabellini
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Russell King
    Cc: Stefano Stabellini
    Cc: Thomas Gleixner
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: rt@linutronix.de
    Cc: xen-devel@lists.xenproject.org
    Link: http://lkml.kernel.org/r/20160713153336.971559670@linutronix.de
    Signed-off-by: Ingo Molnar

    Richard Cochran
     

06 Jul, 2016

7 commits

  • Add support for the Xen HYPERVISOR_vm_assist hypercall.

    Signed-off-by: Juergen Gross
    Reviewed-by: Boris Ostrovsky
    Reviewed-by: Julien Grall
    Reviewed-by: Stefano Stabellini
    Signed-off-by: David Vrabel

    Juergen Gross
     
  • The pv_time_ops structure contains a function pointer for the
    "steal_clock" functionality used only by KVM and Xen on ARM. Xen on x86
    uses its own mechanism to account for the "stolen" time a thread wasn't
    able to run due to hypervisor scheduling.

    Add support in Xen arch independent time handling for this feature by
    moving it out of the arm arch into drivers/xen and remove the x86 Xen
    hack.

    Signed-off-by: Juergen Gross
    Reviewed-by: Boris Ostrovsky
    Reviewed-by: Stefano Stabellini
    Signed-off-by: David Vrabel

    Juergen Gross
     
  • The EFI DT parameters for bare metal are located under /chosen node,
    while for Xen Dom0 they are located under /hyperviosr/uefi node. These
    parameters under /chosen and /hyperviosr/uefi are not expected to appear
    at the same time.

    Parse these EFI parameters and initialize EFI like the way for bare
    metal except the runtime services because the runtime services for Xen
    Dom0 are available through hypercalls and they are always enabled. So it
    sets the EFI_RUNTIME_SERVICES flag if it finds /hyperviosr/uefi node and
    bails out in arm_enable_runtime_services() when EFI_RUNTIME_SERVICES
    flag is set already.

    Signed-off-by: Shannon Zhao
    Cc: Stefano Stabellini
    Cc: Ard Biesheuvel
    Cc: Leif Lindholm
    Signed-off-by: Matt Fleming

    Shannon Zhao
     
  • When running on Xen hypervisor, runtime services are supported through
    hypercall. Add a Xen specific function to initialize runtime services.

    Signed-off-by: Shannon Zhao
    Reviewed-by: Stefano Stabellini
    Tested-by: Julien Grall
    Acked-by: Catalin Marinas

    Shannon Zhao
     
  • Move xen_early_init() before efi_init(), then when calling efi_init()
    could initialize Xen specific UEFI.

    Check if it runs on Xen hypervisor through the flat dts.

    Cc: Russell King
    Signed-off-by: Shannon Zhao
    Reviewed-by: Stefano Stabellini
    Reviewed-by: Julien Grall
    Tested-by: Julien Grall
    Acked-by: Catalin Marinas

    Shannon Zhao
     
  • The kernel will get the event-channel IRQ through
    HVM_PARAM_CALLBACK_IRQ.

    Signed-off-by: Shannon Zhao
    Reviewed-by: Stefano Stabellini
    Reviewed-by: Julien Grall
    Tested-by: Julien Grall

    Shannon Zhao
     
  • Use xen_xlate_map_ballooned_pages to setup grant table. Then it doesn't
    rely on DT or ACPI to pass the start address and size of grant table.

    Signed-off-by: Shannon Zhao
    Acked-by: Stefano Stabellini
    Reviewed-by: Julien Grall
    Tested-by: Julien Grall

    Shannon Zhao
     

21 Dec, 2015

4 commits


07 Nov, 2015

1 commit

  • …d avoiding waking kswapd

    __GFP_WAIT has been used to identify atomic context in callers that hold
    spinlocks or are in interrupts. They are expected to be high priority and
    have access one of two watermarks lower than "min" which can be referred
    to as the "atomic reserve". __GFP_HIGH users get access to the first
    lower watermark and can be called the "high priority reserve".

    Over time, callers had a requirement to not block when fallback options
    were available. Some have abused __GFP_WAIT leading to a situation where
    an optimisitic allocation with a fallback option can access atomic
    reserves.

    This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
    cannot sleep and have no alternative. High priority users continue to use
    __GFP_HIGH. __GFP_DIRECT_RECLAIM identifies callers that can sleep and
    are willing to enter direct reclaim. __GFP_KSWAPD_RECLAIM to identify
    callers that want to wake kswapd for background reclaim. __GFP_WAIT is
    redefined as a caller that is willing to enter direct reclaim and wake
    kswapd for background reclaim.

    This patch then converts a number of sites

    o __GFP_ATOMIC is used by callers that are high priority and have memory
    pools for those requests. GFP_ATOMIC uses this flag.

    o Callers that have a limited mempool to guarantee forward progress clear
    __GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM. bio allocations fall
    into this category where kswapd will still be woken but atomic reserves
    are not used as there is a one-entry mempool to guarantee progress.

    o Callers that are checking if they are non-blocking should use the
    helper gfpflags_allow_blocking() where possible. This is because
    checking for __GFP_WAIT as was done historically now can trigger false
    positives. Some exceptions like dm-crypt.c exist where the code intent
    is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
    flag manipulations.

    o Callers that built their own GFP flags instead of starting with GFP_KERNEL
    and friends now also need to specify __GFP_KSWAPD_RECLAIM.

    The first key hazard to watch out for is callers that removed __GFP_WAIT
    and was depending on access to atomic reserves for inconspicuous reasons.
    In some cases it may be appropriate for them to use __GFP_HIGH.

    The second key hazard is callers that assembled their own combination of
    GFP flags instead of starting with something like GFP_KERNEL. They may
    now wish to specify __GFP_KSWAPD_RECLAIM. It's almost certainly harmless
    if it's missed in most cases as other activity will wake kswapd.

    Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
    Acked-by: Vlastimil Babka <vbabka@suse.cz>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Acked-by: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Vitaly Wool <vitalywool@gmail.com>
    Cc: Rik van Riel <riel@redhat.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

    Mel Gorman
     

23 Oct, 2015

3 commits

  • Call disable_percpu_irq on CPU_DYING and enable_percpu_irq when the cpu
    is coming up.

    Signed-off-by: Stefano Stabellini
    Reviewed-by: Julien Grall

    Stefano Stabellini
     
  • Correct a comment in arch/arm/xen/enlighten.c referencing a wrong
    source file.

    Signed-off-by: Juergen Gross
    Acked-by: Stefano Stabellini
    Signed-off-by: David Vrabel

    Juergen Gross
     
  • Swiotlb is used on ARM64 to support DMA on platform where devices are
    not protected by an SMMU. Furthermore it's only enabled for DOM0.

    While Xen is always using 4KB page granularity in the stage-2 page table,
    Linux ARM64 may either use 4KB or 64KB. This means that a Linux page
    can be spanned accross multiple Xen page.

    The Swiotlb code has to validate that the buffer used for DMA is
    physically contiguous in the memory. As a Linux page can't be shared
    between local memory and foreign page by design (the balloon code always
    removing entirely a Linux page), the changes in the code are very
    minimal because we only need to check the first Xen PFN.

    Note that it may be possible to optimize the function
    check_page_physically_contiguous to avoid looping over every Xen PFN
    for local memory. Although I will let this optimization for a follow-up.

    Signed-off-by: Julien Grall
    Reviewed-by: Stefano Stabellini
    Signed-off-by: David Vrabel

    Julien Grall