Skip to content
  1. Apr 28, 2020
  2. Mar 18, 2020
  3. Mar 07, 2020
    • Ionela Voinescu's avatar
      arm64: use activity monitors for frequency invariance · cd0ed03a
      Ionela Voinescu authored
      
      
      The Frequency Invariance Engine (FIE) is providing a frequency
      scaling correction factor that helps achieve more accurate
      load-tracking.
      
      So far, for arm and arm64 platforms, this scale factor has been
      obtained based on the ratio between the current frequency and the
      maximum supported frequency recorded by the cpufreq policy. The
      setting of this scale factor is triggered from cpufreq drivers by
      calling arch_set_freq_scale. The current frequency used in computation
      is the frequency requested by a governor, but it may not be the
      frequency that was implemented by the platform.
      
      This correction factor can also be obtained using a core counter and a
      constant counter to get information on the performance (frequency based
      only) obtained in a period of time. This will more accurately reflect
      the actual current frequency of the CPU, compared with the alternative
      implementation that reflects the request of a performance level from
      the OS.
      
      Therefore, implement arch_scale_freq_tick to use activity monitors, if
      present, for the computation of the frequency scale factor.
      
      The use of AMU counters depends on:
       - CONFIG_ARM64_AMU_EXTN - depents on the AMU extension being present
       - CONFIG_CPU_FREQ - the current frequency obtained using counter
         information is divided by the maximum frequency obtained from the
         cpufreq policy.
      
      While it is possible to have a combination of CPUs in the system with
      and without support for activity monitors, the use of counters for
      frequency invariance is only enabled for a CPU if all related CPUs
      (CPUs in the same frequency domain) support and have enabled the core
      and constant activity monitor counters. In this way, there is a clear
      separation between the policies for which arch_set_freq_scale (cpufreq
      based FIE) is used, and the policies for which arch_scale_freq_tick
      (counter based FIE) is used to set the frequency scale factor. For
      this purpose, a late_initcall_sync is registered to trigger validation
      work for policies that will enable or disable the use of AMU counters
      for frequency invariance. If CONFIG_CPU_FREQ is not defined, the use
      of counters is enabled on all CPUs only if all possible CPUs correctly
      support the necessary counters.
      
      Signed-off-by: default avatarIonela Voinescu <ionela.voinescu@arm.com>
      Reviewed-by: default avatarLukasz Luba <lukasz.luba@arm.com>
      Acked-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      cd0ed03a
    • Ionela Voinescu's avatar
      arm64: add support for the AMU extension v1 · 2c9d45b4
      Ionela Voinescu authored
      
      
      The activity monitors extension is an optional extension introduced
      by the ARMv8.4 CPU architecture. This implements basic support for
      version 1 of the activity monitors architecture, AMUv1.
      
      This support includes:
      - Extension detection on each CPU (boot, secondary, hotplugged)
      - Register interface for AMU aarch64 registers
      
      Signed-off-by: default avatarIonela Voinescu <ionela.voinescu@arm.com>
      Reviewed-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      2c9d45b4
  4. Jan 22, 2020
  5. Jan 16, 2020
  6. Jan 15, 2020
    • Mark Brown's avatar
      arm64: Use a variable to store non-global mappings decision · 09e3c22a
      Mark Brown authored
      
      
      Refactor the code which checks to see if we need to use non-global
      mappings to use a variable instead of checking with the CPU capabilities
      each time, doing the initial check for KPTI early in boot before we
      start allocating memory so we still avoid transitioning to non-global
      mappings in common cases.
      
      Since this variable always matches our decision about non-global
      mappings this means we can also combine arm64_kernel_use_ng_mappings()
      and arm64_unmap_kernel_at_el0() into a single function, the variable
      simply stores the result and the decision code is elsewhere. We could
      just have the users check the variable directly but having a function
      makes it clear that these uses are read-only.
      
      The result is that we simplify the code a bit and reduces the amount of
      code executed at runtime.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      09e3c22a
    • Mark Brown's avatar
      arm64: Factor out checks for KASLR in KPTI code into separate function · c2d92353
      Mark Brown authored
      
      
      In preparation for integrating E0PD support with KASLR factor out the
      checks for interaction between KASLR and KPTI done in boot context into
      a new function kaslr_requires_kpti(), in the process clarifying the
      distinction between what we do in boot context and what we do at
      runtime.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      c2d92353
    • Mark Brown's avatar
      arm64: Add initial support for E0PD · 3e6c69a0
      Mark Brown authored
      
      
      Kernel Page Table Isolation (KPTI) is used to mitigate some speculation
      based security issues by ensuring that the kernel is not mapped when
      userspace is running but this approach is expensive and is incompatible
      with SPE.  E0PD, introduced in the ARMv8.5 extensions, provides an
      alternative to this which ensures that accesses from userspace to the
      kernel's half of the memory map to always fault with constant time,
      preventing timing attacks without requiring constant unmapping and
      remapping or preventing legitimate accesses.
      
      Currently this feature will only be enabled if all CPUs in the system
      support E0PD, if some CPUs do not support the feature at boot time then
      the feature will not be enabled and in the unlikely event that a late
      CPU is the first CPU to lack the feature then we will reject that CPU.
      
      This initial patch does not yet integrate with KPTI, this will be dealt
      with in followup patches.  Ideally we could ensure that by default we
      don't use KPTI on CPUs where E0PD is present.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      [will: Fixed typo in Kconfig text]
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      3e6c69a0
    • Catalin Marinas's avatar
      arm64: Move the LSE gas support detection to Kconfig · 395af861
      Catalin Marinas authored
      
      
      As the Kconfig syntax gained support for $(as-instr) tests, move the LSE
      gas support detection from Makefile to the main arm64 Kconfig and remove
      the additional CONFIG_AS_LSE definition and check.
      
      Cc: Will Deacon <will@kernel.org>
      Reviewed-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Tested-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      395af861
    • Anshuman Khandual's avatar
      arm64: Introduce ID_ISAR6 CPU register · 8e3747be
      Anshuman Khandual authored
      
      
      This adds basic building blocks required for ID_ISAR6 CPU register which
      identifies support for various instruction implementation on AArch32 state.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: kvmarm@lists.cs.columbia.edu
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      [will: Ensure SPECRES is treated the same as on A64]
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      8e3747be
    • Steven Price's avatar
      arm64: cpufeature: Export matrix and other features to userspace · d4209d8b
      Steven Price authored
      
      
      Export the features introduced as part of ARMv8.6 exposed in the
      ID_AA64ISAR1_EL1 and ID_AA64ZFR0_EL1 registers. This introduces the
      Matrix features (ARMv8.2-I8MM, ARMv8.2-F64MM and ARMv8.2-F32MM) along
      with BFloat16 (Armv8.2-BF16), speculation invalidation (SPECRES) and
      Data Gathering Hint (ARMv8.0-DGH).
      
      Signed-off-by: default avatarJulien Grall <julien.grall@arm.com>
      [Added other features in those registers]
      Signed-off-by: default avatarSteven Price <steven.price@arm.com>
      [will: Don't advertise SPECRES to userspace]
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      d4209d8b
    • Suzuki K Poulose's avatar
      arm64: cpufeature: Set the FP/SIMD compat HWCAP bits properly · 7559950a
      Suzuki K Poulose authored
      We set the compat_elf_hwcap bits unconditionally on arm64 to
      include the VFP and NEON support. However, the FP/SIMD unit
      is optional on Arm v8 and thus could be missing. We already
      handle this properly in the kernel, but still advertise to
      the COMPAT applications that the VFP is available. Fix this
      to make sure we only advertise when we really have them.
      
      Fixes: 82e0191a
      
       ("arm64: Support systems without FP/ASIMD")
      Cc: Will Deacon <will@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      7559950a
    • Suzuki K Poulose's avatar
      arm64: cpufeature: Fix the type of no FP/SIMD capability · 449443c0
      Suzuki K Poulose authored
      The NO_FPSIMD capability is defined with scope SYSTEM, which implies
      that the "absence" of FP/SIMD on at least one CPU is detected only
      after all the SMP CPUs are brought up. However, we use the status
      of this capability for every context switch. So, let us change
      the scope to LOCAL_CPU to allow the detection of this capability
      as and when the first CPU without FP is brought up.
      
      Also, the current type allows hotplugged CPU to be brought up without
      FP/SIMD when all the current CPUs have FP/SIMD and we have the userspace
      up. Fix both of these issues by changing the capability to
      BOOT_RESTRICTED_LOCAL_CPU_FEATURE.
      
      Fixes: 82e0191a
      
       ("arm64: Support systems without FP/ASIMD")
      Cc: Will Deacon <will@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      449443c0
    • Suzuki K Poulose's avatar
      arm64: Introduce system_capabilities_finalized() marker · b51c6ac2
      Suzuki K Poulose authored
      
      
      We finalize the system wide capabilities after the SMP CPUs
      are booted by the kernel. This is used as a marker for deciding
      various checks in the kernel. e.g, sanity check the hotplugged
      CPUs for missing mandatory features.
      
      However there is no explicit helper available for this in the
      kernel. There is sys_caps_initialised, which is not exposed.
      The other closest one we have is the jump_label arm64_const_caps_ready
      which denotes that the capabilities are set and the capability checks
      could use the individual jump_labels for fast path. This is
      performed before setting the ELF Hwcaps, which must be checked
      against the new CPUs. We also perform some of the other initialization
      e.g, SVE setup, which is important for the use of FP/SIMD
      where SVE is supported. Normally userspace doesn't get to run
      before we finish this. However the in-kernel users may
      potentially start using the neon mode. So, we need to
      reject uses of neon mode before we are set. Instead of defining
      a new marker for the completion of SVE setup, we could simply
      reuse the arm64_const_caps_ready and enable it once we have
      finished all the setup. Also we could expose this to the
      various users as "system_capabilities_finalized()" to make
      it more meaningful than "const_caps_ready".
      
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      b51c6ac2
  7. Jan 09, 2020
  8. Nov 06, 2019
  9. Oct 15, 2019
  10. Oct 04, 2019
    • Julien Grall's avatar
      arm64: cpufeature: Effectively expose FRINT capability to userspace · 7230f7e9
      Julien Grall authored
      The HWCAP framework will detect a new capability based on the sanitized
      version of the ID registers.
      
      Sanitization is based on a whitelist, so any field not described will end
      up to be zeroed.
      
      At the moment, ID_AA64ISAR1_EL1.FRINTTS is not described in
      ftr_id_aa64isar1. This means the field will be zeroed and therefore the
      userspace will not be able to see the HWCAP even if the hardware
      supports the feature.
      
      This can be fixed by describing the field in ftr_id_aa64isar1.
      
      Fixes: ca9503fc
      
       ("arm64: Expose FRINT capabilities to userspace")
      Signed-off-by: default avatarJulien Grall <julien.grall@arm.com>
      Cc: mark.brown@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      7230f7e9
  11. Aug 13, 2019
    • Will Deacon's avatar
      arm64: cpufeature: Don't treat granule sizes as strict · 5717fe5a
      Will Deacon authored
      If a CPU doesn't support the page size for which the kernel is
      configured, then we will complain and refuse to bring it online. For
      secondary CPUs (and the boot CPU on a system booting with EFI), we will
      also print an error identifying the mismatch.
      
      Consequently, the only time that the cpufeature code can detect a
      granule size mismatch is for a granule other than the one that is
      currently being used. Although we would rather such systems didn't
      exist, we've unfortunately lost that battle and Kevin reports that
      on his amlogic S922X (odroid-n2 board) we end up warning and taining
      with defconfig because 16k pages are not supported by all of the CPUs.
      
      In such a situation, we don't actually care about the feature mismatch,
      particularly now that KVM only exposes the sanitised view of the CPU
      registers (commit 93390c0a
      
       - "arm64: KVM: Hide unsupported AArch64
      CPU features from guests"). Treat the granule fields as non-strict and
      let Kevin run without a tainted kernel.
      
      Cc: Marc Zyngier <maz@kernel.org>
      Reported-by: default avatarKevin Hilman <khilman@baylibre.com>
      Tested-by: default avatarKevin Hilman <khilman@baylibre.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      [catalin.marinas@arm.com: changelog updated with KVM sanitised regs commit]
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      5717fe5a
  12. Aug 07, 2019
    • Qian Cai's avatar
      arm64/prefetch: fix a -Wtype-limits warning · b99286b0
      Qian Cai authored
      The commit d5370f75
      
       ("arm64: prefetch: add alternative pattern for
      CPUs without a prefetcher") introduced MIDR_IS_CPU_MODEL_RANGE() to be
      used in has_no_hw_prefetch() with rv_min=0 which generates a compilation
      warning from GCC,
      
      In file included from ./arch/arm64/include/asm/cache.h:8,
                     from ./include/linux/cache.h:6,
                     from ./include/linux/printk.h:9,
                     from ./include/linux/kernel.h:15,
                     from ./include/linux/cpumask.h:10,
                     from arch/arm64/kernel/cpufeature.c:11:
      arch/arm64/kernel/cpufeature.c: In function 'has_no_hw_prefetch':
      ./arch/arm64/include/asm/cputype.h:59:26: warning: comparison of
      unsigned expression >= 0 is always true [-Wtype-limits]
      _model == (model) && rv >= (rv_min) && rv <= (rv_max);  \
                              ^~
      arch/arm64/kernel/cpufeature.c:889:9: note: in expansion of macro
      'MIDR_IS_CPU_MODEL_RANGE'
      return MIDR_IS_CPU_MODEL_RANGE(midr, MIDR_THUNDERX,
             ^~~~~~~~~~~~~~~~~~~~~~~
      
      Fix it by converting MIDR_IS_CPU_MODEL_RANGE to a static inline
      function.
      
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      b99286b0
  13. Aug 01, 2019
  14. Jun 25, 2019
  15. Jun 19, 2019
  16. Jun 05, 2019
    • Dave Martin's avatar
      arm64: cpufeature: Fix missing ZFR0 in __read_sysreg_by_encoding() · 78ed70bf
      Dave Martin authored
      In commit 06a916fe ("arm64: Expose SVE2 features for
      userspace"), new hwcaps are added that are detected via fields in
      the SVE-specific ID register ID_AA64ZFR0_EL1.
      
      In order to check compatibility of secondary cpus with the hwcaps
      established at boot, the cpufeatures code uses
      __read_sysreg_by_encoding() to read this ID register based on the
      sys_reg field of the arm64_elf_hwcaps[] table.
      
      This leads to a kernel splat if an hwcap uses an ID register that
      __read_sysreg_by_encoding() doesn't explicitly handle, as now
      happens when exercising cpu hotplug on an SVE2-capable platform.
      
      So fix it by adding the required case in there.
      
      Fixes: 06a916fe
      
       ("arm64: Expose SVE2 features for userspace")
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      78ed70bf
  17. Jun 04, 2019