1. 18 11月, 2016 2 次提交
    • W
      KVM: arm64: Fix the issues when guest PMCCFILTR is configured · b112c84a
      Wei Huang 提交于
      KVM calls kvm_pmu_set_counter_event_type() when PMCCFILTR is configured.
      But this function can't deals with PMCCFILTR correctly because the evtCount
      bits of PMCCFILTR, which is reserved 0, conflits with the SW_INCR event
      type of other PMXEVTYPER<n> registers. To fix it, when eventsel == 0, this
      function shouldn't return immediately; instead it needs to check further
      if select_idx is ARMV8_PMU_CYCLE_IDX.
      
      Another issue is that KVM shouldn't copy the eventsel bits of PMCCFILTER
      blindly to attr.config. Instead it ought to convert the request to the
      "cpu cycle" event type (i.e. 0x11).
      
      To support this patch and to prevent duplicated definitions, a limited
      set of ARMv8 perf event types were relocated from perf_event.c to
      asm/perf_event.h.
      
      Cc: stable@vger.kernel.org # 4.6+
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NWei Huang <wei@redhat.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      b112c84a
    • W
      arm64: KVM: pmu: Fix AArch32 cycle counter access · 9e3f7a29
      Wei Huang 提交于
      We're missing the handling code for the cycle counter accessed
      from a 32bit guest, leading to unexpected results.
      
      Cc: stable@vger.kernel.org # 4.6+
      Signed-off-by: NWei Huang <wei@redhat.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      9e3f7a29
  2. 11 11月, 2016 1 次提交
  3. 09 11月, 2016 3 次提交
  4. 06 11月, 2016 1 次提交
  5. 05 11月, 2016 1 次提交
    • M
      arm/arm64: KVM: Perform local TLB invalidation when multiplexing vcpus on a single CPU · 94d0e598
      Marc Zyngier 提交于
      Architecturally, TLBs are private to the (physical) CPU they're
      associated with. But when multiple vcpus from the same VM are
      being multiplexed on the same CPU, the TLBs are not private
      to the vcpus (and are actually shared across the VMID).
      
      Let's consider the following scenario:
      
      - vcpu-0 maps PA to VA
      - vcpu-1 maps PA' to VA
      
      If run on the same physical CPU, vcpu-1 can hit TLB entries generated
      by vcpu-0 accesses, and access the wrong physical page.
      
      The solution to this is to keep a per-VM map of which vcpu ran last
      on each given physical CPU, and invalidate local TLBs when switching
      to a different vcpu from the same VM.
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      94d0e598
  6. 27 10月, 2016 3 次提交
    • N
      arm64: mm: fix __page_to_voff definition · 3fa72fe9
      Neeraj Upadhyay 提交于
      Fix parameter name for __page_to_voff, to match its definition.
      At present, we don't see any issue, as page_to_virt's caller
      declares 'page'.
      
      Fixes: 9f287591 ("arm64: mm: restrict virt_to_page() to the linear mapping")
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NNeeraj Upadhyay <neeraju@codeaurora.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3fa72fe9
    • H
      arm64/numa: fix incorrect log for memory-less node · 3f7a09f4
      Hanjun Guo 提交于
      When booting on NUMA system with memory-less node (no
      memory dimm on this memory controller), the print
      for setup_node_data() is incorrect:
      
      NUMA: Initmem setup node 2 [mem 0x00000000-0xffffffffffffffff]
      
      It can be fixed by printing [mem 0x00000000-0x00000000] when
      end_pfn is 0, but print <memory-less node> will be more useful.
      
      Fixes: 1a2db300 ("arm64, numa: Add NUMA support for arm64 platforms.")
      Signed-off-by: NHanjun Guo <hanjun.guo@linaro.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Ganapatrao Kulkarni <gkulkarni@caviumnetworks.com>
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3f7a09f4
    • Y
      arm64/numa: fix pcpu_cpu_distance() to get correct CPU proximity · 26984c3b
      Yisheng Xie 提交于
      The pcpu_build_alloc_info() function group CPUs according to their
      proximity, by call callback function @cpu_distance_fn from different
      ARCHs.
      
      For arm64 the callback of @cpu_distance_fn is
          pcpu_cpu_distance(from, to)
              -> node_distance(from, to)
      The @from and @to for function node_distance() should be nid.
      
      However, pcpu_cpu_distance() in arch/arm64/mm/numa.c just past the
      cpu id for @from and @to, and didn't convert to numa node id.
      
      For this incorrect cpu proximity get from ARCH, it may cause each CPU
      in one group and make group_cnt out of bound:
      
      	setup_per_cpu_areas()
      		pcpu_embed_first_chunk()
      			pcpu_build_alloc_info()
      in pcpu_build_alloc_info, since cpu_distance_fn will return
      REMOTE_DISTANCE if we pass cpu ids (0,1,2...), so
      cpu_distance_fn(cpu, tcpu) > LOCAL_DISTANCE will wrongly be ture.
      
      This may results in triggering the BUG_ON(unit != nr_units) later:
      
      [    0.000000] kernel BUG at mm/percpu.c:1916!
      [    0.000000] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      [    0.000000] Modules linked in:
      [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.9.0-rc1-00003-g14155caf-dirty #26
      [    0.000000] Hardware name: Hisilicon Hi1616 Evaluation Board (DT)
      [    0.000000] task: ffff000008d6e900 task.stack: ffff000008d60000
      [    0.000000] PC is at pcpu_embed_first_chunk+0x420/0x704
      [    0.000000] LR is at pcpu_embed_first_chunk+0x3bc/0x704
      [    0.000000] pc : [<ffff000008c754f4>] lr : [<ffff000008c75490>] pstate: 800000c5
      [    0.000000] sp : ffff000008d63eb0
      [    0.000000] x29: ffff000008d63eb0 [    0.000000] x28: 0000000000000000
      [    0.000000] x27: 0000000000000040 [    0.000000] x26: ffff8413fbfcef00
      [    0.000000] x25: 0000000000000042 [    0.000000] x24: 0000000000000042
      [    0.000000] x23: 0000000000001000 [    0.000000] x22: 0000000000000046
      [    0.000000] x21: 0000000000000001 [    0.000000] x20: ffff000008cb3bc8
      [    0.000000] x19: ffff8413fbfcf570 [    0.000000] x18: 0000000000000000
      [    0.000000] x17: ffff000008e49ae0 [    0.000000] x16: 0000000000000003
      [    0.000000] x15: 000000000000001e [    0.000000] x14: 0000000000000004
      [    0.000000] x13: 0000000000000000 [    0.000000] x12: 000000000000006f
      [    0.000000] x11: 00000413fbffff00 [    0.000000] x10: 0000000000000004
      [    0.000000] x9 : 0000000000000000 [    0.000000] x8 : 0000000000000001
      [    0.000000] x7 : ffff8413fbfcf63c [    0.000000] x6 : ffff000008d65d28
      [    0.000000] x5 : ffff000008d65e50 [    0.000000] x4 : 0000000000000000
      [    0.000000] x3 : ffff000008cb3cc8 [    0.000000] x2 : 0000000000000040
      [    0.000000] x1 : 0000000000000040 [    0.000000] x0 : 0000000000000000
      [...]
      [    0.000000] Call trace:
      [    0.000000] Exception stack(0xffff000008d63ce0 to 0xffff000008d63e10)
      [    0.000000] 3ce0: ffff8413fbfcf570 0001000000000000 ffff000008d63eb0 ffff000008c754f4
      [    0.000000] 3d00: ffff000008d63d50 ffff0000081af210 00000413fbfff010 0000000000001000
      [    0.000000] 3d20: ffff000008d63d50 ffff0000081af220 00000413fbfff010 0000000000001000
      [    0.000000] 3d40: 00000413fbfcef00 0000000000000004 ffff000008d63db0 ffff0000081af390
      [    0.000000] 3d60: 00000413fbfcef00 0000000000001000 0000000000000000 0000000000001000
      [    0.000000] 3d80: 0000000000000000 0000000000000040 0000000000000040 ffff000008cb3cc8
      [    0.000000] 3da0: 0000000000000000 ffff000008d65e50 ffff000008d65d28 ffff8413fbfcf63c
      [    0.000000] 3dc0: 0000000000000001 0000000000000000 0000000000000004 00000413fbffff00
      [    0.000000] 3de0: 000000000000006f 0000000000000000 0000000000000004 000000000000001e
      [    0.000000] 3e00: 0000000000000003 ffff000008e49ae0
      [    0.000000] [<ffff000008c754f4>] pcpu_embed_first_chunk+0x420/0x704
      [    0.000000] [<ffff000008c6658c>] setup_per_cpu_areas+0x38/0xc8
      [    0.000000] [<ffff000008c608d8>] start_kernel+0x10c/0x390
      [    0.000000] [<ffff000008c601d8>] __primary_switched+0x5c/0x64
      [    0.000000] Code: b8018660 17ffffd7 6b16037f 54000080 (d4210000)
      [    0.000000] ---[ end trace 0000000000000000 ]---
      [    0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
      
      Fix by getting cpu's node id with early_cpu_to_node() then pass it
      to node_distance() as the original intention.
      
      Fixes: 7af3a0a9 ("arm64/numa: support HAVE_SETUP_PER_CPU_AREA")
      Signed-off-by: NYisheng Xie <xieyisheng1@huawei.com>
      Signed-off-by: NHanjun Guo <hanjun.guo@linaro.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      26984c3b
  7. 24 10月, 2016 1 次提交
  8. 22 10月, 2016 3 次提交
    • M
      arm64: dts: uniphier: change MIO node to SD control node · 8e68c65d
      Masahiro Yamada 提交于
      I made a mistake bacuse the Media I/O block is not implemented in
      this SoC.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      8e68c65d
    • M
      arm64: uniphier: select ARCH_HAS_RESET_CONTROLLER · 75924903
      Masahiro Yamada 提交于
      The UniPhier reset driver (drivers/reset/reset-uniphier.c) has been
      merged.  Select ARCH_HAS_RESET_CONTROLLER from the SoC Kconfig.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      75924903
    • W
      arm64: KVM: Take S1 walks into account when determining S2 write faults · 60e21a0e
      Will Deacon 提交于
      The WnR bit in the HSR/ESR_EL2 indicates whether a data abort was
      generated by a read or a write instruction. For stage 2 data aborts
      generated by a stage 1 translation table walk (i.e. the actual page
      table access faults at EL2), the WnR bit therefore reports whether the
      instruction generating the walk was a load or a store, *not* whether the
      page table walker was reading or writing the entry.
      
      For page tables marked as read-only at stage 2 (e.g. due to KSM merging
      them with the tables from another guest), this could result in livelock,
      where a page table walk generated by a load instruction attempts to
      set the access flag in the stage 1 descriptor, but fails to trigger
      CoW in the host since only a read fault is reported.
      
      This patch modifies the arm64 kvm_vcpu_dabt_iswrite function to
      take into account stage 2 faults in stage 1 walks. Since DBM cannot be
      disabled at EL2 for CPUs that implement it, we assume that these faults
      are always causes by writes, avoiding the livelock situation at the
      expense of occasional, spurious CoWs.
      
      We could, in theory, do a bit better by checking the guest TCR
      configuration and inspecting the page table to see why the PTE faulted.
      However, I doubt this is measurable in practice, and the threat of
      livelock is real.
      
      Cc: <stable@vger.kernel.org>
      Cc: Julien Grall <julien.grall@arm.com>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      60e21a0e
  9. 21 10月, 2016 1 次提交
  10. 20 10月, 2016 7 次提交
    • M
      arm64: remove pr_cont abuse from mem_init · f7881bd6
      Mark Rutland 提交于
      All the lines printed by mem_init are independent, with each ending with
      a newline. While they logically form a large block, none are actually
      continuations of previous lines.
      
      The kernel-side printk code and the userspace demsg tool differ in their
      handling of KERN_CONT following a newline, and while this isn't always a
      problem kernel-side, it does cause difficulty for userspace. Using
      pr_cont causes the userspace tool to not print line prefix (e.g.
      timestamps) even when following a newline, mis-aligning the output and
      making it harder to read, e.g.
      
      [    0.000000] Virtual kernel memory layout:
      [    0.000000]     modules : 0xffff000000000000 - 0xffff000008000000   (   128 MB)
          vmalloc : 0xffff000008000000 - 0xffff7dffbfff0000   (129022 GB)
            .text : 0xffff000008080000 - 0xffff0000088b0000   (  8384 KB)
          .rodata : 0xffff0000088b0000 - 0xffff000008c50000   (  3712 KB)
            .init : 0xffff000008c50000 - 0xffff000008d50000   (  1024 KB)
            .data : 0xffff000008d50000 - 0xffff000008e25200   (   853 KB)
             .bss : 0xffff000008e25200 - 0xffff000008e6bec0   (   284 KB)
          fixed   : 0xffff7dfffe7fd000 - 0xffff7dfffec00000   (  4108 KB)
          PCI I/O : 0xffff7dfffee00000 - 0xffff7dffffe00000   (    16 MB)
          vmemmap : 0xffff7e0000000000 - 0xffff800000000000   (  2048 GB maximum)
                    0xffff7e0000000000 - 0xffff7e0026000000   (   608 MB actual)
          memory  : 0xffff800000000000 - 0xffff800980000000   ( 38912 MB)
      [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=6, Nodes=1
      
      Fix this by using pr_notice consistently for all lines, which both the
      kernel and userspace are happy with.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      f7881bd6
    • M
      arm64: fix show_regs fallout from KERN_CONT changes · db4b0710
      Mark Rutland 提交于
      Recently in commit 4bcc595c ("printk: reinstate KERN_CONT for
      printing continuation lines"), the behaviour of printk changed w.r.t.
      KERN_CONT. Now, KERN_CONT is mandatory to continue existing lines.
      Without this, prefixes are inserted, making output illegible, e.g.
      
      [ 1007.069010] pc : [<ffff00000871898c>] lr : [<ffff000008718948>] pstate: 40000145
      [ 1007.076329] sp : ffff000008d53ec0
      [ 1007.079606] x29: ffff000008d53ec0 [ 1007.082797] x28: 0000000080c50018
      [ 1007.086160]
      [ 1007.087630] x27: ffff000008e0c7f8 [ 1007.090820] x26: ffff80097631ca00
      [ 1007.094183]
      [ 1007.095653] x25: 0000000000000001 [ 1007.098843] x24: 000000ea68b61cac
      [ 1007.102206]
      
      ... or when dumped with the userpace dmesg tool, which has slightly
      different implicit newline behaviour. e.g.
      
      [ 1007.069010] pc : [<ffff00000871898c>] lr : [<ffff000008718948>] pstate: 40000145
      [ 1007.076329] sp : ffff000008d53ec0
      [ 1007.079606] x29: ffff000008d53ec0
      [ 1007.082797] x28: 0000000080c50018
      [ 1007.086160]
      [ 1007.087630] x27: ffff000008e0c7f8
      [ 1007.090820] x26: ffff80097631ca00
      [ 1007.094183]
      [ 1007.095653] x25: 0000000000000001
      [ 1007.098843] x24: 000000ea68b61cac
      [ 1007.102206]
      
      We can't simply always use KERN_CONT for lines which may or may not be
      continuations. That causes line prefixes (e.g. timestamps) to be
      supressed, and the alignment of all but the first line will be broken.
      
      For even more fun, we can't simply insert some dummy empty-string printk
      calls, as GCC warns for an empty printk string, and even if we pass
      KERN_DEFAULT explcitly to silence the warning, the prefix gets swallowed
      unless there is an additional part to the string.
      
      Instead, we must manually iterate over pairs of registers, which gives
      us the legible output we want in either case, e.g.
      
      [  169.771790] pc : [<ffff00000871898c>] lr : [<ffff000008718948>] pstate: 40000145
      [  169.779109] sp : ffff000008d53ec0
      [  169.782386] x29: ffff000008d53ec0 x28: 0000000080c50018
      [  169.787650] x27: ffff000008e0c7f8 x26: ffff80097631de00
      [  169.792913] x25: 0000000000000001 x24: 00000027827b2cf4
      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>
      db4b0710
    • A
      arm64: kernel: force ET_DYN ELF type for CONFIG_RELOCATABLE=y · b9dce7f1
      Ard Biesheuvel 提交于
      GNU ld used to set the ELF file type to ET_DYN for PIE executables, which
      is the same file type used for shared libraries. However, this was changed
      recently, and now PIE executables are emitted as ET_EXEC instead.
      
      The distinction is only relevant for ELF loaders, and so there is little
      reason to care about the difference when building the kernel, which is
      why the change has gone unnoticed until now.
      
      However, debuggers do use the ELF binary, and expect ET_EXEC type files
      to appear in memory at the exact offset described in the ELF metadata.
      This means source level debugging is no longer possible when KASLR is in
      effect or when executing the stub.
      
      So add the -shared LD option when building with CONFIG_RELOCATABLE=y. This
      forces the ELF file type to be set to ET_DYN (which is what you get when
      building with binutils 2.24 and earlier anyway), and has no other ill
      effects.
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      b9dce7f1
    • J
      arm64: suspend: Reconfigure PSTATE after resume from idle · d0854412
      James Morse 提交于
      The suspend/resume path in kernel/sleep.S, as used by cpu-idle, does not
      save/restore PSTATE. As a result of this cpufeatures that were detected
      and have bits in PSTATE get lost when we resume from idle.
      
      UAO gets set appropriately on the next context switch. PAN will be
      re-enabled next time we return from user-space, but on a preemptible
      kernel we may run work accessing user space before this point.
      
      Add code to re-enable theses two features in __cpu_suspend_exit().
      We re-use uao_thread_switch() passing current.
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d0854412
    • J
      arm64: mm: Set PSTATE.PAN from the cpu_enable_pan() call · 7209c868
      James Morse 提交于
      Commit 338d4f49 ("arm64: kernel: Add support for Privileged Access
      Never") enabled PAN by enabling the 'SPAN' feature-bit in SCTLR_EL1.
      This means the PSTATE.PAN bit won't be set until the next return to the
      kernel from userspace. On a preemptible kernel we may schedule work that
      accesses userspace on a CPU before it has done this.
      
      Now that cpufeature enable() calls are scheduled via stop_machine(), we
      can set PSTATE.PAN from the cpu_enable_pan() call.
      
      Add WARN_ON_ONCE(in_interrupt()) to check the PSTATE value we updated
      is not immediately discarded.
      Reported-by: NTony Thompson <anthony.thompson@arm.com>
      Reported-by: NVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: NJames Morse <james.morse@arm.com>
      [will: fixed typo in comment]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      7209c868
    • J
      arm64: cpufeature: Schedule enable() calls instead of calling them via IPI · 2a6dcb2b
      James Morse 提交于
      The enable() call for a cpufeature/errata is called using on_each_cpu().
      This issues a cross-call IPI to get the work done. Implicitly, this
      stashes the running PSTATE in SPSR when the CPU receives the IPI, and
      restores it when we return. This means an enable() call can never modify
      PSTATE.
      
      To allow PAN to do this, change the on_each_cpu() call to use
      stop_machine(). This schedules the work on each CPU which allows
      us to modify PSTATE.
      
      This involves changing the protype of all the enable() functions.
      
      enable_cpu_capabilities() is called during boot and enables the feature
      on all online CPUs. This path now uses stop_machine(). CPU features for
      hotplug'd CPUs are enabled by verify_local_cpu_features() which only
      acts on the local CPU, and can already modify the running PSTATE as it
      is called from secondary_start_kernel().
      Reported-by: NTony Thompson <anthony.thompson@arm.com>
      Reported-by: NVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: NJames Morse <james.morse@arm.com>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      2a6dcb2b
    • A
      arm64: Cortex-A53 errata workaround: check for kernel addresses · 87261d19
      Andre Przywara 提交于
      Commit 7dd01aef ("arm64: trap userspace "dc cvau" cache operation on
      errata-affected core") adds code to execute cache maintenance instructions
      in the kernel on behalf of userland on CPUs with certain ARM CPU errata.
      It turns out that the address hasn't been checked to be a valid user
      space address, allowing userland to clean cache lines in kernel space.
      Fix this by introducing an address check before executing the
      instructions on behalf of userland.
      
      Since the address doesn't come via a syscall parameter, we can't just
      reject tagged pointers and instead have to remove the tag when checking
      against the user address limit.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 7dd01aef ("arm64: trap userspace "dc cvau" cache operation on errata-affected core")
      Reported-by: NKristina Martsenko <kristina.martsenko@arm.com>
      Signed-off-by: NAndre Przywara <andre.przywara@arm.com>
      [will: rework commit message + replace access_ok with max_user_addr()]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      87261d19
  11. 19 10月, 2016 3 次提交
    • W
      arm64: percpu: rewrite ll/sc loops in assembly · 1e6e57d9
      Will Deacon 提交于
      Writing the outer loop of an LL/SC sequence using do {...} while
      constructs potentially allows the compiler to hoist memory accesses
      between the STXR and the branch back to the LDXR. On CPUs that do not
      guarantee forward progress of LL/SC loops when faced with memory
      accesses to the same ERG (up to 2k) between the failed STXR and the
      branch back, we may end up livelocking.
      
      This patch avoids this issue in our percpu atomics by rewriting the
      outer loop as part of the LL/SC inline assembly block.
      
      Cc: <stable@vger.kernel.org>
      Fixes: f97fc810 ("arm64: percpu: Implement this_cpu operations")
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Tested-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      1e6e57d9
    • W
      arm64: swp emulation: bound LL/SC retries before rescheduling · 1c5b51df
      Will Deacon 提交于
      If a CPU does not implement a global monitor for certain memory types,
      then userspace can attempt a kernel DoS by issuing SWP instructions
      targetting the problematic memory (for example, a framebuffer mapped
      with non-cacheable attributes).
      
      The SWP emulation code protects against these sorts of attacks by
      checking for pending signals and potentially rescheduling when the STXR
      instruction fails during the emulation. Whilst this is good for avoiding
      livelock, it harms emulation of legitimate SWP instructions on CPUs
      where forward progress is not guaranteed if there are memory accesses to
      the same reservation granule (up to 2k) between the failing STXR and
      the retry of the LDXR.
      
      This patch solves the problem by retrying the STXR a bounded number of
      times (4) before breaking out of the LL/SC loop and looking for
      something else to do.
      
      Cc: <stable@vger.kernel.org>
      Fixes: bd35a4ad ("arm64: Port SWP/SWPB emulation support from arm")
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      1c5b51df
    • S
      arm64: dts: rockchip: remove the abuse of keep-power-in-suspend · 7c627319
      Shawn Lin 提交于
      It was invented for sdio only, and should not be used for sdmmc
      or emmc. Remove it.
      Signed-off-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NHeiko Stuebner <heiko@sntech.de>
      7c627319
  12. 18 10月, 2016 1 次提交
    • W
      arm64: sysreg: Fix use of XZR in write_sysreg_s · 91cb163e
      Will Deacon 提交于
      Commit 8a71f0c6 ("arm64: sysreg: replace open-coded mrs_s/msr_s with
      {read,write}_sysreg_s") introduced a write_sysreg_s macro for writing
      to system registers that are not supported by binutils.
      
      Unfortunately, this was implemented with the wrong template (%0 vs %x0),
      so in the case that we are writing a constant 0, we will generate
      invalid instruction syntax and bail with a cryptic assembler error:
      
        | Error: constant expression required
      
      This patch fixes the template.
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      91cb163e
  13. 17 10月, 2016 4 次提交
    • A
      arm64: kaslr: keep modules close to the kernel when DYNAMIC_FTRACE=y · 8fe88a41
      Ard Biesheuvel 提交于
      The RANDOMIZE_MODULE_REGION_FULL Kconfig option allows KASLR to be
      configured in such a way that kernel modules and the core kernel are
      allocated completely independently, which implies that modules are likely
      to require branches via PLT entries to reach the core kernel. The dynamic
      ftrace code does not expect that, and assumes that it can patch module
      code to perform a relative branch to anywhere in the core kernel. This
      may result in errors such as
      
        branch_imm_common: offset out of range
        ------------[ cut here ]------------
        WARNING: CPU: 3 PID: 196 at kernel/trace/ftrace.c:1995 ftrace_bug+0x220/0x2e8
        Modules linked in:
      
        CPU: 3 PID: 196 Comm: systemd-udevd Not tainted 4.8.0-22-generic #24
        Hardware name: AMD Seattle/Seattle, BIOS 10:34:40 Oct  6 2016
        task: ffff8d1bef7dde80 task.stack: ffff8d1bef6b0000
        PC is at ftrace_bug+0x220/0x2e8
        LR is at ftrace_process_locs+0x330/0x430
      
      So make RANDOMIZE_MODULE_REGION_FULL mutually exclusive with DYNAMIC_FTRACE
      at the Kconfig level.
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      8fe88a41
    • M
      arm64: kernel: Init MDCR_EL2 even in the absence of a PMU · 85054035
      Marc Zyngier 提交于
      Commit f436b2ac ("arm64: kernel: fix architected PMU registers
      unconditional access") made sure we wouldn't access unimplemented
      PMU registers, but also left MDCR_EL2 uninitialized in that case,
      leading to trap bits being potentially left set.
      
      Make sure we always write something in that register.
      
      Fixes: f436b2ac ("arm64: kernel: fix architected PMU registers unconditional access")
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      85054035
    • L
      arm64: kernel: numa: fix ACPI boot cpu numa node mapping · baa5567c
      Lorenzo Pieralisi 提交于
      Commit 7ba5f605 ("arm64/numa: remove the limitation that cpu0 must
      bind to node0") removed the numa cpu<->node mapping restriction whereby
      logical cpu 0 always corresponds to numa node 0; removing the
      restriction was correct, in that it does not really exist in practice
      but the commit only updated the early mapping of logical cpu 0 to its
      real numa node for the DT boot path, missing the ACPI one, leading to
      boot failures on ACPI systems owing to missing node<->cpu map for
      logical cpu 0.
      
      Fix the issue by updating the ACPI boot path with code that carries out
      the early cpu<->node mapping also for the boot cpu (ie cpu 0), mirroring
      what is currently done in the DT boot path.
      
      Fixes: 7ba5f605 ("arm64/numa: remove the limitation that cpu0 must bind to node0")
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Tested-by: NLaszlo Ersek <lersek@redhat.com>
      Reported-by: NLaszlo Ersek <lersek@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Cc: Hanjun Guo <hanjun.guo@linaro.org>
      Cc: Andrew Jones <drjones@redhat.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      baa5567c
    • A
      arm64: kaslr: fix breakage with CONFIG_MODVERSIONS=y · 9c0e83c3
      Ard Biesheuvel 提交于
      As it turns out, the KASLR code breaks CONFIG_MODVERSIONS, since the
      kcrctab has an absolute address field that is relocated at runtime
      when the kernel offset is randomized.
      
      This has been fixed already for PowerPC in the past, so simply wire up
      the existing code dealing with this issue.
      
      Cc: <stable@vger.kernel.org>
      Fixes: f80fb3a3 ("arm64: add support for kernel ASLR")
      Tested-by: NTimur Tabi <timur@codeaurora.org>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      9c0e83c3
  14. 16 10月, 2016 2 次提交
    • D
      kprobes: Unpoison stack in jprobe_return() for KASAN · 9f7d416c
      Dmitry Vyukov 提交于
      I observed false KSAN positives in the sctp code, when
      sctp uses jprobe_return() in jsctp_sf_eat_sack().
      
      The stray 0xf4 in shadow memory are stack redzones:
      
      [     ] ==================================================================
      [     ] BUG: KASAN: stack-out-of-bounds in memcmp+0xe9/0x150 at addr ffff88005e48f480
      [     ] Read of size 1 by task syz-executor/18535
      [     ] page:ffffea00017923c0 count:0 mapcount:0 mapping:          (null) index:0x0
      [     ] flags: 0x1fffc0000000000()
      [     ] page dumped because: kasan: bad access detected
      [     ] CPU: 1 PID: 18535 Comm: syz-executor Not tainted 4.8.0+ #28
      [     ] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      [     ]  ffff88005e48f2d0 ffffffff82d2b849 ffffffff0bc91e90 fffffbfff10971e8
      [     ]  ffffed000bc91e90 ffffed000bc91e90 0000000000000001 0000000000000000
      [     ]  ffff88005e48f480 ffff88005e48f350 ffffffff817d3169 ffff88005e48f370
      [     ] Call Trace:
      [     ]  [<ffffffff82d2b849>] dump_stack+0x12e/0x185
      [     ]  [<ffffffff817d3169>] kasan_report+0x489/0x4b0
      [     ]  [<ffffffff817d31a9>] __asan_report_load1_noabort+0x19/0x20
      [     ]  [<ffffffff82d49529>] memcmp+0xe9/0x150
      [     ]  [<ffffffff82df7486>] depot_save_stack+0x176/0x5c0
      [     ]  [<ffffffff817d2031>] save_stack+0xb1/0xd0
      [     ]  [<ffffffff817d27f2>] kasan_slab_free+0x72/0xc0
      [     ]  [<ffffffff817d05b8>] kfree+0xc8/0x2a0
      [     ]  [<ffffffff85b03f19>] skb_free_head+0x79/0xb0
      [     ]  [<ffffffff85b0900a>] skb_release_data+0x37a/0x420
      [     ]  [<ffffffff85b090ff>] skb_release_all+0x4f/0x60
      [     ]  [<ffffffff85b11348>] consume_skb+0x138/0x370
      [     ]  [<ffffffff8676ad7b>] sctp_chunk_put+0xcb/0x180
      [     ]  [<ffffffff8676ae88>] sctp_chunk_free+0x58/0x70
      [     ]  [<ffffffff8677fa5f>] sctp_inq_pop+0x68f/0xef0
      [     ]  [<ffffffff8675ee36>] sctp_assoc_bh_rcv+0xd6/0x4b0
      [     ]  [<ffffffff8677f2c1>] sctp_inq_push+0x131/0x190
      [     ]  [<ffffffff867bad69>] sctp_backlog_rcv+0xe9/0xa20
      [ ... ]
      [     ] Memory state around the buggy address:
      [     ]  ffff88005e48f380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [     ]  ffff88005e48f400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [     ] >ffff88005e48f480: f4 f4 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [     ]                    ^
      [     ]  ffff88005e48f500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [     ]  ffff88005e48f580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [     ] ==================================================================
      
      KASAN stack instrumentation poisons stack redzones on function entry
      and unpoisons them on function exit. If a function exits abnormally
      (e.g. with a longjmp like jprobe_return()), stack redzones are left
      poisoned. Later this leads to random KASAN false reports.
      
      Unpoison stack redzones in the frames we are going to jump over
      before doing actual longjmp in jprobe_return().
      Signed-off-by: NDmitry Vyukov <dvyukov@google.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: kasan-dev@googlegroups.com
      Cc: surovegin@google.com
      Cc: rostedt@goodmis.org
      Link: http://lkml.kernel.org/r/1476454043-101898-1-git-send-email-dvyukov@google.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      9f7d416c
    • S
      arm64: dts: rockchip: remove always-on and boot-on from vcc_sd · 0362fcc9
      Shawn Lin 提交于
      Please don't add these for vcc_sd, and mmc-core/driver will control
      it. Otherwise, it will waste energy even without sdmmc in slot.
      
      Moreover, it will causes a bug:
      If we insert/remove sd card, we could see
      [9.337271] mmc0: new ultra high speed SDR25 SDHC card at address 0007
      [9.345144] mmcblk0: mmc0:0007 SD32G 29.3 GiB
      
      This is okay for normal sd insert/remove test, but when I debug some
      issues for sdmmc, I did unbind/bind test. And there is a interesting
      phenomenon when we bind the driver again:
      [58.314069] mmc0: new high speed SDHC card at address 0007
      [58.320282] mmcblk0: mmc0:0007 SD32G 29.3 GiB
      
      So the sd card could just support high speed without power cycle
      since the vcc_sd is always on, which makes the sd card fail to
      reinit its internal ocr mask.
      Signed-off-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NHeiko Stuebner <heiko@sntech.de>
      0362fcc9
  15. 12 10月, 2016 2 次提交
  16. 08 10月, 2016 3 次提交
  17. 29 9月, 2016 2 次提交