Skip to content

Commit 77d0d68

Browse files
committed
test: Add data relocation test
This patch adds a test case that the klp-module has a `.klp.rela.<module name>..rodata.<...>` section. This pattern can be an error if architecture-specific relocation in the kernel does not fully support Livepatch. The prerequisite for this test is that CONFIG_USB_SERIAL_IR=m and CONFIG_USB_SERIAL_WWAN=m are set. In the patched-modules, ir-usb.ko's static local variables refers to usb_wwan.ko's symbols, so `.klp.rela.ir-usb..rodata.<...>` section are generated into test-data-reloc.ko. Signed-off-by: Keiya Nobuta <nobuta.keiya@fujitsu.com>
1 parent 7d76167 commit 77d0d68

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
2+
index 172261a908d8..4fdd666cc75a 100644
3+
--- a/drivers/usb/serial/ir-usb.c
4+
+++ b/drivers/usb/serial/ir-usb.c
5+
@@ -194,10 +194,15 @@ static u8 ir_xbof_change(u8 xbof)
6+
return(result);
7+
}
8+
9+
+#include "usb-wwan.h"
10+
static int ir_startup(struct usb_serial *serial)
11+
{
12+
struct usb_irda_cs_descriptor *irda_desc;
13+
int rates;
14+
+ volatile int i = 0;
15+
+ static volatile void *funcs[] = {usb_wwan_open, usb_wwan_close};
16+
+
17+
+ printk("kpatch: usb_wwan_open=%p\n", funcs[i]);
18+
19+
irda_desc = irda_usb_find_class_desc(serial, 0);
20+
if (!irda_desc) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sudo modprobe usb_wwan
2+
sudo modprobe ir-usb
3+
msleep 5
4+
5+
$KPATCH load test-data-reloc.ko

0 commit comments

Comments
 (0)