[PATCH 1/2] x86: Skip XSAVE state size reset if ISA level requires XSAVE
H.J. Lu
hjl.tools@gmail.com
Thu Mar 27 22:36:45 GMT 2025
On Thu, Mar 27, 2025 at 2:42 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> If we have to use XSAVE or XSAVEC trampolines, do not adjust the size
> information they need. Technically, it is an operator error to try to
> run with -XSAVE,-XSAVEC on such builds, but this change here disables
> some unnecessary code with higher ISA levels and simplifies testing.
>
> Related to commit befe2d3c4dec8be2cdd01a47132e47bdb7020922
> ("x86-64: Don't use SSE resolvers for ISA level 3 or above").
> ---
> sysdeps/x86/cpu-features.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> index 27abaca8b7..06876bff14 100644
> --- a/sysdeps/x86/cpu-features.c
> +++ b/sysdeps/x86/cpu-features.c
> @@ -1161,7 +1161,8 @@ no_cpuid:
>
> bool disable_xsave_features = false;
>
> - if (!CPU_FEATURE_USABLE_P (cpu_features, OSXSAVE))
> + if (MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
> + && !CPU_FEATURE_USABLE_P (cpu_features, OSXSAVE))
> {
> /* These features are usable only if OSXSAVE is usable. */
> CPU_FEATURE_UNSET (cpu_features, XSAVE);
> @@ -1173,9 +1174,10 @@ no_cpuid:
> disable_xsave_features = true;
> }
>
> - if (disable_xsave_features
> - || (!CPU_FEATURE_USABLE_P (cpu_features, XSAVE)
> - && !CPU_FEATURE_USABLE_P (cpu_features, XSAVEC)))
> + if (MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
> + && (disable_xsave_features
> + || (!CPU_FEATURE_USABLE_P (cpu_features, XSAVE)
> + && !CPU_FEATURE_USABLE_P (cpu_features, XSAVEC))))
> {
> /* Clear xsave_state_size if both XSAVE and XSAVEC aren't usable. */
> cpu_features->xsave_state_size = 0;
Since AVX needs xsave, I prefer
if (MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL)
{
Disable XSAVE
Disable XSAVEC
}
or
#if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
...
#endif
> base-commit: be61b9493d38032519e596f282f9695667402c8d
> --
> 2.48.1
>
>
--
H.J.
More information about the Libc-alpha
mailing list