[PATCH v10 04/30] arm64/fpsimd: Determine maximum virtualisable SME vector length
Mark Rutland
mark.rutland at arm.com
Tue May 26 05:55:04 PDT 2026
On Mon, May 11, 2026 at 09:42:36PM +0900, Mark Brown wrote:
> On Mon, May 11, 2026 at 11:32:56AM +0100, Mark Rutland wrote:
> > On Fri, Mar 06, 2026 at 05:00:56PM +0000, Mark Brown wrote:
>
> > > +#define SME_VQ_INVALID (SME_VQ_MAX + 1)
>
> > Does using (SME_VQ_MAX + 1) for this make something easier than if we
> > used 0?
>
> There were checks for VLs less than $THING which were causing annoyance
> IIRC but it should be workable since we shouldn't offer SME to guests if
> the invalid VL comes up. I'll look again when I'm back from holiday.
>
> > To solve all of the above, I think what we actually want to do is find
> > the largest uniformly implemented VL which is smaller than the smallest
> > partially implemented VL.
>
> Yes, that's what we're going for.
To be clear, that was a concrete suggestiong as to the algorithm.
I'm saying we should have code along the lines of:
int find_virtualisable_vl(struct vl_info *info)
{
DECLARE_BITMAP(partial_only_map, SVE_VQ_MAX);
unsigned long b_min_partial, m_max_virt;
bitmap_andnot(partial_only_map, info->va_partial_map, info->vq_map,
SVE_VQ_MAX);
b_min_partial = find_last_bit(partial_only_map, SVE_VQ_MAX);
/* All implemented VLs are virtualisable */
if (m_min_partial >= SVE_VQ_MAX)
return info->max_vl;
b_max_virt = find_next_bit(info->vq_map, SVE_VQ_MAX, b_min_partial);
/* No implemented VLs are virtualisable */
if (b_max_virt >= SVE_VQ_MAX)
return 0;
/* At least one virtualisable VL exists */
return sve_vl_from_vq(__bit_to_vq(b_max_virt));
}
Mark.
More information about the linux-arm-kernel
mailing list