[Devel] [PATCH RH9 18/22] x86/cpuid_fault: Log table updates
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Thu Oct 7 13:57:42 MSK 2021
From: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
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>
Cherry-picked from vz7 commit
395ea929dbce ("cpuid_fault: Log table updates")
https://jira.sw.ru/browse/PSBM-126172
Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
(cherry picked from vz8 commit 6436f0d177fb4cbfba916150324cdcebc1f21d4f)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
arch/x86/kernel/cpuid_fault.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/arch/x86/kernel/cpuid_fault.c b/arch/x86/kernel/cpuid_fault.c
index e48ebe2..3f892e0 100644
--- a/arch/x86/kernel/cpuid_fault.c
+++ b/arch/x86/kernel/cpuid_fault.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <linux/ratelimit.h>
#include <linux/ve.h>
#include <linux/veowner.h>
#include <asm/uaccess.h>
@@ -21,6 +22,35 @@
struct cpuid_override_table __rcu *cpuid_override __read_mostly;
static DEFINE_SPINLOCK(cpuid_override_lock);
+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);
+ }
+ printk(KERN_INFO "%s\n", buf);
+ }
+ rcu_read_unlock();
+}
+
static void cpuid_override_update(struct cpuid_override_table *new_table)
{
struct cpuid_override_table *old_table;
@@ -30,6 +60,8 @@ static void cpuid_override_update(struct cpuid_override_table *new_table)
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);
}
--
1.8.3.1
More information about the Devel
mailing list