[Devel] [PATCH vz7] cpuid_fault: Log table updates

Cyrill Gorcunov gorcunov at virtuozzo.com
Mon May 7 19:34:54 MSK 2018


Updating cpuid_fault table is actually critical in terms
of container migration (migrating with criu involves two
stages: cpu matching and migration itself). If someone
third side involves into cpuid_fault modification the
migration may fail and we get not even a sign of what
happened.

Thus to track cpuid_fault modifications simplier lets
logs this action.

 | [  186.708138] cpuid_override: 0x00000001: 0x000506e3 0x07100800 0x009ae3fd 0xbfebfbff
 | [  186.715823] cpuid_override: 0x00000007 0x00000000: 0x00000000 0x00000000 0x00000000 0x00000000
 | [  186.724427] cpuid_override: 0x0000000d 0x00000001: 0x00000000 0x000003c0 0x00000100 0x00000000
 | [  186.733093] cpuid_override: 0x80000001: 0x00000000 0x00000000 0x00000001 0x2c100800
 | [  186.740746] cpuid_override: 0x80000007: 0x00000000 0x00000000 0x00000000 0x00000100
 | [  186.748469] cpuid_override: 0x80000008: 0x00003027 0x00000000 0x00000000 0x00000000

In a sake of https://jira.sw.ru/browse/PSBM-84029

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 arch/x86/kernel/cpuid_fault.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Index: linux-pcs7.git/arch/x86/kernel/cpuid_fault.c
===================================================================
--- linux-pcs7.git.orig/arch/x86/kernel/cpuid_fault.c
+++ linux-pcs7.git/arch/x86/kernel/cpuid_fault.c
@@ -13,6 +13,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/notifier.h>
+#include <linux/ratelimit.h>
 #include <linux/reboot.h>
 #include <linux/ve.h>
 #include <asm/uaccess.h>
@@ -61,6 +62,35 @@ void set_cpuid_faulting(bool enable)
 }
 EXPORT_SYMBOL(set_cpuid_faulting);
 
+static void cpuid_override_info(struct cpuid_override_table  *t)
+{
+	char buf[128];
+	size_t pos;
+
+	if (!t) {
+		pr_info_ratelimited("cpuid_override: flushed\n");
+		return;
+	}
+
+	rcu_read_lock();
+	for (pos = 0; pos < t->size; pos++) {
+		struct cpuid_override_entry *e = &t->entries[pos];
+		if (e->has_count) {
+			snprintf(buf, sizeof(buf),
+				 "cpuid_override: 0x%08x 0x%08x: "
+				 "0x%08x 0x%08x 0x%08x 0x%08x",
+				 e->op, e->count, e->eax, e->ebx, e->ecx, e->edx);
+		} else {
+			snprintf(buf, sizeof(buf),
+				 "cpuid_override: 0x%08x: "
+				 "0x%08x 0x%08x 0x%08x 0x%08x",
+				 e->op, e->eax, e->ebx, e->ecx, e->edx);
+		}
+		pr_info_ratelimited("%s\n", buf);
+	}
+	rcu_read_unlock();
+}
+
 static void cpuid_override_update(struct cpuid_override_table *new_table)
 {
 	struct cpuid_override_table *old_table;
@@ -70,6 +100,8 @@ static void cpuid_override_update(struct
 	rcu_assign_pointer(cpuid_override, new_table);
 	spin_unlock(&cpuid_override_lock);
 
+	cpuid_override_info(new_table);
+
 	if (old_table)
 		kfree_rcu(old_table, rcu_head);
 }


More information about the Devel mailing list