1. 12 Jan, 2024 2 commits
  2. 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
  3. 19 Dec, 2023 2 commits
  4. 17 Dec, 2023 7 commits
  5. 13 Dec, 2023 9 commits
  6. 12 Dec, 2023 7 commits
    • James Houghton's avatar
      arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify · 3c069607
      James Houghton authored
      It is currently possible for a userspace application to enter an
      infinite page fault loop when using HugeTLB pages implemented with
      contiguous PTEs when HAFDBS is not available. This happens because:
      
      1. The kernel may sometimes write PTEs that are sw-dirty but hw-clean
         (PTE_DIRTY | PTE_RDONLY | PTE_WRITE).
      
      2. If, during a write, the CPU uses a sw-dirty, hw-clean PTE in handling
         the memory access on a system without HAFDBS, we will get a page
         fault.
      
      3. HugeTLB will check if it needs to update the dirty bits on the PTE.
         For contiguous PTEs, it will check to see if the pgprot bits need
         updating. In this case, HugeTLB wants to write a sequence of
         sw-dirty, hw-dirty PTEs, but it finds that all the PTEs it is about
         to overwrite are all pte_dirty() (pte_sw_dirty() => pte_dirty()),
         so it thinks no update is necessary.
      
      We can get the kernel to write a sw-dirty, hw-clean PTE with the
      following steps (showing the relevant VMA flags and pgprot bits):
      
      i.   Create a valid, writable contiguous PTE.
             VMA vmflags:     VM_SHARED | VM_READ | VM_WRITE
             VMA pgprot bits: PTE_RDONLY | PTE_WRITE
             PTE pgprot bits: PTE_DIRTY | PTE_WRITE
      
      ii.  mprotect the VMA to PROT_NONE.
             VMA vmflags:     VM_SHARED
             VMA pgprot bits: PTE_RDONLY
             PTE pgprot bits: PTE_DIRTY | PTE_RDONLY
      
      iii. mprotect the VMA back to PROT_READ | PROT_WRITE.
             VMA vmflags:     VM_SHARED | VM_READ | VM_WRITE
             VMA pgprot bits: PTE_RDONLY | PTE_WRITE
             PTE pgprot bits: PTE_DIRTY | PTE_WRITE | PTE_RDONLY
      
      Make it impossible to create a writeable sw-dirty, hw-clean PTE with
      pte_modify(). Such a PTE should be impossible to create, and there may
      be places that assume that pte_dirty() implies pte_hw_dirty().
      Signed-off-by: default avatarJames Houghton <jthoughton@google.com>
      Fixes: 031e6e6b ("arm64: hugetlb: Avoid unnecessary clearing in huge_ptep_set_access_flags")
      Cc: <stable@vger.kernel.org>
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Reviewed-by: default avatarRyan Roberts <ryan.roberts@arm.com>
      Link: https://lore.kernel.org/r/20231204172646.2541916-3-jthoughton@google.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      3c069607
    • Ard Biesheuvel's avatar
      arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD · 2632e252
      Ard Biesheuvel authored
      Now that kernel mode FPSIMD state is context switched along with other
      task state, we can enable the existing logic that keeps track of which
      task's FPSIMD state the CPU is holding in its registers. If it is the
      context of the task that we are switching to, we can elide the reload of
      the FPSIMD state from memory.
      
      Note that we also need to check whether the FPSIMD state on this CPU is
      the most recent: if a task gets migrated away and back again, the state
      in memory may be more recent than the state in the CPU. So add another
      CPU id field to task_struct to keep track of this. (We could reuse the
      existing CPU id field used for user mode context, but that might result
      in user state to be discarded unnecessarily, given that two distinct
      CPUs could be holding the most recent user mode state and the most
      recent kernel mode state)
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Link: https://lore.kernel.org/r/20231208113218.3001940-9-ardb@google.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      2632e252
    • Ard Biesheuvel's avatar
      arm64: fpsimd: Preserve/restore kernel mode NEON at context switch · aefbab8e
      Ard Biesheuvel authored
      Currently, the FPSIMD register file is not preserved and restored along
      with the general registers on exception entry/exit or context switch.
      For this reason, we disable preemption when enabling FPSIMD for kernel
      mode use in task context, and suspend the processing of softirqs so that
      there are no concurrent uses in the kernel. (Kernel mode FPSIMD may not
      be used at all in other contexts).
      
      Disabling preemption while doing CPU intensive work on inputs of
      potentially unbounded size is bad for real-time performance, which is
      why we try and ensure that SIMD crypto code does not operate on more
      than ~4k at a time, which is an arbitrary limit and requires assembler
      code to implement efficiently.
      
      We can avoid the need for disabling preemption if we can ensure that any
      in-kernel users of the NEON will not lose the FPSIMD register state
      across a context switch. And given that disabling softirqs implicitly
      disables preemption as well, we will also have to ensure that a softirq
      that runs code using FPSIMD can safely interrupt an in-kernel user.
      
      So introduce a thread_info flag TIF_KERNEL_FPSTATE, and modify the
      context switch hook for FPSIMD to preserve and restore the kernel mode
      FPSIMD to/from struct thread_struct when it is set. This avoids any
      scheduling blackouts due to prolonged use of FPSIMD in kernel mode,
      without the need for manual yielding.
      
      In order to support softirq processing while FPSIMD is being used in
      kernel task context, use the same flag to decide whether the kernel mode
      FPSIMD state needs to be preserved and restored before allowing FPSIMD
      to be used in softirq context.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Link: https://lore.kernel.org/r/20231208113218.3001940-8-ardb@google.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      aefbab8e
    • Ard Biesheuvel's avatar
      arm64: fpsimd: Drop unneeded 'busy' flag · 9b19700e
      Ard Biesheuvel authored
      Kernel mode NEON will preserve the user mode FPSIMD state by saving it
      into the task struct before clobbering the registers. In order to avoid
      the need for preserving kernel mode state too, we disallow nested use of
      kernel mode NEON, i..e, use in softirq context while the interrupted
      task context was using kernel mode NEON too.
      
      Originally, this policy was implemented using a per-CPU flag which was
      exposed via may_use_simd(), requiring the users of the kernel mode NEON
      to deal with the possibility that it might return false, and having NEON
      and non-NEON code paths. This policy was changed by commit
      13150149 ("arm64: fpsimd: run kernel mode NEON with softirqs
      disabled"), and now, softirq processing is disabled entirely instead,
      and so may_use_simd() can never fail when called from task or softirq
      context.
      
      This means we can drop the fpsimd_context_busy flag entirely, and
      instead, ensure that we disable softirq processing in places where we
      formerly relied on the flag for preventing races in the FPSIMD preserve
      routines.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20231208113218.3001940-7-ardb@google.com
      [will: Folded in fix from CAMj1kXFhzbJRyWHELCivQW1yJaF=p07LLtbuyXYX3G1WtsdyQg@mail.gmail.com]
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      9b19700e
    • Robin Murphy's avatar
      perf/arm-cmn: Fail DTC counter allocation correctly · 1892fe10
      Robin Murphy authored
      Calling arm_cmn_event_clear() before all DTC indices are allocated is
      wrong, and can lead to arm_cmn_event_add() erroneously clearing live
      counters from full DTCs where allocation fails. Since the DTC counters
      are only updated by arm_cmn_init_counter() after all DTC and DTM
      allocations succeed, nothing actually needs cleaning up in this case
      anyway, and it should just return directly as it did before.
      
      Fixes: 7633ec2c ("perf/arm-cmn: Rework DTC counters (again)")
      Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: default avatarIlkka Koskinen <ilkka@os.amperecomputing.com>
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/ed589c0d8e4130dc68b8ad1625226d28bdc185d4.1702322847.git.robin.murphy@arm.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      1892fe10
    • Ard Biesheuvel's avatar
      arm64/kernel: Move 'nokaslr' parsing out of early idreg code · 50f17617
      Ard Biesheuvel authored
      Parsing and ignoring 'nokaslr' can be done from anywhere, except from
      the code that runs very early and is therefore built with limitations on
      the kind of relocations it is permitted to use.
      
      So move it to a source file that is part of the ordinary kernel build.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Link: https://lore.kernel.org/r/20231129111555.3594833-63-ardb@google.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      50f17617
    • Ard Biesheuvel's avatar
      arm64: idreg-override: Avoid kstrtou64() to parse a single hex digit · ea48626f
      Ard Biesheuvel authored
      All ID register value overrides are =0 with the exception of the nokaslr
      pseudo feature which uses =1. In order to remove the dependency on
      kstrtou64(), which is part of the core kernel and no longer usable once
      we move idreg-override into the early mini C runtime, let's just parse a
      single hex digit (with optional leading 0x) and set the output value
      accordingly.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Link: https://lore.kernel.org/r/20231129111555.3594833-62-ardb@google.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      ea48626f