kpatch-build: fix find_parent_obj KVM shortcut for all arches - #1520
kpatch-build: fix find_parent_obj KVM shortcut for all arches#1520jexbow wants to merge 1 commit into
Conversation
|
Thanks, @jexbow two really small nits:
|
The find_parent_obj() shortcut for virt/kvm files hardcoded arch/x86/kvm, which only worked when targeting x86. On other architectures the parent object lookup for KVM files would fail, falling through to a deep (and slow) search. Instead of adding per-arch if blocks, consolidate the TARGET_ARCH -> kernel source arch mapping into the existing helper, renaming it to kernel_src_arch() and extending it to cover all kpatch-supported architectures (x86, arm64, powerpc, s390, loongarch). The shortcut then simplifies to: find_parent_obj_in_dir "$file" "arch/$(kernel_src_arch "$TARGET_ARCH")/kvm" This also fixes a latent issue in the old helper, which only mapped aarch64 -> arm64 and passed x86_64/ppc64le/s390x/loongarch64 through unchanged (kernel "make ARCH=" expects the source arch name). Fixes: dynup#1519 Signed-off-by: liangliang luo <11797624+jexbow@users.noreply.github.com>
1468511 to
035562b
Compare
|
Thanks @joe-lawrence, both make sense.
Just force-pushed the update (amended commit) with the Signed-off-by line. |
|
Thanks @jpoimboe for the review! And thanks again @joe-lawrence for the suggestion to consolidate the arch mapping — that made the fix much cleaner. |
Summary
The
find_parent_obj()shortcut forvirt/kvm/*files hardcodesarch/x86/kvm, which only works when the target arch is x86. On every other architecture the parent-object lookup for KVM files misses the shortcut and falls through to a deep (and slow) full-tree search — and as reported in #1519, on arm64 it can even miss the parent entirely.Instead of adding per-arch
ifblocks, derive the arch-specific KVM directory from$TARGET_ARCH. The kpatchTARGET_ARCHvalues don't always match the kernel arch directory names, so a small mapping is needed:x86_64arch/x86/kvmaarch64arch/arm64/kvmppc64learch/powerpc/kvms390xarch/s390/kvmloongarch64arch/loongarch/kvmVerification
All kpatch-supported arches build the common KVM code from
virt/kvm/(v4.19: arm64/x86/s390/powerpc useKVM=../../../virt/kvmin their KVM Makefiles; modern kernels setKVM ?= ../../../virt/kvminvirt/kvm/Makefile.kvm; loongarch follows the same pattern). So thevirt/kvm/*shortcut now correctly maps to the right arch directory on every supported arch.Tested only on arm64 (4.19 kernel, gcc 8.2) — I don't have hardware for the other arches, but the change is mechanical and the mapping table above is complete.
Fixes: #1519