1. 18 Jan, 2024 5 commits
    • Mark Brown's avatar
      arm64/sme: Always exit sme_alloc() early with existing storage · dc7eb875
      Mark Brown authored
      When sme_alloc() is called with existing storage and we are not flushing we
      will always allocate new storage, both leaking the existing storage and
      corrupting the state. Fix this by separating the checks for flushing and
      for existing storage as we do for SVE.
      
      Callers that reallocate (eg, due to changing the vector length) should
      call sme_free() themselves.
      
      Fixes: 5d0a8d2f ("arm64/ptrace: Ensure that SME is set up for target when writing SSVE state")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20240115-arm64-sme-flush-v1-1-7472bd3459b7@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      dc7eb875
    • Mark Brown's avatar
      arm64/fpsimd: Remove spurious check for SVE support · 8410186c
      Mark Brown authored
      There is no need to check for SVE support when changing vector lengths,
      even if the system is SME only we still need SVE storage for the streaming
      SVE state.
      
      Fixes: d4d5be94 ("arm64/fpsimd: Ensure SME storage is allocated after SVE VL changes")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20240115-arm64-sve-enabled-check-v1-1-a26360b00f6d@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      8410186c
    • Mark Brown's avatar
      arm64/ptrace: Don't flush ZA/ZT storage when writing ZA via ptrace · b7c510d0
      Mark Brown authored
      When writing ZA we currently unconditionally flush the buffer used to store
      it as part of ensuring that it is allocated. Since this buffer is shared
      with ZT0 this means that a write to ZA when PSTATE.ZA is already set will
      corrupt the value of ZT0 on a SME2 system. Fix this by only flushing the
      backing storage if PSTATE.ZA was not previously set.
      
      This will mean that short or failed writes may leave stale data in the
      buffer, this seems as correct as our current behaviour and unlikely to be
      something that userspace will rely on.
      
      Fixes: f90b529b ("arm64/sme: Implement ZT0 ptrace support")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20240115-arm64-fix-ptrace-za-zt-v1-1-48617517028a@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      b7c510d0
    • Mark Rutland's avatar
      arm64: entry: simplify kernel_exit logic · da59f1d0
      Mark Rutland authored
      For historical reasons, the non-KPTI exception return path is duplicated for
      EL1 and EL0, with the structure:
      
      	.if \el == 0
      	[ KPTI handling ]
      	ldr     lr, [sp, #S_LR]
       	add	sp, sp, #PT_REGS_SIZE		// restore sp
      	[ EL0 exception return workaround ]
      	eret
      	.else
      	ldr     lr, [sp, #S_LR]
       	add	sp, sp, #PT_REGS_SIZE		// restore sp
      	[ EL1 exception return workaround ]
      	eret
      	.endif
      	sb
      
      This would be simpler and clearer with the common portions factored out,
      e.g.
      
      	.if \el == 0
      	[ KPTI handling ]
      	.endif
      
      	ldr     lr, [sp, #S_LR]
       	add	sp, sp, #PT_REGS_SIZE		// restore sp
      
      	.if \el == 0
      	[ EL0 exception return workaround ]
      	.else
      	[ EL1 exception return workaround ]
      	.endif
      
      	eret
      	sb
      
      This expands to the same code, but is simpler for a human to follow as
      it avoids duplicates the restore of LR+SP, and makes it clear that the
      ERET is associated with the SB.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20240116110221.420467-3-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      da59f1d0
    • Mark Rutland's avatar
      arm64: entry: fix ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD · 832dd634
      Mark Rutland authored
      Currently the ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD workaround isn't
      quite right, as it is supposed to be applied after the last explicit
      memory access, but is immediately followed by an LDR.
      
      The ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD workaround is used to
      handle Cortex-A520 erratum 2966298 and Cortex-A510 erratum 3117295,
      which are described in:
      
      * https://developer.arm.com/documentation/SDEN2444153/0600/?lang=en
      * https://developer.arm.com/documentation/SDEN1873361/1600/?lang=en
      
      In both cases the workaround is described as:
      
      | If pagetable isolation is disabled, the context switch logic in the
      | kernel can be updated to execute the following sequence on affected
      | cores before exiting to EL0, and after all explicit memory accesses:
      |
      | 1. A non-shareable TLBI to any context and/or address, including
      |    unused contexts or addresses, such as a `TLBI VALE1 Xzr`.
      |
      | 2. A DSB NSH to guarantee completion of the TLBI.
      
      The important part being that the TLBI+DSB must be placed "after all
      explicit memory accesses".
      
      Unfortunately, as-implemented, the TLBI+DSB is immediately followed by
      an LDR, as we have:
      
      | alternative_if ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD
      | 	tlbi	vale1, xzr
      | 	dsb	nsh
      | alternative_else_nop_endif
      | alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0
      | 	ldr	lr, [sp, #S_LR]
      | 	add	sp, sp, #PT_REGS_SIZE		// restore sp
      | 	eret
      | alternative_else_nop_endif
      |
      | [ ... KPTI exception return path ... ]
      
      This patch fixes this by reworking the logic to place the TLBI+DSB
      immediately before the ERET, after all explicit memory accesses.
      
      The ERET is currently in a separate alternative block, and alternatives
      cannot be nested. To account for this, the alternative block for
      ARM64_UNMAP_KERNEL_AT_EL0 is replaced with a single alternative branch
      to skip the KPTI logic, with the new shape of the logic being:
      
      | alternative_insn "b .L_skip_tramp_exit_\@", nop, ARM64_UNMAP_KERNEL_AT_EL0
      | 	[ ... KPTI exception return path ... ]
      | .L_skip_tramp_exit_\@:
      |
      | 	ldr	lr, [sp, #S_LR]
      | 	add	sp, sp, #PT_REGS_SIZE		// restore sp
      |
      | alternative_if ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD
      | 	tlbi	vale1, xzr
      | 	dsb	nsh
      | alternative_else_nop_endif
      | 	eret
      
      The new structure means that the workaround is only applied when KPTI is
      not in use; this is fine as noted in the documented implications of the
      erratum:
      
      | Pagetable isolation between EL0 and higher level ELs prevents the
      | issue from occurring.
      
      ... and as per the workaround description quoted above, the workaround
      is only necessary "If pagetable isolation is disabled".
      
      Fixes: 471470bc ("arm64: errata: Add Cortex-A520 speculative unprivileged load workaround")
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20240116110221.420467-2-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      832dd634
  2. 12 Jan, 2024 5 commits
  3. 04 Jan, 2024 13 commits
    • Will Deacon's avatar
      Merge branch 'for-next/fixes' into for-next/core · db32cf8e
      Will Deacon authored
      Merge in arm64 fixes queued for 6.7 so that kpti_install_ng_mappings()
      can be updated to use arm64_kernel_unmapped_at_el0() instead of checking
      the ARM64_UNMAP_KERNEL_AT_EL0 CPU capability directly.
      
      * for-next/fixes:
        arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify
        perf/arm-cmn: Fail DTC counter allocation correctly
        arm64: Avoid enabling KPTI unnecessarily
      db32cf8e
    • Will Deacon's avatar
      Merge branch 'for-next/sysregs' into for-next/core · 3e8626b4
      Will Deacon authored
      * for-next/sysregs:
        arm64/sysreg: Add missing system instruction definitions for FGT
        arm64/sysreg: Add missing system register definitions for FGT
        arm64/sysreg: Add missing ExtTrcBuff field definition to ID_AA64DFR0_EL1
        arm64/sysreg: Add missing Pauth_LR field definitions to ID_AA64ISAR1_EL1
        arm64/sysreg: Add new system registers for GCS
        arm64/sysreg: Add definition for FPMR
        arm64/sysreg: Update HCRX_EL2 definition for DDI0601 2023-09
        arm64/sysreg: Update SCTLR_EL1 for DDI0601 2023-09
        arm64/sysreg: Update ID_AA64SMFR0_EL1 definition for DDI0601 2023-09
        arm64/sysreg: Add definition for ID_AA64FPFR0_EL1
        arm64/sysreg: Add definition for ID_AA64ISAR3_EL1
        arm64/sysreg: Update ID_AA64ISAR2_EL1 defintion for DDI0601 2023-09
        arm64/sysreg: Add definition for ID_AA64PFR2_EL1
        arm64/sysreg: update CPACR_EL1 register
        arm64/sysreg: add system register POR_EL{0,1}
        arm64/sysreg: Add definition for HAFGRTR_EL2
        arm64/sysreg: Update HFGITR_EL2 definiton to DDI0601 2023-09
      3e8626b4
    • Will Deacon's avatar
      Merge branch 'for-next/stacktrace' into for-next/core · 41cff14b
      Will Deacon authored
      * for-next/stacktrace:
        arm64: stacktrace: factor out kunwind_stack_walk()
        arm64: stacktrace: factor out kernel unwind state
      41cff14b
    • Will Deacon's avatar
      Merge branch 'for-next/selftests' into for-next/core · ef4896b5
      Will Deacon authored
      * for-next/selftests:
        kselftest/arm64: Don't probe the current VL for unsupported vector types
        kselftest/arm64: Log SVCR when the SME tests barf
        kselftest/arm64: Improve output for skipped TPIDR2 ABI test
      ef4896b5
    • Will Deacon's avatar
      Merge branch 'for-next/rip-vpipt' into for-next/core · 30431774
      Will Deacon authored
      * for-next/rip-vpipt:
        arm64: Rename reserved values for CTR_EL0.L1Ip
        arm64: Kill detection of VPIPT i-cache policy
        KVM: arm64: Remove VPIPT I-cache handling
      30431774
    • Will Deacon's avatar
      Merge branch 'for-next/perf' into for-next/core · dd9168ab
      Will Deacon authored
      * for-next/perf: (30 commits)
        arm: perf: Fix ARCH=arm build with GCC
        MAINTAINERS: add maintainers for DesignWare PCIe PMU driver
        drivers/perf: add DesignWare PCIe PMU driver
        PCI: Move pci_clear_and_set_dword() helper to PCI header
        PCI: Add Alibaba Vendor ID to linux/pci_ids.h
        docs: perf: Add description for Synopsys DesignWare PCIe PMU driver
        Revert "perf/arm_dmc620: Remove duplicate format attribute #defines"
        Documentation: arm64: Document the PMU event counting threshold feature
        arm64: perf: Add support for event counting threshold
        arm: pmu: Move error message and -EOPNOTSUPP to individual PMUs
        KVM: selftests: aarch64: Update tools copy of arm_pmuv3.h
        perf/arm_dmc620: Remove duplicate format attribute #defines
        arm: pmu: Share user ABI format mechanism with SPE
        arm64: perf: Include threshold control fields in PMEVTYPER mask
        arm: perf: Convert remaining fields to use GENMASK
        arm: perf: Use GENMASK for PMMIR fields
        arm: perf/kvm: Use GENMASK for ARMV8_PMU_PMCR_N
        arm: perf: Remove inlines from arm_pmuv3.c
        drivers/perf: arm_dsu_pmu: Remove kerneldoc-style comment syntax
        drivers/perf: Remove usage of the deprecated ida_simple_xx() API
        ...
      dd9168ab
    • Will Deacon's avatar
      Merge branch 'for-next/mm' into for-next/core · 3b47bd8f
      Will Deacon authored
      * for-next/mm:
        arm64: irq: set the correct node for shadow call stack
        arm64: irq: set the correct node for VMAP stack
      3b47bd8f
    • Will Deacon's avatar
      Merge branch 'for-next/misc' into for-next/core · 65180649
      Will Deacon authored
      * for-next/misc:
        arm64: memory: remove duplicated include
        arm64: Delete the zero_za macro
        Documentation/arch/arm64: Fix typo
      65180649
    • Will Deacon's avatar
      Merge branch 'for-next/lpa2-prep' into for-next/core · ccaeeec5
      Will Deacon authored
      * for-next/lpa2-prep:
        arm64: mm: get rid of kimage_vaddr global variable
        arm64: mm: Take potential load offset into account when KASLR is off
        arm64: kernel: Disable latent_entropy GCC plugin in early C runtime
        arm64: Add ARM64_HAS_LPA2 CPU capability
        arm64/mm: Add FEAT_LPA2 specific ID_AA64MMFR0.TGRAN[2]
        arm64/mm: Update tlb invalidation routines for FEAT_LPA2
        arm64/mm: Add lpa2_is_enabled() kvm_lpa2_is_enabled() stubs
        arm64/mm: Modify range-based tlbi to decrement scale
      ccaeeec5
    • Will Deacon's avatar
      Merge branch 'for-next/kbuild' into for-next/core · 88619527
      Will Deacon authored
      * for-next/kbuild:
        efi/libstub: zboot: do not use $(shell ...) in cmd_copy_and_pad
        arm64: properly install vmlinuz.efi
        arm64: replace <asm-generic/export.h> with <linux/export.h>
        arm64: vdso32: rename 32-bit debug vdso to vdso32.so.dbg
      88619527
    • Will Deacon's avatar
      Merge branch 'for-next/fpsimd' into for-next/core · 79eb42b2
      Will Deacon authored
      * for-next/fpsimd:
        arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD
        arm64: fpsimd: Preserve/restore kernel mode NEON at context switch
        arm64: fpsimd: Drop unneeded 'busy' flag
      79eb42b2
    • Will Deacon's avatar
      Merge branch 'for-next/early-idreg-overrides' into for-next/core · e90a8a21
      Will Deacon authored
      * for-next/early-idreg-overrides:
        arm64/kernel: Move 'nokaslr' parsing out of early idreg code
        arm64: idreg-override: Avoid kstrtou64() to parse a single hex digit
        arm64: idreg-override: Avoid sprintf() for simple string concatenation
        arm64: idreg-override: avoid strlen() to check for empty strings
        arm64: idreg-override: Avoid parameq() and parameqn()
        arm64: idreg-override: Prepare for place relative reloc patching
        arm64: idreg-override: Omit non-NULL checks for override pointer
      e90a8a21
    • Will Deacon's avatar
      Merge branch 'for-next/cpufeature' into for-next/core · 3f35db4e
      Will Deacon authored
      * for-next/cpufeature:
        arm64: Align boot cpucap handling with system cpucap handling
        arm64: Cleanup system cpucap handling
        arm64: Kconfig: drop KAISER reference from KPTI option description
        arm64: mm: Only map KPTI trampoline if it is going to be used
        arm64: Get rid of ARM64_HAS_NO_HW_PREFETCH
      3f35db4e
  4. 19 Dec, 2023 2 commits
  5. 17 Dec, 2023 7 commits
  6. 13 Dec, 2023 8 commits