From 7b04a3f7c3fae22fb6ad1b6d3257c3f3f6f7364d Mon Sep 17 00:00:00 2001 From: Keiya Nobuta Date: Mon, 20 Dec 2021 11:47:26 +0900 Subject: [PATCH 1/3] test: Change grep "Call Trace" with -i x86 dmesg displays "Call Trace", but other architectures (for example arm64) may display "Call trace". So change grep with ignore case sensitive. Signed-off-by: Keiya Nobuta --- test/integration/kpatch-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/kpatch-test b/test/integration/kpatch-test index 688ab1dea..20edfda2a 100755 --- a/test/integration/kpatch-test +++ b/test/integration/kpatch-test @@ -383,7 +383,7 @@ if [ "${DYNDEBUG_ENABLED}" == "1" ]; then sudo sh -c "echo \"func klp_try_switch_task ${prev_dyndebug}\" > ${DYNDEBUG_CONTROL} 2>/dev/null" fi -if new_dmesg | grep -q "Call Trace"; then +if new_dmesg | grep -q -i "Call Trace"; then new_dmesg > dmesg.log error "kernel error detected in printk buffer" fi From 7d761679878640b5d8b41a88ed2b57ce6ef3ee28 Mon Sep 17 00:00:00 2001 From: Keiya Nobuta Date: Wed, 16 Feb 2022 19:07:55 +0900 Subject: [PATCH 2/3] test: Export $KPATCH for test programs Signed-off-by: Keiya Nobuta --- test/integration/common/multiple.template | 1 - test/integration/kpatch-test | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/integration/common/multiple.template b/test/integration/common/multiple.template index 678279c45..169d69636 100755 --- a/test/integration/common/multiple.template +++ b/test/integration/common/multiple.template @@ -1,6 +1,5 @@ SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" ROOTDIR="$(readlink -f $SCRIPTDIR/../../..)" -KPATCH="sudo $ROOTDIR/kpatch/kpatch" MODULE_PREFIX="test-" MODULE_POSTFIX=".ko" diff --git a/test/integration/kpatch-test b/test/integration/kpatch-test index 20edfda2a..c2a51664d 100755 --- a/test/integration/kpatch-test +++ b/test/integration/kpatch-test @@ -119,6 +119,9 @@ else done fi +# export envs for test progs +export KPATCH + error() { echo "ERROR: $*" |tee -a $LOG >&2 ERROR=$((ERROR + 1)) From 15581571271f6fc87f52bad1f39be6ccfb713a84 Mon Sep 17 00:00:00 2001 From: Keiya Nobuta Date: Sun, 20 Feb 2022 16:46:43 +0900 Subject: [PATCH 3/3] test: Add data relocation test This patch adds a test case that the klp-module has a `.klp.rela...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 --- .../linux-5.10.11/data-reloc.patch | 20 +++++++++++++++++++ .../integration/linux-5.10.11/data-reloc.test | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 test/integration/linux-5.10.11/data-reloc.patch create mode 100755 test/integration/linux-5.10.11/data-reloc.test diff --git a/test/integration/linux-5.10.11/data-reloc.patch b/test/integration/linux-5.10.11/data-reloc.patch new file mode 100644 index 000000000..c7bbd0f78 --- /dev/null +++ b/test/integration/linux-5.10.11/data-reloc.patch @@ -0,0 +1,20 @@ +diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c +index 172261a908d8..4fdd666cc75a 100644 +--- a/drivers/usb/serial/ir-usb.c ++++ b/drivers/usb/serial/ir-usb.c +@@ -194,10 +194,15 @@ static u8 ir_xbof_change(u8 xbof) + return(result); + } + ++#include "usb-wwan.h" + static int ir_startup(struct usb_serial *serial) + { + struct usb_irda_cs_descriptor *irda_desc; + int rates; ++ volatile int i = 0; ++ static volatile void *funcs[] = {usb_wwan_open, usb_wwan_close}; ++ ++ printk("kpatch: usb_wwan_open=%p\n", funcs[i]); + + irda_desc = irda_usb_find_class_desc(serial, 0); + if (!irda_desc) { diff --git a/test/integration/linux-5.10.11/data-reloc.test b/test/integration/linux-5.10.11/data-reloc.test new file mode 100755 index 000000000..540e37370 --- /dev/null +++ b/test/integration/linux-5.10.11/data-reloc.test @@ -0,0 +1,5 @@ +sudo modprobe usb_wwan +sudo modprobe ir-usb +sleep 5 + +$KPATCH load test-data-reloc.ko