Description of problem: kernel-selftests测试套livepatch下边五个用例,因为dmsg 打印了增加了一行 livepatch: signaling remaining tasks导致的失败,过滤掉这一行后可以运行成功: 失败日志如下: # ./test-ftrace.sh TEST: livepatch interaction with ftrace_enabled sysctl ... not ok --- expected +++ result @@ -14,12 +14,14 @@ livepatch: kernel.ftrace_enabled = 1 livepatch: enabling patch 'test_klp_livepatch' livepatch: 'test_klp_livepatch': initializing patching transition livepatch: 'test_klp_livepatch': starting patching transition +livepatch: signaling remaining tasks livepatch: 'test_klp_livepatch': completing patching transition livepatch: 'test_klp_livepatch': patching complete livepatch: sysctl: setting key "kernel.ftrace_enabled": Device or resource busy % echo 0 > /sys/kernel/livepatch/test_klp_livepatch/enabled livepatch: 'test_klp_livepatch': initializing unpatching transition livepatch: 'test_klp_livepatch': starting unpatching transition +livepatch: signaling remaining tasks livepatch: 'test_klp_livepatch': completing unpatching transition livepatch: 'test_klp_livepatch': unpatching complete % rmmod test_klp_livepatch ERROR: livepatch kselftest(s) failed How reproducible: 必现 Steps to Reproduce: wget 内核对应src.rpm包 rpm -ivh xxx.src.rpm 默认安装到/root下 yum install yum-utils yum-builddep -y /root/rpmbuild/SPECS/kernel.spec 自动安装前置依赖包 需要yum-utils rpmbuild -bp /root/rpmbuild/SPECS/kernel.spec # 这个步骤会打相关的patch, 解压缩tar包,生成BUILD目录 cd /root/rpmbuild/BUILD/kernel-*/linux-* make -C tools/testing/selftests/ cd /root/rpmbuild/BUILD/kernel-*/linux-*/tools/testing/selftests/livepatch make ./test-callbacks.sh ./test-ftrace.sh ./test-livepatch.sh ./test-sysfs.sh ./test-state.sh Actual results: 用例中desmg打印多一条导致的失败 Expected results: 用例执行pass Additional info: [环境信息] ECS # uname -r 6.6.88-cbp.git.1432012a7.an23.aarch64 # free -h total used free shared buff/cache available Mem: 15Gi 884Mi 8.2Gi 7.2Mi 6.2Gi 14Gi Swap: 0B 0B 0B # lscpu Architecture: aarch64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 48 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Vendor ID: ARM BIOS Vendor ID: Alibaba Cloud Model name: Neoverse-N1 BIOS Model name: virt-rhel7.6.0 CPU @ 2.0GHz BIOS CPU family: 1 Model: 1 Thread(s) per core: 1 Core(s) per cluster: 4 Socket(s): 1 Cluster(s): 1 Stepping: r3p1 BogoMIPS: 50.00 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0-3 Vulnerabilities: Gather data sampling: Not affected Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Not affected Reg file data sampling: Not affected Retbleed: Not affected Spec rstack overflow: Not affected Spec store bypass: Not affected Spectre v1: Mitigation; __user pointer sanitization Spectre v2: Mitigation; CSV2, but not BHB Srbds: Not affected Tsx async abort: Not affected
修改functions.sh中function check_result函数: function check_result { local expect="$*" local result # Note: when comparing dmesg output, the kernel log timestamps # help differentiate repeated testing runs. Remove them with a # post-comparison sed filter. result=$(dmesg | comm --nocheck-order -13 "$SAVED_DMESG" - | \ grep -e 'livepatch:' -e 'test_klp' | \ grep -v '\(tainting\|taints\) kernel' | grep -v 'livepatch: signaling remaining tasks' | \ sed 's/^\[[ 0-9.]*\] //') if [[ "$expect" == "$result" ]] ; then echo "ok" else echo -e "not ok\n\n$(diff -upr --label expected --label result <(echo "$expect") <(echo "$result"))\n" die "livepatch kselftest(s) failed" fi cleanup_dmesg_file } 按照如上修改,用例均执行通过,在此记录下