[CRIU] [PATCH 06/18] compel: fpu -- Add compel_test_fpu_cap helper
Cyrill Gorcunov
gorcunov at gmail.com
Thu Jul 19 15:47:34 MSK 2018
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
compel/arch/aarch64/src/lib/cpu.c | 1 +
compel/arch/arm/src/lib/cpu.c | 1 +
compel/arch/ppc64/src/lib/cpu.c | 1 +
compel/arch/s390/src/lib/cpu.c | 1 +
compel/arch/x86/src/lib/cpu.c | 7 +++++++
compel/arch/x86/src/lib/include/uapi/asm/fpu.h | 1 +
compel/include/compel-cpu.h | 1 +
7 files changed, 13 insertions(+)
diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c
index fca699403a3e..c7573f6adef9 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 fca699403a3e..c7573f6adef9 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 0a7adcb0b786..f6d163b89f45 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 3f38f118dda7..85a074a3bab7 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 4657f9723ba6..722c729e2a74 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 b18c9175768f..a32a00e9c8ca 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 a06b2de2ec35..f30afa0f9832 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
--
2.14.4
More information about the CRIU
mailing list