1. 19 7月, 2016 3 次提交
    • W
      arm64: debug: unmask PSTATE.D earlier · 2ce39ad1
      Will Deacon 提交于
      Clearing PSTATE.D is one of the requirements for generating a debug
      exception. The arm64 booting protocol requires that PSTATE.D is set,
      since many of the debug registers (for example, the hw_breakpoint
      registers) are UNKNOWN out of reset and could potentially generate
      spurious, fatal debug exceptions in early boot code if PSTATE.D was
      clear. Once the debug registers have been safely initialised, PSTATE.D
      is cleared, however this is currently broken for two reasons:
      
      (1) The boot CPU clears PSTATE.D in a postcore_initcall and secondary
          CPUs clear PSTATE.D in secondary_start_kernel. Since the initcall
          runs after SMP (and the scheduler) have been initialised, there is
          no guarantee that it is actually running on the boot CPU. In this
          case, the boot CPU is left with PSTATE.D set and is not capable of
          generating debug exceptions.
      
      (2) In a preemptible kernel, we may explicitly schedule on the IRQ
          return path to EL1. If an IRQ occurs with PSTATE.D set in the idle
          thread, then we may schedule the kthread_init thread, run the
          postcore_initcall to clear PSTATE.D and then context switch back
          to the idle thread before returning from the IRQ. The exception
          return path will then restore PSTATE.D from the stack, and set it
          again.
      
      This patch fixes the problem by moving the clearing of PSTATE.D earlier
      to proc.S. This has the desirable effect of clearing it in one place for
      all CPUs, long before we have to worry about the scheduler or any
      exception handling. We ensure that the previous reset of MDSCR_EL1 has
      completed before unmasking the exception, so that any spurious
      exceptions resulting from UNKNOWN debug registers are not generated.
      
      Without this patch applied, the kprobes selftests have been seen to fail
      under KVM, where we end up attempting to step the OOL instruction buffer
      with PSTATE.D set and therefore fail to complete the step.
      
      Cc: <stable@vger.kernel.org>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Reported-by: NCatalin Marinas <catalin.marinas@arm.com>
      Tested-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Tested-by: NCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      2ce39ad1
    • M
      arm64: localise Image objcopy flags · f8fa70f3
      Mark Rutland 提交于
      We currently define OBJCOPYFLAGS in the top-level arm64 Makefile, and
      thus these flags will be passed to all uses of objcopy, kernel-wide, for
      which they are not explicitly overridden. The flags we set are intended
      for converting vmlinux (and ELF) into Image (a raw binary), and thus the
      flags chosen are problematic for some other uses which do not expect a
      raw binary result, e.g. the upcoming lkdtm rodata test:
      
        http://www.openwall.com/lists/kernel-hardening/2016/06/08/2
      
      This patch localises the objcopy flags such that they are only used for
      the vmlinux -> Image conversion.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Tested-by: NLaura Abbott <labbott@redhat.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      f8fa70f3
    • V
      arm64: ptrace: remove extra define for CPSR's E bit · 9df53ff2
      Vladimir Murzin 提交于
      ...and do not confuse source navigation tools ;)
      Signed-off-by: NVladimir Murzin <vladimir.murzin@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      9df53ff2
  2. 12 7月, 2016 5 次提交
    • S
      arm64: cpuinfo: Expose MIDR_EL1 and REVIDR_EL1 to sysfs · f8d9f924
      Steve Capper 提交于
      It can be useful for JIT software to be aware of MIDR_EL1 and
      REVIDR_EL1 to ascertain the presence of any core errata that could
      affect code generation.
      
      This patch exposes these registers through sysfs:
      
      /sys/devices/system/cpu/cpu$ID/regs/identification/midr_el1
      /sys/devices/system/cpu/cpu$ID/regs/identification/revidr_el1
      
      where $ID is the cpu number. For big.LITTLE systems, one can have a
      mixture of cores (e.g. Cortex A53 and Cortex A57), thus all CPUs need
      to be enumerated.
      
      If the kernel does not have valid information to populate these entries
      with, an empty string is returned to userspace.
      
      Cc: Mark Rutland <mark.rutland@arm.com>
      Reviewed-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NSteve Capper <steve.capper@linaro.org>
      [suzuki.poulose@arm.com: ABI documentation updates, hotplug notifiers, kobject changes]
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      f8d9f924
    • K
      arm64: Add support for CLOCK_MONOTONIC_RAW in clock_gettime() vDSO · 49eea433
      Kevin Brodsky 提交于
      So far the arm64 clock_gettime() vDSO implementation only supported
      the following clocks, falling back to the syscall for the others:
      - CLOCK_REALTIME{,_COARSE}
      - CLOCK_MONOTONIC{,_COARSE}
      
      This patch adds support for the CLOCK_MONOTONIC_RAW clock, taking
      advantage of the recent refactoring of the vDSO time functions. Like
      the non-_COARSE clocks, this only works when the "arch_sys_counter"
      clocksource is in use (allowing us to read the current time from the
      virtual counter register), otherwise we also have to fall back to the
      syscall.
      
      Most of the data is shared with CLOCK_MONOTONIC, and the algorithm is
      similar. The reference implementation in kernel/time/timekeeping.c
      shows that:
      - CLOCK_MONOTONIC = tk->wall_to_monotonic + tk->xtime_sec +
        timekeeping_get_ns(&tk->tkr_mono)
      - CLOCK_MONOTONIC_RAW = tk->raw_time + timekeeping_get_ns(&tk->tkr_raw)
      - tkr_mono and tkr_raw are identical (in particular, same
        clocksource), except these members:
        * mult (only mono's multiplier is NTP-adjusted)
        * xtime_nsec (always 0 for raw)
      
      Therefore, tk->raw_time and tkr_raw->mult are now also stored in the
      vDSO data page.
      
      Cc: Ali Saidi <ali.saidi@arm.com>
      Signed-off-by: NKevin Brodsky <kevin.brodsky@arm.com>
      Reviewed-by: NDave Martin <dave.martin@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      49eea433
    • K
      arm64: Refactor vDSO time functions · b33f491f
      Kevin Brodsky 提交于
      Time functions are directly implemented in assembly in arm64, and it
      is desirable to keep it this way for performance reasons (everything
      fits in registers, so that the stack is not used at all). However, the
      current implementation is quite difficult to read and understand (even
      considering it's assembly).  Additionally, due to the structure of
      __kernel_clock_gettime, which heavily uses conditional branches to
      share code between the different clocks, it is difficult to support a
      new clock without making the branches even harder to follow.
      
      This commit completely refactors the structure of clock_gettime (and
      gettimeofday along the way) while keeping exactly the same algorithms.
      We no longer try to share code; instead, macros provide common
      operations. This new approach comes with a number of advantages:
      - In clock_gettime, clock implementations are no longer interspersed,
        making them much more readable. Additionally, macros only use
        registers passed as arguments or reserved with .req, this way it is
        easy to make sure that registers are properly allocated. To avoid a
        large number of branches in a given execution path, a jump table is
        used; a normal execution uses 3 unconditional branches.
      - __do_get_tspec has been replaced with 2 macros (get_ts_clock_mono,
        get_clock_shifted_nsec) and explicit loading of data from the vDSO
        page. Consequently, clock_gettime and gettimeofday are now leaf
        functions, and saving x30 (lr) is no longer necessary.
      - Variables protected by tb_seq_count are now loaded all at once,
        allowing to merge the seqcnt_read macro into seqcnt_check.
      - For CLOCK_REALTIME_COARSE, removed an unused load of the wall to
        monotonic timespec.
      - For CLOCK_MONOTONIC_COARSE, removed a few shift instructions.
      
      Obviously, the downside of sharing less code is an increase in code
      size. However since the vDSO has its own code page, this does not
      really matter, as long as the size of the DSO remains below 4 kB. For
      now this should be all right:
                          Before  After
        vdso.so size (B)  2776    3000
      Signed-off-by: NKevin Brodsky <kevin.brodsky@arm.com>
      Reviewed-by: NDave Martin <dave.martin@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      b33f491f
    • K
      arm64: fix vdso-offsets.h dependency · a66649da
      Kevin Brodsky 提交于
      arm64/kernel/{vdso,signal}.c include vdso-offsets.h, as well as any
      file that includes asm/vdso.h. Therefore, vdso-offsets.h must be
      generated before these files are compiled.
      
      The current rules in arm64/kernel/Makefile do not actually enforce
      this, because even though $(obj)/vdso is listed as a prerequisite for
      vdso-offsets.h, this does not result in the intended effect of
      building the vdso subdirectory (before all the other objects). As a
      consequence, depending on the order in which the rules are followed,
      vdso-offsets.h is updated or not before arm64/kernel/{vdso,signal}.o
      are built. The current rules also impose an unnecessary dependency on
      vdso-offsets.h for all arm64/kernel/*.o, resulting in unnecessary
      rebuilds. This is made obvious when using make -j:
      
        touch arch/arm64/kernel/vdso/gettimeofday.S && make -j$NCPUS arch/arm64/kernel
      
      will sometimes result in none of arm64/kernel/*.o being
      rebuilt, sometimes all of them, or even just some of them.
      
      It is quite difficult to ensure that a header is generated before it
      is used with recursive Makefiles by using normal rules.  Instead,
      arch-specific generated headers are normally built in the archprepare
      recipe in the arch Makefile (see for instance arch/ia64/Makefile).
      Unfortunately, asm-offsets.h is included in gettimeofday.S, and must
      therefore be generated before vdso-offsets.h, which is not the case if
      archprepare is used. For this reason, a rule run after archprepare has
      to be used.
      
      This commit adds rules in arm64/Makefile to build vdso-offsets.h
      during the prepare step, ensuring that vdso-offsets.h is generated
      before building anything. It also removes the now-unnecessary
      dependencies on vdso-offsets.h in arm64/kernel/Makefile. Finally, it
      removes the duplication of asm-offsets.h between arm64/kernel/vdso/
      and include/generated/ and makes include/generated/vdso-offsets.h a
      target in arm64/kernel/vdso/Makefile.
      
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Michal Marek <mmarek@suse.com>
      Signed-off-by: NKevin Brodsky <kevin.brodsky@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      a66649da
    • C
      Revert "arm64: Fix vdso-offsets.h dependency" · 7d9a7086
      Catalin Marinas 提交于
      This reverts commit 90f777be.
      
      While this commit was aimed at fixing the dependencies, with a large
      make -j the vdso-offsets.h file is not generated, leading to build
      failures.
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      7d9a7086
  3. 09 7月, 2016 2 次提交
    • L
      arm64: mm: change IOMMU notifier action to attach DMA ops · 16c11325
      Lorenzo Pieralisi 提交于
      Current bus notifier in ARM64 (__iommu_attach_notifier)
      attempts to attach dma_ops to a device on BUS_NOTIFY_ADD_DEVICE
      action notification.
      
      This will cause issues on ACPI based systems, where PCI devices
      can be added before the IOMMUs the devices are attached to
      had a chance to be probed, causing failures on attempts to
      attach dma_ops in that the domain for the respective IOMMU
      may not be set-up yet by the time the bus notifier is run.
      
      Devices dma_ops do not require to be set-up till the matching
      device drivers are probed. This means that instead of running
      the notifier attaching dma_ops to devices (__iommu_attach_notifier)
      on BUS_NOTIFY_ADD_DEVICE action, it can be run just before the
      device driver is bound to the device in question (on action
      BUS_NOTIFY_BIND_DRIVER) so that it is certain that its IOMMU
      group and domain are set-up accordingly at the time the
      notifier is triggered.
      
      This patch changes the notifier action upon which dma_ops
      are attached to devices and defer it to driver binding time,
      so that IOMMU devices have a chance to be probed and to register
      their bus notifiers before the dma_ops attach sequence for a
      device is actually carried out.
      
      As a result we also no longer need worry about racing with
      iommu_bus_notifier(), or about retrying the queue in case devices
      were added too early on DT-based systems, so clean up the notifier
      itself plus the additional workaround from 722ec35f ("arm64:
      dma-mapping: fix handling of devices registered before arch_initcall")
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      [rm: get rid of other now-redundant bits]
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      16c11325
    • M
      drivers/perf: arm-pmu: Handle per-interrupt affinity mask · 19a469a5
      Marc Zyngier 提交于
      On a big-little system, PMUs can be wired to CPUs using per CPU
      interrups (PPI). In this case, it is important to make sure that
      the enable/disable do happen on the right set of CPUs.
      
      So instead of relying on the interrupt-affinity property, we can
      use the actual percpu affinity that DT exposes as part of the
      interrupt specifier. The DT binding is also updated to reflect
      the fact that the interrupt-affinity property shouldn't be used
      in that case.
      Acked-by: NRob Herring <robh@kernel.org>
      Tested-by: NCaesar Wang <wxt@rock-chips.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      19a469a5
  4. 08 7月, 2016 1 次提交
    • C
      arm64: Fix vdso-offsets.h dependency · 90f777be
      Catalin Marinas 提交于
      arch/arm64/kernel/{vdso,signal}.c include generated/vdso-offsets.h, and
      therefore the symbol offsets must be generated before these files are
      compiled.
      
      The current rules in arm64/kernel/Makefile do not actually enforce
      this, because even though $(obj)/vdso is listed as a prerequisite for
      vdso-offsets.h, this does not result in the intended effect of
      building the vdso subdirectory (before all the other objects). As a
      consequence, depending on the order in which the rules are followed,
      vdso-offsets.h is updated or not before arm64/kernel/{vdso,signal}.o
      are built. The current rules also impose an unnecessary dependency on
      vdso-offsets.h for all arm64/kernel/*.o, resulting in unnecessary
      rebuilds.
      
      This patch removes the arch/arm64/kernel/vdso/vdso-offsets.h file
      generation, leaving only the include/generated/vdso-offsets.h one. It
      adds a forced dependency check of the vdso-offsets.h file in
      arch/arm64/kernel/Makefile which, if not up to date according to the
      arch/arm64/kernel/vdso/Makefile rules (depending on vdso.so.dbg), will
      trigger the vdso/ subdirectory build and vdso-offsets.h re-generation.
      Automatic kbuild dependency rules between kernel/{vdso,signal}.c rules
      and vdso-offsets.h will guarantee that the vDSO object is built first,
      followed by the generated symbol offsets header file.
      Reported-by: NKevin Brodsky <kevin.brodsky@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      90f777be
  5. 01 7月, 2016 12 次提交
  6. 28 6月, 2016 2 次提交
  7. 27 6月, 2016 5 次提交
  8. 22 6月, 2016 4 次提交
    • C
      Revert "arm64: Add support ARCH_SUPPORTS_INT128" · d770b5a0
      Catalin Marinas 提交于
      This reverts commit 6b14c517.
      
      The original patch and UBSAN+KASAN enabled causes Linux to fail to link
      with:
      
      lib/built-in.o: In function `get_signed_val':
      lib/ubsan.c:93: undefined reference to `__ashlti3'
      lib/ubsan.c:93: undefined reference to `__ashrti3'
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      d770b5a0
    • M
      arm64: kill ESR_LNX_EXEC · 541ec870
      Mark Rutland 提交于
      Currently we treat ESR_EL1 bit 24 as software-defined for distinguishing
      instruction aborts from data aborts, but this bit is architecturally
      RES0 for instruction aborts, and could be allocated for an arbitrary
      purpose in future. Additionally, we hard-code the value in entry.S
      without the mnemonic, making the code difficult to understand.
      
      Instead, remove ESR_LNX_EXEC, and distinguish aborts based on the esr,
      which we already pass to the sole use of ESR_LNX_EXEC. A new helper,
      is_el0_instruction_abort() is added to make the logic clear. Any
      instruction aborts taken from EL1 will already have been handled by
      bad_mode, so we need not handle that case in the helper.
      
      For consistency, the existing permission_fault helper is renamed to
      is_permission_fault, and the return type is changed to bool. There
      should be no functional changes as the return value was a boolean
      expression, and the result is only used in another boolean expression.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Dave P Martin <dave.martin@arm.com>
      Cc: Huang Shijie <shijie.huang@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      541ec870
    • M
      arm64/kvm: use ESR_ELx_EC to extract EC · 561454e2
      Mark Rutland 提交于
      Now that we have a helper to extract the EC from an ESR_ELx value, make
      use of this in the arm64 KVM code for simplicity and consistency. There
      should be no functional changes as a result of this patch.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Dave P Martin <dave.martin@arm.com>
      Cc: Huang Shijie <shijie.huang@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: kvmarm@lists.cs.columbia.edu
      Acked-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      561454e2
    • M
      arm64: add macro to extract ESR_ELx.EC · 275f344b
      Mark Rutland 提交于
      Several places open-code extraction of the EC field from an ESR_ELx
      value, in subtly different ways. This is unfortunate duplication and
      variation, and the precise logic used to extract the field is a
      distraction.
      
      This patch adds a new macro, ESR_ELx_EC(), to extract the EC field from
      an ESR_ELx value in a consistent fashion.
      
      Existing open-coded extractions in core arm64 code are moved over to the
      new helper. KVM code is left as-is for the moment.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Tested-by: NHuang Shijie <shijie.huang@arm.com>
      Cc: Dave P Martin <dave.martin@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      275f344b
  9. 21 6月, 2016 6 次提交