diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c index fca699403..c7573f6ad 100644 --- a/compel/arch/aarch64/src/lib/cpu.c +++ b/compel/arch/aarch64/src/lib/cpu.c @@ -16,6 +16,7 @@ static bool rt_info_done = false; void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { } void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { } int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; } +int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; } int compel_cpuid(compel_cpuinfo_t *info) { return 0; } bool compel_cpu_has_feature(unsigned int feature) diff --git a/compel/arch/arm/src/lib/cpu.c b/compel/arch/arm/src/lib/cpu.c index fca699403..c7573f6ad 100644 --- a/compel/arch/arm/src/lib/cpu.c +++ b/compel/arch/arm/src/lib/cpu.c @@ -16,6 +16,7 @@ static bool rt_info_done = false; void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { } void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { } int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; } +int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; } int compel_cpuid(compel_cpuinfo_t *info) { return 0; } bool compel_cpu_has_feature(unsigned int feature) diff --git a/compel/arch/ppc64/src/lib/cpu.c b/compel/arch/ppc64/src/lib/cpu.c index 0a7adcb0b..f6d163b89 100644 --- a/compel/arch/ppc64/src/lib/cpu.c +++ b/compel/arch/ppc64/src/lib/cpu.c @@ -17,6 +17,7 @@ static bool rt_info_done = false; void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { } void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { } +int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; } int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; } int compel_cpuid(compel_cpuinfo_t *info) diff --git a/compel/arch/s390/src/lib/cpu.c b/compel/arch/s390/src/lib/cpu.c index 3f38f118d..85a074a3b 100644 --- a/compel/arch/s390/src/lib/cpu.c +++ b/compel/arch/s390/src/lib/cpu.c @@ -17,6 +17,7 @@ static bool rt_info_done = false; void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) { } void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) { } +int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; } int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) { return 0; } int compel_cpuid(compel_cpuinfo_t *info) diff --git a/compel/arch/x86/src/lib/cpu.c b/compel/arch/x86/src/lib/cpu.c index 4657f9723..722c729e2 100644 --- a/compel/arch/x86/src/lib/cpu.c +++ b/compel/arch/x86/src/lib/cpu.c @@ -67,6 +67,13 @@ int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) return 0; } +int compel_test_fpu_cap(compel_cpuinfo_t *c, unsigned int feature) +{ + if (likely(feature < XFEATURE_MAX)) + return (c->xfeatures_mask & (1UL << feature)); + return 0; +} + static int compel_fpuid(compel_cpuinfo_t *c) { unsigned int last_good_offset; diff --git a/compel/arch/x86/src/lib/include/uapi/asm/fpu.h b/compel/arch/x86/src/lib/include/uapi/asm/fpu.h index b18c91757..a32a00e9c 100644 --- a/compel/arch/x86/src/lib/include/uapi/asm/fpu.h +++ b/compel/arch/x86/src/lib/include/uapi/asm/fpu.h @@ -63,6 +63,7 @@ enum xfeature { #define XFEATURE_MASK_PT (1 << XFEATURE_PT) #define XFEATURE_MASK_PKRU (1 << XFEATURE_PKRU) #define XFEATURE_MASK_HDC (1 << XFEATURE_HDC) +#define XFEATURE_MASK_MAX (1 << XFEATURE_MAX) #define XFEATURE_MASK_FPSSE (XFEATURE_MASK_FP | XFEATURE_MASK_SSE) #define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK | XFEATURE_MASK_ZMM_Hi256 | XFEATURE_MASK_Hi16_ZMM) diff --git a/compel/include/compel-cpu.h b/compel/include/compel-cpu.h index a06b2de2e..f30afa0f9 100644 --- a/compel/include/compel-cpu.h +++ b/compel/include/compel-cpu.h @@ -7,5 +7,6 @@ extern void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature); extern void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature); extern int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature); +extern int compel_test_fpu_cap(compel_cpuinfo_t *c, unsigned int feature); #endif