1. 29 Oct, 2021 11 commits
    • Will Deacon's avatar
      Merge branch 'for-next/sve' into for-next/core · 655ee557
      Will Deacon authored
      * for-next/sve:
        arm64/sve: Fix warnings when SVE is disabled
        arm64/sve: Add stub for sve_max_virtualisable_vl()
        arm64/sve: Track vector lengths for tasks in an array
        arm64/sve: Explicitly load vector length when restoring SVE state
        arm64/sve: Put system wide vector length information into structs
        arm64/sve: Use accessor functions for vector lengths in thread_struct
        arm64/sve: Rename find_supported_vector_length()
        arm64/sve: Make access to FFR optional
        arm64/sve: Make sve_state_size() static
        arm64/sve: Remove sve_load_from_fpsimd_state()
        arm64/fp: Reindent fpsimd_save()
      655ee557
    • Will Deacon's avatar
      Merge branch 'for-next/scs' into for-next/core · 3d9c8315
      Will Deacon authored
      * for-next/scs:
        scs: Release kasan vmalloc poison in scs_free process
      3d9c8315
    • Will Deacon's avatar
      Merge branch 'for-next/pfn-valid' into for-next/core · 16c200e0
      Will Deacon authored
      * for-next/pfn-valid:
        arm64/mm: drop HAVE_ARCH_PFN_VALID
        dma-mapping: remove bogus test for pfn_valid from dma_map_resource
      16c200e0
    • Will Deacon's avatar
      Merge branch 'for-next/perf' into for-next/core · bd334dd7
      Will Deacon authored
      * for-next/perf:
        drivers/perf: Improve build test coverage
        drivers/perf: thunderx2_pmu: Change data in size tx2_uncore_event_update()
        drivers/perf: hisi: Fix PA PMU counter offset
      bd334dd7
    • Will Deacon's avatar
      Merge branch 'for-next/mte' into for-next/core · 7066248c
      Will Deacon authored
      * for-next/mte:
        kasan: Extend KASAN mode kernel parameter
        arm64: mte: Add asymmetric mode support
        arm64: mte: CPU feature detection for Asymm MTE
        arm64: mte: Bitfield definitions for Asymm MTE
        kasan: Remove duplicate of kasan_flag_async
        arm64: kasan: mte: move GCR_EL1 switch to task switch when KASAN disabled
      7066248c
    • Will Deacon's avatar
      Merge branch 'for-next/mm' into for-next/core · dc6bab18
      Will Deacon authored
      * for-next/mm:
        arm64: mm: update max_pfn after memory hotplug
        arm64/mm: Add pud_sect_supported()
        arm64: mm: Drop pointless call to set_max_mapnr()
      dc6bab18
    • Will Deacon's avatar
      Merge branch 'for-next/misc' into for-next/core · 2bc655ce
      Will Deacon authored
      * for-next/misc:
        arm64: Select POSIX_CPU_TIMERS_TASK_WORK
        arm64: Document boot requirements for FEAT_SME_FA64
        arm64: ftrace: use function_nocfi for _mcount as well
        arm64: asm: setup.h: export common variables
        arm64/traps: Avoid unnecessary kernel/user pointer conversion
      2bc655ce
    • Will Deacon's avatar
      Merge branch 'for-next/kselftest' into for-next/core · 082f6b4b
      Will Deacon authored
      * for-next/kselftest:
        selftests: arm64: Factor out utility functions for assembly FP tests
        selftests: arm64: Add coverage of ptrace flags for SVE VL inheritance
        selftests: arm64: Verify that all possible vector lengths are handled
        selftests: arm64: Fix and enable test for setting current VL in vec-syscfg
        selftests: arm64: Remove bogus error check on writing to files
        selftests: arm64: Fix printf() format mismatch in vec-syscfg
        selftests: arm64: Move FPSIMD in SVE ptrace test into a function
        selftests: arm64: More comprehensively test the SVE ptrace interface
        selftests: arm64: Verify interoperation of SVE and FPSIMD register sets
        selftests: arm64: Clarify output when verifying SVE register set
        selftests: arm64: Document what the SVE ptrace test is doing
        selftests: arm64: Remove extraneous register setting code
        selftests: arm64: Don't log child creation as a test in SVE ptrace test
        selftests: arm64: Use a define for the number of SVE ptrace tests to be run
      082f6b4b
    • Will Deacon's avatar
      Merge branch 'for-next/kexec' into for-next/core · d8a2c0fb
      Will Deacon authored
      * for-next/kexec:
        arm64: trans_pgd: remove trans_pgd_map_page()
        arm64: kexec: remove cpu-reset.h
        arm64: kexec: remove the pre-kexec PoC maintenance
        arm64: kexec: keep MMU enabled during kexec relocation
        arm64: kexec: install a copy of the linear-map
        arm64: kexec: use ld script for relocation function
        arm64: kexec: relocate in EL1 mode
        arm64: kexec: configure EL2 vectors for kexec
        arm64: kexec: pass kimage as the only argument to relocation function
        arm64: kexec: Use dcache ops macros instead of open-coding
        arm64: kexec: skip relocation code for inplace kexec
        arm64: kexec: flush image and lists during kexec load time
        arm64: hibernate: abstract ttrb0 setup function
        arm64: trans_pgd: hibernate: Add trans_pgd_copy_el2_vectors
        arm64: kernel: add helper for booted at EL2 and not VHE
      d8a2c0fb
    • Will Deacon's avatar
      Merge branch 'for-next/extable' into for-next/core · 99fe09c8
      Will Deacon authored
      * for-next/extable:
        arm64: vmlinux.lds.S: remove `.fixup` section
        arm64: extable: add load_unaligned_zeropad() handler
        arm64: extable: add a dedicated uaccess handler
        arm64: extable: add `type` and `data` fields
        arm64: extable: use `ex` for `exception_table_entry`
        arm64: extable: make fixup_exception() return bool
        arm64: extable: consolidate definitions
        arm64: gpr-num: support W registers
        arm64: factor out GPR numbering helpers
        arm64: kvm: use kvm_exception_table_entry
        arm64: lib: __arch_copy_to_user(): fold fixups into body
        arm64: lib: __arch_copy_from_user(): fold fixups into body
        arm64: lib: __arch_clear_user(): fold fixups into body
      99fe09c8
    • Will Deacon's avatar
      Merge branch 'for-next/8.6-timers' into for-next/core · a69483ee
      Will Deacon authored
      * for-next/8.6-timers:
        arm64: Add HWCAP for self-synchronising virtual counter
        arm64: Add handling of CNTVCTSS traps
        arm64: Add CNT{P,V}CTSS_EL0 alternatives to cnt{p,v}ct_el0
        arm64: Add a capability for FEAT_ECV
        clocksource/drivers/arch_arm_timer: Move workaround synchronisation around
        clocksource/drivers/arm_arch_timer: Fix masking for high freq counters
        clocksource/drivers/arm_arch_timer: Drop unnecessary ISB on CVAL programming
        clocksource/drivers/arm_arch_timer: Remove any trace of the TVAL programming interface
        clocksource/drivers/arm_arch_timer: Work around broken CVAL implementations
        clocksource/drivers/arm_arch_timer: Advertise 56bit timer to the core code
        clocksource/drivers/arm_arch_timer: Move MMIO timer programming over to CVAL
        clocksource/drivers/arm_arch_timer: Fix MMIO base address vs callback ordering issue
        clocksource/drivers/arm_arch_timer: Move drop _tval from erratum function names
        clocksource/drivers/arm_arch_timer: Move system register timer programming over to CVAL
        clocksource/drivers/arm_arch_timer: Extend write side of timer register accessors to u64
        clocksource/drivers/arm_arch_timer: Drop CNT*_TVAL read accessors
        clocksource/arm_arch_timer: Add build-time guards for unhandled register accesses
      a69483ee
  2. 28 Oct, 2021 2 commits
  3. 26 Oct, 2021 2 commits
  4. 21 Oct, 2021 23 commits
    • Mark Brown's avatar
      selftests: arm64: Factor out utility functions for assembly FP tests · 260ea4ba
      Mark Brown authored
      The various floating point test programs written in assembly have a bunch
      of helper functions and macros which are cut'n'pasted between them. Factor
      them out into a separate source file which is linked into all of them.
      
      We don't include memcmp() since it isn't as generic as it should be and
      directly branches to report an error in the programs.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019181851.3341232-1-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      260ea4ba
    • Mark Rutland's avatar
      arm64: vmlinux.lds.S: remove `.fixup` section · bf6e667f
      Mark Rutland authored
      We no longer place anything into a `.fixup` section, so we no longer
      need to place those sections into the `.text` section in the main kernel
      Image.
      
      Remove the use of `.fixup`.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-14-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      bf6e667f
    • Mark Rutland's avatar
      arm64: extable: add load_unaligned_zeropad() handler · 753b3236
      Mark Rutland authored
      For inline assembly, we place exception fixups out-of-line in the
      `.fixup` section such that these are out of the way of the fast path.
      This has a few drawbacks:
      
      * Since the fixup code is anonymous, backtraces will symbolize fixups as
        offsets from the nearest prior symbol, currently
        `__entry_tramp_text_end`. This is confusing, and painful to debug
        without access to the relevant vmlinux.
      
      * Since the exception handler adjusts the PC to execute the fixup, and
        the fixup uses a direct branch back into the function it fixes,
        backtraces of fixups miss the original function. This is confusing,
        and violates requirements for RELIABLE_STACKTRACE (and therefore
        LIVEPATCH).
      
      * Inline assembly and associated fixups are generated from templates,
        and we have many copies of logically identical fixups which only
        differ in which specific registers are written to and which address is
        branched to at the end of the fixup. This is potentially wasteful of
        I-cache resources, and makes it hard to add additional logic to fixups
        without significant bloat.
      
      * In the case of load_unaligned_zeropad(), the logic in the fixup
        requires a temporary register that we must allocate even in the
        fast-path where it will not be used.
      
      This patch address all four concerns for load_unaligned_zeropad() fixups
      by adding a dedicated exception handler which performs the fixup logic
      in exception context and subsequent returns back after the faulting
      instruction. For the moment, the fixup logic is identical to the old
      assembly fixup logic, but in future we could enhance this by taking the
      ESR and FAR into account to constrain the faults we try to fix up, or to
      specialize fixups for MTE tag check faults.
      
      Other than backtracing, there should be no functional change as a result
      of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-13-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      753b3236
    • Mark Rutland's avatar
      arm64: extable: add a dedicated uaccess handler · 2e77a62c
      Mark Rutland authored
      For inline assembly, we place exception fixups out-of-line in the
      `.fixup` section such that these are out of the way of the fast path.
      This has a few drawbacks:
      
      * Since the fixup code is anonymous, backtraces will symbolize fixups as
        offsets from the nearest prior symbol, currently
        `__entry_tramp_text_end`. This is confusing, and painful to debug
        without access to the relevant vmlinux.
      
      * Since the exception handler adjusts the PC to execute the fixup, and
        the fixup uses a direct branch back into the function it fixes,
        backtraces of fixups miss the original function. This is confusing,
        and violates requirements for RELIABLE_STACKTRACE (and therefore
        LIVEPATCH).
      
      * Inline assembly and associated fixups are generated from templates,
        and we have many copies of logically identical fixups which only
        differ in which specific registers are written to and which address is
        branched to at the end of the fixup. This is potentially wasteful of
        I-cache resources, and makes it hard to add additional logic to fixups
        without significant bloat.
      
      This patch address all three concerns for inline uaccess fixups by
      adding a dedicated exception handler which updates registers in
      exception context and subsequent returns back into the function which
      faulted, removing the need for fixups specialized to each faulting
      instruction.
      
      Other than backtracing, there should be no functional change as a result
      of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-12-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      2e77a62c
    • Mark Rutland's avatar
      arm64: extable: add `type` and `data` fields · d6e2cc56
      Mark Rutland authored
      Subsequent patches will add specialized handlers for fixups, in addition
      to the simple PC fixup and BPF handlers we have today. In preparation,
      this patch adds a new `type` field to struct exception_table_entry, and
      uses this to distinguish the fixup and BPF cases. A `data` field is also
      added so that subsequent patches can associate data specific to each
      exception site (e.g. register numbers).
      
      Handlers are named ex_handler_*() for consistency, following the exmaple
      of x86. At the same time, get_ex_fixup() is split out into a helper so
      that it can be used by other ex_handler_*() functions ins subsequent
      patches.
      
      This patch will increase the size of the exception tables, which will be
      remedied by subsequent patches removing redundant fixup code. There
      should be no functional change as a result of this patch.
      
      Since each entry is now 12 bytes in size, we must reduce the alignment
      of each entry from `.align 3` (i.e. 8 bytes) to `.align 2` (i.e. 4
      bytes), which is the natrual alignment of the `insn` and `fixup` fields.
      The current 8-byte alignment is a holdover from when the `insn` and
      `fixup` fields was 8 bytes, and while not harmful has not been necessary
      since commit:
      
        6c94f27a ("arm64: switch to relative exception tables")
      
      Similarly, RO_EXCEPTION_TABLE_ALIGN is dropped to 4 bytes.
      
      Concurrently with this patch, x86's exception table entry format is
      being updated (similarly to a 12-byte format, with 32-bytes of absolute
      data). Once both have been merged it should be possible to unify the
      sorttable logic for the two.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: James Morse <james.morse@arm.com>
      Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-11-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      d6e2cc56
    • Mark Rutland's avatar
      arm64: extable: use `ex` for `exception_table_entry` · 5d0e7905
      Mark Rutland authored
      Subsequent patches will extend `struct exception_table_entry` with more
      fields, and the distinction between the entry and its `fixup` field will
      become more important.
      
      For clarity, let's consistently use `ex` to refer to refer to an entire
      entry. In subsequent patches we'll use `fixup` to refer to the fixup
      field specifically. This matches the naming convention used today in
      arch/arm64/net/bpf_jit_comp.c.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-10-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      5d0e7905
    • Mark Rutland's avatar
      arm64: extable: make fixup_exception() return bool · e8c328d7
      Mark Rutland authored
      The return values of fixup_exception() and arm64_bpf_fixup_exception()
      represent a boolean condition rather than an error code, so for clarity
      it would be better to return `bool` rather than `int`.
      
      This patch adjusts the code accordingly. While we're modifying the
      prototype, we also remove the unnecessary `extern` keyword, so that this
      won't look out of place when we make subsequent additions to the header.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: James Morse <james.morse@arm.com>
      Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-9-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      e8c328d7
    • Mark Rutland's avatar
      arm64: extable: consolidate definitions · 819771cc
      Mark Rutland authored
      In subsequent patches we'll alter the structure and usage of struct
      exception_table_entry. For inline assembly, we create these using the
      `_ASM_EXTABLE()` CPP macro defined in <asm/uaccess.h>, and for plain
      assembly code we use the `_asm_extable()` GAS macro defined in
      <asm/assembler.h>, which are largely identical save for different
      escaping and stringification requirements.
      
      This patch moves the common definitions to a new <asm/asm-extable.h>
      header, so that it's easier to keep the two in-sync, and to remove the
      implication that these are only used for uaccess helpers (as e.g.
      load_unaligned_zeropad() is only used on kernel memory, and depends upon
      `_ASM_EXTABLE()`.
      
      At the same time, a few minor modifications are made for clarity and in
      preparation for subsequent patches:
      
      * The structure creation is factored out into an `__ASM_EXTABLE_RAW()`
        macro. This will make it easier to support different fixup variants in
        subsequent patches without needing to update all users of
        `_ASM_EXTABLE()`, and makes it easier to see tha the CPP and GAS
        variants of the macros are structurally identical.
      
        For the CPP macro, the stringification of fields is left to the
        wrapper macro, `_ASM_EXTABLE()`, as in subsequent patches it will be
        necessary to stringify fields in wrapper macros to safely concatenate
        strings which cannot be token-pasted together in CPP.
      
      * The fields of the structure are created separately on their own lines.
        This will make it easier to add/remove/modify individual fields
        clearly.
      
      * Additional parentheses are added around the use of macro arguments in
        field definitions to avoid any potential problems with evaluation due
        to operator precedence, and to make errors upon misuse clearer.
      
      * USER() is moved into <asm/asm-uaccess.h>, as it is not required by all
        assembly code, and is already refered to by comments in that file.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-8-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      819771cc
    • Mark Rutland's avatar
      arm64: gpr-num: support W registers · 286fba6c
      Mark Rutland authored
      In subsequent patches we'll want to map W registers to their register
      numbers. Update gpr-num.h so that we can do this.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-7-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      286fba6c
    • Mark Rutland's avatar
      arm64: factor out GPR numbering helpers · 8ed1b498
      Mark Rutland authored
      In <asm/sysreg.h> we have macros to convert the names of general purpose
      registers (GPRs) into integer constants, which we use to manually build
      the encoding for `MRS` and `MSR` instructions where we can't rely on the
      assembler to do so for us.
      
      In subsequent patches we'll need to map the same GPR names to integer
      constants so that we can use this to build metadata for exception
      fixups.
      
      So that the we can use the mappings elsewhere, factor out the
      definitions into a new <asm/gpr-num.h> header, renaming the definitions
      to align with this "GPR num" naming for clarity.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-6-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      8ed1b498
    • Mark Rutland's avatar
      arm64: kvm: use kvm_exception_table_entry · ae2b2f33
      Mark Rutland authored
      In subsequent patches we'll alter `struct exception_table_entry`, adding
      fields that are not needed for KVM exception fixups.
      
      In preparation for this, migrate KVM to its own `struct
      kvm_exception_table_entry`, which is identical to the current format of
      `struct exception_table_entry`. Comments are updated accordingly.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Alexandru Elisei <alexandru.elisei@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-5-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      ae2b2f33
    • Mark Rutland's avatar
      arm64: lib: __arch_copy_to_user(): fold fixups into body · 139f9ab7
      Mark Rutland authored
      Like other functions, __arch_copy_to_user() places its exception fixups
      in the `.fixup` section without any clear association with
      __arch_copy_to_user() itself. If we backtrace the fixup code, it will be
      symbolized as an offset from the nearest prior symbol, which happens to
      be `__entry_tramp_text_end`. Further, since the PC adjustment for the
      fixup is akin to a direct branch rather than a function call,
      __arch_copy_to_user() itself will be missing from the backtrace.
      
      This is confusing and hinders debugging. In general this pattern will
      also be problematic for CONFIG_LIVEPATCH, since fixups often return to
      their associated function, but this isn't accurately captured in the
      stacktrace.
      
      To solve these issues for assembly functions, we must move fixups into
      the body of the functions themselves, after the usual fast-path returns.
      This patch does so for __arch_copy_to_user().
      
      Inline assembly will be dealt with in subsequent patches.
      
      Other than the improved backtracing, there should be no functional
      change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-4-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      139f9ab7
    • Mark Rutland's avatar
      arm64: lib: __arch_copy_from_user(): fold fixups into body · 4012e0e2
      Mark Rutland authored
      Like other functions, __arch_copy_from_user() places its exception
      fixups in the `.fixup` section without any clear association with
      __arch_copy_from_user() itself. If we backtrace the fixup code, it will
      be symbolized as an offset from the nearest prior symbol, which happens
      to be `__entry_tramp_text_end`. Further, since the PC adjustment for the
      fixup is akin to a direct branch rather than a function call,
      __arch_copy_from_user() itself will be missing from the backtrace.
      
      This is confusing and hinders debugging. In general this pattern will
      also be problematic for CONFIG_LIVEPATCH, since fixups often return to
      their associated function, but this isn't accurately captured in the
      stacktrace.
      
      To solve these issues for assembly functions, we must move fixups into
      the body of the functions themselves, after the usual fast-path returns.
      This patch does so for __arch_copy_from_user().
      
      Inline assembly will be dealt with in subsequent patches.
      
      Other than the improved backtracing, there should be no functional
      change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-3-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      4012e0e2
    • Mark Rutland's avatar
      arm64: lib: __arch_clear_user(): fold fixups into body · 35d67794
      Mark Rutland authored
      Like other functions, __arch_clear_user() places its exception fixups in
      the `.fixup` section without any clear association with
      __arch_clear_user() itself. If we backtrace the fixup code, it will be
      symbolized as an offset from the nearest prior symbol, which happens to
      be `__entry_tramp_text_end`. Further, since the PC adjustment for the
      fixup is akin to a direct branch rather than a function call,
      __arch_clear_user() itself will be missing from the backtrace.
      
      This is confusing and hinders debugging. In general this pattern will
      also be problematic for CONFIG_LIVEPATCH, since fixups often return to
      their associated function, but this isn't accurately captured in the
      stacktrace.
      
      To solve these issues for assembly functions, we must move fixups into
      the body of the functions themselves, after the usual fast-path returns.
      This patch does so for __arch_clear_user().
      
      Inline assembly will be dealt with in subsequent patches.
      
      Other than the improved backtracing, there should be no functional
      change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20211019160219.5202-2-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
      35d67794
    • Mark Brown's avatar
      arm64/sve: Track vector lengths for tasks in an array · 5838a155
      Mark Brown authored
      As for SVE we will track a per task SME vector length for tasks. Convert
      the existing storage for the vector length into an array and update
      fpsimd_flush_task() to initialise this in a function.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-10-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      5838a155
    • Mark Brown's avatar
      arm64/sve: Explicitly load vector length when restoring SVE state · ddc806b5
      Mark Brown authored
      Currently when restoring the SVE state we supply the SVE vector length
      as an argument to sve_load_state() and the underlying macros. This becomes
      inconvenient with the addition of SME since we may need to restore any
      combination of SVE and SME vector lengths, and we already separately
      restore the vector length in the KVM code. We don't need to know the vector
      length during the actual register load since the SME load instructions can
      index into the data array for us.
      
      Refactor the interface so we explicitly set the vector length separately
      to restoring the SVE registers in preparation for adding SME support, no
      functional change should be involved.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-9-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      ddc806b5
    • Mark Brown's avatar
      arm64/sve: Put system wide vector length information into structs · b5bc00ff
      Mark Brown authored
      With the introduction of SME we will have a second vector length in the
      system, enumerated and configured in a very similar fashion to the
      existing SVE vector length.  While there are a few differences in how
      things are handled this is a relatively small portion of the overall
      code so in order to avoid code duplication we factor out
      
      We create two structs, one vl_info for the static hardware properties
      and one vl_config for the runtime configuration, with an array
      instantiated for each and update all the users to reference these. Some
      accessor functions are provided where helpful for readability, and the
      write to set the vector length is put into a function since the system
      register being updated needs to be chosen at compile time.
      
      This is a mostly mechanical replacement, further work will be required
      to actually make things generic, ensuring that we handle those places
      where there are differences properly.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-8-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      b5bc00ff
    • Mark Brown's avatar
      arm64/sve: Use accessor functions for vector lengths in thread_struct · 0423eedc
      Mark Brown authored
      In a system with SME there are parallel vector length controls for SVE and
      SME vectors which function in much the same way so it is desirable to
      share the code for handling them as much as possible. In order to prepare
      for doing this add a layer of accessor functions for the various VL related
      operations on tasks.
      
      Since almost all current interactions are actually via task->thread rather
      than directly with the thread_info the accessors use that. Accessors are
      provided for both generic and SVE specific usage, the generic accessors
      should be used for cases where register state is being manipulated since
      the registers are shared between streaming and regular SVE so we know that
      when SME support is implemented we will always have to be in the appropriate
      mode already and hence can generalise now.
      
      Since we are using task_struct and we don't want to cause widespread
      inclusion of sched.h the acessors are all out of line, it is hoped that
      none of the uses are in a sufficiently critical path for this to be an
      issue. Those that are most likely to present an issue are in the same
      translation unit so hopefully the compiler may be able to inline anyway.
      
      This is purely adding the layer of abstraction, additional work will be
      needed to support tasks using SME.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-7-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      0423eedc
    • Mark Brown's avatar
      arm64/sve: Rename find_supported_vector_length() · 059613f5
      Mark Brown authored
      The function has SVE specific checks in it and it will be more trouble
      to add conditional code for SME than it is to simply rename it to be SVE
      specific.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-6-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      059613f5
    • Mark Brown's avatar
      arm64/sve: Make access to FFR optional · 9f584866
      Mark Brown authored
      SME introduces streaming SVE mode in which FFR is not present and the
      instructions for accessing it UNDEF. In preparation for handling this
      update the low level SVE state access functions to take a flag specifying
      if FFR should be handled. When saving the register state we store a zero
      for FFR to guard against uninitialized data being read. No behaviour change
      should be introduced by this patch.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-5-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      9f584866
    • Mark Brown's avatar
      arm64/sve: Make sve_state_size() static · 12cc2352
      Mark Brown authored
      There are no users outside fpsimd.c so make sve_state_size() static.
      KVM open codes an equivalent.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-4-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      12cc2352
    • Mark Brown's avatar
      arm64/sve: Remove sve_load_from_fpsimd_state() · b53223e0
      Mark Brown authored
      Following optimisations of the SVE register handling we no longer load the
      SVE state from a saved copy of the FPSIMD registers, we convert directly
      in registers or from one saved state to another. Remove the function so we
      don't need to update it during further refactoring.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-3-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      b53223e0
    • Mark Brown's avatar
      arm64/fp: Reindent fpsimd_save() · 2d481bd3
      Mark Brown authored
      Currently all the active code in fpsimd_save() is inside a check for
      TIF_FOREIGN_FPSTATE. Reduce the indentation level by changing to return
      from the function if TIF_FOREIGN_FPSTATE is set.
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20211019172247.3045838-2-broonie@kernel.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
      2d481bd3
  5. 19 Oct, 2021 2 commits