Skip to content

Commit 01cc87e

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. Modifications to drivers/usb/serial/bus.c are not directly related to the purpose of this test, but are necessary for testing with the data-reloc-LOADED.test. Signed-off-by: Keiya Nobuta <nobuta.keiya@fujitsu.com>
1 parent a9b82fe commit 01cc87e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sudo modprobe usb_wwan
2+
sudo modprobe ir-usb
3+
4+
cat /sys/bus/usb-serial/drivers/generic/new_id | grep "kpatch"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
2+
index eb0195cf37dd..79c2df488b5a 100644
3+
--- a/drivers/usb/serial/bus.c
4+
+++ b/drivers/usb/serial/bus.c
5+
@@ -137,9 +137,7 @@ static ssize_t new_id_store(struct device_driver *driver,
6+
7+
static ssize_t new_id_show(struct device_driver *driver, char *buf)
8+
{
9+
- struct usb_serial_driver *usb_drv = to_usb_serial_driver(driver);
10+
-
11+
- return usb_show_dynids(&usb_drv->dynids, buf);
12+
+ return snprintf(buf, PAGE_SIZE, "kpatch\n");
13+
}
14+
static DRIVER_ATTR_RW(new_id);
15+
16+
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
17+
index 172261a908d8..4fdd666cc75a 100644
18+
--- a/drivers/usb/serial/ir-usb.c
19+
+++ b/drivers/usb/serial/ir-usb.c
20+
@@ -194,10 +194,15 @@ static u8 ir_xbof_change(u8 xbof)
21+
return(result);
22+
}
23+
24+
+#include "usb-wwan.h"
25+
static int ir_startup(struct usb_serial *serial)
26+
{
27+
struct usb_irda_cs_descriptor *irda_desc;
28+
int rates;
29+
+ volatile int i = 0;
30+
+ static volatile void *funcs[] = {usb_wwan_open, usb_wwan_close};
31+
+
32+
+ printk("kpatch: usb_wwan_open=%p\n", funcs[i]);
33+
34+
irda_desc = irda_usb_find_class_desc(serial, 0);
35+
if (!irda_desc) {

0 commit comments

Comments
 (0)