@@ -337,3 +337,11 @@ enum
x86_cpu_AVX10_YMM = x86_cpu_index_24_ecx_0_ebx + 17,
x86_cpu_AVX10_ZMM = x86_cpu_index_24_ecx_0_ebx + 18,
};
+
+/* Bits in the feature_1 field in TCB. */
+
+enum
+{
+ x86_feature_1_ibt = 1U << 0,
+ x86_feature_1_shstk = 1U << 1
+};
@@ -15,9 +15,18 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-
+#include <assert.h>
+#include <tcb-offsets.h>
#include <ldsodefs.h>
+#ifdef __x86_64__
+# ifdef __LP64__
+_Static_assert (FEATURE_1_OFFSET == 72, "FEATURE_1_OFFSET != 72");
+# else
+_Static_assert (FEATURE_1_OFFSET == 40, "FEATURE_1_OFFSET != 40");
+# endif
+#endif
+
const struct cpuid_feature *
__x86_get_cpuid_feature_leaf (unsigned int leaf)
{
@@ -45,6 +45,23 @@ x86_cpu_present (unsigned int __index)
static __inline__ _Bool
x86_cpu_active (unsigned int __index)
{
+ if (__index == x86_cpu_IBT || __index == x86_cpu_SHSTK)
+ {
+#ifdef __x86_64__
+ unsigned int __feature_1;
+# ifdef __LP64__
+ __asm__ ("mov %%fs:72, %0" : "=r" (__feature_1));
+# else
+ __asm__ ("mov %%fs:40, %0" : "=r" (__feature_1));
+# endif
+ if (__index == x86_cpu_IBT)
+ return __feature_1 & x86_feature_1_ibt;
+ else
+ return __feature_1 & x86_feature_1_shstk;
+#else
+ return false;
+#endif
+ }
const struct cpuid_feature *__ptr = __x86_get_cpuid_feature_leaf
(__index / (8 * sizeof (unsigned int) * 4));
unsigned int __reg