main.c (97acb6a8fcc4e5c2cdc2693a35acdc5a7461aaa3) | main.c (3c206509826094e85ead0b056f484db96829248d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/init/main.c 4 * 5 * Copyright (C) 1991, 1992 Linus Torvalds 6 * 7 * GK 2/5/95 - Changed to support mounting root fs via NFS 8 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96 --- 20 unchanged lines hidden (view full) --- 29#include <linux/memblock.h> 30#include <linux/acpi.h> 31#include <linux/bootconfig.h> 32#include <linux/console.h> 33#include <linux/nmi.h> 34#include <linux/percpu.h> 35#include <linux/kmod.h> 36#include <linux/kprobes.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/init/main.c 4 * 5 * Copyright (C) 1991, 1992 Linus Torvalds 6 * 7 * GK 2/5/95 - Changed to support mounting root fs via NFS 8 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96 --- 20 unchanged lines hidden (view full) --- 29#include <linux/memblock.h> 30#include <linux/acpi.h> 31#include <linux/bootconfig.h> 32#include <linux/console.h> 33#include <linux/nmi.h> 34#include <linux/percpu.h> 35#include <linux/kmod.h> 36#include <linux/kprobes.h> |
37#include <linux/kmsan.h> |
|
37#include <linux/vmalloc.h> 38#include <linux/kernel_stat.h> 39#include <linux/start_kernel.h> 40#include <linux/security.h> 41#include <linux/smp.h> 42#include <linux/profile.h> 43#include <linux/kfence.h> 44#include <linux/rcupdate.h> --- 67 unchanged lines hidden (view full) --- 112#include <trace/events/initcall.h> 113 114#include <kunit/test.h> 115 116static int kernel_init(void *); 117 118extern void init_IRQ(void); 119extern void radix_tree_init(void); | 38#include <linux/vmalloc.h> 39#include <linux/kernel_stat.h> 40#include <linux/start_kernel.h> 41#include <linux/security.h> 42#include <linux/smp.h> 43#include <linux/profile.h> 44#include <linux/kfence.h> 45#include <linux/rcupdate.h> --- 67 unchanged lines hidden (view full) --- 113#include <trace/events/initcall.h> 114 115#include <kunit/test.h> 116 117static int kernel_init(void *); 118 119extern void init_IRQ(void); 120extern void radix_tree_init(void); |
121extern void maple_tree_init(void); |
|
120 121/* 122 * Debug helper: via this flag we know that we are in 'early bootup code' 123 * where only the boot processor is running with IRQ disabled. This means 124 * two things - IRQ must not be enabled before the flag is cleared and some 125 * operations which are not allowed with IRQ disabled are allowed while the 126 * flag is set. 127 */ --- 703 unchanged lines hidden (view full) --- 831 /* 832 * page_ext requires contiguous pages, 833 * bigger than MAX_ORDER unless SPARSEMEM. 834 */ 835 page_ext_init_flatmem(); 836 init_mem_debugging_and_hardening(); 837 kfence_alloc_pool(); 838 report_meminit(); | 122 123/* 124 * Debug helper: via this flag we know that we are in 'early bootup code' 125 * where only the boot processor is running with IRQ disabled. This means 126 * two things - IRQ must not be enabled before the flag is cleared and some 127 * operations which are not allowed with IRQ disabled are allowed while the 128 * flag is set. 129 */ --- 703 unchanged lines hidden (view full) --- 833 /* 834 * page_ext requires contiguous pages, 835 * bigger than MAX_ORDER unless SPARSEMEM. 836 */ 837 page_ext_init_flatmem(); 838 init_mem_debugging_and_hardening(); 839 kfence_alloc_pool(); 840 report_meminit(); |
841 kmsan_init_shadow(); |
|
839 stack_depot_early_init(); 840 mem_init(); 841 mem_init_print_info(); 842 kmem_cache_init(); 843 /* 844 * page_owner must be initialized after buddy is ready, and also after 845 * slab is ready so that stack_depot_init() works properly 846 */ 847 page_ext_init_flatmem_late(); 848 kmemleak_init(); 849 pgtable_init(); 850 debug_objects_mem_init(); 851 vmalloc_init(); | 842 stack_depot_early_init(); 843 mem_init(); 844 mem_init_print_info(); 845 kmem_cache_init(); 846 /* 847 * page_owner must be initialized after buddy is ready, and also after 848 * slab is ready so that stack_depot_init() works properly 849 */ 850 page_ext_init_flatmem_late(); 851 kmemleak_init(); 852 pgtable_init(); 853 debug_objects_mem_init(); 854 vmalloc_init(); |
855 /* Should be run after vmap initialization */ 856 if (early_page_ext_enabled()) 857 page_ext_init(); |
|
852 /* Should be run before the first non-init thread is created */ 853 init_espfix_bsp(); 854 /* Should be run after espfix64 is set up. */ 855 pti_init(); | 858 /* Should be run before the first non-init thread is created */ 859 init_espfix_bsp(); 860 /* Should be run after espfix64 is set up. */ 861 pti_init(); |
862 kmsan_init_runtime(); |
|
856} 857 858#ifdef CONFIG_RANDOMIZE_KSTACK_OFFSET 859DEFINE_STATIC_KEY_MAYBE_RO(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, 860 randomize_kstack_offset); 861DEFINE_PER_CPU(u32, kstack_offset); 862 863static int __init early_randomize_kstack_offset(char *buf) --- 133 unchanged lines hidden (view full) --- 997 * time - but meanwhile we still have a functioning scheduler. 998 */ 999 sched_init(); 1000 1001 if (WARN(!irqs_disabled(), 1002 "Interrupts were enabled *very* early, fixing it\n")) 1003 local_irq_disable(); 1004 radix_tree_init(); | 863} 864 865#ifdef CONFIG_RANDOMIZE_KSTACK_OFFSET 866DEFINE_STATIC_KEY_MAYBE_RO(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, 867 randomize_kstack_offset); 868DEFINE_PER_CPU(u32, kstack_offset); 869 870static int __init early_randomize_kstack_offset(char *buf) --- 133 unchanged lines hidden (view full) --- 1004 * time - but meanwhile we still have a functioning scheduler. 1005 */ 1006 sched_init(); 1007 1008 if (WARN(!irqs_disabled(), 1009 "Interrupts were enabled *very* early, fixing it\n")) 1010 local_irq_disable(); 1011 radix_tree_init(); |
1012 maple_tree_init(); |
|
1005 1006 /* 1007 * Set up housekeeping before setting up workqueues to allow the unbound 1008 * workqueue to take non-housekeeping into account. 1009 */ 1010 housekeeping_init(); 1011 1012 /* --- 428 unchanged lines hidden (view full) --- 1441 1442 return ret; 1443} 1444 1445static noinline void __init kernel_init_freeable(void); 1446 1447#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX) 1448bool rodata_enabled __ro_after_init = true; | 1013 1014 /* 1015 * Set up housekeeping before setting up workqueues to allow the unbound 1016 * workqueue to take non-housekeeping into account. 1017 */ 1018 housekeeping_init(); 1019 1020 /* --- 428 unchanged lines hidden (view full) --- 1449 1450 return ret; 1451} 1452 1453static noinline void __init kernel_init_freeable(void); 1454 1455#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX) 1456bool rodata_enabled __ro_after_init = true; |
1457 1458#ifndef arch_parse_debug_rodata 1459static inline bool arch_parse_debug_rodata(char *str) { return false; } 1460#endif 1461 |
|
1449static int __init set_debug_rodata(char *str) 1450{ | 1462static int __init set_debug_rodata(char *str) 1463{ |
1451 if (strtobool(str, &rodata_enabled)) | 1464 if (arch_parse_debug_rodata(str)) 1465 return 0; 1466 1467 if (str && !strcmp(str, "on")) 1468 rodata_enabled = true; 1469 else if (str && !strcmp(str, "off")) 1470 rodata_enabled = false; 1471 else |
1452 pr_warn("Invalid option string for rodata: '%s'\n", str); | 1472 pr_warn("Invalid option string for rodata: '%s'\n", str); |
1453 return 1; | 1473 return 0; |
1454} | 1474} |
1455__setup("rodata=", set_debug_rodata); | 1475early_param("rodata", set_debug_rodata); |
1456#endif 1457 1458#ifdef CONFIG_STRICT_KERNEL_RWX 1459static void mark_readonly(void) 1460{ 1461 if (rodata_enabled) { 1462 /* 1463 * load_module() results in W+X mappings, which are cleaned --- 137 unchanged lines hidden (view full) --- 1601 lockup_detector_init(); 1602 1603 smp_init(); 1604 sched_init_smp(); 1605 1606 padata_init(); 1607 page_alloc_init_late(); 1608 /* Initialize page ext after all struct pages are initialized. */ | 1476#endif 1477 1478#ifdef CONFIG_STRICT_KERNEL_RWX 1479static void mark_readonly(void) 1480{ 1481 if (rodata_enabled) { 1482 /* 1483 * load_module() results in W+X mappings, which are cleaned --- 137 unchanged lines hidden (view full) --- 1621 lockup_detector_init(); 1622 1623 smp_init(); 1624 sched_init_smp(); 1625 1626 padata_init(); 1627 page_alloc_init_late(); 1628 /* Initialize page ext after all struct pages are initialized. */ |
1609 page_ext_init(); | 1629 if (!early_page_ext_enabled()) 1630 page_ext_init(); |
1610 1611 do_basic_setup(); 1612 1613 kunit_run_all_tests(); 1614 1615 wait_for_initramfs(); 1616 console_on_rootfs(); 1617 --- 20 unchanged lines hidden --- | 1631 1632 do_basic_setup(); 1633 1634 kunit_run_all_tests(); 1635 1636 wait_for_initramfs(); 1637 console_on_rootfs(); 1638 --- 20 unchanged lines hidden --- |