Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
3f9b9df
kselftets/arm64: Use flag bits for features in fp-ptrace assembler code
broonie Nov 12, 2024
4c3c5a6
kselftest/arm64: Expand the set of ZA writes fp-ptrace does
broonie Nov 12, 2024
ad74248
kselftest/arm64: Add FPMR coverage to fp-ptrace
broonie Nov 12, 2024
7e68a34
arm64/fpsimd: signal: Clear PSTATE.SM when restoring FPSIMD frame only
mrutland-arm May 8, 2025
a5d04be
arm64/fpsimd: ptrace: Consistently handle partial writes to NT_ARM_(S…
mrutland-arm May 8, 2025
010abc9
arm64/fpsimd: Clarify sve_sync_*() functions
mrutland-arm May 8, 2025
0f615f7
arm64/fpsimd: Factor out {sve,sme}_state_size() helpers
mrutland-arm May 8, 2025
0f85bcf
arm64/fpsimd: Add task_smstop_sm()
mrutland-arm May 8, 2025
abcc944
arm64/fpsimd: signal: Use SMSTOP behaviour in setup_return()
mrutland-arm May 8, 2025
705b6a7
arm64/fpsimd: Remove redundant task->mm check
mrutland-arm May 8, 2025
7c14197
arm64/fpsimd: Consistently preserve FPSIMD state during clone()
mrutland-arm May 8, 2025
bbfed1e
arm64/fpsimd: Clear PSTATE.SM during clone()
mrutland-arm May 8, 2025
acf62f5
arm64/fpsimd: Make clone() compatible with ZA lazy saving
mrutland-arm May 8, 2025
737e32f
arm64/fpsimd: ptrace/prctl: Ensure VL changes do not resurrect stale …
mrutland-arm May 8, 2025
925e468
arm64/fpsimd: ptrace/prctl: Ensure VL changes leave task in a valid s…
mrutland-arm May 8, 2025
761e61f
arm64/fpsimd: ptrace: Save task state before generating SVE header
mrutland-arm May 8, 2025
c9e522c
arm64/fpsimd: ptrace: Do not present register data for inactive mode
mrutland-arm May 8, 2025
59c5fa6
arm64/fpsimd: ptrace: Mandate SVE payload for streaming-mode state
mrutland-arm May 8, 2025
06363ca
arm64/fpsimd: ptrace: Gracefully handle errors
mrutland-arm May 8, 2025
6861f3c
arm64/fpsimd: Allow CONFIG_ARM64_SME to be selected
mrutland-arm May 8, 2025
5b77244
kselftest/arm64: fp-ptrace: Fix expected FPMR value when PSTATE.SM is…
mrutland-arm May 8, 2025
6af2ed5
kselftest/arm64: tpidr2: Adjust to new clone() behaviour
mrutland-arm May 8, 2025
fc3919a
kselftest/arm64: Test that ptrace takes effect in the target process
broonie Jan 22, 2024
7593983
kselftest/arm64: fp-ptrace: Adjust to new VL change behaviour
mrutland-arm May 8, 2025
a9e05e5
kselftest/arm64: fp-ptrace: Adjust to new inactive mode behaviour
mrutland-arm May 8, 2025
e9964f6
kselftest/arm64: Fix test for streaming FPSIMD write in sve-ptrace
broonie Jun 9, 2025
ab49b2b
arm64/fpsimd: signal: Clear TPIDR2 when delivering signals
mrutland-arm Apr 17, 2025
267796b
kselftest/arm64: Fix SVE write data generation for SME only systems
broonie Jul 18, 2025
489a3e5
kselftest/arm64: Handle attempts to disable SM on SME only systems
broonie Jul 18, 2025
2907609
kselftest/arm64: Don't probe the current VL for unsupported vector types
broonie Dec 18, 2023
cafbb6e
kselftest/arm64: Test SME on SME only systems in fp-ptrace
broonie Jul 18, 2025
3889217
arm64/fpsimd: ptrace: zero target's fpsimd_state, not the tracer's
leitao May 5, 2026
43a9e6f
arm64/fpsimd: ptrace: Fix inactive SVE and SSVE regsets
kmehltretter82 Jul 29, 2026
a2e6430
kselftest/arm64: fp-ptrace: Fix checks for inactive SVE and SSVE regsets
kmehltretter82 Jul 29, 2026
24cc45e
arm64/fpsimd: ptrace: Fix SVE writes on !SME systems
mrutland-arm Jan 20, 2026
1244210
arm64/sysreg: Add definition for ID_AA64PFR2_EL1
broonie Dec 9, 2023
723d688
arm64/sysreg: Update ID_AA64ISAR2_EL1 defintion for DDI0601 2023-09
broonie Dec 9, 2023
0d03de5
arm64/sysreg: Add definition for ID_AA64ISAR3_EL1
broonie Dec 9, 2023
24fc9aa
arm64/sysreg: Add definition for ID_AA64FPFR0_EL1
broonie Dec 9, 2023
fece9c8
arm64/sysreg: Update ID_AA64SMFR0_EL1 definition for DDI0601 2023-09
broonie Dec 9, 2023
3fdec64
arm64/sysreg: Update SCTLR_EL1 for DDI0601 2023-09
broonie Dec 9, 2023
4aa9c59
arm64/sysreg: Update HCRX_EL2 definition for DDI0601 2023-09
broonie Dec 9, 2023
54a33da
arm64/sysreg: Add definition for FPMR
broonie Dec 9, 2023
ae20126
arm64/fpsimd: Add fpsimd_save_and_flush_current_state()
mrutland-arm Apr 9, 2025
973a914
arm64/fpsimd: signal32: Always save+flush state early
mrutland-arm Apr 9, 2025
446a96e
arm64/sve: Report FEAT_SVE_B16B16 to userspace
broonie Sep 15, 2023
646c529
kselftest/arm64: Verify HWCAP2_SVE_B16B16
broonie Sep 15, 2023
eb84abb
arm64/cpufeature: Hook new identification registers up to cpufeature
broonie Mar 6, 2024
8d1eae2
arm64/fpsimd: Enable host kernel access to FPMR
broonie Mar 6, 2024
c154713
arm64/fpsimd: Support FEAT_FPMR
broonie Mar 6, 2024
061e877
arm64/signal: Add FPMR signal handling
broonie Mar 6, 2024
4170e5f
arm64/ptrace: Expose FPMR via ptrace
broonie Mar 6, 2024
3781baf
arm64/hwcap: Define hwcaps for 2023 DPISA features
broonie Mar 6, 2024
71eef2b
kselftest/arm64: Handle FPMR context in generic signal frame parser
broonie Mar 6, 2024
484c0f7
kselftest/arm64: Add basic FPMR test
broonie Mar 6, 2024
ba736db
kselftest/arm64: Add 2023 DPISA hwcap test coverage
broonie Mar 6, 2024
83c2279
arm64: ptrace: fix partial SETREGSET for NT_ARM_FPMR
mrutland-arm Dec 5, 2024
2a943c9
arm64/fpsimd: Don't corrupt FPMR when streaming mode changes
broonie Apr 9, 2025
7ee62e4
arm64/fpsimd: Reset FPMR upon exec()
mrutland-arm Apr 9, 2025
12dc55f
kselftest/arm64: hwcap: fix f8dp2 cpuinfo name
Andre-ARM Aug 16, 2024
3c65fd8
kselftest/arm64: Fix encoding for SVE B16B16 test
broonie Oct 28, 2024
a381a55
arm64/fpsimd: signal: Always save+flush state early
mrutland-arm Apr 9, 2025
939cf75
arm64/fpsimd: Avoid warning when sve_to_fpsimd() is unused
mrutland-arm Apr 30, 2025
72631a6
arm64: fpsimd: Drop unneeded 'busy' flag
ardbiesheuvel Dec 8, 2023
47a8ee7
arm64: fpsimd: Preserve/restore kernel mode NEON at context switch
ardbiesheuvel Dec 8, 2023
400ce9f
arm64: fpsimd: Bring cond_yield asm macro in line with new rules
ardbiesheuvel Jan 11, 2024
951c902
arm64/fpsimd: Avoid erroneous elide of user state reload
ardbiesheuvel May 22, 2024
dfadad3
crypto: api - move crypto_simd_disabled_for_test to lib
ebiggers Oct 18, 2024
aca0ac6
riscv: Optimize crc32 with Zbc extension
XiaoWang1772 Jun 21, 2024
cdef7da
arm64/lib: Handle CRC-32 alternative in C code
ardbiesheuvel Oct 18, 2024
782741e
arm64/crc32: Reorganize bit/byte ordering macros
ardbiesheuvel Oct 18, 2024
907a1e0
arm64/crc32: Implement 4-way interleave using PMULL
ardbiesheuvel Oct 18, 2024
2858d16
arm64/fpsimd: Avoid clobbering kernel FPSIMD state with SMSTOP
mrutland-arm Apr 9, 2025
6a8b470
arm64/sysreg: Update ID_AA64PFR2_EL1 to DDI0601 2024-09
broonie Dec 11, 2024
93ea17c
arm64/sysreg: Update ID_AA64ISAR3_EL1 to DDI0601 2024-09
broonie Dec 11, 2024
1f34fa9
arm64/sysreg: Update ID_AA64FPFR0_EL1 to DDI0601 2024-09
broonie Dec 11, 2024
6771ead
arm64/sysreg: Update ID_AA64ZFR0_EL1 to DDI0601 2024-09
broonie Dec 11, 2024
ae45bcd
arm64/sysreg: Update ID_AA64ISAR2_EL1 to DDI0601 2024-09
broonie Dec 11, 2024
7197e40
arm64/sysreg: Update ID_AA64SMFR0_EL1 to DDI0601 2024-12
broonie Jan 7, 2025
172f195
arm64/hwcap: Describe 2024 dpISA extensions to userspace
broonie Jan 7, 2025
1a291ff
KVM: arm64: Allow control of dpISA extensions in ID_AA64ISAR3_EL1
broonie Jan 7, 2025
23b080a
kselftest/arm64: Add 2024 dpISA extensions to hwcap test
broonie Jan 7, 2025
0f82983
arm64/hwcap: Remove stray references to SF8MMx
broonie Feb 3, 2025
1de0502
arm64: Add missing registrations of hwcaps
broonie Feb 12, 2025
bebb33b
arm64: Filter out SME hwcaps when FEAT_SME isn't implemented
broonie Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/arch/arm64/cpu-feature-registers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ infrastructure:
+------------------------------+---------+---------+
| SHA3 | [35-32] | y |
+------------------------------+---------+---------+
| B16B16 | [27-24] | y |
+------------------------------+---------+---------+
| BF16 | [23-20] | y |
+------------------------------+---------+---------+
| BitPerm | [19-16] | y |
Expand Down
102 changes: 102 additions & 0 deletions Documentation/arch/arm64/elf_hwcaps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,56 @@ HWCAP_PACG
ID_AA64ISAR1_EL1.GPI == 0b0001, as described by
Documentation/arch/arm64/pointer-authentication.rst.

HWCAP_CMPBR
Functionality implied by ID_AA64ISAR2_EL1.CSSC == 0b0010.

HWCAP_FPRCVT
Functionality implied by ID_AA64ISAR3_EL1.FPRCVT == 0b0001.

HWCAP_F8MM8
Functionality implied by ID_AA64FPFR0_EL1.F8MM8 == 0b0001.

HWCAP_F8MM4
Functionality implied by ID_AA64FPFR0_EL1.F8MM4 == 0b0001.

HWCAP_SVE_F16MM
Functionality implied by ID_AA64PFR0_EL1.SVE == 0b0001 and
ID_AA64ZFR0_EL1.F16MM == 0b0001.

HWCAP_SVE_ELTPERM
Functionality implied by ID_AA64PFR0_EL1.SVE == 0b0001 and
ID_AA64ZFR0_EL1.ELTPERM == 0b0001.

HWCAP_SVE_AES2
Functionality implied by ID_AA64PFR0_EL1.SVE == 0b0001 and
ID_AA64ZFR0_EL1.AES == 0b0011.

HWCAP_SVE_BFSCALE
Functionality implied by ID_AA64PFR0_EL1.SVE == 0b0001 and
ID_AA64ZFR0_EL1.B16B16 == 0b0010.

HWCAP_SVE2P2
Functionality implied by ID_AA64PFR0_EL1.SVE == 0b0001 and
ID_AA64ZFR0_EL1.SVEver == 0b0011.

HWCAP_SME2P2
Functionality implied by ID_AA64SMFR0_EL1.SMEver == 0b0011.

HWCAP_SME_SBITPERM
Functionality implied by ID_AA64SMFR0_EL1.SBitPerm == 0b1.

HWCAP_SME_AES
Functionality implied by ID_AA64SMFR0_EL1.AES == 0b1.

HWCAP_SME_SFEXPA
Functionality implied by ID_AA64SMFR0_EL1.SFEXPA == 0b1.

HWCAP_SME_STMOP
Functionality implied by ID_AA64SMFR0_EL1.STMOP == 0b1.

HWCAP_SME_SMOP4
Functionality implied by ID_AA64SMFR0_EL1.SMOP4 == 0b1.

HWCAP2_DCPODP
Functionality implied by ID_AA64ISAR1_EL1.DPB == 0b0010.

Expand Down Expand Up @@ -320,12 +370,64 @@ HWCAP2_MOPS
HWCAP2_HBC
Functionality implied by ID_AA64ISAR2_EL1.BC == 0b0001.

HWCAP2_SVE_B16B16
Functionality implied by ID_AA64ZFR0_EL1.B16B16 == 0b0001.

HWCAP3_LS64
Functionality implied by ID_AA64ISAR1_EL1.LS64 == 0b0001.

HWCAP3_LS64_V
Functionality implied by ID_AA64ISAR1_EL1.LS64 == 0b0010.

HWCAP2_FPMR
Functionality implied by ID_AA64PFR2_EL1.FMR == 0b0001.

HWCAP2_LUT
Functionality implied by ID_AA64ISAR2_EL1.LUT == 0b0001.

HWCAP2_FAMINMAX
Functionality implied by ID_AA64ISAR3_EL1.FAMINMAX == 0b0001.

HWCAP2_F8CVT
Functionality implied by ID_AA64FPFR0_EL1.F8CVT == 0b1.

HWCAP2_F8FMA
Functionality implied by ID_AA64FPFR0_EL1.F8FMA == 0b1.

HWCAP2_F8DP4
Functionality implied by ID_AA64FPFR0_EL1.F8DP4 == 0b1.

HWCAP2_F8DP2
Functionality implied by ID_AA64FPFR0_EL1.F8DP2 == 0b1.

HWCAP2_F8E4M3
Functionality implied by ID_AA64FPFR0_EL1.F8E4M3 == 0b1.

HWCAP2_F8E5M2
Functionality implied by ID_AA64FPFR0_EL1.F8E5M2 == 0b1.

HWCAP2_SME_LUTV2
Functionality implied by ID_AA64SMFR0_EL1.LUTv2 == 0b1.

HWCAP2_SME_F8F16
Functionality implied by ID_AA64SMFR0_EL1.F8F16 == 0b1.

HWCAP2_SME_F8F32
Functionality implied by ID_AA64SMFR0_EL1.F8F32 == 0b1.

HWCAP2_SME_SF8FMA
Functionality implied by ID_AA64SMFR0_EL1.SF8FMA == 0b1.

HWCAP2_SME_SF8DP4
Functionality implied by ID_AA64SMFR0_EL1.SF8DP4 == 0b1.

HWCAP2_SME_SF8DP2
Functionality implied by ID_AA64SMFR0_EL1.SF8DP2 == 0b1.

HWCAP2_SME_SF8DP4
Functionality implied by ID_AA64SMFR0_EL1.SF8DP4 == 0b1.


4. Unused AT_HWCAP bits
-----------------------

Expand Down
8 changes: 4 additions & 4 deletions Documentation/arch/arm64/sme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ model features for SME is included in Appendix A.
vectors from 0 to VL/8-1 stored in the same endianness invariant format as is
used for SVE vectors.

* On thread creation TPIDR2_EL0 is preserved unless CLONE_SETTLS is specified,
in which case it is set to 0.
* On thread creation PSTATE.ZA and TPIDR2_EL0 are preserved unless CLONE_VM
is specified, in which case PSTATE.ZA is set to 0 and TPIDR2_EL0 is set to 0.

2. Vector lengths
------------------
Expand Down Expand Up @@ -115,7 +115,7 @@ be zeroed.
5. Signal handling
-------------------

* Signal handlers are invoked with streaming mode and ZA disabled.
* Signal handlers are invoked with PSTATE.SM=0, PSTATE.ZA=0, and TPIDR2_EL0=0.

* A new signal frame record TPIDR2_MAGIC is added formatted as a struct
tpidr2_context to allow access to TPIDR2_EL0 from signal handlers.
Expand Down Expand Up @@ -241,7 +241,7 @@ prctl(PR_SME_SET_VL, unsigned long arg)
length, or calling PR_SME_SET_VL with the PR_SVE_SET_VL_ONEXEC flag,
does not constitute a change to the vector length for this purpose.

* Changing the vector length causes PSTATE.ZA and PSTATE.SM to be cleared.
* Changing the vector length causes PSTATE.ZA to be cleared.
Calling PR_SME_SET_VL with vl equal to the thread's current vector
length, or calling PR_SME_SET_VL with the PR_SVE_SET_VL_ONEXEC flag,
does not constitute a change to the vector length for this purpose.
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2244,7 +2244,6 @@ config ARM64_SME
bool "ARM Scalable Matrix Extension support"
default y
depends on ARM64_SVE
depends on BROKEN
help
The Scalable Matrix Extension (SME) is an extension to the AArch64
execution state which utilises a substantial subset of the SVE
Expand Down
25 changes: 9 additions & 16 deletions arch/arm64/include/asm/assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,32 +766,25 @@ alternative_endif
.endm

/*
* Check whether preempt/bh-disabled asm code should yield as soon as
* it is able. This is the case if we are currently running in task
* context, and either a softirq is pending, or the TIF_NEED_RESCHED
* flag is set and re-enabling preemption a single time would result in
* a preempt count of zero. (Note that the TIF_NEED_RESCHED flag is
* stored negated in the top word of the thread_info::preempt_count
* Check whether asm code should yield as soon as it is able. This is
* the case if we are currently running in task context, and the
* TIF_NEED_RESCHED flag is set. (Note that the TIF_NEED_RESCHED flag
* is stored negated in the top word of the thread_info::preempt_count
* field)
*/
.macro cond_yield, lbl:req, tmp:req, tmp2:req
.macro cond_yield, lbl:req, tmp:req, tmp2
#ifdef CONFIG_PREEMPT_VOLUNTARY
get_current_task \tmp
ldr \tmp, [\tmp, #TSK_TI_PREEMPT]
/*
* If we are serving a softirq, there is no point in yielding: the
* softirq will not be preempted no matter what we do, so we should
* run to completion as quickly as we can.
* run to completion as quickly as we can. The preempt_count field will
* have BIT(SOFTIRQ_SHIFT) set in this case, so the zero check will
* catch this case too.
*/
tbnz \tmp, #SOFTIRQ_SHIFT, .Lnoyield_\@
#ifdef CONFIG_PREEMPTION
sub \tmp, \tmp, #PREEMPT_DISABLE_OFFSET
cbz \tmp, \lbl
#endif
adr_l \tmp, irq_stat + IRQ_CPUSTAT_SOFTIRQ_PENDING
get_this_cpu_offset \tmp2
ldr w\tmp, [\tmp, \tmp2]
cbnz w\tmp, \lbl // yield on pending softirq in task context
.Lnoyield_\@:
.endm

/*
Expand Down
3 changes: 3 additions & 0 deletions arch/arm64/include/asm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ struct cpuinfo_arm64 {
u64 reg_id_aa64isar0;
u64 reg_id_aa64isar1;
u64 reg_id_aa64isar2;
u64 reg_id_aa64isar3;
u64 reg_id_aa64mmfr0;
u64 reg_id_aa64mmfr1;
u64 reg_id_aa64mmfr2;
u64 reg_id_aa64mmfr3;
u64 reg_id_aa64pfr0;
u64 reg_id_aa64pfr1;
u64 reg_id_aa64pfr2;
u64 reg_id_aa64zfr0;
u64 reg_id_aa64smfr0;
u64 reg_id_aa64fpfr0;

struct cpuinfo_32bit aarch32;

Expand Down
5 changes: 5 additions & 0 deletions arch/arm64/include/asm/cpufeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ static __always_inline bool system_supports_tpidr2(void)
return system_supports_sme();
}

static __always_inline bool system_supports_fpmr(void)
{
return alternative_has_cap_unlikely(ARM64_HAS_FPMR);
}

static __always_inline bool system_supports_cnp(void)
{
return alternative_has_cap_unlikely(ARM64_HAS_CNP);
Expand Down
62 changes: 46 additions & 16 deletions arch/arm64/include/asm/fpsimd.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ extern void fpsimd_load_state(struct user_fpsimd_state *state);
extern void fpsimd_thread_switch(struct task_struct *next);
extern void fpsimd_flush_thread(void);

extern void fpsimd_signal_preserve_current_state(void);
extern void fpsimd_preserve_current_state(void);
extern void fpsimd_restore_current_state(void);
extern void fpsimd_update_current_state(struct user_fpsimd_state const *state);
Expand All @@ -90,6 +89,7 @@ struct cpu_fp_state {
void *sve_state;
void *sme_state;
u64 *svcr;
u64 *fpmr;
unsigned int sve_vl;
unsigned int sme_vl;
enum fp_type *fp_type;
Expand All @@ -101,6 +101,7 @@ DECLARE_PER_CPU(struct cpu_fp_state, fpsimd_last_state);
extern void fpsimd_bind_state_to_cpu(struct cpu_fp_state *fp_state);

extern void fpsimd_flush_task_state(struct task_struct *target);
extern void fpsimd_save_and_flush_current_state(void);
extern void fpsimd_save_and_flush_cpu_state(void);

static inline bool thread_sm_enabled(struct thread_struct *thread)
Expand All @@ -113,6 +114,8 @@ static inline bool thread_za_enabled(struct thread_struct *thread)
return system_supports_sme() && (thread->svcr & SVCR_ZA_MASK);
}

extern void task_smstop_sm(struct task_struct *task);

/* Maximum VL that SVE/SME VL-agnostic software can transparently support */
#define VL_ARCH_MAX 0x100

Expand Down Expand Up @@ -157,6 +160,7 @@ extern void cpu_enable_sve(const struct arm64_cpu_capabilities *__unused);
extern void cpu_enable_sme(const struct arm64_cpu_capabilities *__unused);
extern void cpu_enable_sme2(const struct arm64_cpu_capabilities *__unused);
extern void cpu_enable_fa64(const struct arm64_cpu_capabilities *__unused);
extern void cpu_enable_fpmr(const struct arm64_cpu_capabilities *__unused);

extern u64 read_zcr_features(void);
extern u64 read_smcr_features(void);
Expand Down Expand Up @@ -202,10 +206,9 @@ struct vl_info {

extern void sve_alloc(struct task_struct *task, bool flush);
extern void fpsimd_release_task(struct task_struct *task);
extern void fpsimd_sync_to_sve(struct task_struct *task);
extern void fpsimd_force_sync_to_sve(struct task_struct *task);
extern void sve_sync_to_fpsimd(struct task_struct *task);
extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task);
extern void fpsimd_sync_from_effective_state(struct task_struct *task);
extern void fpsimd_sync_to_effective_state_zeropad(struct task_struct *task);

extern int vec_set_vector_length(struct task_struct *task, enum vec_type type,
unsigned long vl, unsigned long flags);
Expand Down Expand Up @@ -299,14 +302,29 @@ static inline bool sve_vq_available(unsigned int vq)
return vq_available(ARM64_VEC_SVE, vq);
}

size_t sve_state_size(struct task_struct const *task);
static inline size_t __sve_state_size(unsigned int sve_vl, unsigned int sme_vl)
{
unsigned int vl = max(sve_vl, sme_vl);
return SVE_SIG_REGS_SIZE(sve_vq_from_vl(vl));
}

/*
* Return how many bytes of memory are required to store the full SVE
* state for task, given task's currently configured vector length.
*/
static inline size_t sve_state_size(struct task_struct const *task)
{
unsigned int sve_vl = task_get_sve_vl(task);
unsigned int sme_vl = task_get_sme_vl(task);
return __sve_state_size(sve_vl, sme_vl);
}

#else /* ! CONFIG_ARM64_SVE */

static inline void sve_alloc(struct task_struct *task, bool flush) { }
static inline void fpsimd_release_task(struct task_struct *task) { }
static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
static inline void fpsimd_sync_from_effective_state(struct task_struct *task) { }
static inline void fpsimd_sync_to_effective_state_zeropad(struct task_struct *task) { }

static inline int sve_max_virtualisable_vl(void)
{
Expand Down Expand Up @@ -340,6 +358,11 @@ static inline void vec_update_vq_map(enum vec_type t) { }
static inline int vec_verify_vq_map(enum vec_type t) { return 0; }
static inline void sve_setup(void) { }

static inline size_t __sve_state_size(unsigned int sve_vl, unsigned int sme_vl)
{
return 0;
}

static inline size_t sve_state_size(struct task_struct const *task)
{
return 0;
Expand Down Expand Up @@ -392,22 +415,24 @@ extern int sme_set_current_vl(unsigned long arg);
extern int sme_get_current_vl(void);
extern void sme_suspend_exit(void);

static inline size_t __sme_state_size(unsigned int sme_vl)
{
size_t size = ZA_SIG_REGS_SIZE(sve_vq_from_vl(sme_vl));

if (system_supports_sme2())
size += ZT_SIG_REG_SIZE;

return size;
}

/*
* Return how many bytes of memory are required to store the full SME
* specific state for task, given task's currently configured vector
* length.
*/
static inline size_t sme_state_size(struct task_struct const *task)
{
unsigned int vl = task_get_sme_vl(task);
size_t size;

size = ZA_SIG_REGS_SIZE(sve_vq_from_vl(vl));

if (system_supports_sme2())
size += ZT_SIG_REG_SIZE;

return size;
return __sme_state_size(task_get_sme_vl(task));
}

#else
Expand All @@ -428,6 +453,11 @@ static inline int sme_set_current_vl(unsigned long arg) { return -EINVAL; }
static inline int sme_get_current_vl(void) { return -EINVAL; }
static inline void sme_suspend_exit(void) { }

static inline size_t __sme_state_size(unsigned int sme_vl)
{
return 0;
}

static inline size_t sme_state_size(struct task_struct const *task)
{
return 0;
Expand Down
Loading