1. 28 Oct, 2019 12 commits
    • Catalin Marinas's avatar
      Merge branch 'for-next/entry-s-to-c' into for-next/core · 8301ae82
      Catalin Marinas authored
      Move the synchronous exception paths from entry.S into a C file to
      improve the code readability.
      
      * for-next/entry-s-to-c:
        arm64: entry-common: don't touch daif before bp-hardening
        arm64: Remove asmlinkage from updated functions
        arm64: entry: convert el0_sync to C
        arm64: entry: convert el1_sync to C
        arm64: add local_daif_inherit()
        arm64: Add prototypes for functions called by entry.S
        arm64: remove __exception annotations
      8301ae82
    • Catalin Marinas's avatar
      Merge branch 'kvm-arm64/erratum-1319367' of... · 346f6a46
      Catalin Marinas authored
      Merge branch 'kvm-arm64/erratum-1319367' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into for-next/core
      
      Similarly to erratum 1165522 that affects Cortex-A76, A57 and A72
      respectively suffer from errata 1319537 and 1319367, potentially
      resulting in TLB corruption if the CPU speculates an AT instruction
      while switching guests.
      
      The fix is slightly more involved since we don't have VHE to help us
      here, but the idea is the same: when switching a guest in, we must
      prevent any speculated AT from being able to parse the page tables
      until S2 is up and running. Only at this stage can we allow AT to take
      place.
      
      For this, we always restore the guest sysregs first, except for its
      SCTLR and TCR registers, which must be set with SCTLR.M=1 and
      TCR.EPD{0,1} = {1, 1}, effectively disabling the PTW and TLB
      allocation. Once S2 is setup, we restore the guest's SCTLR and
      TCR. Similar things must be done on TLB invalidation...
      
      * 'kvm-arm64/erratum-1319367' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms:
        arm64: Enable and document ARM errata 1319367 and 1319537
        arm64: KVM: Prevent speculative S1 PTW when restoring vcpu context
        arm64: KVM: Disable EL1 PTW when invalidating S2 TLBs
        arm64: KVM: Reorder system register restoration and stage-2 activation
        arm64: Add ARM64_WORKAROUND_1319367 for all A57 and A72 versions
      346f6a46
    • Catalin Marinas's avatar
      Merge branch 'for-next/neoverse-n1-stale-instr' into for-next/core · 6a036afb
      Catalin Marinas authored
      Neoverse-N1 cores with the 'COHERENT_ICACHE' feature may fetch stale
      instructions when software depends on prefetch-speculation-protection
      instead of explicit synchronization. [0]
      
      The workaround is to trap I-Cache maintenance and issue an
      inner-shareable TLBI. The affected cores have a Coherent I-Cache, so the
      I-Cache maintenance isn't necessary. The core tells user-space it can
      skip it with CTR_EL0.DIC. We also have to trap this register to hide the
      bit forcing DIC-aware user-space to perform the maintenance.
      
      To avoid trapping all cache-maintenance, this workaround depends on
      a firmware component that only traps I-cache maintenance from EL0 and
      performs the workaround.
      
      For user-space, the kernel's work is to trap CTR_EL0 to hide DIC, and
      produce a fake IminLine. EL3 traps the now-necessary I-Cache maintenance
      and performs the inner-shareable-TLBI that makes everything better.
      
      [0] https://developer.arm.com/docs/sden885747/latest/arm-neoverse-n1-mp050-software-developer-errata-notice
      
      * for-next/neoverse-n1-stale-instr:
        arm64: Silence clang warning on mismatched value/register sizes
        arm64: compat: Workaround Neoverse-N1 #1542419 for compat user-space
        arm64: Fake the IminLine size on systems affected by Neoverse-N1 #1542419
        arm64: errata: Hide CTR_EL0.DIC on systems affected by Neoverse-N1 #1542419
      6a036afb
    • Catalin Marinas's avatar
      Merge remote-tracking branch 'arm64/for-next/fixes' into for-next/core · ba95e9bd
      Catalin Marinas authored
      This is required to solve the conflicts with subsequent merges of two
      more errata workaround branches.
      
      * arm64/for-next/fixes:
        arm64: tags: Preserve tags for addresses translated via TTBR1
        arm64: mm: fix inverted PAR_EL1.F check
        arm64: sysreg: fix incorrect definition of SYS_PAR_EL1_F
        arm64: entry.S: Do not preempt from IRQ before all cpufeatures are enabled
        arm64: hibernate: check pgd table allocation
        arm64: cpufeature: Treat ID_AA64ZFR0_EL1 as RAZ when SVE is not enabled
        arm64: Fix kcore macros after 52-bit virtual addressing fallout
        arm64: Allow CAVIUM_TX2_ERRATUM_219 to be selected
        arm64: Avoid Cavium TX2 erratum 219 when switching TTBR
        arm64: Enable workaround for Cavium TX2 erratum 219 when running SMT
        arm64: KVM: Trap VM ops when ARM64_WORKAROUND_CAVIUM_TX2_219_TVM is set
      ba95e9bd
    • James Morse's avatar
      arm64: entry-common: don't touch daif before bp-hardening · bfe29874
      James Morse authored
      The previous patches mechanically transformed the assembly version of
      entry.S to entry-common.c for synchronous exceptions.
      
      The C version of local_daif_restore() doesn't quite do the same thing
      as the assembly versions if pseudo-NMI is in use. In particular,
      | local_daif_restore(DAIF_PROCCTX_NOIRQ)
      will still allow pNMI to be delivered. This is not the behaviour
      do_el0_ia_bp_hardening() and do_sp_pc_abort() want as it should not
      be possible for the PMU handler to run as an NMI until the bp-hardening
      sequence has run.
      
      The bp-hardening calls were placed where they are because this was the
      first C code to run after the relevant exceptions. As we've now moved
      that point earlier, move the checks and calls earlier too.
      
      This makes it clearer that this stuff runs before any kind of exception,
      and saves modifying PSTATE twice.
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      bfe29874
    • James Morse's avatar
      arm64: Remove asmlinkage from updated functions · afa7c0e5
      James Morse authored
      Now that the callers of these functions have moved into C, they no longer
      need the asmlinkage annotation. Remove it.
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      afa7c0e5
    • Mark Rutland's avatar
      arm64: entry: convert el0_sync to C · 582f9583
      Mark Rutland authored
      This is largely a 1-1 conversion of asm to C, with a couple of caveats.
      
      The el0_sync{_compat} switches explicitly handle all the EL0 debug
      cases, so el0_dbg doesn't have to try to bail out for unexpected EL1
      debug ESR values. This also means that an unexpected vector catch from
      AArch32 is routed to el0_inv.
      
      We *could* merge the native and compat switches, which would make the
      diffstat negative, but I've tried to stay as close to the existing
      assembly as possible for the moment.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      [split out of a bigger series, added nokprobes. removed irq trace
       calls as the C helpers do this. renamed el0_dbg's use of FAR]
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      582f9583
    • Mark Rutland's avatar
      arm64: entry: convert el1_sync to C · ed3768db
      Mark Rutland authored
      This patch converts the EL1 sync entry assembly logic to C code.
      
      Doing this will allow us to make changes in a slightly more
      readable way. A case in point is supporting kernel-first RAS.
      do_sea() should be called on the CPU that took the fault.
      
      Largely the assembly code is converted to C in a relatively
      straightforward manner.
      
      Since all sync sites share a common asm entry point, the ASM_BUG()
      instances are no longer required for effective backtraces back to
      assembly, and we don't need similar BUG() entries.
      
      The ESR_ELx.EC codes for all (supported) debug exceptions are now
      checked in the el1_sync_handler's switch statement, which renders the
      check in el1_dbg redundant. This both simplifies the el1_dbg handler,
      and makes the EL1 exception handling more robust to
      currently-unallocated ESR_ELx.EC encodings.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      [split out of a bigger series, added nokprobes, moved prototypes]
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      ed3768db
    • Mark Rutland's avatar
      arm64: add local_daif_inherit() · 51077e03
      Mark Rutland authored
      Some synchronous exceptions can be taken from a number of contexts,
      e.g. where IRQs may or may not be masked. In the entry assembly for
      these exceptions, we use the inherit_daif assembly macro to ensure
      that we only mask those exceptions which were masked when the exception
      was taken.
      
      So that we can do the same from C code, this patch adds a new
      local_daif_inherit() function, following the existing local_daif_*()
      naming scheme.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      [moved away from local_daif_restore()]
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      51077e03
    • James Morse's avatar
      arm64: Add prototypes for functions called by entry.S · e540e0a7
      James Morse authored
      Functions that are only called by assembly don't always have a
      C header file prototype.
      
      Add the prototypes before moving the assembly callers to C.
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      e540e0a7
    • James Morse's avatar
      arm64: remove __exception annotations · b6e43c0e
      James Morse authored
      Since commit 73267498 ("arm64: unwind: reference pt_regs via embedded
      stack frame") arm64 has not used the __exception annotation to dump
      the pt_regs during stack tracing. in_exception_text() has no callers.
      
      This annotation is only used to blacklist kprobes, it means the same as
      __kprobes.
      
      Section annotations like this require the functions to be grouped
      together between the start/end markers, and placed according to
      the linker script. For kprobes we also have NOKPROBE_SYMBOL() which
      logs the symbol address in a section that kprobes parses and
      blacklists at boot.
      
      Using NOKPROBE_SYMBOL() instead lets kprobes publish the list of
      blacklisted symbols, and saves us from having an arm64 specific
      spelling of __kprobes.
      
      do_debug_exception() already has a NOKPROBE_SYMBOL() annotation.
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      b6e43c0e
    • Catalin Marinas's avatar
      arm64: Silence clang warning on mismatched value/register sizes · 27a22fbd
      Catalin Marinas authored
      Clang reports a warning on the __tlbi(aside1is, 0) macro expansion since
      the value size does not match the register size specified in the inline
      asm. Construct the ASID value using the __TLBI_VADDR() macro.
      
      Fixes: 222fc0c8 ("arm64: compat: Workaround Neoverse-N1 #1542419 for compat user-space")
      Reported-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Cc: James Morse <james.morse@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      27a22fbd
  2. 26 Oct, 2019 4 commits
  3. 25 Oct, 2019 3 commits
  4. 18 Oct, 2019 1 commit
  5. 17 Oct, 2019 1 commit
    • Will Deacon's avatar
      Merge branch 'errata/tx2-219' into for-next/fixes · 777d062e
      Will Deacon authored
      Workaround for Cavium/Marvell ThunderX2 erratum #219.
      
      * errata/tx2-219:
        arm64: Allow CAVIUM_TX2_ERRATUM_219 to be selected
        arm64: Avoid Cavium TX2 erratum 219 when switching TTBR
        arm64: Enable workaround for Cavium TX2 erratum 219 when running SMT
        arm64: KVM: Trap VM ops when ARM64_WORKAROUND_CAVIUM_TX2_219_TVM is set
      777d062e
  6. 16 Oct, 2019 4 commits
  7. 15 Oct, 2019 2 commits
  8. 13 Oct, 2019 13 commits