[CRIU] [PATCH 08/11] compel: cpu -- Add ability to clear features

Cyrill Gorcunov gorcunov at gmail.com
Thu Jun 14 20:27:27 MSK 2018


Will need them to mask some of the features from
command line options.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 compel/arch/aarch64/src/lib/cpu.c | 18 ++++++++++++++++++
 compel/arch/arm/src/lib/cpu.c     | 18 ++++++++++++++++++
 compel/arch/ppc64/src/lib/cpu.c   | 18 ++++++++++++++++++
 compel/arch/s390/src/lib/cpu.c    | 18 ++++++++++++++++++
 compel/arch/x86/src/lib/cpu.c     | 18 ++++++++++++++++++
 compel/include/uapi/cpu.h         |  2 ++
 6 files changed, 92 insertions(+)

diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c
index 30263b3772bd..fca699403a3e 100644
--- a/compel/arch/aarch64/src/lib/cpu.c
+++ b/compel/arch/aarch64/src/lib/cpu.c
@@ -26,3 +26,21 @@ bool compel_cpu_has_feature(unsigned int feature)
 	}
 	return compel_test_cpu_cap(&rt_info, feature);
 }
+
+void compel_cpu_clear_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_clear_cpu_cap(&rt_info, feature);
+}
+
+void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	memcpy(c, &rt_info, sizeof(rt_info));
+}
diff --git a/compel/arch/arm/src/lib/cpu.c b/compel/arch/arm/src/lib/cpu.c
index 30263b3772bd..fca699403a3e 100644
--- a/compel/arch/arm/src/lib/cpu.c
+++ b/compel/arch/arm/src/lib/cpu.c
@@ -26,3 +26,21 @@ bool compel_cpu_has_feature(unsigned int feature)
 	}
 	return compel_test_cpu_cap(&rt_info, feature);
 }
+
+void compel_cpu_clear_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_clear_cpu_cap(&rt_info, feature);
+}
+
+void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	memcpy(c, &rt_info, sizeof(rt_info));
+}
diff --git a/compel/arch/ppc64/src/lib/cpu.c b/compel/arch/ppc64/src/lib/cpu.c
index 24c3c0cc6ffd..0a7adcb0b786 100644
--- a/compel/arch/ppc64/src/lib/cpu.c
+++ b/compel/arch/ppc64/src/lib/cpu.c
@@ -40,3 +40,21 @@ bool compel_cpu_has_feature(unsigned int feature)
 	}
 	return compel_test_cpu_cap(&rt_info, feature);
 }
+
+void compel_cpu_clear_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_clear_cpu_cap(&rt_info, feature);
+}
+
+void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	memcpy(c, &rt_info, sizeof(rt_info));
+}
diff --git a/compel/arch/s390/src/lib/cpu.c b/compel/arch/s390/src/lib/cpu.c
index b5c066c90eb6..3f38f118dda7 100644
--- a/compel/arch/s390/src/lib/cpu.c
+++ b/compel/arch/s390/src/lib/cpu.c
@@ -40,3 +40,21 @@ bool cpu_has_feature(unsigned int feature)
 	}
 	return compel_test_cpu_cap(&rt_info, feature);
 }
+
+void compel_cpu_clear_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_clear_cpu_cap(&rt_info, feature);
+}
+
+void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	memcpy(c, &rt_info, sizeof(rt_info));
+}
diff --git a/compel/arch/x86/src/lib/cpu.c b/compel/arch/x86/src/lib/cpu.c
index f8d5e1ba3801..93e430face6f 100644
--- a/compel/arch/x86/src/lib/cpu.c
+++ b/compel/arch/x86/src/lib/cpu.c
@@ -233,3 +233,21 @@ bool compel_cpu_has_feature(unsigned int feature)
 	}
 	return compel_test_cpu_cap(&rt_info, feature);
 }
+
+void compel_cpu_clear_feature(unsigned int feature)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	return compel_clear_cpu_cap(&rt_info, feature);
+}
+
+void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c)
+{
+	if (!rt_info_done) {
+		compel_cpuid(&rt_info);
+		rt_info_done = true;
+	}
+	memcpy(c, &rt_info, sizeof(rt_info));
+}
diff --git a/compel/include/uapi/cpu.h b/compel/include/uapi/cpu.h
index 4268b6c4f48c..3799595852b0 100644
--- a/compel/include/uapi/cpu.h
+++ b/compel/include/uapi/cpu.h
@@ -7,5 +7,7 @@
 
 extern int compel_cpuid(compel_cpuinfo_t *info);
 extern bool compel_cpu_has_feature(unsigned int feature);
+extern void compel_cpu_clear_feature(unsigned int feature);
+extern void compel_cpu_copy_cpuinfo(compel_cpuinfo_t *c);
 
 #endif /* UAPI_COMPEL_CPU_H__ */
-- 
2.14.4



More information about the CRIU mailing list