]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - init/main.c
Merge branch 'for-5.11-null-console' into for-linus
[thirdparty/linux.git] / init / main.c
index b3fcf446f99e6a55f3c5f1560f1f5692c9c1fb24..08cd3a52a7e8d7e38117e32640666af947f5f98f 100644 (file)
 #define CREATE_TRACE_POINTS
 #include <trace/events/initcall.h>
 
+#include <kunit/test.h>
+
 static int kernel_init(void *);
 
 extern void init_IRQ(void);
@@ -267,14 +269,24 @@ static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum)
        u32 size, csum;
        char *data;
        u32 *hdr;
+       int i;
 
        if (!initrd_end)
                return NULL;
 
        data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN;
-       if (memcmp(data, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN))
-               return NULL;
+       /*
+        * Since Grub may align the size of initrd to 4, we must
+        * check the preceding 3 bytes as well.
+        */
+       for (i = 0; i < 4; i++) {
+               if (!memcmp(data, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN))
+                       goto found;
+               data--;
+       }
+       return NULL;
 
+found:
        hdr = (u32 *)(data - 8);
        size = hdr[0];
        csum = hdr[1];
@@ -1519,6 +1531,8 @@ static noinline void __init kernel_init_freeable(void)
 
        do_basic_setup();
 
+       kunit_run_all_tests();
+
        console_on_rootfs();
 
        /*