Blame test/integration/rhel-8.1/module.patch

Packit Service da4517
From 08078d00ab1749a6f84148a00d8d26572af4ec97 Mon Sep 17 00:00:00 2001
Packit Service da4517
Message-Id: <08078d00ab1749a6f84148a00d8d26572af4ec97.1586900628.git.jpoimboe@redhat.com>
Packit Service da4517
From: Josh Poimboeuf <jpoimboe@redhat.com>
Packit Service da4517
Date: Tue, 14 Apr 2020 15:17:51 -0500
Packit Service da4517
Subject: [PATCH] kpatch module integration test
Packit Service da4517
Packit Service da4517
This tests several things related to the patching of modules:
Packit Service da4517
Packit Service da4517
- 'kpatch_string' tests the referencing of a symbol which is outside the
Packit Service da4517
  .o, but inside the patch module.
Packit Service da4517
Packit Service da4517
- alternatives patching (.altinstructions)
Packit Service da4517
Packit Service da4517
- paravirt patching (.parainstructions)
Packit Service da4517
Packit Service da4517
- jump labels (5.8+ kernels only) -- including dynamic printk
Packit Service da4517
Packit Service da4517
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Packit Service da4517
---
Packit Service da4517
 fs/nfsd/export.c         | 30 ++++++++++++++++++++++++++++++
Packit Service da4517
 net/netlink/af_netlink.c |  5 +++++
Packit Service da4517
 2 files changed, 35 insertions(+)
Packit Service da4517
Packit Service da4517
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
Packit Service da4517
index a1143f7c2201..253c15ad82b2 100644
Packit Service da4517
--- a/fs/nfsd/export.c
Packit Service da4517
+++ b/fs/nfsd/export.c
Packit Service da4517
@@ -1196,15 +1196,45 @@ static void exp_flags(struct seq_file *m, int flag, int fsid,
Packit Service da4517
 	}
Packit Service da4517
 }
Packit Service da4517
 
Packit Service da4517
+#include <linux/version.h>
Packit Service da4517
+extern char *kpatch_string(void);
Packit Service da4517
+
Packit Service da4517
 static int e_show(struct seq_file *m, void *p)
Packit Service da4517
 {
Packit Service da4517
 	struct cache_head *cp = p;
Packit Service da4517
 	struct svc_export *exp = container_of(cp, struct svc_export, h);
Packit Service da4517
 	struct cache_detail *cd = m->private;
Packit Service da4517
+#ifdef CONFIG_X86_64
Packit Service da4517
+	unsigned long long sched_clock;
Packit Service da4517
+
Packit Service da4517
+	alternative("ud2", "call yield", X86_FEATURE_ALWAYS);
Packit Service da4517
+	alternative("call yield", "ud2", X86_FEATURE_IA64);
Packit Service da4517
+
Packit Service da4517
+	sched_clock = paravirt_sched_clock();
Packit Service da4517
+	if (!jiffies)
Packit Service da4517
+		printk("kpatch: sched_clock: %llu\n", sched_clock);
Packit Service da4517
+#endif
Packit Service da4517
+
Packit Service da4517
+	pr_debug("kpatch: pr_debug() test\n");
Packit Service da4517
+
Packit Service da4517
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
Packit Service da4517
+{
Packit Service da4517
+	static DEFINE_STATIC_KEY_TRUE(kpatch_key);
Packit Service da4517
+
Packit Service da4517
+	if (static_branch_unlikely(&mcsafe_key))
Packit Service da4517
+		printk("kpatch: mcsafe_key\n");
Packit Service da4517
+
Packit Service da4517
+	BUG_ON(!static_branch_likely(&kpatch_key));
Packit Service da4517
+	static_branch_disable(&kpatch_key);
Packit Service da4517
+	BUG_ON(static_branch_likely(&kpatch_key));
Packit Service da4517
+	static_branch_enable(&kpatch_key);
Packit Service da4517
+}
Packit Service da4517
+#endif
Packit Service da4517
 
Packit Service da4517
 	if (p == SEQ_START_TOKEN) {
Packit Service da4517
 		seq_puts(m, "# Version 1.1\n");
Packit Service da4517
 		seq_puts(m, "# Path Client(Flags) # IPs\n");
Packit Service da4517
+		seq_puts(m, kpatch_string());
Packit Service da4517
 		return 0;
Packit Service da4517
 	}
Packit Service da4517
 
Packit Service da4517
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
Packit Service da4517
index 44fa4ea5df76..dc36ec2901b8 100644
Packit Service da4517
--- a/net/netlink/af_netlink.c
Packit Service da4517
+++ b/net/netlink/af_netlink.c
Packit Service da4517
@@ -2809,4 +2809,9 @@ static int __init netlink_proto_init(void)
Packit Service da4517
 	panic("netlink_init: Cannot allocate nl_table\n");
Packit Service da4517
 }
Packit Service da4517
 
Packit Service da4517
+char *kpatch_string(void)
Packit Service da4517
+{
Packit Service da4517
+	return "# kpatch\n";
Packit Service da4517
+}
Packit Service da4517
+
Packit Service da4517
 core_initcall(netlink_proto_init);
Packit Service da4517
-- 
Packit Service da4517
2.21.1
Packit Service da4517