AMDESE / AMDSEV

AMD Secure Encrypted Virtualization
272 stars 84 forks source link

Failed when using build.sh to build qemu branch "snp-latest" #172

Closed LouXiaoxuan closed 10 months ago

LouXiaoxuan commented 11 months ago

Using build.sh to build and install qemu under the branch of "snp-latest" is failed. This is the error message:

[2014/2763] Compiling C object libqemu-x86_64-softmmu.fa.p/target_i386_cpu-sysemu.c.o
FAILED: libqemu-x86_64-softmmu.fa.p/target_i386_cpu-sysemu.c.o 
cc -m64 -mcx16 -Ilibqemu-x86_64-softmmu.fa.p -I. -I.. -Itarget/i386 -I../target/i386 -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -isystem /home/xiaoxuan/serverless/official-sev-codes/AMDSEV/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/xiaoxuan/serverless/official-sev-codes/AMDSEV/qemu -iquote /home/xiaoxuan/serverless/official-sev-codes/AMDSEV/qemu/include -iquote /home/xiaoxuan/serverless/official-sev-codes/AMDSEV/qemu/tcg/i386 -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIE -isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="x86_64-softmmu-config-target.h"' '-DCONFIG_DEVICES="x86_64-softmmu-config-devices.h"' -MD -MQ libqemu-x86_64-softmmu.fa.p/target_i386_cpu-sysemu.c.o -MF libqemu-x86_64-softmmu.fa.p/target_i386_cpu-sysemu.c.o.d -o libqemu-x86_64-softmmu.fa.p/target_i386_cpu-sysemu.c.o -c ../target/i386/cpu-sysemu.c
In file included from /home/xiaoxuan/serverless/official-sev-codes/AMDSEV/qemu/linux-headers/linux/kvm.h:15,
                 from /home/xiaoxuan/serverless/official-sev-codes/AMDSEV/qemu/include/sysemu/kvm.h:25,
                 from ../target/i386/kvm/kvm_i386.h:14,
                 from ../target/i386/cpu-sysemu.c:24:
linux-headers/asm/kvm.h:509:3: error: expected specifier-qualifier-list before ‘__DECLARE_FLEX_ARRAY’
  509 |   __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx);
      |   ^~~~~~~~~~~~~~~~~~~~

After checking the code of qemu branch "snp-latest", I found that __DECLARE_FLEX_ARRAY used in qemu/linux-headers/asm-x86/kvm.h is not declared in whole project.

How can I solve this problem?

tlendacky commented 11 months ago

It looks like the kernel on which you are building qemu isn't new enough to support the latest version of qemu. Can you try building and installing just the kernel first (including the header files) and then trying to building qemu after rebooting into the new kernel?

LouXiaoxuan commented 11 months ago

Thanks for your prompt response. Currently, I removed __DECLARE_FLEX_ARRAY from the qemu/linux-headers/asm-x86/kvm.h:

union {
        struct kvm_vmx_nested_state_data vmx[0];
        struct kvm_svm_nested_state_data svm[0];
        //__DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx);
        //__DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm);
    } data;

After that, the qemu can be built correctly, even the backwards-compatability seems to be lost.