Skip to content

Commit 87c021a

Browse files
Dave Martinctmarinas
authored andcommitted
arm64/sve: Thin out initialisation sanity-checks for sve_max_vl
Now that the kernel SVE support is reasonably mature, it is excessive to default sve_max_vl to the invalid value -1 and then sprinkle WARN_ON()s around the place to make sure it has been initialised before use. The cpufeatures code already runs pretty early, and will ensure sve_max_vl gets initialised. This patch initialises sve_max_vl to something sane that will be supported by every SVE implementation, and removes most of the sanity checks. The checks in find_supported_vector_length() are retained for now. If anything goes horribly wrong, we are likely to trip a check here sooner or later. Signed-off-by: Dave Martin <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent cb87771 commit 87c021a

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

arch/arm64/kernel/fpsimd.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int sve_default_vl = -1;
128128
#ifdef CONFIG_ARM64_SVE
129129

130130
/* Maximum supported vector length across all CPUs (initially poisoned) */
131-
int __ro_after_init sve_max_vl = -1;
131+
int __ro_after_init sve_max_vl = SVE_VL_MIN;
132132
/* Set of available vector lengths, as vq_to_bit(vq): */
133133
static __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);
134134
static void __percpu *efi_sve_state;
@@ -359,22 +359,13 @@ static int sve_proc_do_default_vl(struct ctl_table *table, int write,
359359
return ret;
360360

361361
/* Writing -1 has the special meaning "set to max": */
362-
if (vl == -1) {
363-
/* Fail safe if sve_max_vl wasn't initialised */
364-
if (WARN_ON(!sve_vl_valid(sve_max_vl)))
365-
vl = SVE_VL_MIN;
366-
else
367-
vl = sve_max_vl;
368-
369-
goto chosen;
370-
}
362+
if (vl == -1)
363+
vl = sve_max_vl;
371364

372365
if (!sve_vl_valid(vl))
373366
return -EINVAL;
374367

375-
vl = find_supported_vector_length(vl);
376-
chosen:
377-
sve_default_vl = vl;
368+
sve_default_vl = find_supported_vector_length(vl);
378369
return 0;
379370
}
380371

arch/arm64/kernel/ptrace.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,6 @@ static void sve_init_header_from_task(struct user_sve_header *header,
766766
vq = sve_vq_from_vl(header->vl);
767767

768768
header->max_vl = sve_max_vl;
769-
if (WARN_ON(!sve_vl_valid(sve_max_vl)))
770-
header->max_vl = header->vl;
771-
772769
header->size = SVE_PT_SIZE(vq, header->flags);
773770
header->max_size = SVE_PT_SIZE(sve_vq_from_vl(header->max_vl),
774771
SVE_PT_REGS_SVE);

0 commit comments

Comments
 (0)