> -----Original Message-----
> From: Wilco Dijkstra <[email protected]>
> Sent: 03 November 2026 14:56
> To: gcc-patches mailing list <[email protected]>
> Cc: Kyrylo Tkachov <[email protected]>; Alex Coplan
> <[email protected]>; Alice Carlotti <[email protected]>; Tamar
> Christina <[email protected]>; Richard Earnshaw
> <[email protected]>; Andrea Pinski
> <[email protected]>
> Subject: libgcc: Enable AArch64 SVE2 features only if SVE is enabled
> [PR126935]
> 
> 
> Linux kernels before 6.12 may set SVE2 features without SVE in some cases.
> Clear affected SVE2 features if SVE is not enabled.
> 
> Passes regress, OK for commit?

OK.

Thanks,
Tamar.

> 
> libgcc:
> 
>       * config/aarch64/cpuinfo.c (__init_cpu_features_constructor):
>       Clear SVE2 features if SVE is not enabled.
> 
> ---
> 
> diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c
> index
> 93d9491f7a488e7da890d9f3f942e1c5cc4bf834..fbc8ea01bc678709d1881
> 2f1810895d53f279a14 100644
> --- a/libgcc/config/aarch64/cpuinfo.c
> +++ b/libgcc/config/aarch64/cpuinfo.c
> @@ -124,6 +124,14 @@ __init_cpu_features_constructor (unsigned long
> hwcap,
>    unsigned long hwcap4 __attribute__ ((unused)) = 0;
>    if ((hwcap & _IFUNC_ARG_HWCAP) && arg->_size >=
> __IFUNC_ARG_SIZE_HWCAP4)
>      hwcap4 = arg->_hwcap4;
> +
> +  /* Kernels before 6.12 may set some SVE2 features without SVE
> (PR126935).
> +     Workaround this by clearing such features if SVE is not enabled.  */
> +  if (!(hwcap & HWCAP_SVE))
> +    hwcap2 &= ~(HWCAP2_SVE2 | HWCAP2_SVEPMULL |
> HWCAP2_SVEBITPERM
> +             | HWCAP2_SVESHA3 | HWCAP2_SVESM4 |
> HWCAP2_SVEF32MM
> +             | HWCAP2_SVEF64MM);
> +
>    if (hwcap & HWCAP_CRC32)
>      setCPUFeature(FEAT_CRC);
>    if (hwcap & HWCAP_PMULL)

Reply via email to