From d25af82cc05b9f98d6be7ce4623aaa1381a156ab Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 19 Jul 2018 15:47:36 +0300 Subject: [PATCH] compel: fpu -- Add compel_fpu_feature_size Signed-off-by: Cyrill Gorcunov Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Andrei Vagin --- compel/arch/aarch64/src/lib/cpu.c | 9 +++++++++ compel/arch/arm/src/lib/cpu.c | 9 +++++++++ compel/arch/ppc64/src/lib/cpu.c | 9 +++++++++ compel/arch/s390/src/lib/cpu.c | 9 +++++++++ compel/arch/x86/src/lib/cpu.c | 12 ++++++++++++ compel/include/uapi/cpu.h | 2 ++ 6 files changed, 50 insertions(+) diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c index 38d9cbf4e..e82988879 100644 --- a/compel/arch/aarch64/src/lib/cpu.c +++ b/compel/arch/aarch64/src/lib/cpu.c @@ -37,6 +37,15 @@ bool compel_fpu_has_feature(unsigned int feature) return compel_test_fpu_cap(&rt_info, feature); } +uint32_t compel_fpu_feature_size(unsigned int feature) +{ + if (!rt_info_done) { + compel_cpuid(&rt_info); + rt_info_done = true; + } + return 0; +} + void compel_cpu_clear_feature(unsigned int feature) { if (!rt_info_done) { diff --git a/compel/arch/arm/src/lib/cpu.c b/compel/arch/arm/src/lib/cpu.c index 38d9cbf4e..e82988879 100644 --- a/compel/arch/arm/src/lib/cpu.c +++ b/compel/arch/arm/src/lib/cpu.c @@ -37,6 +37,15 @@ bool compel_fpu_has_feature(unsigned int feature) return compel_test_fpu_cap(&rt_info, feature); } +uint32_t compel_fpu_feature_size(unsigned int feature) +{ + if (!rt_info_done) { + compel_cpuid(&rt_info); + rt_info_done = true; + } + return 0; +} + void compel_cpu_clear_feature(unsigned int feature) { if (!rt_info_done) { diff --git a/compel/arch/ppc64/src/lib/cpu.c b/compel/arch/ppc64/src/lib/cpu.c index 27a21a53a..a9be1fd6b 100644 --- a/compel/arch/ppc64/src/lib/cpu.c +++ b/compel/arch/ppc64/src/lib/cpu.c @@ -51,6 +51,15 @@ bool compel_fpu_has_feature(unsigned int feature) return compel_test_fpu_cap(&rt_info, feature); } +uint32_t compel_fpu_feature_size(unsigned int feature) +{ + if (!rt_info_done) { + compel_cpuid(&rt_info); + rt_info_done = true; + } + return 0; +} + void compel_cpu_clear_feature(unsigned int feature) { if (!rt_info_done) { diff --git a/compel/arch/s390/src/lib/cpu.c b/compel/arch/s390/src/lib/cpu.c index 97ab809b8..bb32affe8 100644 --- a/compel/arch/s390/src/lib/cpu.c +++ b/compel/arch/s390/src/lib/cpu.c @@ -51,6 +51,15 @@ bool compel_fpu_has_feature(unsigned int feature) return compel_test_fpu_cap(&rt_info, feature); } +uint32_t compel_fpu_feature_size(unsigned int feature) +{ + if (!rt_info_done) { + compel_cpuid(&rt_info); + rt_info_done = true; + } + return 0; +} + void compel_cpu_clear_feature(unsigned int feature) { if (!rt_info_done) { diff --git a/compel/arch/x86/src/lib/cpu.c b/compel/arch/x86/src/lib/cpu.c index 85a936299..dd5524d81 100644 --- a/compel/arch/x86/src/lib/cpu.c +++ b/compel/arch/x86/src/lib/cpu.c @@ -454,6 +454,18 @@ bool compel_fpu_has_feature(unsigned int feature) return compel_test_fpu_cap(&rt_info, feature); } +uint32_t compel_fpu_feature_size(unsigned int feature) +{ + if (!rt_info_done) { + compel_cpuid(&rt_info); + rt_info_done = true; + } + if (feature >= FIRST_EXTENDED_XFEATURE && + feature < XFEATURE_MAX) + return rt_info.xstate_sizes[feature]; + return 0; +} + void compel_cpu_clear_feature(unsigned int feature) { if (!rt_info_done) { diff --git a/compel/include/uapi/cpu.h b/compel/include/uapi/cpu.h index d858a0b46..c82f8abb6 100644 --- a/compel/include/uapi/cpu.h +++ b/compel/include/uapi/cpu.h @@ -2,12 +2,14 @@ #define UAPI_COMPEL_CPU_H__ #include +#include #include extern int compel_cpuid(compel_cpuinfo_t *info); extern bool compel_cpu_has_feature(unsigned int feature); extern bool compel_fpu_has_feature(unsigned int feature); +extern uint32_t compel_fpu_feature_size(unsigned int feature); extern void compel_cpu_clear_feature(unsigned int feature); extern void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c);