* [PATCH] <sys/platform/x86.h>: Add APX support
@ 2023-07-25 19:04 H.J. Lu
2023-07-25 19:55 ` Florian Weimer
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2023-07-25 19:04 UTC (permalink / raw)
To: libc-alpha
Add support for Intel Advanced Performance Extensions:
https://www.intel.com/content/www/us/en/developer/articles/technical/advanced-performance-extensions-apx.html
to <sys/platform/x86.h>.
---
manual/platform.texi | 3 +++
sysdeps/x86/bits/platform/x86.h | 1 +
sysdeps/x86/cpu-features.c | 4 ++++
sysdeps/x86/include/cpu-features.h | 4 ++++
sysdeps/x86/tst-get-cpu-features.c | 2 ++
5 files changed, 14 insertions(+)
diff --git a/manual/platform.texi b/manual/platform.texi
index c6ed73cb97..2a2d557067 100644
--- a/manual/platform.texi
+++ b/manual/platform.texi
@@ -209,6 +209,9 @@ The supported processor features are:
@item
@code{AMX_TILE} -- Tile architecture.
+@item
+@code{APX_F} -- The APX instruction extensions.
+
@item
@code{ARCH_CAPABILITIES} -- IA32_ARCH_CAPABILITIES MSR.
diff --git a/sysdeps/x86/bits/platform/x86.h b/sysdeps/x86/bits/platform/x86.h
index 6555f9b91d..88ca071aa7 100644
--- a/sysdeps/x86/bits/platform/x86.h
+++ b/sysdeps/x86/bits/platform/x86.h
@@ -312,6 +312,7 @@ enum
x86_cpu_AVX_NE_CONVERT = x86_cpu_index_7_ecx_1_edx + 5,
x86_cpu_AMX_COMPLEX = x86_cpu_index_7_ecx_1_edx + 8,
x86_cpu_PREFETCHI = x86_cpu_index_7_ecx_1_edx + 14,
+ x86_cpu_APX_F = x86_cpu_index_7_ecx_1_edx + 21,
x86_cpu_index_19_ebx
= (CPUID_INDEX_19 * 8 * 4 * sizeof (unsigned int)
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 9ac195810f..376e3c7501 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -226,6 +226,10 @@ update_active (struct cpu_features *cpu_features)
CPU_FEATURE_SET_ACTIVE (cpu_features, AMX_COMPLEX);
}
+ /* Is AVX state usable? */
+ if ((xcrlow & bit_AVX_state) != 0)
+ CPU_FEATURE_SET_ACTIVE (cpu_features, APX_F);
+
/* These features are usable only when OSXSAVE is enabled. */
CPU_FEATURE_SET (cpu_features, XSAVE);
CPU_FEATURE_SET_ACTIVE (cpu_features, XSAVEOPT);
diff --git a/sysdeps/x86/include/cpu-features.h b/sysdeps/x86/include/cpu-features.h
index c740e1a5fc..68db82f732 100644
--- a/sysdeps/x86/include/cpu-features.h
+++ b/sysdeps/x86/include/cpu-features.h
@@ -319,6 +319,7 @@ enum
#define bit_cpu_AVX_NE_CONVERT (1u << 5)
#define bit_cpu_AMX_COMPLEX (1u << 8)
#define bit_cpu_PREFETCHI (1u << 14)
+#define bit_cpu_APX_F (1u << 21)
/* CPUID_INDEX_19. */
@@ -562,6 +563,7 @@ enum
#define index_cpu_AVX_NE_CONVERT CPUID_INDEX_7_ECX_1
#define index_cpu_AMX_COMPLEX CPUID_INDEX_7_ECX_1
#define index_cpu_PREFETCHI CPUID_INDEX_7_ECX_1
+#define index_cpu_APX_F CPUID_INDEX_7_ECX_1
/* CPUID_INDEX_19. */
@@ -807,6 +809,7 @@ enum
#define reg_AVX_NE_CONVERT edx
#define reg_AMX_COMPLEX edx
#define reg_PREFETCHI edx
+#define reg_APX_F edx
/* CPUID_INDEX_19. */
@@ -845,6 +848,7 @@ enum
#define bit_ZMM16_31_state (1u << 7)
#define bit_XTILECFG_state (1u << 17)
#define bit_XTILEDATA_state (1u << 18)
+#define bit_AVX_state (1u << 19)
enum cpu_features_kind
{
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index 1bd7e0be53..b27fa7324a 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -219,6 +219,7 @@ do_test (void)
CHECK_CPU_FEATURE_PRESENT (AVX_NE_CONVERT);
CHECK_CPU_FEATURE_PRESENT (AMX_COMPLEX);
CHECK_CPU_FEATURE_PRESENT (PREFETCHI);
+ CHECK_CPU_FEATURE_PRESENT (APX_F);
CHECK_CPU_FEATURE_PRESENT (AESKLE);
CHECK_CPU_FEATURE_PRESENT (WIDE_KL);
CHECK_CPU_FEATURE_PRESENT (PTWRITE);
@@ -390,6 +391,7 @@ do_test (void)
CHECK_CPU_FEATURE_ACTIVE (AVX_NE_CONVERT);
CHECK_CPU_FEATURE_ACTIVE (AMX_COMPLEX);
CHECK_CPU_FEATURE_ACTIVE (PREFETCHI);
+ CHECK_CPU_FEATURE_ACTIVE (APX_F);
CHECK_CPU_FEATURE_ACTIVE (AESKLE);
CHECK_CPU_FEATURE_ACTIVE (WIDE_KL);
CHECK_CPU_FEATURE_ACTIVE (PTWRITE);
--
2.41.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] <sys/platform/x86.h>: Add APX support
2023-07-25 19:04 [PATCH] <sys/platform/x86.h>: Add APX support H.J. Lu
@ 2023-07-25 19:55 ` Florian Weimer
2023-07-25 20:16 ` H.J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2023-07-25 19:55 UTC (permalink / raw)
To: H.J. Lu via Libc-alpha; +Cc: H.J. Lu
* H. J. Lu via Libc-alpha:
> diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> index 9ac195810f..376e3c7501 100644
> --- a/sysdeps/x86/cpu-features.c
> +++ b/sysdeps/x86/cpu-features.c
> @@ -226,6 +226,10 @@ update_active (struct cpu_features *cpu_features)
> CPU_FEATURE_SET_ACTIVE (cpu_features, AMX_COMPLEX);
> }
>
> + /* Is AVX state usable? */
> + if ((xcrlow & bit_AVX_state) != 0)
> + CPU_FEATURE_SET_ACTIVE (cpu_features, APX_F);
> +
> /* These features are usable only when OSXSAVE is enabled. */
> CPU_FEATURE_SET (cpu_features, XSAVE);
> CPU_FEATURE_SET_ACTIVE (cpu_features, XSAVEOPT);
AVX vs APX looks like a typo, this needs a comment.
Will this really work without further kernel enablement? Finally a
compelling use case for MPX. 8-)
Thanks,
Floria
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] <sys/platform/x86.h>: Add APX support
2023-07-25 19:55 ` Florian Weimer
@ 2023-07-25 20:16 ` H.J. Lu
2023-07-26 2:46 ` Noah Goldstein
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2023-07-25 20:16 UTC (permalink / raw)
To: Florian Weimer; +Cc: H.J. Lu via Libc-alpha
On Tue, Jul 25, 2023 at 12:55 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> > index 9ac195810f..376e3c7501 100644
> > --- a/sysdeps/x86/cpu-features.c
> > +++ b/sysdeps/x86/cpu-features.c
> > @@ -226,6 +226,10 @@ update_active (struct cpu_features *cpu_features)
> > CPU_FEATURE_SET_ACTIVE (cpu_features, AMX_COMPLEX);
> > }
> >
> > + /* Is AVX state usable? */
> > + if ((xcrlow & bit_AVX_state) != 0)
> > + CPU_FEATURE_SET_ACTIVE (cpu_features, APX_F);
> > +
> > /* These features are usable only when OSXSAVE is enabled. */
> > CPU_FEATURE_SET (cpu_features, XSAVE);
> > CPU_FEATURE_SET_ACTIVE (cpu_features, XSAVEOPT);
>
> AVX vs APX looks like a typo, this needs a comment.
Will be fixed.
> Will this really work without further kernel enablement? Finally a
The bit_AVX_state bit should be set by kernel. I think APX needs
some kernel support.
> compelling use case for MPX. 8-)
>
> Thanks,
> Floria
>
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] <sys/platform/x86.h>: Add APX support
2023-07-25 20:16 ` H.J. Lu
@ 2023-07-26 2:46 ` Noah Goldstein
2023-07-26 4:59 ` Florian Weimer
0 siblings, 1 reply; 5+ messages in thread
From: Noah Goldstein @ 2023-07-26 2:46 UTC (permalink / raw)
To: H.J. Lu; +Cc: Florian Weimer, H.J. Lu via Libc-alpha
On Tue, Jul 25, 2023 at 3:17 PM H.J. Lu via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On Tue, Jul 25, 2023 at 12:55 PM Florian Weimer <fweimer@redhat.com> wrote:
> >
> > * H. J. Lu via Libc-alpha:
> >
> > > diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> > > index 9ac195810f..376e3c7501 100644
> > > --- a/sysdeps/x86/cpu-features.c
> > > +++ b/sysdeps/x86/cpu-features.c
> > > @@ -226,6 +226,10 @@ update_active (struct cpu_features *cpu_features)
> > > CPU_FEATURE_SET_ACTIVE (cpu_features, AMX_COMPLEX);
> > > }
> > >
> > > + /* Is AVX state usable? */
> > > + if ((xcrlow & bit_AVX_state) != 0)
> > > + CPU_FEATURE_SET_ACTIVE (cpu_features, APX_F);
> > > +
Isn't the APX state bigger than the AVX state?
> > > /* These features are usable only when OSXSAVE is enabled. */
> > > CPU_FEATURE_SET (cpu_features, XSAVE);
> > > CPU_FEATURE_SET_ACTIVE (cpu_features, XSAVEOPT);
> >
> > AVX vs APX looks like a typo, this needs a comment.
>
> Will be fixed.
>
> > Will this really work without further kernel enablement? Finally a
>
> The bit_AVX_state bit should be set by kernel. I think APX needs
> some kernel support.
>
> > compelling use case for MPX. 8-)
> >
> > Thanks,
> > Floria
> >
>
>
> --
> H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] <sys/platform/x86.h>: Add APX support
2023-07-26 2:46 ` Noah Goldstein
@ 2023-07-26 4:59 ` Florian Weimer
0 siblings, 0 replies; 5+ messages in thread
From: Florian Weimer @ 2023-07-26 4:59 UTC (permalink / raw)
To: Noah Goldstein; +Cc: H.J. Lu, H.J. Lu via Libc-alpha
* Noah Goldstein:
> On Tue, Jul 25, 2023 at 3:17 PM H.J. Lu via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> On Tue, Jul 25, 2023 at 12:55 PM Florian Weimer <fweimer@redhat.com> wrote:
>> >
>> > * H. J. Lu via Libc-alpha:
>> >
>> > > diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
>> > > index 9ac195810f..376e3c7501 100644
>> > > --- a/sysdeps/x86/cpu-features.c
>> > > +++ b/sysdeps/x86/cpu-features.c
>> > > @@ -226,6 +226,10 @@ update_active (struct cpu_features *cpu_features)
>> > > CPU_FEATURE_SET_ACTIVE (cpu_features, AMX_COMPLEX);
>> > > }
>> > >
>> > > + /* Is AVX state usable? */
>> > > + if ((xcrlow & bit_AVX_state) != 0)
>> > > + CPU_FEATURE_SET_ACTIVE (cpu_features, APX_F);
>> > > +
>
> Isn't the APX state bigger than the AVX state?
There is this:
| • EBX (Offset in bytes in XSAVE/XRSTOR area for this feature)
| – 960 (0x3C0).
| * Intel® APX is feature index 19 in XCR0.
| * Intel® APX is architected to re-use the deprecated area of Intel® MPX.
<https://www.intel.com/content/www/us/en/content-details/784266/intel-advanced-performance-extensions-intel-apx-architecture-specification.html>
But the “AVX” is really a typo for APX here—bit_AVX_state is bit 19, the
APX bit.
Thanks,
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-26 4:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-25 19:04 [PATCH] <sys/platform/x86.h>: Add APX support H.J. Lu
2023-07-25 19:55 ` Florian Weimer
2023-07-25 20:16 ` H.J. Lu
2023-07-26 2:46 ` Noah Goldstein
2023-07-26 4:59 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).