@@ -632,7 +632,7 @@ void sve_sync_from_fpsimd_zeropad(struct task_struct *task)
632
632
__fpsimd_to_sve (sst , fst , vq );
633
633
}
634
634
635
- int sve_set_vector_length (struct task_struct * task ,
635
+ int vec_set_vector_length (struct task_struct * task , enum vec_type type ,
636
636
unsigned long vl , unsigned long flags )
637
637
{
638
638
if (flags & ~(unsigned long )(PR_SVE_VL_INHERIT |
@@ -643,33 +643,35 @@ int sve_set_vector_length(struct task_struct *task,
643
643
return - EINVAL ;
644
644
645
645
/*
646
- * Clamp to the maximum vector length that VL-agnostic SVE code can
647
- * work with. A flag may be assigned in the future to allow setting
648
- * of larger vector lengths without confusing older software.
646
+ * Clamp to the maximum vector length that VL-agnostic code
647
+ * can work with. A flag may be assigned in the future to
648
+ * allow setting of larger vector lengths without confusing
649
+ * older software.
649
650
*/
650
- if (vl > SVE_VL_ARCH_MAX )
651
- vl = SVE_VL_ARCH_MAX ;
651
+ if (vl > VL_ARCH_MAX )
652
+ vl = VL_ARCH_MAX ;
652
653
653
- vl = find_supported_vector_length (ARM64_VEC_SVE , vl );
654
+ vl = find_supported_vector_length (type , vl );
654
655
655
656
if (flags & (PR_SVE_VL_INHERIT |
656
657
PR_SVE_SET_VL_ONEXEC ))
657
- task_set_sve_vl_onexec (task , vl );
658
+ task_set_vl_onexec (task , type , vl );
658
659
else
659
660
/* Reset VL to system default on next exec: */
660
- task_set_sve_vl_onexec (task , 0 );
661
+ task_set_vl_onexec (task , type , 0 );
661
662
662
663
/* Only actually set the VL if not deferred: */
663
664
if (flags & PR_SVE_SET_VL_ONEXEC )
664
665
goto out ;
665
666
666
- if (vl == task_get_sve_vl (task ))
667
+ if (vl == task_get_vl (task , type ))
667
668
goto out ;
668
669
669
670
/*
670
671
* To ensure the FPSIMD bits of the SVE vector registers are preserved,
671
672
* write any live register state back to task_struct, and convert to a
672
- * non-SVE thread.
673
+ * regular FPSIMD thread. Since the vector length can only be changed
674
+ * with a syscall we can't be in streaming mode while reconfiguring.
673
675
*/
674
676
if (task == current ) {
675
677
get_cpu_fpsimd_context ();
@@ -690,31 +692,32 @@ int sve_set_vector_length(struct task_struct *task,
690
692
*/
691
693
sve_free (task );
692
694
693
- task_set_sve_vl (task , vl );
695
+ task_set_vl (task , type , vl );
694
696
695
697
out :
696
- update_tsk_thread_flag (task , TIF_SVE_VL_INHERIT ,
698
+ update_tsk_thread_flag (task , vec_vl_inherit_flag ( type ) ,
697
699
flags & PR_SVE_VL_INHERIT );
698
700
699
701
return 0 ;
700
702
}
701
703
702
704
/*
703
705
* Encode the current vector length and flags for return.
704
- * This is only required for prctl(): ptrace has separate fields
706
+ * This is only required for prctl(): ptrace has separate fields.
707
+ * SVE and SME use the same bits for _ONEXEC and _INHERIT.
705
708
*
706
- * flags are as for sve_set_vector_length ().
709
+ * flags are as for vec_set_vector_length ().
707
710
*/
708
- static int sve_prctl_status ( unsigned long flags )
711
+ static int vec_prctl_status ( enum vec_type type , unsigned long flags )
709
712
{
710
713
int ret ;
711
714
712
715
if (flags & PR_SVE_SET_VL_ONEXEC )
713
- ret = task_get_sve_vl_onexec (current );
716
+ ret = task_get_vl_onexec (current , type );
714
717
else
715
- ret = task_get_sve_vl (current );
718
+ ret = task_get_vl (current , type );
716
719
717
- if (test_thread_flag (TIF_SVE_VL_INHERIT ))
720
+ if (test_thread_flag (vec_vl_inherit_flag ( type ) ))
718
721
ret |= PR_SVE_VL_INHERIT ;
719
722
720
723
return ret ;
@@ -732,11 +735,11 @@ int sve_set_current_vl(unsigned long arg)
732
735
if (!system_supports_sve () || is_compat_task ())
733
736
return - EINVAL ;
734
737
735
- ret = sve_set_vector_length (current , vl , flags );
738
+ ret = vec_set_vector_length (current , ARM64_VEC_SVE , vl , flags );
736
739
if (ret )
737
740
return ret ;
738
741
739
- return sve_prctl_status ( flags );
742
+ return vec_prctl_status ( ARM64_VEC_SVE , flags );
740
743
}
741
744
742
745
/* PR_SVE_GET_VL */
@@ -745,7 +748,7 @@ int sve_get_current_vl(void)
745
748
if (!system_supports_sve () || is_compat_task ())
746
749
return - EINVAL ;
747
750
748
- return sve_prctl_status ( 0 );
751
+ return vec_prctl_status ( ARM64_VEC_SVE , 0 );
749
752
}
750
753
751
754
static void vec_probe_vqs (struct vl_info * info ,
0 commit comments