intel / tdx-linux

GNU General Public License v2.0
18 stars 3 forks source link

Compile TDX Kernel Error #2

Closed DiWangShePi closed 3 months ago

DiWangShePi commented 5 months ago

I'm compiling the kernel for the TDX VM and server based on the instructions from this repository. The kernel I used is:

https://github.com/torvalds/linux/tree/v6.6-rc2

After obtaining the complete files, I used the patch files in this repository to patch the kernel:

for patchfile in ~/tdx-linux/kernel-patch/kernel_patch-breakdown/*.patch; do
    patch -p1 < "$patchfile"
done

Subsequently, I tried to generate a .config file, but due to the lack of relevant instructions in this repository, I referred to the configuration files in branch tdx-1.0 and tdx-1.5 under this repository:

https://github.com/intel/tdx-tools

After that, I used the make -j$(getconf _NPROCESSORS_ONLN) LOCALVERSION="-tdx" deb-pkg command and encountered the following error:

make[5]: *** [Makefile:1913:.] error 2
make[4]: *** [Makefile:359:__build_one_by_one] error 2
make[3]: *** [debian/rules:25:build-arch] error 2
dpkg-buildpackage: error: make -f debian/rules binary subprocess returned exit status 2
make[2]: *** [scripts/Makefile.package:146:deb-pkg] error 2
make[1]: *** [/home/gulu/Desktop/Intel-TDX/linux-6.6-rc2/Makefile:1538:deb-pkg] error 2
make: *** [Makefile:234:__sub-make] error 2

Which seems to indicates that error occurs while executing command make -f debian/rules, so I execute this command in the same location, and got the following result:

arch/x86/hyperv/ivm.c:387:16: error: variable ‘args’ has initializer but incomplete type
  387 |         struct tdx_hypercall_args args = {
      |                ^~~~~~~~~~~~~~~~~~
arch/x86/hyperv/ivm.c:388:18: error: ‘struct tdx_hypercall_args’ has no member named ‘r10’
  388 |                 .r10 = TDX_HYPERCALL_STANDARD,
      |                  ^~~
...
arch/x86/hyperv/ivm.c:389:18: error: ‘struct tdx_hypercall_args’ has no member named ‘r11’
  389 |                 .r11 = EXIT_REASON_MSR_WRITE,
      |   
...
arch/x86/hyperv/ivm.c:390:18: error: ‘struct tdx_hypercall_args’ has no member named ‘r12’
  390 |                 .r12 = msr,
      |                  ^~~
arch/x86/hyperv/ivm.c:390:24: warning: excess elements in struct initializer
  390 |                 .r12 = msr,
      |                        ^~~
arch/x86/hyperv/ivm.c:390:24: note: (near initialization for ‘args’)
arch/x86/hyperv/ivm.c:391:18: error: ‘struct tdx_hypercall_args’ has no member named ‘r13’
  391 |                 .r13 = val,
      |                  ^~~
arch/x86/hyperv/ivm.c:391:24: warning: excess elements in struct initializer
  391 |                 .r13 = val,
      |                        ^~~
arch/x86/hyperv/ivm.c:391:24: note: (near initialization for ‘args’)
arch/x86/hyperv/ivm.c:387:35: error: storage size of ‘args’ isn’t known
  387 |         struct tdx_hypercall_args args = {
      |                                   ^~~~
arch/x86/hyperv/ivm.c:387:35: warning: unused variable ‘args’ [-Wunused-variable]
arch/x86/hyperv/ivm.c: In function ‘hv_tdx_msr_read’:
arch/x86/hyperv/ivm.c:401:16: error: variable ‘args’ has initializer but incomplete type
  401 |         struct tdx_hypercall_args args = {
      |                ^~~~~~~~~~~~~~~~~~
arch/x86/hyperv/ivm.c:402:18: error: ‘struct tdx_hypercall_args’ has no member named ‘r10’
  402 |                 .r10 = TDX_HYPERCALL_STANDARD,
      |                  ^~~

It looks like this has to do with the implementation of the TDX part, I'm not quite sure if I'm missing a patch or have the wrong environment configured(Ubuntu 22.04). I have no problem compiling TDVF and QEMU following the instructions in the wiki section of this repository. Would appreciate any help :pray::pray::pray:

fyin1 commented 3 months ago

Sorry for late response.

This build issue is related with hyper-V guest support. Please refer https://github.com/intel/tdx-linux/wiki/Instruction-to-set-up-TDX-host-and-guest#kernel-configuration-for-tdx-support

      +- Microsoft Hyper-V guest support [N]

The build issue was fixed in upstream hyper-v after 6.6 kernel.