[kvm-unit-tests BUG] x86: debug.c compilation error with --target-efi

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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):

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),)

For reference:

$ gcc --version
gcc (GCC) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat config.mak
SRCDIR=/path/to/kvm-unit-tests
PREFIX=/usr/local
HOST=x86_64
ARCH=x86_64
ARCH_NAME=x86_64
PROCESSOR=x86_64
CC=gcc
CFLAGS=
LD=ld
OBJCOPY=objcopy
OBJDUMP=objdump
AR=ar
ADDR2LINE=addr2line
TEST_DIR=x86
TEST_SUBDIR=x86/efi
FIRMWARE=
ENDIAN=
PRETTY_PRINT_STACKS=yes
ENVIRON_DEFAULT=yes
ERRATATXT=/path/to/kvm-unit-tests/errata.txt
U32_LONG_FMT=
WA_DIVIDE=
GENPROTIMG=genprotimg
HOST_KEY_DOCUMENT=
TARGET_EFI=y
GEN_SE_HEADER=

Thanks,
Alex



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux