[Devel] [PATCH RHEL8 COMMIT] x86/cpuid_fault: Log table updates
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Apr 13 19:56:13 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.12
------>
commit 3ff5e479286b9f4cf20e31d55ca48aa784caa03f
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date: Tue Apr 13 19:56:13 2021 +0300
x86/cpuid_fault: Log table updates
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>
---
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 2093b6bfe71f..8a1e624fcc0d 100644
--- a/arch/x86/kernel/cpuid_fault.c
+++ b/arch/x86/kernel/cpuid_fault.c
@@ -6,6 +6,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 <linux/uaccess.h>
@@ -13,6 +14,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;
@@ -22,6 +52,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);
}
More information about the Devel
mailing list