kvm: x86-32 fails to link with tdp_mmu

From: Daniel Díaz
Date: Fri Oct 23 2020 - 22:13:35 EST


Hello!

We found the following problem building torvalds/master, which
recently merged the for-linus tag from the KVM tree, when building
with gcc 7.3.0 and glibc 2.27 for x86 32-bits under OpenEmbedded:

| LD vmlinux.o
| MODPOST vmlinux.symvers
| MODINFO modules.builtin.modinfo
| GEN modules.builtin
| LD .tmp_vmlinux.kallsyms1
| arch/x86/kvm/mmu/tdp_mmu.o: In function `__handle_changed_spte':
| tdp_mmu.c:(.text+0x78a): undefined reference to `__umoddi3'
| /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/Makefile:1164:
recipe for target 'vmlinux' failed
| make[1]: *** [vmlinux] Error 1
| /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/Makefile:185:
recipe for target '__sub-make' failed
| make: *** [__sub-make] Error 2

This builds fine for x86 (64 bits) and arm (32/64 bits) with the same
toolchain. This also builds correctly (outside OpenEmbedded) with
gcc-8, gcc-9 and gcc-10 for: x86 (32/64 bits), arm (32/64 bits), MIPS,
and RISCV; and gcc-8 and gcc-9 for ARC.

We first noticed this when 0adc313c4f20 was pushed, but reverting
f9a705ad1c07 ("Merge tag 'for-linus' of
git://git.kernel.org/pub/scm/virt/kvm/kvm") brought it back into
building.

A follow-up bisection led to faaf05b00aec ("kvm: x86/mmu: Support
zapping SPTEs in the TDP MMU"). In that commit, the problematic code
was:

handle_changed_spte(kvm, as_id, iter->gfn, iter->old_spte, new_spte,
iter->level);

which was later changed by f8e144971c68 ("kvm: x86/mmu: Add access
tracking for tdp_mmu") to:

__handle_changed_spte(kvm, as_id, iter->gfn, iter->old_spte, new_spte,
iter->level);

Greetings!

Daniel Díaz
daniel.diaz@xxxxxxxxxx