1. 24 5月, 2018 1 次提交
  2. 23 5月, 2018 1 次提交
    • P
      arm64: fault: Don't leak data in ESR context for user fault on kernel VA · cc198460
      Peter Maydell 提交于
      If userspace faults on a kernel address, handing them the raw ESR
      value on the sigframe as part of the delivered signal can leak data
      useful to attackers who are using information about the underlying hardware
      fault type (e.g. translation vs permission) as a mechanism to defeat KASLR.
      
      However there are also legitimate uses for the information provided
      in the ESR -- notably the GCC and LLVM sanitizers use this to report
      whether wild pointer accesses by the application are reads or writes
      (since a wild write is a more serious bug than a wild read), so we
      don't want to drop the ESR information entirely.
      
      For faulting addresses in the kernel, sanitize the ESR. We choose
      to present userspace with the illusion that there is nothing mapped
      in the kernel's part of the address space at all, by reporting all
      faults as level 0 translation faults taken to EL1.
      
      These fields are safe to pass through to userspace as they depend
      only on the instruction that userspace used to provoke the fault:
       EC IL (always)
       ISV CM WNR (for all data aborts)
      All the other fields in ESR except DFSC are architecturally RES0
      for an L0 translation fault taken to EL1, so can be zeroed out
      without confusing userspace.
      
      The illusion is not entirely perfect, as there is a tiny wrinkle
      where we will report an alignment fault that was not due to the memory
      type (for instance a LDREX to an unaligned address) as a translation
      fault, whereas if you do this on real unmapped memory the alignment
      fault takes precedence. This is not likely to trip anybody up in
      practice, as the only users we know of for the ESR information who
      care about the behaviour for kernel addresses only really want to
      know about the WnR bit.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      cc198460
  3. 22 5月, 2018 2 次提交
    • J
      arm64: export tishift functions to modules · 255845fc
      Jason A. Donenfeld 提交于
      Otherwise modules that use these arithmetic operations will fail to
      link. We accomplish this with the usual EXPORT_SYMBOL, which on most
      architectures goes in the .S file but the ARM64 maintainers prefer that
      insead it goes into arm64ksyms.
      
      While we're at it, we also fix this up to use SPDX, and I personally
      choose to relicense this as GPL2||BSD so that these symbols don't need
      to be export_symbol_gpl, so all modules can use the routines, since
      these are important general purpose compiler-generated function calls.
      Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
      Reported-by: NPaX Team <pageexec@freemail.hu>
      Cc: stable@vger.kernel.org
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      255845fc
    • W
      arm64: lse: Add early clobbers to some input/output asm operands · 32c3fa7c
      Will Deacon 提交于
      For LSE atomics that read and write a register operand, we need to
      ensure that these operands are annotated as "early clobber" if the
      register is written before all of the input operands have been consumed.
      Failure to do so can result in the compiler allocating the same register
      to both operands, leading to splats such as:
      
       Unable to handle kernel paging request at virtual address 11111122222221
       [...]
       x1 : 1111111122222222 x0 : 1111111122222221
       Process swapper/0 (pid: 1, stack limit = 0x000000008209f908)
       Call trace:
        test_atomic64+0x1360/0x155c
      
      where x0 has been allocated as both the value to be stored and also the
      atomic_t pointer.
      
      This patch adds the missing clobbers.
      
      Cc: <stable@vger.kernel.org>
      Cc: Dave Martin <dave.martin@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Reported-by: NMark Salter <msalter@redhat.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      32c3fa7c
  4. 15 5月, 2018 1 次提交
  5. 14 5月, 2018 1 次提交
    • M
      arm64: dts: exynos: Fix interrupt type for I2S1 device on Exynos5433 · 0d463d84
      Marek Szyprowski 提交于
      All interrupts from SoC internal modules are level triggered, so fix
      incorrect trigger type for I2S1 device on Exynos5433 SoCs.
      
      This fixes following kernel warning:
      
      WARNING: CPU: 2 PID: 1 at drivers/irqchip/irq-gic.c:1016 gic_irq_domain_translate+0xb0/0xb8
      Modules linked in:
      CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.16.0-rc7-next-20180329 #646
      Hardware name: Samsung TM2 board (DT)
      pstate: 20000005 (nzCv daif -PAN -UAO)
      pc : gic_irq_domain_translate+0xb0/0xb8
      lr : irq_create_fwspec_mapping+0x64/0x328
      sp : ffff0000098b38d0
      ...
      Call trace:
       gic_irq_domain_translate+0xb0/0xb8
       irq_create_of_mapping+0x78/0xa0
       of_irq_get+0x6c/0xa0
       of_irq_to_resource+0x38/0x108
       of_irq_to_resource_table+0x50/0x78
       of_device_alloc+0x118/0x1b8
       of_platform_device_create_pdata+0x54/0xe0
       of_platform_bus_create+0x118/0x340
       of_platform_bus_create+0x17c/0x340
       of_platform_populate+0x74/0xd8
       of_platform_default_populate_init+0xb0/0xcc
       do_one_initcall+0x50/0x158
       kernel_init_freeable+0x184/0x22c
       kernel_init+0x10/0x108
       ret_from_fork+0x10/0x18
      ---[ end trace 6decb2b3078d73f0 ]---
      
      Fixes: d8d579c3 ("ARM: dts: exynos: Add I2S1 device node to exynos5433")
      Signed-off-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: NOlof Johansson <olof@lixom.net>
      0d463d84
  6. 09 5月, 2018 2 次提交
  7. 04 5月, 2018 2 次提交
    • J
      arm64: vgic-v2: Fix proxying of cpuif access · b220244d
      James Morse 提交于
      Proxying the cpuif accesses at EL2 makes use of vcpu_data_guest_to_host
      and co, which check the endianness, which call into vcpu_read_sys_reg...
      which isn't mapped at EL2 (it was inlined before, and got moved OoL
      with the VHE optimizations).
      
      The result is of course a nice panic. Let's add some specialized
      cruft to keep the broken platforms that require this hack alive.
      
      But, this code used vcpu_data_guest_to_host(), which expected us to
      write the value to host memory, instead we have trapped the guest's
      read or write to an mmio-device, and are about to replay it using the
      host's readl()/writel() which also perform swabbing based on the host
      endianness. This goes wrong when both host and guest are big-endian,
      as readl()/writel() will undo the guest's swabbing, causing the
      big-endian value to be written to device-memory.
      
      What needs doing?
      A big-endian guest will have pre-swabbed data before storing, undo this.
      If its necessary for the host, writel() will re-swab it.
      
      For a read a big-endian guest expects to swab the data after the load.
      The hosts's readl() will correct for host endianness, giving us the
      device-memory's value in the register. For a big-endian guest, swab it
      as if we'd only done the load.
      
      For a little-endian guest, nothing needs doing as readl()/writel() leave
      the correct device-memory value in registers.
      
      Tested on Juno with that rarest of things: a big-endian 64K host.
      Based on a patch from Marc Zyngier.
      Reported-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Fixes: bf8feb39 ("arm64: KVM: vgic-v2: Add GICV access from HYP")
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      b220244d
    • J
      KVM: arm64: Fix order of vcpu_write_sys_reg() arguments · 1975fa56
      James Morse 提交于
      A typo in kvm_vcpu_set_be()'s call:
      | vcpu_write_sys_reg(vcpu, SCTLR_EL1, sctlr)
      causes us to use the 32bit register value as an index into the sys_reg[]
      array, and sail off the end of the linear map when we try to bring up
      big-endian secondaries.
      
      | Unable to handle kernel paging request at virtual address ffff80098b982c00
      | Mem abort info:
      |  ESR = 0x96000045
      |  Exception class = DABT (current EL), IL = 32 bits
      |   SET = 0, FnV = 0
      |   EA = 0, S1PTW = 0
      | Data abort info:
      |   ISV = 0, ISS = 0x00000045
      |   CM = 0, WnR = 1
      | swapper pgtable: 4k pages, 48-bit VAs, pgdp = 000000002ea0571a
      | [ffff80098b982c00] pgd=00000009ffff8803, pud=0000000000000000
      | Internal error: Oops: 96000045 [#1] PREEMPT SMP
      | Modules linked in:
      | CPU: 2 PID: 1561 Comm: kvm-vcpu-0 Not tainted 4.17.0-rc3-00001-ga912e2261ca6-dirty #1323
      | Hardware name: ARM Juno development board (r1) (DT)
      | pstate: 60000005 (nZCv daif -PAN -UAO)
      | pc : vcpu_write_sys_reg+0x50/0x134
      | lr : vcpu_write_sys_reg+0x50/0x134
      
      | Process kvm-vcpu-0 (pid: 1561, stack limit = 0x000000006df4728b)
      | Call trace:
      |  vcpu_write_sys_reg+0x50/0x134
      |  kvm_psci_vcpu_on+0x14c/0x150
      |  kvm_psci_0_2_call+0x244/0x2a4
      |  kvm_hvc_call_handler+0x1cc/0x258
      |  handle_hvc+0x20/0x3c
      |  handle_exit+0x130/0x1ec
      |  kvm_arch_vcpu_ioctl_run+0x340/0x614
      |  kvm_vcpu_ioctl+0x4d0/0x840
      |  do_vfs_ioctl+0xc8/0x8d0
      |  ksys_ioctl+0x78/0xa8
      |  sys_ioctl+0xc/0x18
      |  el0_svc_naked+0x30/0x34
      | Code: 73620291 604d00b0 00201891 1ab10194 (957a33f8)
      |---[ end trace 4b4a4f9628596602 ]---
      
      Fix the order of the arguments.
      
      Fixes: 8d404c4c ("KVM: arm64: Rewrite system register accessors to read/write functions")
      CC: Christoffer Dall <cdall@cs.columbia.edu>
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      1975fa56
  8. 03 5月, 2018 1 次提交
  9. 01 5月, 2018 1 次提交
  10. 28 4月, 2018 1 次提交
  11. 27 4月, 2018 3 次提交
    • M
      ARM64: dts: marvell: armada-cp110: Add mg_core_clk for ethernet node · f43194c1
      Maxime Chevallier 提交于
      Marvell PPv2.2 controller present on CP-110 need the extra "mg_core_clk"
      clock to avoid system hangs when powering some network interfaces up.
      
      This issue appeared after a recent clock rework on Armada 7K/8K platforms.
      
      This commit adds the new clock and updates the documentation accordingly.
      
      [gregory.clement: use the real first commit to fix and add the cc:stable
      flag]
      Fixes: e3af9f7c ("RM64: dts: marvell: armada-cp110: Fix clock resources for various node")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMaxime Chevallier <maxime.chevallier@bootlin.com>
      Signed-off-by: NGregory CLEMENT <gregory.clement@bootlin.com>
      f43194c1
    • M
      ARM64: dts: marvell: armada-cp110: Add clocks for the xmdio node · a0573448
      Maxime Chevallier 提交于
      The Marvell XSMI controller needs 3 clocks to operate correctly :
       - The MG clock (clk 5)
       - The MG Core clock (clk 6)
       - The GOP clock (clk 18)
      
       This commit adds them, to avoid system hangs when using these
       interfaces.
      
      [gregory.clement: use the real first commit to fix and add the cc:stable
      flag]
      Fixes: f66b2aff ("arm64: dts: marvell: add xmdio nodes for 7k/8k")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMaxime Chevallier <maxime.chevallier@bootlin.com>
      Signed-off-by: NGregory CLEMENT <gregory.clement@bootlin.com>
      a0573448
    • M
      arm64: avoid instrumenting atomic_ll_sc.o · 3789c122
      Mark Rutland 提交于
      Our out-of-line atomics are built with a special calling convention,
      preventing pointless stack spilling, and allowing us to patch call sites
      with ARMv8.1 atomic instructions.
      
      Instrumentation inserted by the compiler may result in calls to
      functions not following this special calling convention, resulting in
      registers being unexpectedly clobbered, and various problems resulting
      from this.
      
      For example, if a kernel is built with KCOV and ARM64_LSE_ATOMICS, the
      compiler inserts calls to __sanitizer_cov_trace_pc in the prologues of
      the atomic functions. This has been observed to result in spurious
      cmpxchg failures, leading to a hang early on in the boot process.
      
      This patch avoids such issues by preventing instrumentation of our
      out-of-line atomics.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3789c122
  12. 26 4月, 2018 1 次提交
  13. 25 4月, 2018 4 次提交
    • J
      arm64: support __int128 with clang · ad40bdaf
      Jason A. Donenfeld 提交于
      Commit fb872273 ("arm64: support __int128 on gcc 5+") added support
      for arm64 __int128 with gcc with a version-conditional, but neglected to
      enable this for clang, which in fact appears to support aarch64 __int128.
      This commit therefore enables it if the compiler is clang, using the
      same type of makefile conditional used elsewhere in the tree.
      Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      ad40bdaf
    • M
      arm64: only advance singlestep for user instruction traps · 9478f192
      Mark Rutland 提交于
      Our arm64_skip_faulting_instruction() helper advances the userspace
      singlestep state machine, but this is also called by the kernel BRK
      handler, as used for WARN*().
      
      Thus, if we happen to hit a WARN*() while the user singlestep state
      machine is in the active-no-pending state, we'll advance to the
      active-pending state without having executed a user instruction, and
      will take a step exception earlier than expected when we return to
      userspace.
      
      Let's fix this by only advancing the state machine when skipping a user
      instruction.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      9478f192
    • K
      arm64/kernel: rename module_emit_adrp_veneer->module_emit_veneer_for_adrp · ed231ae3
      Kim Phillips 提交于
      Commit a257e025 ("arm64/kernel: don't ban ADRP to work around
      Cortex-A53 erratum #843419") introduced a function whose name ends with
      "_veneer".
      
      This clashes with commit bd8b22d2 ("Kbuild: kallsyms: ignore veneers
      emitted by the ARM linker"), which removes symbols ending in "_veneer"
      from kallsyms.
      
      The problem was manifested as 'perf test -vvvvv vmlinux' failed,
      correctly claiming the symbol 'module_emit_adrp_veneer' was present in
      vmlinux, but not in kallsyms.
      
      ...
          ERR : 0xffff00000809aa58: module_emit_adrp_veneer not on kallsyms
      ...
          test child finished with -1
          ---- end ----
          vmlinux symtab matches kallsyms: FAILED!
      
      Fix the problem by renaming module_emit_adrp_veneer to
      module_emit_veneer_for_adrp.  Now the test passes.
      
      Fixes: a257e025 ("arm64/kernel: don't ban ADRP to work around Cortex-A53 erratum #843419")
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Michal Marek <mmarek@suse.cz>
      Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      ed231ae3
    • M
      arm64: ptrace: remove addr_limit manipulation · 59275a0c
      Mark Rutland 提交于
      We transiently switch to KERNEL_DS in compat_ptrace_gethbpregs() and
      compat_ptrace_sethbpregs(), but in either case this is pointless as we
      don't perform any uaccess during this window.
      
      let's rip out the redundant addr_limit manipulation.
      Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      59275a0c
  14. 24 4月, 2018 3 次提交
  15. 20 4月, 2018 1 次提交
    • M
      arm/arm64: KVM: Add PSCI version selection API · 85bd0ba1
      Marc Zyngier 提交于
      Although we've implemented PSCI 0.1, 0.2 and 1.0, we expose either 0.1
      or 1.0 to a guest, defaulting to the latest version of the PSCI
      implementation that is compatible with the requested version. This is
      no different from doing a firmware upgrade on KVM.
      
      But in order to give a chance to hypothetical badly implemented guests
      that would have a fit by discovering something other than PSCI 0.2,
      let's provide a new API that allows userspace to pick one particular
      version of the API.
      
      This is implemented as a new class of "firmware" registers, where
      we expose the PSCI version. This allows the PSCI version to be
      save/restored as part of a guest migration, and also set to
      any supported version if the guest requires it.
      
      Cc: stable@vger.kernel.org #4.16
      Reviewed-by: NChristoffer Dall <cdall@kernel.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      85bd0ba1
  16. 19 4月, 2018 8 次提交
  17. 18 4月, 2018 1 次提交
  18. 17 4月, 2018 2 次提交
    • M
      arm64: kasan: avoid pfn_to_nid() before page array is initialized · 800cb2e5
      Mark Rutland 提交于
      In arm64's kasan_init(), we use pfn_to_nid() to find the NUMA node a
      span of memory is in, hoping to allocate shadow from the same NUMA node.
      However, at this point, the page array has not been initialized, and
      thus this is bogus.
      
      Since commit:
      
        f165b378 ("mm: uninitialized struct page poisoning sanity")
      
      ... accessing fields of the page array results in a boot time Oops(),
      highlighting this problem:
      
      [    0.000000] Unable to handle kernel paging request at virtual address dfff200000000000
      [    0.000000] Mem abort info:
      [    0.000000]   ESR = 0x96000004
      [    0.000000]   Exception class = DABT (current EL), IL = 32 bits
      [    0.000000]   SET = 0, FnV = 0
      [    0.000000]   EA = 0, S1PTW = 0
      [    0.000000] Data abort info:
      [    0.000000]   ISV = 0, ISS = 0x00000004
      [    0.000000]   CM = 0, WnR = 0
      [    0.000000] [dfff200000000000] address between user and kernel address ranges
      [    0.000000] Internal error: Oops: 96000004 [#1] PREEMPT SMP
      [    0.000000] Modules linked in:
      [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.16.0-07317-gf165b378 #42
      [    0.000000] Hardware name: ARM Juno development board (r1) (DT)
      [    0.000000] pstate: 80000085 (Nzcv daIf -PAN -UAO)
      [    0.000000] pc : __asan_load8+0x8c/0xa8
      [    0.000000] lr : __dump_page+0x3c/0x3b8
      [    0.000000] sp : ffff2000099b7ca0
      [    0.000000] x29: ffff2000099b7ca0 x28: ffff20000a1762c0
      [    0.000000] x27: ffff7e0000000000 x26: ffff2000099dd000
      [    0.000000] x25: ffff200009a3f960 x24: ffff200008f9c38c
      [    0.000000] x23: ffff20000a9d3000 x22: ffff200009735430
      [    0.000000] x21: fffffffffffffffe x20: ffff7e0001e50420
      [    0.000000] x19: ffff7e0001e50400 x18: 0000000000001840
      [    0.000000] x17: ffffffffffff8270 x16: 0000000000001840
      [    0.000000] x15: 0000000000001920 x14: 0000000000000004
      [    0.000000] x13: 0000000000000000 x12: 0000000000000800
      [    0.000000] x11: 1ffff0012d0f89ff x10: ffff10012d0f89ff
      [    0.000000] x9 : 0000000000000000 x8 : ffff8009687c5000
      [    0.000000] x7 : 0000000000000000 x6 : ffff10000f282000
      [    0.000000] x5 : 0000000000000040 x4 : fffffffffffffffe
      [    0.000000] x3 : 0000000000000000 x2 : dfff200000000000
      [    0.000000] x1 : 0000000000000005 x0 : 0000000000000000
      [    0.000000] Process swapper (pid: 0, stack limit = 0x        (ptrval))
      [    0.000000] Call trace:
      [    0.000000]  __asan_load8+0x8c/0xa8
      [    0.000000]  __dump_page+0x3c/0x3b8
      [    0.000000]  dump_page+0xc/0x18
      [    0.000000]  kasan_init+0x2e8/0x5a8
      [    0.000000]  setup_arch+0x294/0x71c
      [    0.000000]  start_kernel+0xdc/0x500
      [    0.000000] Code: aa0403e0 9400063c 17ffffee d343fc00 (38e26800)
      [    0.000000] ---[ end trace 67064f0e9c0cc338 ]---
      [    0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
      [    0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
      
      Let's fix this by using early_pfn_to_nid(), as other architectures do in
      their kasan init code. Note that early_pfn_to_nid acquires the nid from
      the memblock array, which we iterate over in kasan_init(), so this
      should be fine.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Fixes: 39d114dd ("arm64: add KASAN support")
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      800cb2e5
    • M
      arm64: KVM: Demote SVE and LORegion warnings to debug only · 165d1029
      Marc Zyngier 提交于
      While generating a message about guests probing for SVE/LORegions
      is a useful debugging tool, considering it an error is slightly
      over the top, as this is the only way the guest can find out
      about the presence of the feature.
      
      Let's turn these message into kvm_debug so that they can only
      be seen if CONFIG_DYNAMIC_DEBUG, and kept quiet otherwise.
      Acked-by: NChristoffer Dall <christoffer.dall@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      165d1029
  19. 16 4月, 2018 1 次提交
  20. 12 4月, 2018 3 次提交