kpatch/test/integration/rhel-8.4/module.patch
Joe Lawrence fed5786932 integration: add rhel-8.4
Rebased to kernel-4.18.0-304.el8.

Note: since RHEL-8.4 dropped klp.arch support, we can now re-enable
those tests that reference static keys defined in vmlinux.

Also, adjust for adjust for ppc64le inlining:

Building gcc-static-local-var-4.patch on ppc64le results in test
failure, as the kpatch .ko now contains a 'free_ioctx' symbol (the test
expects to NOT see one).

From the build log:

  aio.o: changed function: free_ioctx
  aio.o: new function: put_aio_ring_file      << now un-inlined?
  aio.o: changed function: aio_free_ring
  aio.o: changed function: ioctx_alloc
  aio.o: changed function: aio_prep_rw
  aio.o: changed function: aio_read_events
  aio.o: new function: kpatch_aio_foo         << expected new function

and a source code change to free_ioctx():

  % diff -upr \
       <(objdump -D -j .text.free_ioctx ~/.kpatch/tmp/orig/fs/aio.o) \
       <(objdump -D -j .text.free_ioctx ~/.kpatch/tmp/patched/fs/aio.o)

  --- /dev/fd/63  2020-10-26 14:28:18.086236019 -0400
  +++ /dev/fd/62  2020-10-26 14:28:18.086236019 -0400
  @@ -1,5 +1,5 @@

  -/root/.kpatch/tmp/orig/fs/aio.o:     file format elf64-powerpcle
  +/root/.kpatch/tmp/patched/fs/aio.o:     file format elf64-powerpcle

   Disassembly of section .text.free_ioctx:
  @@ -53,7 +53,7 @@ Disassembly of section .text.free_ioctx:
     b0:  00 00 82 3c     addis   r4,r2,0
     b4:  00 00 84 e8     ld      r4,0(r4)
     b8:  78 fb e6 7f     mr      r6,r31
  -  bc:  e0 00 63 38     addi    r3,r3,224
  +  bc:  38 00 63 38     addi    r3,r3,56
     c0:  01 00 00 48     bl      c0 <free_ioctx+0xb8>
     c4:  00 00 00 60     nop
     c8:  70 ff ff 4b     b       38 <free_ioctx+0x30>

Marking put_aio_ring_file() as __always_inline keeps the r3 / 224
offset value, leaving free_ioctx() unchanged.  Since it's no longer
included in the resulting .ko, gcc-static-local-var-4.test will pass
once again.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2021-04-20 11:40:59 -04:00

86 lines
2.5 KiB
Diff

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