seL4 / capdl

Capability Distribution Language tools for seL4
https://sel4.systems
35 stars 46 forks source link

capdl/capdl-loader-app/src/main.c:1522:27: error: ‘memory_region’ undeclared (first use in this function) #72

Open hugusmaximus opened 3 months ago

hugusmaximus commented 3 months ago

I'm getting this error while compiling this file as part of this project (https://docs.sel4.systems/projects/sel4webserver/). This is the error:

[30/79] Building C object CMakeFiles/capdl-loader.dir/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c.obj
FAILED: CMakeFiles/capdl-loader.dir/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c.obj 
/usr/bin/ccache /usr/bin/aarch64-linux-gnu-gcc --sysroot=/home/hugo/sel4_linux_guest_qemu_virt/build  -I/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/sel4runtime/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/sel4runtime/include/mode/64 -I/home/hugo/sel4_linux_guest_qemu_virt/projects/sel4runtime/include/arch/arm -I/home/hugo/sel4_linux_guest_qemu_virt/projects/sel4runtime/include/sel4_arch/aarch64 -I/home/hugo/sel4_linux_guest_qemu_virt/kernel/libsel4/include -I/home/hugo/sel4_linux_guest_qemu_virt/kernel/libsel4/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/kernel/libsel4/sel4_arch_include/aarch64 -I/home/hugo/sel4_linux_guest_qemu_virt/kernel/libsel4/sel4_plat_include/qemu-arm-virt -I/home/hugo/sel4_linux_guest_qemu_virt/kernel/libsel4/mode_include/64 -I/home/hugo/sel4_linux_guest_qemu_virt/build/libsel4/include -I/home/hugo/sel4_linux_guest_qemu_virt/build/libsel4/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/build/libsel4/sel4_arch_include/aarch64 -I/home/hugo/sel4_linux_guest_qemu_virt/build/libsel4/autoconf -I/home/hugo/sel4_linux_guest_qemu_virt/build/kernel/gen_config -I/home/hugo/sel4_linux_guest_qemu_virt/build/libsel4/gen_config -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libcpio/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4platsupport/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4platsupport/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4platsupport/plat_include/qemu-arm-virt -I/home/hugo/sel4_linux_guest_qemu_virt/build/musllibc/build-temp/stage/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4simple/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4simple/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libutils/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libutils/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/build/util_libs/libutils/gen_config -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4vka/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4vka/sel4_arch_include/aarch64 -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4vka/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/build/seL4_libs/libsel4vka/gen_config -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4debug/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4debug/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4debug/sel4_arch_include/aarch64 -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4vspace/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4vspace/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/build/seL4_libs/libsel4utils/gen_config -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libplatsupport/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libplatsupport/plat_include/qemu-arm-virt -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libplatsupport/sel4_arch_include/aarch64 -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libplatsupport/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libfdt/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libfdt/. -I/home/hugo/sel4_linux_guest_qemu_virt/build/util_libs/libplatsupport/gen_config -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4simple-default/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4utils/include -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4utils/sel4_arch_include/aarch64 -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4utils/arch_include/arm -I/home/hugo/sel4_linux_guest_qemu_virt/projects/util_libs/libelf/include -I/home/hugo/sel4_linux_guest_qemu_virt/build/capdl/capdl-loader-app/gen_config -I/home/hugo/sel4_linux_guest_qemu_virt/projects/seL4_libs/libsel4muslcsys/include -I/home/hugo/sel4_linux_guest_qemu_virt/build/seL4_libs/libsel4muslcsys/gen_config -march=armv8-a  -D__KERNEL_64__ -g -nostdinc -fno-pic -fno-pie -fno-stack-protector -fno-asynchronous-unwind-tables -ftls-model=local-exec -mstrict-align -mno-outline-atomics -std=gnu11 -MD -MT CMakeFiles/capdl-loader.dir/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c.obj -MF CMakeFiles/capdl-loader.dir/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c.obj.d -o CMakeFiles/capdl-loader.dir/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c.obj -c /home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c
/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c: In function ‘map_page’:
/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c:1522:27: error: ‘memory_region’ undeclared (first use in this function)
 1522 |         if (addr.paddr >= memory_region[0].start && addr.paddr <= memory_region[0].end) {
      |                           ^~~~~~~~~~~~~
/home/hugo/sel4_linux_guest_qemu_virt/projects/capdl/capdl-loader-app/src/main.c:1522:27: note: each undeclared identifier is reported only once for each function it appears in
ninja: build stopped: subcommand failed.

Any hint?

hugusmaximus commented 3 months ago

Not sure if this breaks something, but commenting this:

//#ifdef CONFIG_ARCH_ARM
        /* When seL4 creates a new frame object it zeroes the associated memory
         * through a cached kernel mapping. If we are configuring a cached
         * mapping for the target, standard coherence protocols ensure
         * everything works as expected. However, if we are configuring an
         * uncached mapping for the target, the dirty zero data cached from the
         * kernel's mapping is likely flushed to memory at some time in the
         * future causing an unpleasant surprise for the target whose own
         * uncached writes are mysteriously overwritten. To prevent this, we
         * unify the mapping here, flushing the cached data from the kernel's
         * mapping.
         */
/*
        seL4_Word size_bits = spec->objects[page].size_bits;
        assert(size_bits <= sizeof(uintptr_t) * CHAR_BIT - 1 && "illegal object size");

        seL4_ARCH_Page_GetAddress_t addr = seL4_ARCH_Page_GetAddress(sel4_page);
        if (addr.paddr >= memory_region[0].start && addr.paddr <= memory_region[0].end) {
            if (!(vm_attribs & seL4_ARM_PageCacheable) && CDL_Obj_Paddr(&spec->objects[page]) == 0) {
                error = seL4_ARM_Page_CleanInvalidate_Data(sel4_page, 0, BIT(size_bits));
                ZF_LOGF_IFERR(error, "");
            }

            if (seL4_CapRights_get_capAllowGrant(rights)) {
                error = seL4_ARM_Page_Unify_Instruction(sel4_page, 0, BIT(size_bits));
                ZF_LOGF_IFERR(error, "");
            }
        }
#endif
*/

allowed me to finish compilation and my image boots correctly:

ELF-loader started on CPU: ARM Ltd. Cortex-A53 r0p4
  paddr=[622f4000..63ebc0d7]
No DTB passed in from boot loader.
Looking for DTB in CPIO archive...found at 623f6100.
Loaded DTB from 623f6100.
   paddr=[60242000..60243fff]
ELF-loading image 'kernel' to 60000000
  paddr=[60000000..60241fff]
  vaddr=[8060000000..8060241fff]
  virt_entry=8060000000
ELF-loading image 'capdl-loader' to 60244000
  paddr=[60244000..61efcfff]
  vaddr=[400000..20b8fff]
  virt_entry=408c30
Enabling hypervisor MMU and paging
Jumping to kernel-image entry point...

Bootstrapping kernel
available phys memory regions: 1
  [60000000..c0000000]
reserved virt address space regions: 3
  [8060000000..8060242000]
  [8060242000..8060243ed8]
  [8060244000..8061efd000]
Booting all finished, dropped to user space
<<seL4(CPU 0) [decodeUntypedInvocation/205 T0x80bf817400 "rootserver" @4006f8]: Untyped Retype: Insufficient memory (1 * 2097152 bytes needed, 0 bytes available).>>
clean_up@fdtgen.c:374 Non-existing node /platform@c000000 specified to be kept
install_vm_devices@main.c:704 module name: map_frame_hack
install_vm_devices@main.c:704 module name: init_ram
install_vm_devices@main.c:704 module name: cross_vm_connections
Loading Kernel: 'linux'
Loading Initrd: 'linux-initrd'
Loading Generated DTB
OnDemandInstall: Created RAM-backed memory for addr 0x8020000
OnDemandInstall: Created device-backed memory for addr 0x9000000
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 4.19.320-ExploitChance (hugo@anakin) (gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)) #3 SMP Wed Aug 21 18:17:01 UTC 2024

(...)

Welcome to Buildroot
buildroot login: root
# uname -a
Linux buildroot 4.19.320-ExploitChance #3 SMP Wed Aug 21 18:17:01 UTC 2024 aarch64 GNU/Linux