Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/integration/common/multiple.template
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 4 additions & 1 deletion test/integration/kpatch-test
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ else
done
fi

# export envs for test progs
export KPATCH

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should supercede the assignment here:

KPATCH="sudo $ROOTDIR/kpatch/kpatch"
so the multiple.test cases would honor the flags added by 78f2c063ae91f to allow the user control over which kpatch tools is used.

In that case, the assignment in multiple.template can be removed and I think it should percolate down to that test just as it did for the new one in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed KPATCH assignment in multiple.template.

error() {
echo "ERROR: $*" |tee -a $LOG >&2
ERROR=$((ERROR + 1))
Expand Down Expand Up @@ -383,7 +386,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
Expand Down
20 changes: 20 additions & 0 deletions test/integration/linux-5.10.11/data-reloc.patch
Original file line number Diff line number Diff line change
@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't seem to build this patch, I get this error,

ERROR: ir-usb.o: 1 function(s) can not be patched
ir-usb.o: WARNING: unable to correlate static local variable funcs.20 used by ir_startup, assuming variable is new
ir-usb.o: function irda_usb_dump_class_desc.isra.0 doesn't have patchable function entry, unable to patch
/root/github-kpatch/kpatch-build/create-diff-object: unreconcilable difference

Here are my versions, probably something is compiling slightly different for me:
gcc: gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)
ld: GNU ld version 2.35.2-17.el9
kernel tree: amazon-arm-livepatch-v5.10
kpatch-build: surajjs95-arm64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm not ready for gcc11 environment yet. I will check it as soon as it is ready.

Copy link
Contributor Author

@keiya-nobuta keiya-nobuta Feb 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not get this error with gcc11 of ubuntu21.04.
I can prepare rhel-9 at my workplace, so I will try it this week.

my versions:
gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0
ld (GNU Binutils for Ubuntu) 2.37
kernel tree: https://github.com/sm00th/linux/tree/kpatch/aarch64
kpatch-build: https://github.com/joe-lawrence/kpatch/tree/arm64-rebase

5 changes: 5 additions & 0 deletions test/integration/linux-5.10.11/data-reloc.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sudo modprobe usb_wwan
sudo modprobe ir-usb
sleep 5

$KPATCH load test-data-reloc.ko
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our integration test scripts could stand to be more robust, but a similar one:
https://github.com/dynup/kpatch/blob/master/test/integration/rhel-8.4/module-LOADED.test sets errexit as well as adds a sleep 5 to give time for the incoming modules to settle. This is hardly bulletproof, but easy to avoid (probably) most false negatives from errors/races:

set -o errexit
...
sudo modprobe nfsd
sleep 5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added sleep 5 after modprobes