From 611c044d13b527a9ce152382716ea6ac71cf4959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Kosti=C4=87?= Date: Fri, 6 Nov 2026 14:26:44 +0100 Subject: [PATCH] test/integration: add target module reload test case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a regression test for an upstream kernel fix commit 37251c7114e1b743b077ca74b93557c1ad92a97e: powerpc/module_64: Fix "expected nop" error on module re-patching When a module with a livepatched function is unloaded and then reloaded, klp attempts to dynamically re-patch it. On ppc64, that fails with the following error: module_64: livepatch_nfsd: Expected nop after call, got e8410018 at e_show+0x60/0x548 [livepatch_nfsd] livepatch: failed to initialize patch 'livepatch_nfsd' for module 'nfsd' (-8) livepatch: patch 'livepatch_nfsd' failed for module 'nfsd', refusing to load module 'nfsd' The error happens because the restore r2 instructionhad already previously been written into the klp module's replacement function when the original function was patched the first time. So the instruction wasn't a nop as expected. When the restore r2 instruction has already been patched in, detect that and skip the warning and the instruction write. Signed-off-by: Josh Poimboeuf Reviewed-by: Petr Mladek Acked-by: Song Liu Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/2f6329ffd9674df6ff57e03edeb2ca54414770ab.1674617130.git.jpoimboe@kernel.org Signed-off-by: Marko Kostić --- .packit.yml | 52 ++----------------- .../rhel-9.8/target-module-reload-LOADED.test | 22 ++++++++ .../rhel-9.8/target-module-reload.patch | 23 ++++++++ 3 files changed, 50 insertions(+), 47 deletions(-) create mode 100755 test/integration/rhel-9.8/target-module-reload-LOADED.test create mode 100644 test/integration/rhel-9.8/target-module-reload.patch diff --git a/.packit.yml b/.packit.yml index aa6f2795..e1b820a0 100644 --- a/.packit.yml +++ b/.packit.yml @@ -1,3 +1,4 @@ +--- _: common-upstream-kernel-test-config: &common-upstream-kernel-test-config job: tests @@ -30,66 +31,23 @@ _: identifier: "integration-rhel" use_internal_tf: true targets: - epel-8-x86_64: - distros: [RHEL-8.10.0-Nightly, RHEL-8.8.0-Nightly, RHEL-8.6.0-Nightly, RHEL-8.4.0-Nightly] epel-9-x86_64: - distros: [RHEL-9.9.0-Nightly, RHEL-9.8.0-Nightly, RHEL-9.7.0-Nightly, RHEL-9.6.0-Nightly, RHEL-9.4.0-Nightly, RHEL-9.2.0-Nightly, RHEL-9.0.0-Nightly] - epel-8-ppc64le: - distros: [RHEL-8.10.0-Nightly, RHEL-8.8.0-Nightly, RHEL-8.6.0-Nightly, RHEL-8.4.0-Nightly] + distros: [RHEL-9.8.0-Nightly] epel-9-ppc64le: - distros: [RHEL-9.9.0-Nightly, RHEL-9.8.0-Nightly, RHEL-9.7.0-Nightly, RHEL-9.6.0-Nightly, RHEL-9.4.0-Nightly, RHEL-9.2.0-Nightly, RHEL-9.0.0-Nightly] - rhel+epel-10-s390x: - distros: [RHEL-10.3-Nightly, RHEL-10.2-Nightly] - rhel+epel-10-ppc64le: - distros: [RHEL-10.3-Nightly, RHEL-10.2-Nightly] - rhel+epel-10-aarch64: - distros: [RHEL-10.3-Nightly, RHEL-10.2-Nightly] + distros: [RHEL-9.8.0-Nightly] skip_build: true manual_trigger: false tmt_plan: kpatch-integration-rhel/kernel$ fmf_url: https://gitlab.com/redhat/centos-stream/tests/kernel/test-plans.git fmf_ref: main - common-rhel-64k-test-config: &common-rhel-64k-test-config - job: tests - branch: master - identifier: "integration-rhel-64k" - use_internal_tf: true - targets: - rhel+epel-10-aarch64: - distros: [RHEL-10.3-Nightly] - skip_build: true - manual_trigger: false - tmt_plan: kpatch-integration-rhel/kernel-64k$ - fmf_url: https://gitlab.com/redhat/centos-stream/tests/kernel/test-plans.git - fmf_ref: main - jobs: - - <<: *common-upstream-kernel-test-config - trigger: pull_request - labels: - - integration-pr - - - <<: *common-upstream-kernel-test-config - trigger: commit - labels: - - integration-commit - - - <<: *common-rhel-test-config + - !!merge <<: *common-rhel-test-config trigger: pull_request labels: - integration-pr - - <<: *common-rhel-test-config - trigger: commit - labels: - - integration-commit - - - <<: *common-rhel-64k-test-config - trigger: pull_request - labels: - - integration-pr - - <<: *common-rhel-64k-test-config + - !!merge <<: *common-rhel-test-config trigger: commit labels: - integration-commit diff --git a/test/integration/rhel-9.8/target-module-reload-LOADED.test b/test/integration/rhel-9.8/target-module-reload-LOADED.test new file mode 100755 index 00000000..8f580c84 --- /dev/null +++ b/test/integration/rhel-9.8/target-module-reload-LOADED.test @@ -0,0 +1,22 @@ +#!/bin/bash + +set -o errexit + +# Clean slate: +sudo systemctl stop nfs-server rpcbind 2>/dev/null || true +sudo umount /proc/fs/nfsd 2>/dev/null || true + +# 1. Initial load & check +sudo modprobe nfsd +sleep 2 +grep -q kpatch /proc/fs/nfs/exports + +# 2. Target module reload +sudo systemctl stop nfs-server rpcbind 2>/dev/null || true +sudo umount /proc/fs/nfsd 2>/dev/null || true +sudo modprobe -r nfsd + +# 3. Final load & check +sudo modprobe nfsd +sleep 2 +grep -q kpatch /proc/fs/nfs/exports diff --git a/test/integration/rhel-9.8/target-module-reload.patch b/test/integration/rhel-9.8/target-module-reload.patch new file mode 100644 index 00000000..68fe862c --- /dev/null +++ b/test/integration/rhel-9.8/target-module-reload.patch @@ -0,0 +1,23 @@ +diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c +--- a/fs/nfsd/export.c ++++ b/fs/nfsd/export.c +@@ -1409,6 +1409,7 @@ static void exp_flags(struct seq_file *m, int flag, int fsid, + } + } + ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + static int e_show(struct seq_file *m, void *p) + { + struct cache_head *cp = p; +@@ -1416,8 +1417,11 @@ static int e_show(struct seq_file *m, void *p) + struct cache_detail *cd = m->private; + bool export_stats = is_export_stats_file(m); + ++ pr_info("kpatch: e_show patched\n"); ++ + if (p == SEQ_START_TOKEN) { + seq_puts(m, "# Version 1.1\n"); ++ seq_puts(m, "# kpatch\n"); + if (export_stats) + seq_puts(m, "# Path Client Start-time\n#\tStats\n"); + else