1. 15 6月, 2017 3 次提交
    • D
      arm64: Export save_stack_trace_tsk() · e27c7fa0
      Dustin Brown 提交于
      The kernel watchdog is a great debugging tool for finding tasks that
      consume a disproportionate amount of CPU time in contiguous chunks. One
      can imagine building a similar watchdog for arbitrary driver threads
      using save_stack_trace_tsk() and print_stack_trace(). However, this is
      not viable for dynamically loaded driver modules on ARM platforms
      because save_stack_trace_tsk() is not exported for those architectures.
      Export save_stack_trace_tsk() for the ARM64 architecture to align with
      x86 and support various debugging use cases such as arbitrary driver
      thread watchdog timers.
      Signed-off-by: NDustin Brown <dustinb@codeaurora.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      e27c7fa0
    • L
      ARM64/irqchip: Update ACPI_IORT symbol selection logic · c6bb8f89
      Lorenzo Pieralisi 提交于
      ACPI IORT is an ACPI addendum to describe the connection topology of
      devices with IOMMUs and interrupt controllers on ARM64 ACPI systems.
      
      Currently the ACPI IORT Kbuild symbol is selected whenever the Kbuild
      symbol ARM_GIC_V3_ITS is enabled, which in turn is selected by ARM64
      Kbuild defaults. This makes the logic behind ACPI_IORT selection a bit
      twisted and not easy to follow. On ARM64 systems enabling ACPI the
      kbuild symbol ACPI_IORT should always be selected in that it is a kernel
      layer provided to the ARM64 arch code to parse and enable ACPI firmware
      bindings.
      
      Make the ACPI_IORT selection explicit in ARM64 Kbuild and remove the
      selection from ARM_GIC_V3_ITS entry, making the ACPI_IORT selection
      logic clearer to follow.
      Acked-by: NHanjun Guo <hanjun.guo@linaro.org>
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Hanjun Guo <hanjun.guo@linaro.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      c6bb8f89
    • O
      arm64/dma-mapping: Remove extraneous null-pointer checks · 577dfe16
      Olav Haugan 提交于
      The current null-pointer check in __dma_alloc_coherent and
      __dma_free_coherent is not needed anymore since the
      __dma_alloc/__dma_free functions won't be called if !dev (dummy ops will
      be called instead).
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NOlav Haugan <ohaugan@codeaurora.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      577dfe16
  2. 12 6月, 2017 9 次提交
  3. 07 6月, 2017 3 次提交
  4. 05 6月, 2017 1 次提交
  5. 02 6月, 2017 1 次提交
    • A
      arm64: kernel: restrict /dev/mem read() calls to linear region · 1151f838
      Ard Biesheuvel 提交于
      When running lscpu on an AArch64 system that has SMBIOS version 2.0
      tables, it will segfault in the following way:
      
        Unable to handle kernel paging request at virtual address ffff8000bfff0000
        pgd = ffff8000f9615000
        [ffff8000bfff0000] *pgd=0000000000000000
        Internal error: Oops: 96000007 [#1] PREEMPT SMP
        Modules linked in:
        CPU: 0 PID: 1284 Comm: lscpu Not tainted 4.11.0-rc3+ #103
        Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
        task: ffff8000fa78e800 task.stack: ffff8000f9780000
        PC is at __arch_copy_to_user+0x90/0x220
        LR is at read_mem+0xcc/0x140
      
      This is caused by the fact that lspci issues a read() on /dev/mem at the
      offset where it expects to find the SMBIOS structure array. However, this
      region is classified as EFI_RUNTIME_SERVICE_DATA (as per the UEFI spec),
      and so it is omitted from the linear mapping.
      
      So let's restrict /dev/mem read/write access to those areas that are
      covered by the linear region.
      Reported-by: NAlexander Graf <agraf@suse.de>
      Fixes: 4dffbfc4 ("arm64/efi: mark UEFI reserved regions as MEMBLOCK_NOMAP")
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      1151f838
  6. 30 5月, 2017 8 次提交
    • L
      ARM64/PCI: Set root bus NUMA node on ACPI systems · db46a72b
      Lorenzo Pieralisi 提交于
      PCI core requires the NUMA node for the struct pci_host_bridge.dev to
      be set by using the pcibus_to_node(struct pci_bus*) API, that on ARM64
      systems relies on the struct pci_host_bridge->bus.dev NUMA node.
      
      The struct pci_host_bridge.dev NUMA node is then propagated through
      the PCI device hierarchy as PCI devices (and bridges) are enumerated
      under it.
      
      Therefore, in order to set-up the PCI NUMA hierarchy appropriately, the
      struct pci_host_bridge->bus.dev NUMA node must be set before core
      code calls pcibus_to_node(struct pci_bus*) on it so that PCI core can
      retrieve the NUMA node for the struct pci_host_bridge.dev device and can
      propagate it through the PCI bus tree.
      
      On ARM64 ACPI based systems the struct pci_host_bridge->bus.dev NUMA
      node can be set-up in pcibios_root_bridge_prepare() by parsing the root
      bridge ACPI device firmware binding.
      
      Add code to the pcibios_root_bridge_prepare() that, when booting with
      ACPI, parse the root bridge ACPI device companion NUMA binding and set
      the corresponding struct pci_host_bridge->bus.dev NUMA node
      appropriately.
      
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: NRobert Richter <rrichter@cavium.com>
      Tested-by: NRobert Richter <rrichter@cavium.com>
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      db46a72b
    • W
      arm64: futex: Fix undefined behaviour with FUTEX_OP_OPARG_SHIFT usage · 5f16a046
      Will Deacon 提交于
      FUTEX_OP_OPARG_SHIFT instructs the futex code to treat the 12-bit oparg
      field as a shift value, potentially leading to a left shift value that
      is negative or with an absolute value that is significantly larger then
      the size of the type. UBSAN chokes with:
      
      ================================================================================
      UBSAN: Undefined behaviour in ./arch/arm64/include/asm/futex.h:60:13
      shift exponent -1 is negative
      CPU: 1 PID: 1449 Comm: syz-executor0 Not tainted 4.11.0-rc4-00005-g977eb52-dirty #11
      Hardware name: linux,dummy-virt (DT)
      Call trace:
      [<ffff200008094778>] dump_backtrace+0x0/0x538 arch/arm64/kernel/traps.c:73
      [<ffff200008094cd0>] show_stack+0x20/0x30 arch/arm64/kernel/traps.c:228
      [<ffff200008c194a8>] __dump_stack lib/dump_stack.c:16 [inline]
      [<ffff200008c194a8>] dump_stack+0x120/0x188 lib/dump_stack.c:52
      [<ffff200008cc24b8>] ubsan_epilogue+0x18/0x98 lib/ubsan.c:164
      [<ffff200008cc3098>] __ubsan_handle_shift_out_of_bounds+0x250/0x294 lib/ubsan.c:421
      [<ffff20000832002c>] futex_atomic_op_inuser arch/arm64/include/asm/futex.h:60 [inline]
      [<ffff20000832002c>] futex_wake_op kernel/futex.c:1489 [inline]
      [<ffff20000832002c>] do_futex+0x137c/0x1740 kernel/futex.c:3231
      [<ffff200008320504>] SYSC_futex kernel/futex.c:3281 [inline]
      [<ffff200008320504>] SyS_futex+0x114/0x268 kernel/futex.c:3249
      [<ffff200008084770>] el0_svc_naked+0x24/0x28
      ================================================================================
      syz-executor1 uses obsolete (PF_INET,SOCK_PACKET)
      sock: process `syz-executor0' is using obsolete setsockopt SO_BSDCOMPAT
      
      This patch attempts to fix some of this by:
      
        * Making encoded_op an unsigned type, so we can shift it left even if
          the top bit is set.
      
        * Casting to signed prior to shifting right when extracting oparg
          and cmparg
      
        * Consider only the bottom 5 bits of oparg when using it as a left-shift
          value.
      
      Whilst I think this catches all of the issues, I'd much prefer to remove
      this stuff, as I think it's unused and the bugs are copy-pasted between
      a bunch of architectures.
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      5f16a046
    • K
      arm64: check return value of of_flat_dt_get_machine_name · 690e95dd
      Kefeng Wang 提交于
      It's useless to print machine name and setup arch-specific system
      identifiers if of_flat_dt_get_machine_name() return NULL, especially
      when ACPI-based boot.
      Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      690e95dd
    • W
      arm64: cpufeature: Don't dump useless backtrace on CPU_OUT_OF_SPEC · 3fde2999
      Will Deacon 提交于
      Unfortunately, it turns out that mismatched CPU features in big.LITTLE
      systems are starting to appear in the wild. Whilst we should continue to
      taint the kernel with CPU_OUT_OF_SPEC for features that differ in ways
      that we can't fix up, dumping a useless backtrace out of the cpufeature
      code is pointless and irritating.
      
      This patch removes the backtrace from the taint.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3fde2999
    • T
      arm64: mm: explicity include linux/vmalloc.h · 6efd8499
      Tobias Klauser 提交于
      arm64's mm/mmu.c uses vm_area_add_early, struct vm_area and other
      definitions  but relies on implict inclusion of linux/vmalloc.h which
      means that changes in other headers could break the build. Thus, add an
      explicit include.
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NTobias Klauser <tklauser@distanz.ch>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      6efd8499
    • K
      arm64: Add dump_backtrace() in show_regs · 1149aad1
      Kefeng Wang 提交于
      Generic code expects show_regs() to dump the stack, but arm64's
      show_regs() does not. This makes it hard to debug softlockups and
      other issues that result in show_regs() being called.
      
      This patch updates arm64's show_regs() to dump the stack, as common
      code expects.
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>
      [will: folded in bug_handler fix from mrutland]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      1149aad1
    • K
      arm64: Call __show_regs directly · c07ab957
      Kefeng Wang 提交于
      Generic code expects show_regs() to also dump the stack, but arm64's
      show_reg() does not do this. Some arm64 callers of show_regs() *only*
      want the registers dumped, without the stack.
      
      To enable generic code to work as expected, we need to make
      show_regs() dump the stack. Where we only want the registers dumped,
      we must use __show_regs().
      
      This patch updates code to use __show_regs() where only registers are
      desired. A subsequent patch will modify show_regs().
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      c07ab957
    • D
      arm64: Preventing READ_IMPLIES_EXEC propagation · 48f99c8e
      Dong Bo 提交于
      Like arch/arm/, we inherit the READ_IMPLIES_EXEC personality flag across
      fork(). This is undesirable for a number of reasons:
      
        * ELF files that don't require executable stack can end up with it
          anyway
      
        * We end up performing un-necessary I-cache maintenance when mapping
          what should be non-executable pages
      
        * Restricting what is executable is generally desirable when defending
          against overflow attacks
      
      This patch clears the personality flag when setting up the personality for
      newly spwaned native tasks. Given that semi-recent AArch64 toolchains emit
      a non-executable PT_GNU_STACK header, userspace applications can already
      not rely on READ_IMPLIES_EXEC so shouldn't be adversely affected by this
      change.
      
      Cc: <stable@vger.kernel.org>
      Reported-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NDong Bo <dongbo4@huawei.com>
      [will: added comment to compat code, rewrote commit message]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      48f99c8e
  7. 23 5月, 2017 5 次提交
  8. 19 5月, 2017 4 次提交
    • A
      arm64: dts: rockchip: fix include reference · 6bf1c2d2
      Arnd Bergmann 提交于
      The way we handle include paths for DT has changed a bit, which
      broke a file that had an unconventional way to reference a common
      header file:
      
      arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts:47:10: fatal error: include/dt-bindings/input/linux-event-codes.h: No such file or directory
      
      This removes the leading "include/" from the path name, which fixes it.
      
      Fixes: d5d332d3 ("devicetree: Move include prefixes from arch to separate directory")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      6bf1c2d2
    • R
      arm64: defconfig: enable options needed for QCom DB410c board · f4e506c5
      Rob Herring 提交于
      Enable Qualcomm drivers needed to boot Dragonboard 410c with HDMI. This
      enables support for clocks, regulators, and USB PHY.
      
      Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      [Olof: Turned off _RPM configs per follow-up email]
      Signed-off-by: NOlof Johansson <olof@lixom.net>
      f4e506c5
    • R
      arm64: defconfig: sync with savedefconfig · eb1e6716
      Rob Herring 提交于
      Sync the defconfig with savedefconfig as config options change/move over
      time.
      
      Generated with the following commands:
      make defconfig
      make savedefconfig
      cp defconfig arch/arm64/configs/defconfig
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NOlof Johansson <olof@lixom.net>
      eb1e6716
    • O
      devicetree: Move include prefixes from arch to separate directory · d5d332d3
      Olof Johansson 提交于
      We use a directory under arch/$ARCH/boot/dts as an include path
      that has links outside of the subtree to find dt-bindings from under
      include/dt-bindings. That's been working well, but new DT architectures
      haven't been adding them by default.
      
      Recently there's been a desire to share some of the DT material between
      arm and arm64, which originally caused developers to create symlinks or
      relative includes between the subtrees. This isn't ideal -- it breaks
      if the DT files aren't stored in the exact same hierarchy as the kernel
      tree, and generally it's just icky.
      
      As a somewhat cleaner solution we decided to add a $ARCH/ prefix link
      once, and allow DTS files to reference dtsi (and dts) files in other
      architectures that way.
      
      Original approach was to create these links under each architecture,
      but it lead to the problem of recursive symlinks.
      
      As a remedy, move the include link directories out of the architecture
      trees into a common location. At the same time, they can now share one
      directory and one dt-bindings/ link as well.
      
      Fixes: 4027494a ('ARM: dts: add arm/arm64 include symlinks')
      Reported-by: NRussell King <linux@armlinux.org.uk>
      Reported-by: NOmar Sandoval <osandov@osandov.com>
      Reviewed-by: NHeiko Stuebner <heiko@sntech.de>
      Reviewed-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: NHeiko Stuebner <heiko@sntech.de>
      Acked-by: NRob Herring <robh@kernel.org>
      Cc: Heiko Stuebner <heiko@sntech.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Mikael Starvik <starvik@axis.com>
      Cc: Jesper Nilsson <jesper.nilsson@axis.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: linux-arch <linux-arch@vger.kernel.org>
      Signed-off-by: NOlof Johansson <olof@lixom.net>
      d5d332d3
  9. 18 5月, 2017 1 次提交
    • M
      arm64/cpufeature: don't use mutex in bringup path · 63a1e1c9
      Mark Rutland 提交于
      Currently, cpus_set_cap() calls static_branch_enable_cpuslocked(), which
      must take the jump_label mutex.
      
      We call cpus_set_cap() in the secondary bringup path, from the idle
      thread where interrupts are disabled. Taking a mutex in this path "is a
      NONO" regardless of whether it's contended, and something we must avoid.
      We didn't spot this until recently, as ___might_sleep() won't warn for
      this case until all CPUs have been brought up.
      
      This patch avoids taking the mutex in the secondary bringup path. The
      poking of static keys is deferred until enable_cpu_capabilities(), which
      runs in a suitable context on the boot CPU. To account for the static
      keys being set later, cpus_have_const_cap() is updated to use another
      static key to check whether the const cap keys have been initialised,
      falling back to the caps bitmap until this is the case.
      
      This means that users of cpus_have_const_cap() gain should only gain a
      single additional NOP in the fast path once the const caps are
      initialised, but should always see the current cap value.
      
      The hyp code should never dereference the caps array, since the caps are
      initialized before we run the module initcall to initialise hyp. A check
      is added to the hyp init code to document this requirement.
      
      This change will sidestep a number of issues when the upcoming hotplug
      locking rework is merged.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Reviewed-by: NMarc Zyniger <marc.zyngier@arm.com>
      Reviewed-by: NSuzuki Poulose <suzuki.poulose@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Christoffer Dall <christoffer.dall@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sebastian Sewior <bigeasy@linutronix.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      63a1e1c9
  10. 16 5月, 2017 2 次提交
    • G
      arm64: perf: Ignore exclude_hv when kernel is running in HYP · 78a19cfd
      Ganapatrao Kulkarni 提交于
      commit d98ecdac ("arm64: perf: Count EL2 events if the kernel is
      running in HYP") returns -EINVAL when perf system call perf_event_open is
      called with exclude_hv != exclude_kernel. This change breaks applications
      on VHE enabled ARMv8.1 platforms. The issue was observed with HHVM
      application, which calls perf_event_open with exclude_hv = 1 and
      exclude_kernel = 0.
      
      There is no separate hypervisor privilege level when VHE is enabled, the
      host kernel runs at EL2. So when VHE is enabled, we should ignore
      exclude_hv from the application. This behaviour is consistent with PowerPC
      where the exclude_hv is ignored when the hypervisor is not present and with
      x86 where this flag is ignored.
      Signed-off-by: NGanapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
      [will: added comment to justify the behaviour of exclude_hv]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      78a19cfd
    • R
      arm64: Remove redundant mov from LL/SC cmpxchg · 8df728e1
      Robin Murphy 提交于
      The cmpxchg implementation introduced by commit c342f782 ("arm64:
      cmpxchg: patch in lse instructions when supported by the CPU") performs
      an apparently redundant register move of [old] to [oldval] in the
      success case - it always uses the same register width as [oldval] was
      originally loaded with, and is only executed when [old] and [oldval] are
      known to be equal anyway.
      
      The only effect it seemingly does have is to take up a surprising amount
      of space in the kernel text, as removing it reveals:
      
         text	   data	    bss	    dec	    hex	filename
      12426658	1348614	4499749	18275021	116dacd	vmlinux.o.new
      12429238	1348614	4499749	18277601	116e4e1	vmlinux.o.old
      Reviewed-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      8df728e1
  11. 15 5月, 2017 1 次提交
  12. 12 5月, 2017 1 次提交
    • D
      bpf, arm64: fix faulty emission of map access in tail calls · d8b54110
      Daniel Borkmann 提交于
      Shubham was recently asking on netdev why in arm64 JIT we don't multiply
      the index for accessing the tail call map by 8. That led me into testing
      out arm64 JIT wrt tail calls and it turned out I got a NULL pointer
      dereference on the tail call.
      
      The buggy access is at:
      
        prog = array->ptrs[index];
        if (prog == NULL)
            goto out;
      
        [...]
        00000060:  d2800e0a  mov x10, #0x70 // #112
        00000064:  f86a682a  ldr x10, [x1,x10]
        00000068:  f862694b  ldr x11, [x10,x2]
        0000006c:  b40000ab  cbz x11, 0x00000080
        [...]
      
      The code triggering the crash is f862694b. x1 at the time contains the
      address of the bpf array, x10 offsetof(struct bpf_array, ptrs). Meaning,
      above we load the pointer to the program at map slot 0 into x10. x10
      can then be NULL if the slot is not occupied, which we later on try to
      access with a user given offset in x2 that is the map index.
      
      Fix this by emitting the following instead:
      
        [...]
        00000060:  d2800e0a  mov x10, #0x70 // #112
        00000064:  8b0a002a  add x10, x1, x10
        00000068:  d37df04b  lsl x11, x2, #3
        0000006c:  f86b694b  ldr x11, [x10,x11]
        00000070:  b40000ab  cbz x11, 0x00000084
        [...]
      
      This basically adds the offset to ptrs to the base address of the bpf
      array we got and we later on access the map with an index * 8 offset
      relative to that. The tail call map itself is basically one large area
      with meta data at the head followed by the array of prog pointers.
      This makes tail calls working again, tested on Cavium ThunderX ARMv8.
      
      Fixes: ddb55992 ("arm64: bpf: implement bpf_tail_call() helper")
      Reported-by: NShubham Bansal <illusionist.neo@gmail.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d8b54110
  13. 11 5月, 2017 1 次提交