ccc-certifier-framework / certifier-framework-for-confidential-computing

The Confidential Computing Certifier Framework consists of a client API called the Certifier-API and server-based policy evaluation called the Certifier Service. It simplifies and unifies programming and operations support for multi-vendor Confidential Computing platforms by providing support for scalable, policy-driven trust management including
Apache License 2.0
52 stars 16 forks source link

CI: make in ./sev-snp-simulator dir fails with fatal error: passing argument 1 of ‘class_create’ from incompatible pointer type #242

Open gapisback opened 4 months ago

gapisback commented 4 months ago

CI Job for PR #241 fails with following hard error:

make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-1018-azure'
rm -f modules.order Module.symvers Module.markers *.o *.cmd sevnull.ko
rm -rf keys
make -C /lib/modules/6.5.0-1018-azure/build M=/home/runner/work/certifier-framework-for-confidential-computing/certifier-framework-for-confidential-computing/sev-snp-simulator modules
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-1018-azure'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
  You are using:           gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
  CC [M]  /home/runner/work/certifier-framework-for-confidential-computing/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.o
In file included from ./include/linux/linkage.h:7,
                 from ./arch/x86/include/asm/cache.h:5,
                 from ./include/linux/cache.h:6,
                 from ./include/linux/time.h:5,
                 from ./include/linux/stat.h:19,
                 from ./include/linux/module.h:13,
                 from /home/runner/work/certifier-framework-for-confidential-computing/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.c:14:
/home/runner/work/certifier-framework-for-confidential-computing/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.c: In function ‘sev_guest_init_module’:
./include/linux/export.h:29:22: error: passing argument 1 of ‘class_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   29 | #define THIS_MODULE (&__this_module)
      |                     ~^~~~~~~~~~~~~~~
      |                      |
      |                      struct module *
/home/runner/work/certifier-framework-for-confidential-computing/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.c:355:28: note: in expansion of macro ‘THIS_MODULE’
  355 |   sev_class = class_create(THIS_MODULE, DEVICE_NAME);
      |                            ^~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:251: /home/runner/work/certifier-framework-for-confidential-computing/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.5.0-1018-azure/Makefile:2039: /home/runner/work/certifier-framework-for-confidential-computing/certifier-framework-for-confidential-computing/sev-snp-simulator] Error 2
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-1018-azure'
make: *** [Makefile:22: modules] Error 2

CI's build.yml specifies: runs-on: ubuntu-latest

I am able to reproduce this on my Linux-VM running: Ubuntu 22.04.4 LTS jammy

Somethings seem to have changed in Linux system / include files. By default, if you do the following:

$ cd ./sev-snp-simulator

$ make

This will fail with:

agurajada-Linux-Vm:[31] $ make
make -C /lib/modules/6.5.0-27-generic/build M=/home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator modules
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-27-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  You are using:
  CC [M]  /home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.o
/bin/sh: 1: gcc-12: not found
make[3]: *** [scripts/Makefile.build:251: /home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.o] Error 127
make[2]: *** [/usr/src/linux-headers-6.5.0-27-generic/Makefile:2039: /home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator] Error 2

Fix this by installing gcc-12 (for whatever reasons): $ sudo apt-get install -y gcc-12

Upon re-run this make command now fails with the same signature of failure as seen in CI job:

agurajada-Linux-Vm:[43] $ make
make -C /lib/modules/6.5.0-27-generic/build M=/home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator modules
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-27-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  You are using:           gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  CC [M]  /home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.o
In file included from ./include/linux/linkage.h:7,
                 from ./arch/x86/include/asm/cache.h:5,
                 from ./include/linux/cache.h:6,
                 from ./include/linux/time.h:5,
                 from ./include/linux/stat.h:19,
                 from ./include/linux/module.h:13,
                 from /home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.c:14:
/home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.c: In function ‘sev_guest_init_module’:
./include/linux/export.h:29:22: error: passing argument 1 of ‘class_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   29 | #define THIS_MODULE (&__this_module)
      |                     ~^~~~~~~~~~~~~~~
      |                      |
      |                      struct module *
/home/agurajada/Projects/certifier-framework-for-confidential-computing/sev-snp-simulator/sevguest.c:355:28: note: in expansion of macro ‘THIS_MODULE’
  355 |   sev_class = class_create(THIS_MODULE, DEVICE_NAME);
      |                            ^~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
cc1: some warnings being treated as errors
gapisback commented 4 months ago

Hi, @rgerganov @yelvmw -- can you help give this issue a fresh look?

This is a brand-new failure happening in CI when I started a PR to merge some doc-changes. Before I do some deep-dive investigation, would like a quick cross-check from your Linux env.

From my initial investigation, it appears that some Linux system / headers interfaces have changed.

If you have an active Linux-VM on which this CFCC repo was building correctly before, can you please try the following out and let me know how it works?

(Cut-n-paste your outputs here as a reply, so it's publicly visible.)

cd ./sev-snp-simulator
make

This used to build just fine previously.

If you run into an error that /bin/sh: 1: gcc-12: not found, I "worked-around it" by installing gcc-12, as: sudo apt-get install -y gcc-12.

But I am not sure why that should even be necessary.

gapisback commented 4 months ago

History: The last successful PR that was merged into this repo was in Dec 2023 (PR #232), after which this repo was moved to CCC's ci-infra.

So, that might be one cause for the drift in Linux rev-levels, triggering some build issue.

yelvmw commented 4 months ago

Looks like a kernel 6.4 change to API. We might want to try this:

+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
   sev_class = class_create(THIS_MODULE, DEVICE_NAME);
+#else
+  sev_class = class_create(DEVICE_NAME);
+#endif
yelvmw commented 4 months ago

I'm actually not sure about the exact version. Got some hints from discussions elsewhere. Can you confirm the CI environment kernel version?

gapisback commented 4 months ago

Thanks for the tip, @yelvmw, that looks promising. -- I'll work on this after Sangwan checks-in his Islet-cleanup PR.

Will let you know what I find out about Linux kernel version.