Message ID | YgT9ZIEkSSWJ+YTX@monolith.localdoman (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [kvm-unit-tests,BUG] x86: debug.c compilation error with --target-efi | expand |
On Thu, Feb 10, 2022, Alexandru Elisei wrote: > When compiling kvm-unit-tests configured with --target-efi I get the following > error: > > [..] > gcc -mno-red-zone -mno-sse -mno-sse2 -fcf-protection=full -m64 -O1 -g -MMD -MF x86/.debug.d -fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body -Wuninitialized -Wignored-qualifiers -Werror -Wno-missing-braces -fno-omit-frame-pointer -fno-stack-protector -Wno-frame-address -DTARGET_EFI -maccumulate-outgoing-args -fshort-wchar -fPIC -Wclobbered -Wunused-but-set-parameter -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes -std=gnu99 -ffreestanding -I /path/to/kvm-unit-tests/lib -I /path/to/kvm-unit-tests/lib/x86 -I lib -c -o x86/debug.o x86/debug.c > ld -T /path/to/kvm-unit-tests/x86/efi/elf_x86_64_efi.lds -Bsymbolic -shared -nostdlib -o x86/debug.so \ > x86/debug.o x86/efi/efistart64.o lib/libcflat.a > ld: x86/debug.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC > make: *** [/path/to/kvm-unit-tests/x86/Makefile.common:51: x86/debug.so] Error 1 > rm x86/emulator.o x86/tsc.o x86/msr.o x86/tsc_adjust.o x86/idt_test.o x86/sieve.o x86/s3.o x86/asyncpf.o x86/rmap_chain.o x86/init.o x86/xsave.o x86/debug.o x86/pmu.o x86/kvmclock_test.o x86/pcid.o x86/umip.o x86/setjmp.o x86/eventinj.o x86/hyperv_connections.o x86/apic.o x86/dummy.o x86/hypercall.o x86/vmexit.o x86/tsx-ctrl.o x86/hyperv_synic.o x86/smap.o x86/hyperv_stimer.o x86/efi/efistart64.o x86/smptest.o > > The error does not happen if the test is not configured with --target-efi. > > I bisected the error to commit 9734b4236294 ("x86/debug: Add framework for > single-step #DB tests"). Changing the Makefile to build x86/debug.o when > !TARGET_EFI has fixed the issue for me (it might be that the inline assembly > added by the commit contains absolute addresses, but my knowledge of x86 > assembly is sketchy at best): Fix posted: https://lore.kernel.org/all/20220210092044.18808-1-zhenzhong.duan@intel.com
Hi, On Thu, Feb 10, 2022 at 05:13:43PM +0000, Sean Christopherson wrote: > On Thu, Feb 10, 2022, Alexandru Elisei wrote: > > When compiling kvm-unit-tests configured with --target-efi I get the following > > error: > > > > [..] > > gcc -mno-red-zone -mno-sse -mno-sse2 -fcf-protection=full -m64 -O1 -g -MMD -MF x86/.debug.d -fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body -Wuninitialized -Wignored-qualifiers -Werror -Wno-missing-braces -fno-omit-frame-pointer -fno-stack-protector -Wno-frame-address -DTARGET_EFI -maccumulate-outgoing-args -fshort-wchar -fPIC -Wclobbered -Wunused-but-set-parameter -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes -std=gnu99 -ffreestanding -I /path/to/kvm-unit-tests/lib -I /path/to/kvm-unit-tests/lib/x86 -I lib -c -o x86/debug.o x86/debug.c > > ld -T /path/to/kvm-unit-tests/x86/efi/elf_x86_64_efi.lds -Bsymbolic -shared -nostdlib -o x86/debug.so \ > > x86/debug.o x86/efi/efistart64.o lib/libcflat.a > > ld: x86/debug.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC > > make: *** [/path/to/kvm-unit-tests/x86/Makefile.common:51: x86/debug.so] Error 1 > > rm x86/emulator.o x86/tsc.o x86/msr.o x86/tsc_adjust.o x86/idt_test.o x86/sieve.o x86/s3.o x86/asyncpf.o x86/rmap_chain.o x86/init.o x86/xsave.o x86/debug.o x86/pmu.o x86/kvmclock_test.o x86/pcid.o x86/umip.o x86/setjmp.o x86/eventinj.o x86/hyperv_connections.o x86/apic.o x86/dummy.o x86/hypercall.o x86/vmexit.o x86/tsx-ctrl.o x86/hyperv_synic.o x86/smap.o x86/hyperv_stimer.o x86/efi/efistart64.o x86/smptest.o > > > > The error does not happen if the test is not configured with --target-efi. > > > > I bisected the error to commit 9734b4236294 ("x86/debug: Add framework for > > single-step #DB tests"). Changing the Makefile to build x86/debug.o when > > !TARGET_EFI has fixed the issue for me (it might be that the inline assembly > > added by the commit contains absolute addresses, but my knowledge of x86 > > assembly is sketchy at best): > > Fix posted: https://lore.kernel.org/all/20220210092044.18808-1-zhenzhong.duan@intel.com Thanks for the heads-up, I missed it because it didn't have kvm-unit-tests in the subject line. Thanks, Alex
diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 index a3cb75ae5868..7532de46e0fd 100644 --- a/x86/Makefile.x86_64 +++ b/x86/Makefile.x86_64 @@ -21,9 +21,9 @@ cflatobjs += lib/x86/usermode.o tests = $(TEST_DIR)/apic.$(exe) \ $(TEST_DIR)/emulator.$(exe) $(TEST_DIR)/idt_test.$(exe) \ $(TEST_DIR)/xsave.$(exe) $(TEST_DIR)/rmap_chain.$(exe) \ - $(TEST_DIR)/pcid.$(exe) $(TEST_DIR)/debug.$(exe) \ - $(TEST_DIR)/ioapic.$(exe) $(TEST_DIR)/memory.$(exe) \ - $(TEST_DIR)/pku.$(exe) $(TEST_DIR)/hyperv_clock.$(exe) + $(TEST_DIR)/pcid.$(exe) $(TEST_DIR)/ioapic.$(exe) \ + $(TEST_DIR)/memory.$(exe) $(TEST_DIR)/pku.$(exe) \ + $(TEST_DIR)/hyperv_clock.$(exe) tests += $(TEST_DIR)/syscall.$(exe) tests += $(TEST_DIR)/tscdeadline_latency.$(exe) tests += $(TEST_DIR)/intel-iommu.$(exe) @@ -43,6 +43,7 @@ ifneq ($(TARGET_EFI),y) tests += $(TEST_DIR)/access_test.$(exe) tests += $(TEST_DIR)/svm.$(exe) tests += $(TEST_DIR)/vmx.$(exe) +tests += $(TEST_DIR)/debug.$(exe) endif ifneq ($(fcf_protection_full),)