From a4df2071f1a2bb5b003eb179e1a51625d26b04d5 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 20 Oct 2025 11:16:13 +0200 Subject: [PATCH 01/39] modpost: drop '*_probe' from section check whitelist Several symbol patterns used to be whitelisted to allow drivers to refer to functions annotated with __devinit and __devexit, which have since been removed. Commit e1dc1bfe5b27 ("modpost: remove more symbol patterns from the section check whitelist") removed most of these patterns but left '*_probe' after a reported warning in an irqchip driver. Turns out that was indeed an incorrect reference which has now been fixed by commit 9b685058ca93 ("irqchip/qcom-irq-combiner: Fix section mismatch"). A recently added clocksource driver also relies on this suffix to suppress another valid warning, and that is being fixed separately. [1] Note that drivers with valid reasons for suppressing the warnings can use the __ref macros. Link: https://lore.kernel.org/lkml/20251017054943.7195-1-johan@kernel.org/ [1] Signed-off-by: Johan Hovold Reviewed-by: Thomas Gleixner Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20251020091613.22562-1-johan@kernel.org Signed-off-by: Nathan Chancellor --- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 755b842f1f9b..d042b355c9d6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -958,7 +958,7 @@ static int secref_whitelist(const char *fromsec, const char *fromsym, /* symbols in data sections that may refer to any init/exit sections */ if (match(fromsec, PATTERNS(DATA_SECTIONS)) && match(tosec, PATTERNS(ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS)) && - match(fromsym, PATTERNS("*_ops", "*_probe", "*_console"))) + match(fromsym, PATTERNS("*_ops", "*_console"))) return 0; /* Check for pattern 3 */ From 18e2d526bf24525995d4312937e82d9b6810f663 Mon Sep 17 00:00:00 2001 From: Rostislav Krasny Date: Wed, 17 Dec 2025 03:54:09 +0200 Subject: [PATCH 02/39] kconfig: move XPM icons to separate files Replace deprecated gdk_pixbuf_new_from_xpm_data() with gdk_pixbuf_new_from_file() and update both GTK and QT frontends to load XPM icons from separate files in scripts/kconfig/icons/ instead of from the code. xpm_menu_inv and xpm_void were removed and not converted into xpm files because they are not used since commit 64285dc5c41f ("kconfig: gconf: inline fill_row() into set_node()"). This eliminates the GTK deprecation warnings at compile time and improves memory usage and code organization. Signed-off-by: Rostislav Krasny Acked-by: Randy Dunlap Tested-by: Randy Dunlap Link: https://patch.msgid.link/20251217015409.30102-2-rostiprodev@gmail.com [nathan: Minor commit message clean ups] Signed-off-by: Nathan Chancellor --- scripts/kconfig/Makefile | 4 +- scripts/kconfig/gconf.c | 35 ++- scripts/kconfig/icons/back.xpm | 29 +++ scripts/kconfig/icons/choice_no.xpm | 18 ++ scripts/kconfig/icons/choice_yes.xpm | 18 ++ scripts/kconfig/icons/load.xpm | 31 +++ scripts/kconfig/icons/menu.xpm | 18 ++ scripts/kconfig/icons/menuback.xpm | 18 ++ scripts/kconfig/icons/save.xpm | 31 +++ scripts/kconfig/icons/single_view.xpm | 28 +++ scripts/kconfig/icons/split_view.xpm | 28 +++ scripts/kconfig/icons/symbol_mod.xpm | 18 ++ scripts/kconfig/icons/symbol_no.xpm | 18 ++ scripts/kconfig/icons/symbol_yes.xpm | 18 ++ scripts/kconfig/icons/tree_view.xpm | 28 +++ scripts/kconfig/images.c | 328 -------------------------- scripts/kconfig/images.h | 33 --- scripts/kconfig/qconf.cc | 29 ++- 18 files changed, 345 insertions(+), 385 deletions(-) create mode 100644 scripts/kconfig/icons/back.xpm create mode 100644 scripts/kconfig/icons/choice_no.xpm create mode 100644 scripts/kconfig/icons/choice_yes.xpm create mode 100644 scripts/kconfig/icons/load.xpm create mode 100644 scripts/kconfig/icons/menu.xpm create mode 100644 scripts/kconfig/icons/menuback.xpm create mode 100644 scripts/kconfig/icons/save.xpm create mode 100644 scripts/kconfig/icons/single_view.xpm create mode 100644 scripts/kconfig/icons/split_view.xpm create mode 100644 scripts/kconfig/icons/symbol_mod.xpm create mode 100644 scripts/kconfig/icons/symbol_no.xpm create mode 100644 scripts/kconfig/icons/symbol_yes.xpm create mode 100644 scripts/kconfig/icons/tree_view.xpm delete mode 100644 scripts/kconfig/images.c delete mode 100644 scripts/kconfig/images.h diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index fb50bd4f4103..5baf1c44ffa2 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -201,7 +201,7 @@ $(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags # qconf: Used for the xconfig target based on Qt hostprogs += qconf qconf-cxxobjs := qconf.o qconf-moc.o -qconf-objs := images.o $(common-objs) +qconf-objs := $(common-objs) HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs) HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) @@ -219,7 +219,7 @@ targets += qconf-moc.cc # gconf: Used for the gconfig target based on GTK+ hostprogs += gconf -gconf-objs := gconf.o images.o $(common-objs) +gconf-objs := gconf.o $(common-objs) HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs) HOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 8b164ccfa008..9f8586cb8a3e 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -5,7 +5,6 @@ #include #include "lkc.h" -#include "images.h" #include @@ -951,12 +950,24 @@ static void fixup_rootmenu(struct menu *menu) } /* Main Window Initialization */ -static void replace_button_icon(GtkWidget *widget, const char * const xpm[]) +static void replace_button_icon(GtkWidget *widget, const char *filename) { GdkPixbuf *pixbuf; GtkWidget *image; + GError *err = NULL; + + char *env = getenv(SRCTREE); + gchar *path = g_strconcat(env ? env : g_get_current_dir(), "/scripts/kconfig/icons/", filename, NULL); + + pixbuf = gdk_pixbuf_new_from_file(path, &err); + g_free(path); + + if (err) { + g_warning("Failed to load icon %s: %s", filename, err->message); + g_error_free(err); + return; + } - pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)xpm); image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); @@ -1078,17 +1089,17 @@ static void init_main_window(const gchar *glade_file) single_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button4")); g_signal_connect(single_btn, "clicked", G_CALLBACK(on_single_clicked), NULL); - replace_button_icon(single_btn, xpm_single_view); + replace_button_icon(single_btn, "single_view.xpm"); split_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button5")); g_signal_connect(split_btn, "clicked", G_CALLBACK(on_split_clicked), NULL); - replace_button_icon(split_btn, xpm_split_view); + replace_button_icon(split_btn, "split_view.xpm"); full_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button6")); g_signal_connect(full_btn, "clicked", G_CALLBACK(on_full_clicked), NULL); - replace_button_icon(full_btn, xpm_tree_view); + replace_button_icon(full_btn, "tree_view.xpm"); widget = GTK_WIDGET(gtk_builder_get_object(builder, "button7")); g_signal_connect(widget, "clicked", @@ -1269,7 +1280,17 @@ static void init_right_tree(void) g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(renderer_edited), tree2_w); - pix_menu = gdk_pixbuf_new_from_xpm_data((const char **)xpm_menu); + char *env = getenv(SRCTREE); + gchar *path = g_strconcat(env ? env : g_get_current_dir(), "/scripts/kconfig/icons/menu.xpm", NULL); + GError *err = NULL; + + pix_menu = gdk_pixbuf_new_from_file(path, &err); + g_free(path); + + if (err) { + g_warning("Failed to load menu icon: %s", err->message); + g_error_free(err); + } for (i = 0; i < COL_VALUE; i++) { column = gtk_tree_view_get_column(view, i); diff --git a/scripts/kconfig/icons/back.xpm b/scripts/kconfig/icons/back.xpm new file mode 100644 index 000000000000..2a4c30127608 --- /dev/null +++ b/scripts/kconfig/icons/back.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static char * back_xpm[] = { +"22 22 3 1", +". c None", +"# c #000083", +"a c #838183", +"......................", +"......................", +"......................", +"......................", +"......................", +"...........######a....", +"..#......##########...", +"..##...####......##a..", +"..###.###.........##..", +"..######..........##..", +"..#####...........##..", +"..######..........##..", +"..#######.........##..", +"..########.......##a..", +"...............a###...", +"...............###....", +"......................", +"......................", +"......................", +"......................", +"......................", +"......................" +}; diff --git a/scripts/kconfig/icons/choice_no.xpm b/scripts/kconfig/icons/choice_no.xpm new file mode 100644 index 000000000000..306e314ed9c6 --- /dev/null +++ b/scripts/kconfig/icons/choice_no.xpm @@ -0,0 +1,18 @@ +/* XPM */ +static char * choice_no_xpm[] = { +"12 12 2 1", +" c white", +". c black", +" ", +" .... ", +" .. .. ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" .. .. ", +" .... ", +" " +}; diff --git a/scripts/kconfig/icons/choice_yes.xpm b/scripts/kconfig/icons/choice_yes.xpm new file mode 100644 index 000000000000..edeb91067379 --- /dev/null +++ b/scripts/kconfig/icons/choice_yes.xpm @@ -0,0 +1,18 @@ +/* XPM */ +static char * choice_yes_xpm[] = { +"12 12 2 1", +" c white", +". c black", +" ", +" .... ", +" .. .. ", +" . . ", +" . .. . ", +" . .... . ", +" . .... . ", +" . .. . ", +" . . ", +" .. .. ", +" .... ", +" " +}; diff --git a/scripts/kconfig/icons/load.xpm b/scripts/kconfig/icons/load.xpm new file mode 100644 index 000000000000..8c2d8725d1ef --- /dev/null +++ b/scripts/kconfig/icons/load.xpm @@ -0,0 +1,31 @@ +/* XPM */ +static char * load_xpm[] = { +"22 22 5 1", +". c None", +"# c #000000", +"c c #838100", +"a c #ffff00", +"b c #ffffff", +"......................", +"......................", +"......................", +"............####....#.", +"...........#....##.##.", +"..................###.", +".................####.", +".####...........#####.", +"#abab##########.......", +"#babababababab#.......", +"#ababababababa#.......", +"#babababababab#.......", +"#ababab###############", +"#babab##cccccccccccc##", +"#abab##cccccccccccc##.", +"#bab##cccccccccccc##..", +"#ab##cccccccccccc##...", +"#b##cccccccccccc##....", +"###cccccccccccc##.....", +"##cccccccccccc##......", +"###############.......", +"......................" +}; diff --git a/scripts/kconfig/icons/menu.xpm b/scripts/kconfig/icons/menu.xpm new file mode 100644 index 000000000000..8ae1b74b3c0c --- /dev/null +++ b/scripts/kconfig/icons/menu.xpm @@ -0,0 +1,18 @@ +/* XPM */ +static char * menu_xpm[] = { +"12 12 2 1", +" c white", +". c black", +" ", +" .......... ", +" . . ", +" . .. . ", +" . .... . ", +" . ...... . ", +" . ...... . ", +" . .... . ", +" . .. . ", +" . . ", +" .......... ", +" " +}; diff --git a/scripts/kconfig/icons/menuback.xpm b/scripts/kconfig/icons/menuback.xpm new file mode 100644 index 000000000000..f988c2c323c3 --- /dev/null +++ b/scripts/kconfig/icons/menuback.xpm @@ -0,0 +1,18 @@ +/* XPM */ +static char * menuback_xpm[] = { +"12 12 2 1", +" c white", +". c black", +" ", +" .......... ", +" . . ", +" . .. . ", +" . .... . ", +" . ...... . ", +" . ...... . ", +" . .... . ", +" . .. . ", +" . . ", +" .......... ", +" " +}; diff --git a/scripts/kconfig/icons/save.xpm b/scripts/kconfig/icons/save.xpm new file mode 100644 index 000000000000..f8be53d83b40 --- /dev/null +++ b/scripts/kconfig/icons/save.xpm @@ -0,0 +1,31 @@ +/* XPM */ +static char * save_xpm[] = { +"22 22 5 1", +". c None", +"# c #000000", +"a c #838100", +"b c #c5c2c5", +"c c #cdb6d5", +"......................", +".####################.", +".#aa#bbbbbbbbbbbb#bb#.", +".#aa#bbbbbbbbbbbb#bb#.", +".#aa#bbbbbbbbbcbb####.", +".#aa#bbbccbbbbbbb#aa#.", +".#aa#bbbccbbbbbbb#aa#.", +".#aa#bbbbbbbbbbbb#aa#.", +".#aa#bbbbbbbbbbbb#aa#.", +".#aa#bbbbbbbbbbbb#aa#.", +".#aa#bbbbbbbbbbbb#aa#.", +".#aaa############aaa#.", +".#aaaaaaaaaaaaaaaaaa#.", +".#aaaaaaaaaaaaaaaaaa#.", +".#aaa#############aa#.", +".#aaa#########bbb#aa#.", +".#aaa#########bbb#aa#.", +".#aaa#########bbb#aa#.", +".#aaa#########bbb#aa#.", +".#aaa#########bbb#aa#.", +"..##################..", +"......................" +}; diff --git a/scripts/kconfig/icons/single_view.xpm b/scripts/kconfig/icons/single_view.xpm new file mode 100644 index 000000000000..33c3b239dc8e --- /dev/null +++ b/scripts/kconfig/icons/single_view.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char * single_view_xpm[] = { +"22 22 2 1", +". c None", +"# c #000000", +"......................", +"......................", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"..........#...........", +"......................", +"......................" +}; diff --git a/scripts/kconfig/icons/split_view.xpm b/scripts/kconfig/icons/split_view.xpm new file mode 100644 index 000000000000..09e22246d936 --- /dev/null +++ b/scripts/kconfig/icons/split_view.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char * split_view_xpm[] = { +"22 22 2 1", +". c None", +"# c #000000", +"......................", +"......................", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......#......#........", +"......................", +"......................" +}; diff --git a/scripts/kconfig/icons/symbol_mod.xpm b/scripts/kconfig/icons/symbol_mod.xpm new file mode 100644 index 000000000000..769465fcb0ce --- /dev/null +++ b/scripts/kconfig/icons/symbol_mod.xpm @@ -0,0 +1,18 @@ +/* XPM */ +static char * symbol_mod_xpm[] = { +"12 12 2 1", +" c white", +". c black", +" ", +" .......... ", +" . . ", +" . . ", +" . .. . ", +" . .... . ", +" . .... . ", +" . .. . ", +" . . ", +" . . ", +" .......... ", +" " +}; diff --git a/scripts/kconfig/icons/symbol_no.xpm b/scripts/kconfig/icons/symbol_no.xpm new file mode 100644 index 000000000000..e4e9d46c9aca --- /dev/null +++ b/scripts/kconfig/icons/symbol_no.xpm @@ -0,0 +1,18 @@ +/* XPM */ +static char * symbol_no_xpm[] = { +"12 12 2 1", +" c white", +". c black", +" ", +" .......... ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" .......... ", +" " +}; diff --git a/scripts/kconfig/icons/symbol_yes.xpm b/scripts/kconfig/icons/symbol_yes.xpm new file mode 100644 index 000000000000..dab7e10ae7a9 --- /dev/null +++ b/scripts/kconfig/icons/symbol_yes.xpm @@ -0,0 +1,18 @@ +/* XPM */ +static char * symbol_yes_xpm[] = { +"12 12 2 1", +" c white", +". c black", +" ", +" .......... ", +" . . ", +" . . ", +" . . . ", +" . .. . ", +" . . .. . ", +" . .... . ", +" . .. . ", +" . . ", +" .......... ", +" " +}; diff --git a/scripts/kconfig/icons/tree_view.xpm b/scripts/kconfig/icons/tree_view.xpm new file mode 100644 index 000000000000..290835b802eb --- /dev/null +++ b/scripts/kconfig/icons/tree_view.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char * tree_view_xpm[] = { +"22 22 2 1", +". c None", +"# c #000000", +"......................", +"......................", +"......#...............", +"......#...............", +"......#...............", +"......#...............", +"......#...............", +"......########........", +"......#...............", +"......#...............", +"......#...............", +"......#...............", +"......#...............", +"......########........", +"......#...............", +"......#...............", +"......#...............", +"......#...............", +"......#...............", +"......########........", +"......................", +"......................" +}; diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c deleted file mode 100644 index 2f9afffa5d79..000000000000 --- a/scripts/kconfig/images.c +++ /dev/null @@ -1,328 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (C) 2002 Roman Zippel - */ - -#include "images.h" - -const char * const xpm_load[] = { -"22 22 5 1", -". c None", -"# c #000000", -"c c #838100", -"a c #ffff00", -"b c #ffffff", -"......................", -"......................", -"......................", -"............####....#.", -"...........#....##.##.", -"..................###.", -".................####.", -".####...........#####.", -"#abab##########.......", -"#babababababab#.......", -"#ababababababa#.......", -"#babababababab#.......", -"#ababab###############", -"#babab##cccccccccccc##", -"#abab##cccccccccccc##.", -"#bab##cccccccccccc##..", -"#ab##cccccccccccc##...", -"#b##cccccccccccc##....", -"###cccccccccccc##.....", -"##cccccccccccc##......", -"###############.......", -"......................"}; - -const char * const xpm_save[] = { -"22 22 5 1", -". c None", -"# c #000000", -"a c #838100", -"b c #c5c2c5", -"c c #cdb6d5", -"......................", -".####################.", -".#aa#bbbbbbbbbbbb#bb#.", -".#aa#bbbbbbbbbbbb#bb#.", -".#aa#bbbbbbbbbcbb####.", -".#aa#bbbccbbbbbbb#aa#.", -".#aa#bbbccbbbbbbb#aa#.", -".#aa#bbbbbbbbbbbb#aa#.", -".#aa#bbbbbbbbbbbb#aa#.", -".#aa#bbbbbbbbbbbb#aa#.", -".#aa#bbbbbbbbbbbb#aa#.", -".#aaa############aaa#.", -".#aaaaaaaaaaaaaaaaaa#.", -".#aaaaaaaaaaaaaaaaaa#.", -".#aaa#############aa#.", -".#aaa#########bbb#aa#.", -".#aaa#########bbb#aa#.", -".#aaa#########bbb#aa#.", -".#aaa#########bbb#aa#.", -".#aaa#########bbb#aa#.", -"..##################..", -"......................"}; - -const char * const xpm_back[] = { -"22 22 3 1", -". c None", -"# c #000083", -"a c #838183", -"......................", -"......................", -"......................", -"......................", -"......................", -"...........######a....", -"..#......##########...", -"..##...####......##a..", -"..###.###.........##..", -"..######..........##..", -"..#####...........##..", -"..######..........##..", -"..#######.........##..", -"..########.......##a..", -"...............a###...", -"...............###....", -"......................", -"......................", -"......................", -"......................", -"......................", -"......................"}; - -const char * const xpm_tree_view[] = { -"22 22 2 1", -". c None", -"# c #000000", -"......................", -"......................", -"......#...............", -"......#...............", -"......#...............", -"......#...............", -"......#...............", -"......########........", -"......#...............", -"......#...............", -"......#...............", -"......#...............", -"......#...............", -"......########........", -"......#...............", -"......#...............", -"......#...............", -"......#...............", -"......#...............", -"......########........", -"......................", -"......................"}; - -const char * const xpm_single_view[] = { -"22 22 2 1", -". c None", -"# c #000000", -"......................", -"......................", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"..........#...........", -"......................", -"......................"}; - -const char * const xpm_split_view[] = { -"22 22 2 1", -". c None", -"# c #000000", -"......................", -"......................", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......#......#........", -"......................", -"......................"}; - -const char * const xpm_symbol_no[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .......... ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" .......... ", -" "}; - -const char * const xpm_symbol_mod[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .......... ", -" . . ", -" . . ", -" . .. . ", -" . .... . ", -" . .... . ", -" . .. . ", -" . . ", -" . . ", -" .......... ", -" "}; - -const char * const xpm_symbol_yes[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .......... ", -" . . ", -" . . ", -" . . . ", -" . .. . ", -" . . .. . ", -" . .... . ", -" . .. . ", -" . . ", -" .......... ", -" "}; - -const char * const xpm_choice_no[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .... ", -" .. .. ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" . . ", -" .. .. ", -" .... ", -" "}; - -const char * const xpm_choice_yes[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .... ", -" .. .. ", -" . . ", -" . .. . ", -" . .... . ", -" . .... . ", -" . .. . ", -" . . ", -" .. .. ", -" .... ", -" "}; - -const char * const xpm_menu[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .......... ", -" . . ", -" . .. . ", -" . .... . ", -" . ...... . ", -" . ...... . ", -" . .... . ", -" . .. . ", -" . . ", -" .......... ", -" "}; - -const char * const xpm_menu_inv[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .......... ", -" .......... ", -" .. ...... ", -" .. .... ", -" .. .. ", -" .. .. ", -" .. .... ", -" .. ...... ", -" .......... ", -" .......... ", -" "}; - -const char * const xpm_menuback[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" .......... ", -" . . ", -" . .. . ", -" . .... . ", -" . ...... . ", -" . ...... . ", -" . .... . ", -" . .. . ", -" . . ", -" .......... ", -" "}; - -const char * const xpm_void[] = { -"12 12 2 1", -" c white", -". c black", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/scripts/kconfig/images.h b/scripts/kconfig/images.h deleted file mode 100644 index 7212dec2006c..000000000000 --- a/scripts/kconfig/images.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (C) 2002 Roman Zippel - */ - -#ifndef IMAGES_H -#define IMAGES_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern const char * const xpm_load[]; -extern const char * const xpm_save[]; -extern const char * const xpm_back[]; -extern const char * const xpm_tree_view[]; -extern const char * const xpm_single_view[]; -extern const char * const xpm_split_view[]; -extern const char * const xpm_symbol_no[]; -extern const char * const xpm_symbol_mod[]; -extern const char * const xpm_symbol_yes[]; -extern const char * const xpm_choice_no[]; -extern const char * const xpm_choice_yes[]; -extern const char * const xpm_menu[]; -extern const char * const xpm_menu_inv[]; -extern const char * const xpm_menuback[]; -extern const char * const xpm_void[]; - -#ifdef __cplusplus -} -#endif - -#endif /* IMAGES_H */ diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index b84c9f2485d1..b02ead7a3f98 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -26,8 +26,6 @@ #include "lkc.h" #include "qconf.h" -#include "images.h" - static QApplication *configApp; static ConfigSettings *configSettings; @@ -1283,13 +1281,14 @@ ConfigMainWindow::ConfigMainWindow(void) move(x.toInt(), y.toInt()); // set up icons - ConfigItem::symbolYesIcon = QIcon(QPixmap(xpm_symbol_yes)); - ConfigItem::symbolModIcon = QIcon(QPixmap(xpm_symbol_mod)); - ConfigItem::symbolNoIcon = QIcon(QPixmap(xpm_symbol_no)); - ConfigItem::choiceYesIcon = QIcon(QPixmap(xpm_choice_yes)); - ConfigItem::choiceNoIcon = QIcon(QPixmap(xpm_choice_no)); - ConfigItem::menuIcon = QIcon(QPixmap(xpm_menu)); - ConfigItem::menubackIcon = QIcon(QPixmap(xpm_menuback)); + QString iconsDir = QString(getenv(SRCTREE) ? getenv(SRCTREE) : QDir::currentPath()) + "/scripts/kconfig/icons/"; + ConfigItem::symbolYesIcon = QIcon(QPixmap(iconsDir + "symbol_yes.xpm")); + ConfigItem::symbolModIcon = QIcon(QPixmap(iconsDir + "symbol_mod.xpm")); + ConfigItem::symbolNoIcon = QIcon(QPixmap(iconsDir + "symbol_no.xpm")); + ConfigItem::choiceYesIcon = QIcon(QPixmap(iconsDir + "choice_yes.xpm")); + ConfigItem::choiceNoIcon = QIcon(QPixmap(iconsDir + "choice_no.xpm")); + ConfigItem::menuIcon = QIcon(QPixmap(iconsDir + "menu.xpm")); + ConfigItem::menubackIcon = QIcon(QPixmap(iconsDir + "menuback.xpm")); QWidget *widget = new QWidget(this); setCentralWidget(widget); @@ -1312,7 +1311,7 @@ ConfigMainWindow::ConfigMainWindow(void) configList->setFocus(); - backAction = new QAction(QPixmap(xpm_back), "Back", this); + backAction = new QAction(QPixmap(iconsDir + "back.xpm"), "Back", this); backAction->setShortcut(QKeySequence::Back); connect(backAction, &QAction::triggered, this, &ConfigMainWindow::goBack); @@ -1322,12 +1321,12 @@ ConfigMainWindow::ConfigMainWindow(void) connect(quitAction, &QAction::triggered, this, &ConfigMainWindow::close); - QAction *loadAction = new QAction(QPixmap(xpm_load), "&Open", this); + QAction *loadAction = new QAction(QPixmap(iconsDir + "load.xpm"), "&Open", this); loadAction->setShortcut(QKeySequence::Open); connect(loadAction, &QAction::triggered, this, &ConfigMainWindow::loadConfig); - saveAction = new QAction(QPixmap(xpm_save), "&Save", this); + saveAction = new QAction(QPixmap(iconsDir + "save.xpm"), "&Save", this); saveAction->setShortcut(QKeySequence::Save); connect(saveAction, &QAction::triggered, this, &ConfigMainWindow::saveConfig); @@ -1344,15 +1343,15 @@ ConfigMainWindow::ConfigMainWindow(void) searchAction->setShortcut(QKeySequence::Find); connect(searchAction, &QAction::triggered, this, &ConfigMainWindow::searchConfig); - singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this); + singleViewAction = new QAction(QPixmap(iconsDir + "single_view.xpm"), "Single View", this); singleViewAction->setCheckable(true); connect(singleViewAction, &QAction::triggered, this, &ConfigMainWindow::showSingleView); - splitViewAction = new QAction(QPixmap(xpm_split_view), "Split View", this); + splitViewAction = new QAction(QPixmap(iconsDir + "split_view.xpm"), "Split View", this); splitViewAction->setCheckable(true); connect(splitViewAction, &QAction::triggered, this, &ConfigMainWindow::showSplitView); - fullViewAction = new QAction(QPixmap(xpm_tree_view), "Full View", this); + fullViewAction = new QAction(QPixmap(iconsDir + "tree_view.xpm"), "Full View", this); fullViewAction->setCheckable(true); connect(fullViewAction, &QAction::triggered, this, &ConfigMainWindow::showFullView); From f8e05c10631e665ccabc8410beec6058d2a07c57 Mon Sep 17 00:00:00 2001 From: Nicolas Schier Date: Fri, 28 Nov 2025 21:01:55 +0100 Subject: [PATCH 03/39] kbuild: Add top-level target for building gen_init_cpio Add a top-level target for building gen_init_cpio to prevent re-entering kbuild for 'modules-cpio-pkg'. The recently introduced target 'modules-cpio-pkg' depends on gen_init_cpio but there is no simple way to add this dependency as a prerequisite that can be built in parallel to other recipes. Introducing the top-level target, enables fixing this and also prepares a possible move of gen_init_cpio from usr/ to scripts/. Signed-off-by: Nicolas Schier Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Link: https://patch.msgid.link/20251128-kbuild-add-top-level-target-for-building-gen_init_cpio-v1-1-84c63a8fc8d4@kernel.org Signed-off-by: Nathan Chancellor --- Makefile | 6 ++++++ scripts/Makefile.package | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e404e4767944..ad91e6a936aa 100644 --- a/Makefile +++ b/Makefile @@ -1417,6 +1417,10 @@ ifdef CONFIG_HEADERS_INSTALL prepare: headers endif +PHONY += usr_gen_init_cpio +usr_gen_init_cpio: scripts_basic + $(Q)$(MAKE) $(build)=usr usr/gen_init_cpio + PHONY += scripts_unifdef scripts_unifdef: scripts_basic $(Q)$(MAKE) $(build)=scripts scripts/unifdef @@ -1669,6 +1673,8 @@ distclean: mrproper # Packaging of the kernel to various formats # --------------------------------------------------------------------------- +modules-cpio-pkg: usr_gen_init_cpio + %src-pkg: FORCE $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ %pkg: include/config/kernel.release FORCE diff --git a/scripts/Makefile.package b/scripts/Makefile.package index 83bfcf7cb09f..0ec946f9b905 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -201,7 +201,6 @@ quiet_cmd_cpio = CPIO $@ cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $< modules-$(KERNELRELEASE)-$(ARCH).cpio: .tmp_modules_cpio - $(Q)$(MAKE) $(build)=usr usr/gen_init_cpio $(call cmd,cpio) PHONY += modules-cpio-pkg From 1b5e068d598e16b3a4ee3fa632108ea393d4e3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 30 Dec 2025 08:09:29 +0100 Subject: [PATCH 04/39] kbuild: uapi: Drop check_config() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit headers_install.sh already tests for CONFIG symbols. It does so in a more comprehensive way, by only checking for references in code and also running even if CONFIG_UAPI_HEADER_TEST is disabled. And check_config() has been disabled any case. Drop the pointless check. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20251230-uapi-check_config-v1-1-00ecec109f39@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/headers_check.pl | 8 -------- 1 file changed, 8 deletions(-) diff --git a/usr/include/headers_check.pl b/usr/include/headers_check.pl index af5a513eaa00..6cd6eb652c8d 100755 --- a/usr/include/headers_check.pl +++ b/usr/include/headers_check.pl @@ -40,7 +40,6 @@ foreach my $file (@files) { &check_include(); &check_asm_types(); &check_declarations(); - # Dropped for now. Too much noise &check_config(); } close $fh; } @@ -77,13 +76,6 @@ sub check_declarations } } -sub check_config -{ - if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) { - printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n"; - } -} - my $linux_asm_types; sub check_asm_types { From 660e899103e29aabcc05447ab20684811ea86107 Mon Sep 17 00:00:00 2001 From: Vincent Mailhol Date: Sat, 20 Dec 2025 12:02:19 +0100 Subject: [PATCH 05/39] kbuild: remove gcc's -Wtype-limits W=2 builds are heavily polluted by the -Wtype-limits warning. Here are some W=12 statistics on Linux v6.19-rc1 for an x86_64 defconfig (with just CONFIG_WERROR set to "n") using gcc 14.3.1: Warning name count percent ------------------------------------------------- -Wlogical-op 2 0.00 % -Wmaybe-uninitialized 138 0.20 % -Wunused-macros 869 1.24 % -Wmissing-field-initializers 1418 2.02 % -Wshadow 2234 3.19 % -Wtype-limits 65378 93.35 % ------------------------------------------------- Total 70039 100.00 % As we can see, -Wtype-limits represents the vast majority of all warnings. The reason behind this is that these warnings appear in some common header files, meaning that some unique warnings are repeated tens of thousands of times (once per header inclusion). Add to this the fact that each warning is coupled with a dozen lines detailing some macro expansion. The end result is that the W=2 output is just too bloated and painful to use. Three years ago, I proposed in [1] modifying one such header to silence that noise. Because the code was not faulty, Linus rejected the idea and instead suggested simply removing that warning. At that time, I could not bring myself to send such a patch because, despite its problems, -Wtype-limits would still catch the below bug: unsigned int ret; ret = check(); if (ret < 0) error(); Meanwhile, based on another suggestion from Linus, I added a new check to sparse [2] that would catch the above bug without the useless spam. With this, remove gcc's -Wtype-limits. People who still want to catch incorrect comparisons between unsigned integers and zero can now use sparse instead. On a side note, clang also has a -Wtype-limits warning but: * it is not enabled in the kernel at the moment because, contrary to gcc, clang did not include it under -Wextra. * it does not warn if the code results from a macro expansion. So, if activated, it would not cause as much spam as gcc does. * -Wtype-limits is split into four sub-warnings [3] meaning that if it were to be activated, we could select which one to keep. So there is no present need to explicitly disable -Wtype-limits in clang. [1] linux/bits.h: GENMASK_INPUT_CHECK: reduce W=2 noise by 31% treewide Link: https://lore.kernel.org/all/20220308141201.2343757-1-mailhol.vincent@wanadoo.fr/ [2] Warn about "unsigned value that used to be signed against zero" Link: https://lore.kernel.org/all/20250921061337.3047616-1-mailhol@kernel.org/ [3] clang's -Wtype-limits Link: https://clang.llvm.org/docs/DiagnosticsReference.html#wtype-limits Reviewed-by: Nicolas Schier Signed-off-by: Vincent Mailhol Link: https://patch.msgid.link/20251220-remove_wtype-limits-v3-1-24b170af700e@kernel.org Signed-off-by: Nathan Chancellor --- scripts/Makefile.warn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn index 68e6fafcb80c..c593ab1257de 100644 --- a/scripts/Makefile.warn +++ b/scripts/Makefile.warn @@ -55,6 +55,9 @@ else KBUILD_CFLAGS += -Wno-main endif +# Too noisy on range checks and in macros handling both signed and unsigned. +KBUILD_CFLAGS += -Wno-type-limits + # These result in bogus false positives KBUILD_CFLAGS += $(call cc-option, -Wno-dangling-pointer) @@ -174,7 +177,6 @@ else # The following turn off the warnings enabled by -Wextra KBUILD_CFLAGS += -Wno-missing-field-initializers -KBUILD_CFLAGS += -Wno-type-limits KBUILD_CFLAGS += -Wno-shift-negative-value ifdef CONFIG_CC_IS_CLANG From 34a1bd0b6b2c03206f3ca629eafd2cad95fd6b22 Mon Sep 17 00:00:00 2001 From: Vincent Mailhol Date: Sat, 20 Dec 2025 12:02:20 +0100 Subject: [PATCH 06/39] kbuild: cleanup local -Wno-type-limits exceptions Now that -Wtype-limits is globally deactivated, there is no need for local exceptions anymore. Acked-by: David Sterba Signed-off-by: Vincent Mailhol Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20251220-remove_wtype-limits-v3-2-24b170af700e@kernel.org Signed-off-by: Nathan Chancellor --- drivers/gpu/drm/Makefile | 1 - fs/btrfs/Makefile | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 0e1c668b46d2..b879a60ca79a 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -22,7 +22,6 @@ subdir-ccflags-y += $(call cc-option, -Wstringop-truncation) # The following turn off the warnings enabled by -Wextra ifeq ($(findstring 2, $(KBUILD_EXTRA_WARN)),) subdir-ccflags-y += -Wno-missing-field-initializers -subdir-ccflags-y += -Wno-type-limits subdir-ccflags-y += -Wno-shift-negative-value endif ifeq ($(findstring 3, $(KBUILD_EXTRA_WARN)),) diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile index 743d7677b175..40bc2f7e6f6b 100644 --- a/fs/btrfs/Makefile +++ b/fs/btrfs/Makefile @@ -17,7 +17,6 @@ subdir-ccflags-y += $(condflags) # The following turn off the warnings enabled by -Wextra subdir-ccflags-y += -Wno-missing-field-initializers subdir-ccflags-y += -Wno-sign-compare -subdir-ccflags-y += -Wno-type-limits subdir-ccflags-y += -Wno-shift-negative-value obj-$(CONFIG_BTRFS_FS) := btrfs.o From 5ce3218d4f102aca5e90d3c831259b6e380f88b4 Mon Sep 17 00:00:00 2001 From: Vincent Mailhol Date: Sat, 20 Dec 2025 12:02:21 +0100 Subject: [PATCH 07/39] overflow: Remove is_non_negative() and is_negative() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The is_non_negative() and is_negative() function-like macros just exist as a workaround to silence the -Wtype-limits warning. Now that this warning is disabled, those two macros have lost their raison d'être. Remove them. This reverts commit dc7fe518b049 ("overflow: Fix -Wtype-limits compilation warnings"). Suggested-by: Nicolas Schier Link: https://lore.kernel.org/all/aUT_yWin_xslnOFh@derry.ads.avm.de Signed-off-by: Vincent Mailhol Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20251220-remove_wtype-limits-v3-3-24b170af700e@kernel.org Signed-off-by: Nathan Chancellor --- include/linux/overflow.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/include/linux/overflow.h b/include/linux/overflow.h index 736f633b2d5f..ab142d60c6b5 100644 --- a/include/linux/overflow.h +++ b/include/linux/overflow.h @@ -36,12 +36,6 @@ #define __type_min(T) ((T)((T)-type_max(T)-(T)1)) #define type_min(t) __type_min(typeof(t)) -/* - * Avoids triggering -Wtype-limits compilation warning, - * while using unsigned data types to check a < 0. - */ -#define is_non_negative(a) ((a) > 0 || (a) == 0) -#define is_negative(a) (!(is_non_negative(a))) /* * Allows for effectively applying __must_check to a macro so we can have @@ -201,9 +195,9 @@ static inline bool __must_check __must_check_overflow(bool overflow) typeof(d) _d = d; \ unsigned long long _a_full = _a; \ unsigned int _to_shift = \ - is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \ + _s >= 0 && _s < 8 * sizeof(*d) ? _s : 0; \ *_d = (_a_full << _to_shift); \ - (_to_shift != _s || is_negative(*_d) || is_negative(_a) || \ + (_to_shift != _s || *_d < 0 || _a < 0 || \ (*_d >> _to_shift) != _a); \ })) From 76df6815dab76d7890936dc5f6d91cf7e7f88358 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Mon, 15 Dec 2025 15:06:54 -0800 Subject: [PATCH 08/39] kconfig: Support conditional deps using "depends on X if Y" Extend the "depends on" syntax to support conditional dependencies using "depends on X if Y". While functionally equivalent to "depends on X || (Y == n)", "depends on X if Y" is much more readable and makes the kconfig language uniform in supporting the "if " suffix. This also improves readability for "optional" dependencies, which are the subset of conditional dependencies where X is Y. Previously such optional dependencies had to be expressed as the counterintuitive "depends on X || !X", now this can be represented as "depends on X if X". The change is implemented by converting the "X if Y" syntax into the "X || (Y == n)" syntax during "depends on" token processing. Signed-off-by: Nicolas Pitre [Graham Roff: Rewrote commit message, updated patch, added tests] Signed-off-by: Graham Roff Acked-by: Randy Dunlap Link: https://patch.msgid.link/20251215-kconfig_conditional_deps-v3-1-59519af0a5df@qti.qualcomm.com [nathan: Minor adjustments to spacing] Signed-off-by: Nathan Chancellor --- Documentation/kbuild/kconfig-language.rst | 22 +++++++++++-- scripts/kconfig/lkc.h | 2 +- scripts/kconfig/menu.c | 12 ++++++- scripts/kconfig/parser.y | 6 ++-- scripts/kconfig/tests/conditional_dep/Kconfig | 32 +++++++++++++++++++ .../kconfig/tests/conditional_dep/__init__.py | 14 ++++++++ .../tests/conditional_dep/expected_config1 | 11 +++++++ .../tests/conditional_dep/expected_config2 | 9 ++++++ .../tests/conditional_dep/expected_config3 | 11 +++++++ .../tests/conditional_dep/test_config1 | 6 ++++ .../tests/conditional_dep/test_config2 | 7 ++++ .../tests/conditional_dep/test_config3 | 6 ++++ 12 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 scripts/kconfig/tests/conditional_dep/Kconfig create mode 100644 scripts/kconfig/tests/conditional_dep/__init__.py create mode 100644 scripts/kconfig/tests/conditional_dep/expected_config1 create mode 100644 scripts/kconfig/tests/conditional_dep/expected_config2 create mode 100644 scripts/kconfig/tests/conditional_dep/expected_config3 create mode 100644 scripts/kconfig/tests/conditional_dep/test_config1 create mode 100644 scripts/kconfig/tests/conditional_dep/test_config2 create mode 100644 scripts/kconfig/tests/conditional_dep/test_config3 diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst index abce88f15d7c..9ff3e530b2b4 100644 --- a/Documentation/kbuild/kconfig-language.rst +++ b/Documentation/kbuild/kconfig-language.rst @@ -118,7 +118,7 @@ applicable everywhere (see syntax). This is a shorthand notation for a type definition plus a value. Optionally dependencies for this default value can be added with "if". -- dependencies: "depends on" +- dependencies: "depends on" ["if" ] This defines a dependency for this menu entry. If multiple dependencies are defined, they are connected with '&&'. Dependencies @@ -134,6 +134,16 @@ applicable everywhere (see syntax). bool "foo" default y + The dependency definition itself may be conditional by appending "if" + followed by an expression. For example:: + + config FOO + tristate + depends on BAR if BAZ + + meaning that FOO is constrained by the value of BAR only if BAZ is + also set. + - reverse dependencies: "select" ["if" ] While normal dependencies reduce the upper limit of a symbol (see @@ -602,8 +612,14 @@ Some drivers are able to optionally use a feature from another module or build cleanly with that module disabled, but cause a link failure when trying to use that loadable module from a built-in driver. -The most common way to express this optional dependency in Kconfig logic -uses the slightly counterintuitive:: +The recommended way to express this optional dependency in Kconfig logic +uses the conditional form:: + + config FOO + tristate "Support for foo hardware" + depends on BAR if BAR + +This slightly counterintuitive style is also widely used:: config FOO tristate "Support for foo hardware" diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 56548efc14d7..798985961215 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -82,7 +82,7 @@ void menu_warn(const struct menu *menu, const char *fmt, ...); struct menu *menu_add_menu(void); void menu_end_menu(void); void menu_add_entry(struct symbol *sym, enum menu_type type); -void menu_add_dep(struct expr *dep); +void menu_add_dep(struct expr *dep, struct expr *cond); void menu_add_visibility(struct expr *dep); struct property *menu_add_prompt(enum prop_type type, const char *prompt, struct expr *dep); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 0f1a6513987c..b2d8d4e11e07 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -127,8 +127,18 @@ static struct expr *rewrite_m(struct expr *e) return e; } -void menu_add_dep(struct expr *dep) +void menu_add_dep(struct expr *dep, struct expr *cond) { + if (cond) { + /* + * We have "depends on X if Y" and we want: + * Y != n --> X + * Y == n --> y + * That simplifies to: (X || (Y == n)) + */ + dep = expr_alloc_or(dep, + expr_trans_compare(cond, E_EQUAL, &symbol_no)); + } current_entry->dep = expr_alloc_and(current_entry->dep, dep); } diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 49b79dde1725..6d1bbee38f5d 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -323,7 +323,7 @@ if_entry: T_IF expr T_EOL { printd(DEBUG_PARSE, "%s:%d:if\n", cur_filename, cur_lineno); menu_add_entry(NULL, M_IF); - menu_add_dep($2); + menu_add_dep($2, NULL); $$ = menu_add_menu(); }; @@ -422,9 +422,9 @@ help: help_start T_HELPTEXT /* depends option */ -depends: T_DEPENDS T_ON expr T_EOL +depends: T_DEPENDS T_ON expr if_expr T_EOL { - menu_add_dep($3); + menu_add_dep($3, $4); printd(DEBUG_PARSE, "%s:%d:depends on\n", cur_filename, cur_lineno); }; diff --git a/scripts/kconfig/tests/conditional_dep/Kconfig b/scripts/kconfig/tests/conditional_dep/Kconfig new file mode 100644 index 000000000000..2015dfbce2b1 --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/Kconfig @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0 +# Test Kconfig file for conditional dependencies. + +# Enable module support for tristate testing +config MODULES + bool "Enable loadable module support" + modules + default y + +config FOO + bool "FOO symbol" + +config BAR + bool "BAR symbol" + +config TEST_BASIC + bool "Test basic conditional dependency" + depends on FOO if BAR + default y + +config TEST_COMPLEX + bool "Test complex conditional dependency" + depends on (FOO && BAR) if (FOO || BAR) + default y + +config BAZ + tristate "BAZ symbol" + +config TEST_OPTIONAL + tristate "Test simple optional dependency" + depends on BAZ if BAZ + default y diff --git a/scripts/kconfig/tests/conditional_dep/__init__.py b/scripts/kconfig/tests/conditional_dep/__init__.py new file mode 100644 index 000000000000..ab16df6487ec --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/__init__.py @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Correctly handle conditional dependencies. +""" + +def test(conf): + assert conf.oldconfig('test_config1') == 0 + assert conf.config_matches('expected_config1') + + assert conf.oldconfig('test_config2') == 0 + assert conf.config_matches('expected_config2') + + assert conf.oldconfig('test_config3') == 0 + assert conf.config_matches('expected_config3') diff --git a/scripts/kconfig/tests/conditional_dep/expected_config1 b/scripts/kconfig/tests/conditional_dep/expected_config1 new file mode 100644 index 000000000000..826ed7f541b8 --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/expected_config1 @@ -0,0 +1,11 @@ +# +# Automatically generated file; DO NOT EDIT. +# Main menu +# +CONFIG_MODULES=y +CONFIG_FOO=y +CONFIG_BAR=y +CONFIG_TEST_BASIC=y +CONFIG_TEST_COMPLEX=y +CONFIG_BAZ=m +CONFIG_TEST_OPTIONAL=m diff --git a/scripts/kconfig/tests/conditional_dep/expected_config2 b/scripts/kconfig/tests/conditional_dep/expected_config2 new file mode 100644 index 000000000000..10d2354f687f --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/expected_config2 @@ -0,0 +1,9 @@ +# +# Automatically generated file; DO NOT EDIT. +# Main menu +# +CONFIG_MODULES=y +# CONFIG_FOO is not set +CONFIG_BAR=y +CONFIG_BAZ=y +CONFIG_TEST_OPTIONAL=y diff --git a/scripts/kconfig/tests/conditional_dep/expected_config3 b/scripts/kconfig/tests/conditional_dep/expected_config3 new file mode 100644 index 000000000000..b04fa6fdfeb4 --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/expected_config3 @@ -0,0 +1,11 @@ +# +# Automatically generated file; DO NOT EDIT. +# Main menu +# +CONFIG_MODULES=y +# CONFIG_FOO is not set +# CONFIG_BAR is not set +CONFIG_TEST_BASIC=y +CONFIG_TEST_COMPLEX=y +# CONFIG_BAZ is not set +CONFIG_TEST_OPTIONAL=y diff --git a/scripts/kconfig/tests/conditional_dep/test_config1 b/scripts/kconfig/tests/conditional_dep/test_config1 new file mode 100644 index 000000000000..9b05f3ce8a99 --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/test_config1 @@ -0,0 +1,6 @@ +# Basic check that everything can be configured if selected. +CONFIG_FOO=y +CONFIG_BAR=y +CONFIG_BAZ=m +# Ensure that TEST_OPTIONAL=y with BAZ=m is converted to TEST_OPTIONAL=m +CONFIG_TEST_OPTIONAL=y diff --git a/scripts/kconfig/tests/conditional_dep/test_config2 b/scripts/kconfig/tests/conditional_dep/test_config2 new file mode 100644 index 000000000000..5e66d230a836 --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/test_config2 @@ -0,0 +1,7 @@ +# If FOO is not selected, then TEST_BASIC should fail the conditional +# dependency since BAR is set. +# TEST_COMPLEX will fail dependency as it depends on both FOO and BAR +# if either of those is selected. +CONFIG_FOO=n +CONFIG_BAR=y +CONFIG_BAZ=y diff --git a/scripts/kconfig/tests/conditional_dep/test_config3 b/scripts/kconfig/tests/conditional_dep/test_config3 new file mode 100644 index 000000000000..86304f3aa557 --- /dev/null +++ b/scripts/kconfig/tests/conditional_dep/test_config3 @@ -0,0 +1,6 @@ +# If FOO is not selected, but BAR is also not selected, then TEST_BASIC +# should pass since the dependency on FOO is conditional on BAR. +# TEST_COMPLEX should be also set since neither FOO nor BAR are selected +# so it has no dependencies. +CONFIG_FOO=n +CONFIG_BAR=n From 6059b880a93c38a90d178b49fa80403c76d1a89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 23 Dec 2025 08:04:08 +0100 Subject: [PATCH 09/39] kbuild: uapi: validate that headers do not use libc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UAPI headers should be self-contained. That means they should not use other headers from libc. Currently this is not enforced and various dependencies have crept in. Add a check to make sure no new ones are added. Signed-off-by: Thomas Weißschuh Link: https://patch.msgid.link/20251223-uapi-nostdinc-v1-1-d91545d794f7@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/Makefile | 77 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/usr/include/Makefile b/usr/include/Makefile index d8a508042fed..a9a861ec8702 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -68,12 +68,89 @@ endif # asm-generic/*.h is used by asm/*.h, and should not be included directly no-header-test += asm-generic/% +# The following are using libc header and types. +# +# Do not add a new header to the list without legitimate reason. +# Please consider to fix the header first. +# +# Sorted alphabetically. +uses-libc += linux/a.out.h +uses-libc += linux/atmbr2684.h +uses-libc += linux/auto_dev-ioctl.h +uses-libc += linux/auto_fs.h +uses-libc += linux/auto_fs4.h +uses-libc += linux/btrfs_tree.h +uses-libc += linux/cec-funcs.h +uses-libc += linux/cec.h +uses-libc += linux/dvb/dmx.h +uses-libc += linux/dvb/video.h +uses-libc += linux/ethtool.h +uses-libc += linux/ethtool_netlink.h +uses-libc += linux/fuse.h +uses-libc += linux/gsmmux.h +uses-libc += linux/icmp.h +uses-libc += linux/idxd.h +uses-libc += linux/if.h +uses-libc += linux/if_arp.h +uses-libc += linux/if_bonding.h +uses-libc += linux/if_pppox.h +uses-libc += linux/if_tunnel.h +uses-libc += linux/input.h +uses-libc += linux/ip6_tunnel.h +uses-libc += linux/joystick.h +uses-libc += linux/llc.h +uses-libc += linux/mctp.h +uses-libc += linux/mdio.h +uses-libc += linux/mii.h +uses-libc += linux/mptcp.h +uses-libc += linux/netdevice.h +uses-libc += linux/netfilter/xt_RATEEST.h +uses-libc += linux/netfilter/xt_hashlimit.h +uses-libc += linux/netfilter/xt_physdev.h +uses-libc += linux/netfilter/xt_rateest.h +uses-libc += linux/netfilter_arp/arp_tables.h +uses-libc += linux/netfilter_arp/arpt_mangle.h +uses-libc += linux/netfilter_bridge.h +uses-libc += linux/netfilter_bridge/ebtables.h +uses-libc += linux/netfilter_ipv4.h +uses-libc += linux/netfilter_ipv4/ip_tables.h +uses-libc += linux/netfilter_ipv6.h +uses-libc += linux/netfilter_ipv6/ip6_tables.h +uses-libc += linux/route.h +uses-libc += linux/shm.h +uses-libc += linux/soundcard.h +uses-libc += linux/string.h +uses-libc += linux/tipc_config.h +uses-libc += linux/uhid.h +uses-libc += linux/uinput.h +uses-libc += linux/vhost.h +uses-libc += linux/vhost_types.h +uses-libc += linux/virtio_ring.h +uses-libc += linux/wireless.h +uses-libc += regulator/regulator.h +uses-libc += scsi/fc/fc_els.h + +ifeq ($(SRCARCH),hexagon) +uses-libc += asm/sigcontext.h +endif + +ifeq ($(SRCARCH),nios2) +uses-libc += asm/ptrace.h +uses-libc += linux/bpf_perf_event.h +endif + +ifeq ($(SRCARCH),s390) +uses-libc += asm/chpid.h +uses-libc += asm/chsc.h +endif + always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ + $(if $(filter-out $(uses-libc), $*.h), -nostdinc) \ $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ From cc45d2ea5cfb820fd95cba1fcc3aed18e80a92d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 23 Dec 2025 08:04:09 +0100 Subject: [PATCH 10/39] hexagon: Drop invalid UAPI header asm/signal.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This UAPI header contains declarations of internal kernel symbols. Such declarations are invalid. Normally headers_check.pl would report an error, but apparently its dependency on CC_CAN_LINK prevent its execution on hexagon so far. As the header does not expose any additional UAPI, just make it a regular internal kernel header. asm-generic/signal.h will be used for the UAPI automatically, the same as before. Signed-off-by: Thomas Weißschuh Link: https://patch.msgid.link/20251223-uapi-nostdinc-v1-2-d91545d794f7@linutronix.de Signed-off-by: Nathan Chancellor --- arch/hexagon/include/{uapi => }/asm/signal.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename arch/hexagon/include/{uapi => }/asm/signal.h (100%) diff --git a/arch/hexagon/include/uapi/asm/signal.h b/arch/hexagon/include/asm/signal.h similarity index 100% rename from arch/hexagon/include/uapi/asm/signal.h rename to arch/hexagon/include/asm/signal.h From e2772ba5f43df6b13b04041fe52b07e8cac06ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 23 Dec 2025 08:04:10 +0100 Subject: [PATCH 11/39] kbuild: uapi: don't compile test bpf_perf_event.h on xtensa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The xtensa UAPI headers do not provide 'struct pt_regs', triggering an error: usr/include/linux/bpf_perf_event.h:14:28: error: field 'regs' has incomplete type Disable the header tests for this file on xtensa. Signed-off-by: Thomas Weißschuh Link: https://patch.msgid.link/20251223-uapi-nostdinc-v1-3-d91545d794f7@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr/include/Makefile b/usr/include/Makefile index a9a861ec8702..fd29c11c35cb 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -65,6 +65,10 @@ no-header-test += asm/uctx.h no-header-test += asm/fbio.h endif +ifeq ($(SRCARCH),xtensa) +no-header-test += linux/bpf_perf_event.h +endif + # asm-generic/*.h is used by asm/*.h, and should not be included directly no-header-test += asm-generic/% From 4ac85d9bc73ed38a3bf98a58f9a44087375332b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 23 Dec 2025 08:04:11 +0100 Subject: [PATCH 12/39] kbuild: uapi: split out command conditions into variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The condition logic will become a bit more complicated. Split them out into dedicated variables so they stay readable. Signed-off-by: Thomas Weißschuh Link: https://patch.msgid.link/20251223-uapi-nostdinc-v1-4-d91545d794f7@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index fd29c11c35cb..fa01bcda21f5 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -150,12 +150,15 @@ endif always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) +target-no-libc = $(filter-out $(uses-libc), $*.h) +target-can-compile = $(filter-out $(no-header-test), $*.h) + # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ - $(if $(filter-out $(uses-libc), $*.h), -nostdinc) \ - $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ + $(if $(target-no-libc), -nostdinc) \ + $(if $(target-can-compile), -include $< -include $<); \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ From 379b749add7eff1d1e9fdd53206e1ec5e7cd2266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 13 Jan 2026 08:29:58 +0100 Subject: [PATCH 13/39] kbuild: Drop superfluous compiler option checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many of the compiler option checks are not necessary anymore with the current supported versions of compilers (clang 15+, GCC 8.1+). Remove them. Signed-off-by: Thomas Weißschuh Link: https://patch.msgid.link/20260113-kbuild-cc-option-v1-1-011314a0f7f1@weissschuh.net [nathan: Add minor note about currently supported compilers] Signed-off-by: Nathan Chancellor --- Makefile | 2 +- scripts/Makefile.warn | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index ad91e6a936aa..362df202fb8a 100644 --- a/Makefile +++ b/Makefile @@ -1102,7 +1102,7 @@ KBUILD_CFLAGS += -fno-builtin-wcslen # change __FILE__ to the relative path to the source directory ifdef building_out_of_srctree -KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=) +KBUILD_CPPFLAGS += -fmacro-prefix-map=$(srcroot)/= endif # include additional Makefiles when needed diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn index c593ab1257de..5567da6c7dfe 100644 --- a/scripts/Makefile.warn +++ b/scripts/Makefile.warn @@ -16,7 +16,7 @@ KBUILD_CFLAGS += -Werror=return-type KBUILD_CFLAGS += -Werror=strict-prototypes KBUILD_CFLAGS += -Wno-format-security KBUILD_CFLAGS += -Wno-trigraphs -KBUILD_CFLAGS += $(call cc-option, -Wno-frame-address) +KBUILD_CFLAGS += -Wno-frame-address KBUILD_CFLAGS += $(call cc-option, -Wno-address-of-packed-member) KBUILD_CFLAGS += -Wmissing-declarations KBUILD_CFLAGS += -Wmissing-prototypes @@ -75,7 +75,7 @@ KBUILD_CFLAGS += -Wno-pointer-sign # In order to make sure new function cast mismatches are not introduced # in the kernel (to avoid tripping CFI checking), the kernel should be # globally built with -Wcast-function-type. -KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type) +KBUILD_CFLAGS += -Wcast-function-type # Currently, disable -Wstringop-overflow for GCC 11, globally. KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow) @@ -102,7 +102,7 @@ KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH) KBUILD_CFLAGS += -Werror=date-time # enforce correct pointer usage -KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) +KBUILD_CFLAGS += -Werror=incompatible-pointer-types # Require designated initializers for all marked structures KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) @@ -119,7 +119,7 @@ ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) KBUILD_CFLAGS += -Wmissing-format-attribute KBUILD_CFLAGS += -Wmissing-include-dirs -KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable) +KBUILD_CFLAGS += -Wunused-const-variable KBUILD_CPPFLAGS += -Wundef KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 @@ -128,12 +128,12 @@ else # Some diagnostics enabled by default are noisy. # Suppress them by using -Wno... except for W=1. -KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable) -KBUILD_CFLAGS += $(call cc-option, -Wno-unused-const-variable) +KBUILD_CFLAGS += -Wno-unused-but-set-variable +KBUILD_CFLAGS += -Wno-unused-const-variable KBUILD_CFLAGS += $(call cc-option, -Wno-packed-not-aligned) KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow) ifdef CONFIG_CC_IS_GCC -KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation) +KBUILD_CFLAGS += -Wno-format-truncation endif KBUILD_CFLAGS += $(call cc-option, -Wno-stringop-truncation) @@ -148,14 +148,11 @@ KBUILD_CFLAGS += -Wno-format # problematic. KBUILD_CFLAGS += -Wformat-extra-args -Wformat-invalid-specifier KBUILD_CFLAGS += -Wformat-zero-length -Wnonnull -# Requires clang-12+. -ifeq ($(call clang-min-version, 120000),y) KBUILD_CFLAGS += -Wformat-insufficient-args endif -endif -KBUILD_CFLAGS += $(call cc-option, -Wno-pointer-to-enum-cast) +KBUILD_CFLAGS += -Wno-pointer-to-enum-cast KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare -KBUILD_CFLAGS += $(call cc-option, -Wno-unaligned-access) +KBUILD_CFLAGS += -Wno-unaligned-access KBUILD_CFLAGS += -Wno-enum-compare-conditional endif @@ -169,7 +166,7 @@ ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),) KBUILD_CFLAGS += -Wdisabled-optimization KBUILD_CFLAGS += -Wshadow KBUILD_CFLAGS += $(call cc-option, -Wlogical-op) -KBUILD_CFLAGS += $(call cc-option, -Wunused-macros) +KBUILD_CFLAGS += -Wunused-macros KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2 From 1e5271393d777f6159d896943b4c44c4f3ecff52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 15 Jan 2026 08:35:44 +0100 Subject: [PATCH 14/39] hyper-v: Mark inner union in hv_kvp_exchg_msg_value as packed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The unpacked union within a packed struct generates alignment warnings on clang for 32-bit ARM: ./usr/include/linux/hyperv.h:361:2: error: field within 'struct hv_kvp_exchg_msg_value' is less aligned than 'union hv_kvp_exchg_msg_value::(anonymous at ./usr/include/linux/hyperv.h:361:2)' and is usually due to 'struct hv_kvp_exchg_msg_value' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] 361 | union { | ^ With the recent changes to compile-test the UAPI headers in more cases, this warning in combination with CONFIG_WERROR breaks the build. Fix the warning. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202512140314.DzDxpIVn-lkp@intel.com/ Reported-by: Nathan Chancellor Closes: https://lore.kernel.org/linux-kbuild/20260110-uapi-test-disable-headers-arm-clang-unaligned-access-v1-1-b7b0fa541daa@kernel.org/ Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-kbuild/29b2e736-d462-45b7-a0a9-85f8d8a3de56@app.fastmail.com/ Signed-off-by: Thomas Weißschuh Acked-by: Wei Liu (Microsoft) Tested-by: Nicolas Schier Reviewed-by: Nicolas Schier Acked-by: Greg Kroah-Hartman Link: https://patch.msgid.link/20260115-kbuild-alignment-vbox-v1-1-076aed1623ff@linutronix.de Signed-off-by: Nathan Chancellor --- include/uapi/linux/hyperv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h index aaa502a7bff4..1749b35ab2c2 100644 --- a/include/uapi/linux/hyperv.h +++ b/include/uapi/linux/hyperv.h @@ -362,7 +362,7 @@ struct hv_kvp_exchg_msg_value { __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; __u32 value_u32; __u64 value_u64; - }; + } __attribute__((packed)); } __attribute__((packed)); struct hv_kvp_msg_enumerate { From c25d01e1c4f2d43f47af87c00e223f5ca7c71792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 15 Jan 2026 08:35:45 +0100 Subject: [PATCH 15/39] virt: vbox: uapi: Mark inner unions in packed structs as packed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The unpacked unions within a packed struct generates alignment warnings on clang for 32-bit ARM: ./usr/include/linux/vbox_vmmdev_types.h:239:4: error: field u within 'struct vmmdev_hgcm_function_parameter32' is less aligned than 'union (unnamed union at ./usr/include/linux/vbox_vmmdev_types.h:223:2)' and is usually due to 'struct vmmdev_hgcm_function_parameter32' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] 239 | } u; | ^ ./usr/include/linux/vbox_vmmdev_types.h:254:6: error: field u within 'struct vmmdev_hgcm_function_parameter64::(anonymous union)::(unnamed at ./usr/include/linux/vbox_vmmdev_types.h:249:3)' is less aligned than 'union (unnamed union at ./usr/include/linux/vbox_vmmdev_types.h:251:4)' and is usually due to 'struct vmmdev_hgcm_function_parameter64::(anonymous union)::(unnamed at ./usr/include/linux/vbox_vmmdev_types.h:249:3)' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] With the recent changes to compile-test the UAPI headers in more cases, these warning in combination with CONFIG_WERROR breaks the build. Fix the warnings. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202512140314.DzDxpIVn-lkp@intel.com/ Reported-by: Nathan Chancellor Closes: https://lore.kernel.org/linux-kbuild/20260110-uapi-test-disable-headers-arm-clang-unaligned-access-v1-1-b7b0fa541daa@kernel.org/ Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-kbuild/29b2e736-d462-45b7-a0a9-85f8d8a3de56@app.fastmail.com/ Signed-off-by: Thomas Weißschuh Tested-by: Nicolas Schier Reviewed-by: Nicolas Schier Acked-by: Greg Kroah-Hartman Link: https://patch.msgid.link/20260115-kbuild-alignment-vbox-v1-2-076aed1623ff@linutronix.de Signed-off-by: Nathan Chancellor --- include/uapi/linux/vbox_vmmdev_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h index 6073858d52a2..11f3627c3729 100644 --- a/include/uapi/linux/vbox_vmmdev_types.h +++ b/include/uapi/linux/vbox_vmmdev_types.h @@ -236,7 +236,7 @@ struct vmmdev_hgcm_function_parameter32 { /** Relative to the request header. */ __u32 offset; } page_list; - } u; + } __packed u; } __packed; VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter32, 4 + 8); @@ -251,7 +251,7 @@ struct vmmdev_hgcm_function_parameter64 { union { __u64 phys_addr; __u64 linear_addr; - } u; + } __packed u; } __packed pointer; struct { /** Size of the buffer described by the page list. */ From 2a0a30805a7d27470e02137cae72f7c3188e44eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 23 Dec 2025 08:04:12 +0100 Subject: [PATCH 16/39] kbuild: uapi: drop dependency on CC_CAN_LINK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The header tests try to compile each header. Some UAPI headers depend on libc headers so they need a full userspace toolchain to build. This dependency is expressed in kconfig as a dependency on CC_CAN_LINK. Many kernel builds do not satisfy CC_CAN_LINK as they only use a minimal kernel (cross-) compiler. In those configurations the UAPI headers are not tested at all. However most UAPI headers do not even depend on any libc headers, and such dependencies are undesired in any case. Also the static analysis performed by headers_check.pl does not need CC_CAN_LINK. Drop the hard dependency on CC_CAN_LINK and instead skip the affected compilation step for exactly those headers which require libc. Signed-off-by: Thomas Weißschuh Link: https://patch.msgid.link/20251223-uapi-nostdinc-v1-5-d91545d794f7@linutronix.de Signed-off-by: Nathan Chancellor --- init/Kconfig | 2 +- usr/include/Makefile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index fa79feb8fe57..4e7ae65683ee 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -247,7 +247,7 @@ config WERROR config UAPI_HEADER_TEST bool "Compile test UAPI headers" - depends on HEADERS_INSTALL && CC_CAN_LINK + depends on HEADERS_INSTALL help Compile test headers exported to user-space to ensure they are self-contained, i.e. compilable as standalone units. diff --git a/usr/include/Makefile b/usr/include/Makefile index fa01bcda21f5..6d86a53c6f0a 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -151,7 +151,8 @@ endif always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) target-no-libc = $(filter-out $(uses-libc), $*.h) -target-can-compile = $(filter-out $(no-header-test), $*.h) +target-can-compile = $(and $(filter-out $(no-header-test), $*.h), \ + $(or $(CONFIG_CC_CAN_LINK), $(target-no-libc))) # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< From 983233ac2ef1b6a423419e0542734e8f79802124 Mon Sep 17 00:00:00 2001 From: Jihan LIN Date: Wed, 14 Jan 2026 19:47:44 +0800 Subject: [PATCH 17/39] Documentation/kbuild: Document gendwarfksyms build dependencies Although dependencies for gendwarfksyms were recently added to the packaging rules [1-2], the corresponding documentation was missing. Document the required build dependencies for gendwarfksyms, and include a few examples for installing these dependencies on some distributions. [1] commit 657f96cb7c06 ("kbuild: deb-pkg: Add libdw-dev:native to Build-Depends-Arch") [2] commit 5bd6bdd0f76e ("kbuild: rpm-pkg: Add (elfutils-devel or libdw-devel) to BuildRequires") Signed-off-by: Jihan LIN Reviewed-by: Petr Pavlu Link: https://patch.msgid.link/20260114-documents_gendwarfksyms-v2-1-297c98bd62c6@gmail.com [nathan: Applied Petr's suggested changes from review and minor commit message formatting adjustments] Signed-off-by: Nathan Chancellor --- Documentation/kbuild/gendwarfksyms.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Documentation/kbuild/gendwarfksyms.rst b/Documentation/kbuild/gendwarfksyms.rst index ed366250a54e..c5e4617b4b41 100644 --- a/Documentation/kbuild/gendwarfksyms.rst +++ b/Documentation/kbuild/gendwarfksyms.rst @@ -14,6 +14,29 @@ selected, **gendwarfksyms** is used instead to calculate symbol versions from the DWARF debugging information, which contains the necessary details about the final module ABI. +Dependencies +------------ + +gendwarfksyms depends on the libelf, libdw, and zlib libraries. + +Here are a few examples of how to install these dependencies: + +* Arch Linux and derivatives:: + + sudo pacman --needed -S libelf zlib + +* Debian, Ubuntu, and derivatives:: + + sudo apt install libelf-dev libdw-dev zlib1g-dev + +* Fedora and derivatives:: + + sudo dnf install elfutils-libelf-devel elfutils-devel zlib-devel + +* openSUSE and derivatives:: + + sudo zypper install libelf-devel libdw-devel zlib-devel + Usage ----- From 301a02d405a3ac4c7661b47571e2b843671e9c60 Mon Sep 17 00:00:00 2001 From: Jihan LIN Date: Wed, 14 Jan 2026 19:47:45 +0800 Subject: [PATCH 18/39] Documentation/kbuild: gendwarfksyms: Style cleanup The indentation in gendwarfksyms.rst currently uses a mix of tabs and spaces. Convert all indentation to tabs, and match the usage output and code examples with theirs references. Suggested-by: Miguel Ojeda Signed-off-by: Jihan LIN Reviewed-by: Petr Pavlu Link: https://patch.msgid.link/20260114-documents_gendwarfksyms-v2-2-297c98bd62c6@gmail.com [nathan: Minor commit message formatting adjustment] Signed-off-by: Nathan Chancellor --- Documentation/kbuild/gendwarfksyms.rst | 100 ++++++++++++------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Documentation/kbuild/gendwarfksyms.rst b/Documentation/kbuild/gendwarfksyms.rst index c5e4617b4b41..f1573dcc63ac 100644 --- a/Documentation/kbuild/gendwarfksyms.rst +++ b/Documentation/kbuild/gendwarfksyms.rst @@ -43,17 +43,17 @@ Usage gendwarfksyms accepts a list of object files on the command line, and a list of symbol names (one per line) in standard input:: - Usage: gendwarfksyms [options] elf-object-file ... < symbol-list + Usage: gendwarfksyms [options] elf-object-file ... < symbol-list - Options: - -d, --debug Print debugging information - --dump-dies Dump DWARF DIE contents - --dump-die-map Print debugging information about die_map changes - --dump-types Dump type strings - --dump-versions Dump expanded type strings used for symbol versions - -s, --stable Support kABI stability features - -T, --symtypes file Write a symtypes file - -h, --help Print this message + Options: + -d, --debug Print debugging information + --dump-dies Dump DWARF DIE contents + --dump-die-map Print debugging information about die_map changes + --dump-types Dump type strings + --dump-versions Dump expanded type strings used for symbol versions + -s, --stable Support kABI stability features + -T, --symtypes file Write a symtypes file + -h, --help Print this message Type information availability @@ -69,9 +69,9 @@ TU where symbols are actually exported, gendwarfksyms adds a pointer to exported symbols in the `EXPORT_SYMBOL()` macro using the following macro:: - #define __GENDWARFKSYMS_EXPORT(sym) \ - static typeof(sym) *__gendwarfksyms_ptr_##sym __used \ - __section(".discard.gendwarfksyms") = &sym; + #define __GENDWARFKSYMS_EXPORT(sym) \ + static typeof(sym) *__gendwarfksyms_ptr_##sym __used \ + __section(".discard.gendwarfksyms") = &sym; When a symbol pointer is found in DWARF, gendwarfksyms can use its @@ -94,14 +94,14 @@ either a type reference or a symbol name. Type references have a one-letter prefix followed by "#" and the name of the type. Four reference types are supported:: - e# = enum - s# = struct - t# = typedef - u# = union + e# = enum + s# = struct + t# = typedef + u# = union Type names with spaces in them are wrapped in single quotes, e.g.:: - s#'core::result::Result' + s#'core::result::Result' The rest of the line contains a type string. Unlike with genksyms that produces C-style type strings, gendwarfksyms uses the same simple parsed @@ -151,8 +151,8 @@ the rules. The fields are as follows: The following helper macros, for example, can be used to specify rules in the source code:: - #define ___KABI_RULE(hint, target, value) \ - static const char __PASTE(__gendwarfksyms_rule_, \ + #define ___KABI_RULE(hint, target, value) \ + static const char __PASTE(__gendwarfksyms_rule_, \ __COUNTER__)[] __used __aligned(1) \ __section(".discard.gendwarfksyms.kabi_rules") = \ "1\0" #hint "\0" target "\0" value @@ -273,18 +273,18 @@ The rule fields are expected to be as follows: Using the `__KABI_RULE` macro, this rule can be defined as:: - #define KABI_BYTE_SIZE(fqn, value) \ - __KABI_RULE(byte_size, fqn, value) + #define KABI_BYTE_SIZE(fqn, value) \ + __KABI_RULE(byte_size, fqn, value) Example usage:: struct s { - /* Unchanged original members */ + /* Unchanged original members */ unsigned long a; - void *p; + void *p; - /* Appended new members */ - KABI_IGNORE(0, unsigned long n); + /* Appended new members */ + KABI_IGNORE(0, unsigned long n); }; KABI_BYTE_SIZE(s, 16); @@ -353,21 +353,21 @@ reserved member needs a unique name, but as the actual purpose is usually not known at the time the space is reserved, for convenience, names that start with `__kabi_` are left out when calculating symbol versions:: - struct s { - long a; - long __kabi_reserved_0; /* reserved for future use */ - }; + struct s { + long a; + long __kabi_reserved_0; /* reserved for future use */ + }; The reserved space can be taken into use by wrapping the member in a union, which includes the original type and the replacement member:: - struct s { - long a; - union { - long __kabi_reserved_0; /* original type */ - struct b b; /* replaced field */ - }; - }; + struct s { + long a; + union { + long __kabi_reserved_0; /* original type */ + struct b b; /* replaced field */ + }; + }; If the `__kabi_` naming scheme was used when reserving space, the name of the first member of the union must start with `__kabi_reserved`. This @@ -392,11 +392,11 @@ Predicting which structures will require changes during the support timeframe isn't always possible, in which case one might have to resort to placing new members into existing alignment holes:: - struct s { - int a; - /* a 4-byte alignment hole */ - unsigned long b; - }; + struct s { + int a; + /* a 4-byte alignment hole */ + unsigned long b; + }; While this won't change the size of the data structure, one needs to @@ -405,14 +405,14 @@ to reserved fields, this can be accomplished by wrapping the added member to a union where one of the fields has a name starting with `__kabi_ignored`:: - struct s { - int a; - union { - char __kabi_ignored_0; - int n; - }; - unsigned long b; - }; + struct s { + int a; + union { + char __kabi_ignored_0; + int n; + }; + unsigned long b; + }; With **--stable**, both versions produce the same symbol version. The examples include a `KABI_IGNORE` macro to simplify the code. From 502678b88cb3b01908315bc2ba91557f4d2cf49a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 21 Jan 2026 14:42:39 +0100 Subject: [PATCH 19/39] kbuild: Reject unexpected values for LLVM= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The LLVM argument is documented to accept one of three forms: * a literal '1' to use the default 'clang', * a toolchain prefix path, ending in a trailing '/', * a version suffix. All other values are silently treated as '1'. If for example the user accidentally forgets the trailing '/' of a toolchain prefix, kbuild will unexpectedly and silently fall back to the system toolchain. Instead report an error if the user specified an invalid value for LLVM. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Link: https://patch.msgid.link/20260121-kbuild-llvm-arg-v2-1-5e4d8dca4ad8@weissschuh.net Signed-off-by: Nathan Chancellor --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 362df202fb8a..93831019c17b 100644 --- a/Makefile +++ b/Makefile @@ -447,6 +447,8 @@ ifneq ($(filter %/,$(LLVM)),) LLVM_PREFIX := $(LLVM) else ifneq ($(filter -%,$(LLVM)),) LLVM_SUFFIX := $(LLVM) +else ifneq ($(LLVM),1) +$(error Invalid value for LLVM, see Documentation/kbuild/llvm.rst) endif HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX) From 8f989b3b6f0f029e34fcfbf259e4ac47e2028d4b Mon Sep 17 00:00:00 2001 From: Guillaume Tucker Date: Thu, 22 Jan 2026 15:06:59 +0100 Subject: [PATCH 20/39] scripts: add tool to run containerized builds Add a 'scripts/container' tool written in Python to run any command in the source tree from within a container. This can typically be used to call 'make' with a compiler toolchain image to run reproducible builds but any arbitrary command can be run too. Only Docker and Podman are supported in this initial version. Add a new entry to MAINTAINERS accordingly. Link: https://lore.kernel.org/all/affb7aff-dc9b-4263-bbd4-a7965c19ac4e@gtucker.io/ Signed-off-by: Guillaume Tucker Tested-by: Nicolas Schier Acked-by: Nicolas Schier Link: https://patch.msgid.link/9b8da20157e409e8fa3134d2101678779e157256.1769090419.git.gtucker@gtucker.io Signed-off-by: Nathan Chancellor --- MAINTAINERS | 6 ++ scripts/container | 199 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100755 scripts/container diff --git a/MAINTAINERS b/MAINTAINERS index 5b11839cba9d..d48ba2e5ec24 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6380,6 +6380,11 @@ S: Supported F: drivers/video/console/ F: include/linux/console* +CONTAINER BUILD SCRIPT +M: Guillaume Tucker +S: Maintained +F: scripts/container + CONTEXT TRACKING M: Frederic Weisbecker M: "Paul E. McKenney" @@ -13668,6 +13673,7 @@ F: scripts/Makefile* F: scripts/bash-completion/ F: scripts/basic/ F: scripts/clang-tools/ +F: scripts/container F: scripts/dummy-tools/ F: scripts/include/ F: scripts/mk* diff --git a/scripts/container b/scripts/container new file mode 100755 index 000000000000..b05333d8530b --- /dev/null +++ b/scripts/container @@ -0,0 +1,199 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2025 Guillaume Tucker + +"""Containerized builds""" + +import abc +import argparse +import logging +import os +import pathlib +import shutil +import subprocess +import sys +import uuid + + +class ContainerRuntime(abc.ABC): + """Base class for a container runtime implementation""" + + name = None # Property defined in each implementation class + + def __init__(self, args, logger): + self._uid = args.uid or os.getuid() + self._gid = args.gid or args.uid or os.getgid() + self._env_file = args.env_file + self._shell = args.shell + self._logger = logger + + @classmethod + def is_present(cls): + """Determine whether the runtime is present on the system""" + return shutil.which(cls.name) is not None + + @abc.abstractmethod + def _do_run(self, image, cmd, container_name): + """Runtime-specific handler to run a command in a container""" + + @abc.abstractmethod + def _do_abort(self, container_name): + """Runtime-specific handler to abort a running container""" + + def run(self, image, cmd): + """Run a command in a runtime container""" + container_name = str(uuid.uuid4()) + self._logger.debug("container: %s", container_name) + try: + return self._do_run(image, cmd, container_name) + except KeyboardInterrupt: + self._logger.error("user aborted") + self._do_abort(container_name) + return 1 + + +class CommonRuntime(ContainerRuntime): + """Common logic for Docker and Podman""" + + def _do_run(self, image, cmd, container_name): + cmdline = [self.name, 'run'] + cmdline += self._get_opts(container_name) + cmdline.append(image) + cmdline += cmd + self._logger.debug('command: %s', ' '.join(cmdline)) + return subprocess.call(cmdline) + + def _get_opts(self, container_name): + opts = [ + '--name', container_name, + '--rm', + '--volume', f'{pathlib.Path.cwd()}:/src', + '--workdir', '/src', + ] + if self._env_file: + opts += ['--env-file', self._env_file] + if self._shell: + opts += ['--interactive', '--tty'] + return opts + + def _do_abort(self, container_name): + subprocess.call([self.name, 'kill', container_name]) + + +class DockerRuntime(CommonRuntime): + """Run a command in a Docker container""" + + name = 'docker' + + def _get_opts(self, container_name): + return super()._get_opts(container_name) + [ + '--user', f'{self._uid}:{self._gid}' + ] + + +class PodmanRuntime(CommonRuntime): + """Run a command in a Podman container""" + + name = 'podman' + + def _get_opts(self, container_name): + return super()._get_opts(container_name) + [ + '--userns', f'keep-id:uid={self._uid},gid={self._gid}', + ] + + +class Runtimes: + """List of all supported runtimes""" + + runtimes = [PodmanRuntime, DockerRuntime] + + @classmethod + def get_names(cls): + """Get a list of all the runtime names""" + return list(runtime.name for runtime in cls.runtimes) + + @classmethod + def get(cls, name): + """Get a single runtime class matching the given name""" + for runtime in cls.runtimes: + if runtime.name == name: + if not runtime.is_present(): + raise ValueError(f"runtime not found: {name}") + return runtime + raise ValueError(f"unknown runtime: {name}") + + @classmethod + def find(cls): + """Find the first runtime present on the system""" + for runtime in cls.runtimes: + if runtime.is_present(): + return runtime + raise ValueError("no runtime found") + + +def _get_logger(verbose): + """Set up a logger with the appropriate level""" + logger = logging.getLogger('container') + handler = logging.StreamHandler() + handler.setFormatter(logging.Formatter( + fmt='[container {levelname}] {message}', style='{' + )) + logger.addHandler(handler) + logger.setLevel(logging.DEBUG if verbose is True else logging.INFO) + return logger + + +def main(args): + """Main entry point for the container tool""" + logger = _get_logger(args.verbose) + try: + cls = Runtimes.get(args.runtime) if args.runtime else Runtimes.find() + except ValueError as ex: + logger.error(ex) + return 1 + logger.debug("runtime: %s", cls.name) + logger.debug("image: %s", args.image) + return cls(args, logger).run(args.image, args.cmd) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + 'container', + description="See the documentation for more details: " + "https://docs.kernel.org/dev-tools/container.html" + ) + parser.add_argument( + '-e', '--env-file', + help="Path to an environment file to load in the container." + ) + parser.add_argument( + '-g', '--gid', + help="Group ID to use inside the container." + ) + parser.add_argument( + '-i', '--image', required=True, + help="Container image name." + ) + parser.add_argument( + '-r', '--runtime', choices=Runtimes.get_names(), + help="Container runtime name. If not specified, the first one found " + "on the system will be used i.e. Podman if present, otherwise Docker." + ) + parser.add_argument( + '-s', '--shell', action='store_true', + help="Run the container in an interactive shell." + ) + parser.add_argument( + '-u', '--uid', + help="User ID to use inside the container. If the -g option is not " + "specified, the user ID will also be set as the group ID." + ) + parser.add_argument( + '-v', '--verbose', action='store_true', + help="Enable verbose output." + ) + parser.add_argument( + 'cmd', nargs='+', + help="Command to run in the container" + ) + sys.exit(main(parser.parse_args(sys.argv[1:]))) From 6eac13c876805f61bbb588eaff5ada0b6dc603e8 Mon Sep 17 00:00:00 2001 From: Guillaume Tucker Date: Thu, 22 Jan 2026 15:07:00 +0100 Subject: [PATCH 21/39] Documentation: dev-tools: add container.rst page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a dev-tools/container.rst documentation page for the scripts/container tool. This covers the basic usage with additional information about environment variables and user IDs. It also includes a number of practical examples with a reference to the experimental kernel.org toolchain images. Update MAINTAINERS accordingly with a reference to the added file. Signed-off-by: Guillaume Tucker Reviewed-by: Onur Özkan Tested-by: Nicolas Schier Acked-by: Nicolas Schier Link: https://patch.msgid.link/af886533cc5cbdd6ef1d909793b79a1ad42c74ca.1769090419.git.gtucker@gtucker.io Signed-off-by: Nathan Chancellor --- Documentation/dev-tools/container.rst | 227 ++++++++++++++++++++++++++ Documentation/dev-tools/index.rst | 1 + MAINTAINERS | 1 + 3 files changed, 229 insertions(+) create mode 100644 Documentation/dev-tools/container.rst diff --git a/Documentation/dev-tools/container.rst b/Documentation/dev-tools/container.rst new file mode 100644 index 000000000000..452415b64662 --- /dev/null +++ b/Documentation/dev-tools/container.rst @@ -0,0 +1,227 @@ +.. SPDX-License-Identifier: GPL-2.0-only +.. Copyright (C) 2025 Guillaume Tucker + +==================== +Containerized Builds +==================== + +The ``container`` tool can be used to run any command in the kernel source tree +from within a container. Doing so facilitates reproducing builds across +various platforms, for example when a test bot has reported an issue which +requires a specific version of a compiler or an external test suite. While +this can already be done by users who are familiar with containers, having a +dedicated tool in the kernel tree lowers the barrier to entry by solving common +problems once and for all (e.g. user id management). It also makes it easier +to share an exact command line leading to a particular result. The main use +case is likely to be kernel builds but virtually anything can be run: KUnit, +checkpatch etc. provided a suitable image is available. + + +Options +======= + +Command line syntax:: + + scripts/container -i IMAGE [OPTION]... CMD... + +Available options: + +``-e, --env-file ENV_FILE`` + + Path to an environment file to load in the container. + +``-g, --gid GID`` + + Group id to use inside the container. + +``-i, --image IMAGE`` + + Container image name (required). + +``-r, --runtime RUNTIME`` + + Container runtime name. Supported runtimes: ``docker``, ``podman``. + + If not specified, the first one found on the system will be used + i.e. Podman if present, otherwise Docker. + +``-s, --shell`` + + Run the container in an interactive shell. + +``-u, --uid UID`` + + User id to use inside the container. + + If the ``-g`` option is not specified, the user id will also be used for + the group id. + +``-v, --verbose`` + + Enable verbose output. + +``-h, --help`` + + Show the help message and exit. + + +Usage +===== + +It's entirely up to the user to choose which image to use and the ``CMD`` +arguments are passed directly as an arbitrary command line to run in the +container. The tool will take care of mounting the source tree as the current +working directory and adjust the user and group id as needed. + +The container image which would typically include a compiler toolchain is +provided by the user and selected via the ``-i`` option. The container runtime +can be selected with the ``-r`` option, which can be either ``docker`` or +``podman``. If none is specified, the first one found on the system will be +used while giving priority to Podman. Support for other runtimes may be added +later depending on their popularity among users. + +By default, commands are run non-interactively. The user can abort a running +container with SIGINT (Ctrl-C). To run commands interactively with a TTY, the +``--shell`` or ``-s`` option can be used. Signals will then be received by the +shell directly rather than the parent ``container`` process. To exit an +interactive shell, use Ctrl-D or ``exit``. + +.. note:: + + The only host requirement aside from a container runtime is Python 3.10 or + later. + +.. note:: + + Out-of-tree builds are not fully supported yet. The ``O=`` option can + however already be used with a relative path inside the source tree to keep + separate build outputs. A workaround to build outside the tree is to use + ``mount --bind``, see the examples section further down. + + +Environment Variables +===================== + +Environment variables are not propagated to the container so they have to be +either defined in the image itself or via the ``-e`` option using an +environment file. In some cases it makes more sense to have them defined in +the Containerfile used to create the image. For example, a Clang-only compiler +toolchain image may have ``LLVM=1`` defined. + +The local environment file is more useful for user-specific variables added +during development. It is passed as-is to the container runtime so its format +may vary. Typically, it will look like the output of ``env``. For example:: + + INSTALL_MOD_STRIP=1 + SOME_RANDOM_TEXT=One upon a time + +Please also note that ``make`` options can still be passed on the command line, +so while this can't be done since the first argument needs to be the +executable:: + + scripts/container -i docker.io/tuxmake/korg-clang LLVM=1 make # won't work + +this will work:: + + scripts/container -i docker.io/tuxmake/korg-clang make LLVM=1 + + +User IDs +======== + +This is an area where the behaviour will vary slightly depending on the +container runtime. The goal is to run commands as the user invoking the tool. +With Podman, a namespace is created to map the current user id to a different +one in the container (1000 by default). With Docker, while this is also +possible with recent versions it requires a special feature to be enabled in +the daemon so it's not used here for simplicity. Instead, the container is run +with the current user id directly. In both cases, this will provide the same +file permissions for the kernel source tree mounted as a volume. The only +difference is that when using Docker without a namespace, the user id may not +be the same as the default one set in the image. + +Say, we're using an image which sets up a default user with id 1000 and the +current user calling the ``container`` tool has id 1234. The kernel source +tree was checked out by this same user so the files belong to user 1234. With +Podman, the container will be running as user id 1000 with a mapping to id 1234 +so that the files from the mounted volume appear to belong to id 1000 inside +the container. With Docker and no namespace, the container will be running +with user id 1234 which can access the files in the volume but not in the user +1000 home directory. This shouldn't be an issue when running commands only in +the kernel tree but it is worth highlighting here as it might matter for +special corner cases. + +.. note:: + + Podman's `Docker compatibility + `__ + mode to run ``docker`` commands on top of a Podman backend is more complex + and not fully supported yet. As such, Podman will take priority if both + runtimes are available on the system. + + +Examples +======== + +The TuxMake project provides a variety of prebuilt container images available +on `Docker Hub `__. Here's the shortest +example to build a kernel using a TuxMake Clang image:: + + scripts/container -i docker.io/tuxmake/korg-clang -- make LLVM=1 defconfig + scripts/container -i docker.io/tuxmake/korg-clang -- make LLVM=1 -j$(nproc) + +.. note:: + + When running a command with options within the container, it should be + separated with a double dash ``--`` to not confuse them with the + ``container`` tool options. Plain commands with no options don't strictly + require the double dashes e.g.:: + + scripts/container -i docker.io/tuxmake/korg-clang make mrproper + +To run ``checkpatch.pl`` in a ``patches`` directory with a generic Perl image:: + + scripts/container -i perl:slim-trixie scripts/checkpatch.pl patches/* + +As an alternative to the TuxMake images, the examples below refer to +``kernel.org`` images which are based on the `kernel.org compiler toolchains +`__. These aren't (yet) officially +available in any public registry but users can build their own locally instead +using this `experimental repository +`__ by running ``make +PREFIX=kernel.org/``. + +To build just ``bzImage`` using Clang:: + + scripts/container -i kernel.org/clang -- make bzImage -j$(nproc) + +Same with GCC 15 as a particular version tag:: + + scripts/container -i kernel.org/gcc:15 -- make bzImage -j$(nproc) + +For an out-of-tree build, a trick is to bind-mount the destination directory to +a relative path inside the source tree:: + + mkdir -p $HOME/tmp/my-kernel-build + mkdir -p build + sudo mount --bind $HOME/tmp/my-kernel-build build + scripts/container -i kernel.org/gcc -- make mrproper + scripts/container -i kernel.org/gcc -- make O=build defconfig + scripts/container -i kernel.org/gcc -- make O=build -j$(nproc) + +To run KUnit in an interactive shell and get the full output:: + + scripts/container -s -i kernel.org/gcc:kunit -- \ + tools/testing/kunit/kunit.py \ + run \ + --arch=x86_64 \ + --cross_compile=x86_64-linux- + +To just start an interactive shell:: + + scripts/container -si kernel.org/gcc bash + +To build the HTML documentation, which requires the ``kdocs`` image built with +``make PREFIX=kernel.org/ extra`` as it's not a compiler toolchain:: + + scripts/container -i kernel.org/kdocs make htmldocs diff --git a/Documentation/dev-tools/index.rst b/Documentation/dev-tools/index.rst index 4b8425e348ab..527a0e4cf2ed 100644 --- a/Documentation/dev-tools/index.rst +++ b/Documentation/dev-tools/index.rst @@ -38,6 +38,7 @@ Documentation/process/debugging/index.rst gpio-sloppy-logic-analyzer autofdo propeller + container .. only:: subproject and html diff --git a/MAINTAINERS b/MAINTAINERS index d48ba2e5ec24..643cbdf608ea 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6383,6 +6383,7 @@ F: include/linux/console* CONTAINER BUILD SCRIPT M: Guillaume Tucker S: Maintained +F: Documentation/dev-tools/container.rst F: scripts/container CONTEXT TRACKING From ff79d31eb536f6d87bcbc09287d54d5606bf6dbe Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 16 Jan 2026 10:34:01 +0100 Subject: [PATCH 22/39] mips: Add support for PC32 relocations in vmlinux MIPS supports PC32 relocations like most other architectures, which will be used by kallsyms to make its symbol references visible to the linker. Given that these are place-relative, they can be ignored by the 'relocs' tool, just like other PC type relocations. Signed-off-by: Ard Biesheuvel Link: https://patch.msgid.link/20260116093359.2442297-5-ardb+git@google.com Signed-off-by: Nathan Chancellor --- arch/mips/boot/tools/relocs.c | 2 ++ arch/mips/include/asm/elf.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/mips/boot/tools/relocs.c b/arch/mips/boot/tools/relocs.c index 9863e1d5c62e..30809f47415a 100644 --- a/arch/mips/boot/tools/relocs.c +++ b/arch/mips/boot/tools/relocs.c @@ -79,6 +79,7 @@ static const char *rel_type(unsigned type) REL_TYPE(R_MIPS_HIGHEST), REL_TYPE(R_MIPS_PC21_S2), REL_TYPE(R_MIPS_PC26_S2), + REL_TYPE(R_MIPS_PC32), #undef REL_TYPE }; const char *name = "unknown type rel type name"; @@ -522,6 +523,7 @@ static int do_reloc(struct section *sec, Elf_Rel *rel, Elf_Sym *sym, case R_MIPS_PC16: case R_MIPS_PC21_S2: case R_MIPS_PC26_S2: + case R_MIPS_PC32: /* * NONE can be ignored and PC relative relocations don't * need to be adjusted. diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h index dc8d2863752c..aaef0eaa68d5 100644 --- a/arch/mips/include/asm/elf.h +++ b/arch/mips/include/asm/elf.h @@ -123,6 +123,8 @@ #define R_MIPS_LOVENDOR 100 #define R_MIPS_HIVENDOR 127 +#define R_MIPS_PC32 248 + #define SHN_MIPS_ACCOMON 0xff00 /* Allocated common symbols */ #define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ #define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ From a081b5789255d27b76cd2cbab85676b2a31dbde1 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 16 Jan 2026 10:34:02 +0100 Subject: [PATCH 23/39] kallsyms: Get rid of kallsyms relative base When the kallsyms relative base was introduced, per-CPU variable references on x86_64 SMP were implemented as offsets into the respective per-CPU region, rather than offsets relative to the location of the variable's template in the kernel image, which is how other architectures implement it. This required kallsyms to reason about the difference between the two, and the sign of the value in the kallsyms_offsets[] array was used to distinguish them. This meant that negative offsets were not permitted for ordinary variables, and so it was crucial that the relative base was chosen such that all offsets were positive numbers. This is no longer needed: instead, the offsets can simply be encoded as values in the range -/+ 2 GiB, which is precisely what PC32 relocations provide on most architectures. So it is possible to simplify the logic, and just use _text as the anchor directly, and let the linker calculate the final value based on the location of the entry itself. Some architectures (nios2, extensa) do not support place-relative relocations at all, but these are all 32-bit and non-relocatable, and so there is no need for place-relative relocations in the first place, and the actual symbol values can just be stored directly. This makes all entries in the kallsyms_offsets[] array visible as place-relative references in the ELF metadata, which will be important when implementing ELF-based fg-kaslr. Reviewed-by: Kees Cook Signed-off-by: Ard Biesheuvel Link: https://patch.msgid.link/20260116093359.2442297-6-ardb+git@google.com Signed-off-by: Nathan Chancellor --- kernel/kallsyms.c | 6 ++- kernel/kallsyms_internal.h | 1 - kernel/vmcore_info.c | 1 - scripts/kallsyms.c | 62 ++++++++--------------------- scripts/link-vmlinux.sh | 4 ++ tools/perf/tests/vmlinux-kallsyms.c | 1 - 6 files changed, 24 insertions(+), 51 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 049e296f586c..6125724aadb1 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -151,8 +151,10 @@ static unsigned int get_symbol_offset(unsigned long pos) unsigned long kallsyms_sym_address(int idx) { - /* values are unsigned offsets */ - return kallsyms_relative_base + (u32)kallsyms_offsets[idx]; + /* non-relocatable 32-bit kernels just embed the value directly */ + if (!IS_ENABLED(CONFIG_64BIT) && !IS_ENABLED(CONFIG_RELOCATABLE)) + return (u32)kallsyms_offsets[idx]; + return (unsigned long)offset_to_ptr(kallsyms_offsets + idx); } static unsigned int get_symbol_seq(int index) diff --git a/kernel/kallsyms_internal.h b/kernel/kallsyms_internal.h index 9633782f8250..81a867dbe57d 100644 --- a/kernel/kallsyms_internal.h +++ b/kernel/kallsyms_internal.h @@ -8,7 +8,6 @@ extern const int kallsyms_offsets[]; extern const u8 kallsyms_names[]; extern const unsigned int kallsyms_num_syms; -extern const unsigned long kallsyms_relative_base; extern const char kallsyms_token_table[]; extern const u16 kallsyms_token_index[]; diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c index fe9bf8db1922..f114719f6cb5 100644 --- a/kernel/vmcore_info.c +++ b/kernel/vmcore_info.c @@ -238,7 +238,6 @@ static int __init crash_save_vmcoreinfo_init(void) VMCOREINFO_SYMBOL(kallsyms_token_table); VMCOREINFO_SYMBOL(kallsyms_token_index); VMCOREINFO_SYMBOL(kallsyms_offsets); - VMCOREINFO_SYMBOL(kallsyms_relative_base); #endif /* CONFIG_KALLSYMS */ arch_crash_save_vmcoreinfo(); diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 4b0234e4b12f..37d5c095ad22 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -46,7 +46,6 @@ struct addr_range { }; static unsigned long long _text; -static unsigned long long relative_base; static struct addr_range text_ranges[] = { { "_stext", "_etext" }, { "_sinittext", "_einittext" }, @@ -57,6 +56,7 @@ static struct addr_range text_ranges[] = { static struct sym_entry **table; static unsigned int table_size, table_cnt; static int all_symbols; +static int pc_relative; static int token_profit[0x10000]; @@ -280,7 +280,7 @@ static void read_map(const char *in) static void output_label(const char *label) { printf(".globl %s\n", label); - printf("\tALGN\n"); + printf("\t.balign 4\n"); printf("%s:\n", label); } @@ -343,15 +343,6 @@ static void write_src(void) unsigned int *markers, markers_cnt; char buf[KSYM_NAME_LEN]; - printf("#include \n"); - printf("#if BITS_PER_LONG == 64\n"); - printf("#define PTR .quad\n"); - printf("#define ALGN .balign 8\n"); - printf("#else\n"); - printf("#define PTR .long\n"); - printf("#define ALGN .balign 4\n"); - printf("#endif\n"); - printf("\t.section .rodata, \"a\"\n"); output_label("kallsyms_num_syms"); @@ -434,34 +425,24 @@ static void write_src(void) output_label("kallsyms_offsets"); for (i = 0; i < table_cnt; i++) { - /* - * Use the offset relative to the lowest value - * encountered of all relative symbols, and emit - * non-relocatable fixed offsets that will be fixed - * up at runtime. - */ + if (pc_relative) { + long long offset = table[i]->addr - _text; - long long offset; - - offset = table[i]->addr - relative_base; - if (offset < 0 || offset > UINT_MAX) { - fprintf(stderr, "kallsyms failure: " - "relative symbol value %#llx out of range\n", - table[i]->addr); - exit(EXIT_FAILURE); + if (offset < INT_MIN || offset > INT_MAX) { + fprintf(stderr, "kallsyms failure: " + "relative symbol value %#llx out of range\n", + table[i]->addr); + exit(EXIT_FAILURE); + } + printf("\t.long\t_text - . + (%d)\t/* %s */\n", + (int)offset, table[i]->sym); + } else { + printf("\t.long\t%#x\t/* %s */\n", + (unsigned int)table[i]->addr, table[i]->sym); } - printf("\t.long\t%#x\t/* %s */\n", (int)offset, table[i]->sym); } printf("\n"); - output_label("kallsyms_relative_base"); - /* Provide proper symbols relocatability by their '_text' relativeness. */ - if (_text <= relative_base) - printf("\tPTR\t_text + %#llx\n", relative_base - _text); - else - printf("\tPTR\t_text - %#llx\n", _text - relative_base); - printf("\n"); - sort_symbols_by_name(); output_label("kallsyms_seqs_of_names"); for (i = 0; i < table_cnt; i++) @@ -701,22 +682,12 @@ static void sort_symbols(void) qsort(table, table_cnt, sizeof(table[0]), compare_symbols); } -/* find the minimum non-absolute symbol address */ -static void record_relative_base(void) -{ - /* - * The table is sorted by address. - * Take the first symbol value. - */ - if (table_cnt) - relative_base = table[0]->addr; -} - int main(int argc, char **argv) { while (1) { static const struct option long_options[] = { {"all-symbols", no_argument, &all_symbols, 1}, + {"pc-relative", no_argument, &pc_relative, 1}, {}, }; @@ -734,7 +705,6 @@ int main(int argc, char **argv) read_map(argv[optind]); shrink_table(); sort_symbols(); - record_relative_base(); optimize_token_table(); write_src(); diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 4ab44c73da4d..73531cb63efc 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -143,6 +143,10 @@ kallsyms() kallsymopt="${kallsymopt} --all-symbols" fi + if is_enabled CONFIG_64BIT || is_enabled CONFIG_RELOCATABLE; then + kallsymopt="${kallsymopt} --pc-relative" + fi + info KSYMS "${2}.S" scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S" diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c index 74cdbd2ce9d0..524d46478364 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c @@ -27,7 +27,6 @@ static bool is_ignored_symbol(const char *name, char type) * stable symbol list. */ "kallsyms_offsets", - "kallsyms_relative_base", "kallsyms_num_syms", "kallsyms_names", "kallsyms_markers", From 5fa9b82cbcfc524a2dad581ac2af136536d4e8e5 Mon Sep 17 00:00:00 2001 From: Anders Roxell Date: Thu, 22 Jan 2026 12:57:49 +0200 Subject: [PATCH 24/39] scripts: kconfig: merge_config.sh: refactor from shell/sed/grep to awk merge_config.sh shell/sed/grep loop scales poorly and is slow. With Yocto genericarm64 kernel and around 190 config fragments the script takes more than 20 minutes to run on a fast build machine. Re-implementation with awk does the same job in 10 seconds. Using awk since it is likely available in the build environments and using perl, python etc would introduce more complex runtime dependencies. awk is good enough and lot better than shell/sed/grep. Output stays the same but changed execution time means that parallel job output may be ordered differently. Signed-off-by: Anders Roxell Signed-off-by: Mikko Rapeli Link: https://patch.msgid.link/20260122105751.2186609-1-mikko.rapeli@linaro.org Signed-off-by: Nathan Chancellor --- scripts/kconfig/merge_config.sh | 166 ++++++++++++++++++++++++-------- 1 file changed, 127 insertions(+), 39 deletions(-) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index 79c09b378be8..de217771b78c 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -16,8 +16,8 @@ set -e clean_up() { - rm -f $TMP_FILE - rm -f $MERGE_FILE + rm -f "$TMP_FILE" + rm -f "$TMP_FILE.new" } usage() { @@ -43,6 +43,10 @@ STRICT=false CONFIG_PREFIX=${CONFIG_-CONFIG_} WARNOVERRIDE=echo +if [ -z "$AWK" ]; then + AWK=awk +fi + while true; do case $1 in "-n") @@ -117,11 +121,8 @@ if [ ! -r "$INITFILE" ]; then fi MERGE_LIST=$* -SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p" -SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p" TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) -MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX) echo "Using $INITFILE as base" @@ -136,42 +137,129 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do echo "The merge file '$ORIG_MERGE_FILE' does not exist. Exit." >&2 exit 1 fi - cat $ORIG_MERGE_FILE > $MERGE_FILE - CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE) + # Use awk for single-pass processing instead of per-symbol grep/sed + if ! "$AWK" -v prefix="$CONFIG_PREFIX" \ + -v warnoverride="$WARNOVERRIDE" \ + -v strict="$STRICT" \ + -v builtin="$BUILTIN" \ + -v warnredun="$WARNREDUN" ' + BEGIN { + strict_violated = 0 + cfg_regex = "^" prefix "[a-zA-Z0-9_]+" + notset_regex = "^# " prefix "[a-zA-Z0-9_]+ is not set$" + } - for CFG in $CFG_LIST ; do - grep -q -w $CFG $TMP_FILE || continue - PREV_VAL=$(grep -w $CFG $TMP_FILE) - NEW_VAL=$(grep -w $CFG $MERGE_FILE) - BUILTIN_FLAG=false - if [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then - ${WARNOVERRIDE} Previous value: $PREV_VAL - ${WARNOVERRIDE} New value: $NEW_VAL - ${WARNOVERRIDE} -y passed, will not demote y to m - ${WARNOVERRIDE} - BUILTIN_FLAG=true - elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then - ${WARNOVERRIDE} Value of $CFG is redefined by fragment $ORIG_MERGE_FILE: - ${WARNOVERRIDE} Previous value: $PREV_VAL - ${WARNOVERRIDE} New value: $NEW_VAL - ${WARNOVERRIDE} - if [ "$STRICT" = "true" ]; then - STRICT_MODE_VIOLATED=true - fi - elif [ "$WARNREDUN" = "true" ]; then - ${WARNOVERRIDE} Value of $CFG is redundant by fragment $ORIG_MERGE_FILE: - fi - if [ "$BUILTIN_FLAG" = "false" ]; then - sed -i "/$CFG[ =]/d" $TMP_FILE - else - sed -i "/$CFG[ =]/d" $MERGE_FILE - fi - done - # In case the previous file lacks a new line at the end - echo >> $TMP_FILE - cat $MERGE_FILE >> $TMP_FILE + # Extract config name from a line, returns "" if not a config line + function get_cfg(line) { + if (match(line, cfg_regex)) { + return substr(line, RSTART, RLENGTH) + } else if (match(line, notset_regex)) { + # Extract CONFIG_FOO from "# CONFIG_FOO is not set" + sub(/^# /, "", line) + sub(/ is not set$/, "", line) + return line + } + return "" + } + + function warn_builtin(cfg, prev, new) { + if (warnoverride == "true") return + print cfg ": -y passed, will not demote y to m" + print "Previous value: " prev + print "New value: " new + print "" + } + + function warn_redefined(cfg, prev, new) { + if (warnoverride == "true") return + print "Value of " cfg " is redefined by fragment " mergefile ":" + print "Previous value: " prev + print "New value: " new + print "" + } + + function warn_redundant(cfg) { + if (warnredun != "true" || warnoverride == "true") return + print "Value of " cfg " is redundant by fragment " mergefile ":" + } + + # First pass: read merge file, store all lines and index + FILENAME == ARGV[1] { + mergefile = FILENAME + merge_lines[FNR] = $0 + merge_total = FNR + cfg = get_cfg($0) + if (cfg != "") { + merge_cfg[cfg] = $0 + merge_cfg_line[cfg] = FNR + } + next + } + + # Second pass: process base file (TMP_FILE) + FILENAME == ARGV[2] { + cfg = get_cfg($0) + + # Not a config or not in merge file - keep it + if (cfg == "" || !(cfg in merge_cfg)) { + print $0 >> ARGV[3] + next + } + + prev_val = $0 + new_val = merge_cfg[cfg] + + # BUILTIN: do not demote y to m + if (builtin == "true" && new_val ~ /=m$/ && prev_val ~ /=y$/) { + warn_builtin(cfg, prev_val, new_val) + print $0 >> ARGV[3] + skip_merge[merge_cfg_line[cfg]] = 1 + next + } + + # Values equal - redundant + if (prev_val == new_val) { + warn_redundant(cfg) + next + } + + # "=n" is the same as "is not set" + if (prev_val ~ /=n$/ && new_val ~ / is not set$/) { + print $0 >> ARGV[3] + next + } + + # Values differ - redefined + warn_redefined(cfg, prev_val, new_val) + if (strict == "true") { + strict_violated = 1 + } + } + + # output file, skip all lines + FILENAME == ARGV[3] { + nextfile + } + + END { + # Newline in case base file lacks trailing newline + print "" >> ARGV[3] + # Append merge file, skipping lines marked for builtin preservation + for (i = 1; i <= merge_total; i++) { + if (!(i in skip_merge)) { + print merge_lines[i] >> ARGV[3] + } + } + if (strict_violated) { + exit 1 + } + }' \ + "$ORIG_MERGE_FILE" "$TMP_FILE" "$TMP_FILE.new"; then + # awk exited non-zero, strict mode was violated + STRICT_MODE_VIOLATED=true + fi + mv "$TMP_FILE.new" "$TMP_FILE" done - if [ "$STRICT_MODE_VIOLATED" = "true" ]; then echo "The fragment redefined a value and strict mode had been passed." exit 1 From dfc97e1c5da5ba56356cd403b97546c86d43ca9a Mon Sep 17 00:00:00 2001 From: Mikko Rapeli Date: Thu, 22 Jan 2026 12:57:50 +0200 Subject: [PATCH 25/39] scripts: kconfig: merge_config.sh: use awk in checks too Converting from shell/sed/grep loop to awk improves runtime checks of Yocto genericarm64 kernel config from 20 seconds to under 1 second. The checks catch this kind of issues: WARNING: CONFIG_BLK_DEV_DM differs: Requested value: CONFIG_BLK_DEV_DM=y Actual value: CONFIG_BLK_DEV_DM=m WARNING: CONFIG_SECURITY_NETWORK differs: Requested value: CONFIG_SECURITY_NETWORK=n Actual value: CONFIG_SECURITY_NETWORK=y WARNING: Value requested for CONFIG_ARM64_BTI_KERNEL not in final .config Requested value: CONFIG_ARM64_BTI_KERNEL=y Actual value: Signed-off-by: Mikko Rapeli Link: https://patch.msgid.link/20260122105751.2186609-2-mikko.rapeli@linaro.org Signed-off-by: Nathan Chancellor --- scripts/kconfig/merge_config.sh | 97 +++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 11 deletions(-) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index de217771b78c..9eda9dbd4542 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -286,16 +286,91 @@ fi # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET +# Check all specified config values took effect (might have missed-dependency issues) +if ! "$AWK" -v prefix="$CONFIG_PREFIX" \ + -v warnoverride="$WARNOVERRIDE" \ + -v strict="$STRICT" \ + -v warnredun="$WARNREDUN" ' +BEGIN { + strict_violated = 0 + cfg_regex = "^" prefix "[a-zA-Z0-9_]+" + notset_regex = "^# " prefix "[a-zA-Z0-9_]+ is not set$" +} -# Check all specified config values took (might have missed-dependency issues) -for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do +# Extract config name from a line, returns "" if not a config line +function get_cfg(line) { + if (match(line, cfg_regex)) { + return substr(line, RSTART, RLENGTH) + } else if (match(line, notset_regex)) { + # Extract CONFIG_FOO from "# CONFIG_FOO is not set" + sub(/^# /, "", line) + sub(/ is not set$/, "", line) + return line + } + return "" +} - REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) - ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG" || true) - if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then - echo "Value requested for $CFG not in final .config" - echo "Requested value: $REQUESTED_VAL" - echo "Actual value: $ACTUAL_VAL" - echo "" - fi -done +function warn_mismatch(cfg, merged, final) { + if (warnredun == "true") return + if (final == "" && !(merged ~ / is not set$/ || merged ~ /=n$/)) { + print "WARNING: Value requested for " cfg " not in final .config" + print "Requested value: " merged + print "Actual value: " final + } else if (final == "" && merged ~ / is not set$/) { + # not set, pass + } else if (merged == "" && final != "") { + print "WARNING: " cfg " not in merged config but added in final .config:" + print "Requested value: " merged + print "Actual value: " final + } else { + print "WARNING: " cfg " differs:" + print "Requested value: " merged + print "Actual value: " final + } +} + +# First pass: read effective config file, store all lines +FILENAME == ARGV[1] { + cfg = get_cfg($0) + if (cfg != "") { + config_cfg[cfg] = $0 + } + next +} + +# Second pass: process merged config and compare against effective config +{ + cfg = get_cfg($0) + if (cfg == "") next + + # strip trailing comment + sub(/[[:space:]]+#.*/, "", $0) + merged_val = $0 + final_val = config_cfg[cfg] + + if (merged_val == final_val) next + + if (merged_val ~ /=n$/ && final_val ~ / is not set$/) next + if (merged_val ~ /=n$/ && final_val == "") next + + warn_mismatch(cfg, merged_val, final_val) + + if (strict == "true") { + strict_violated = 1 + } +} + +END { + if (strict_violated) { + exit 1 + } +}' \ +"$KCONFIG_CONFIG" "$TMP_FILE"; then + # awk exited non-zero, strict mode was violated + STRICT_MODE_VIOLATED=true +fi + +if [ "$STRICT" == "true" ] && [ "$STRICT_MODE_VIOLATED" == "true" ]; then + echo "Requested and effective config differ" + exit 1 +fi From a5b46cd1a08ceb8af35b01a335ee810c855b87e2 Mon Sep 17 00:00:00 2001 From: Mikko Rapeli Date: Thu, 22 Jan 2026 12:57:51 +0200 Subject: [PATCH 26/39] scripts: kconfig: merge_config.sh: warn on duplicate input files External scripts like yocto kernel scc may provide same input config fragment multiple times. This may be a bug since processing same fragments multiple times can be time consuming. Signed-off-by: Mikko Rapeli Link: https://patch.msgid.link/20260122105751.2186609-3-mikko.rapeli@linaro.org Signed-off-by: Nathan Chancellor --- scripts/kconfig/merge_config.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index 9eda9dbd4542..735e1de450c6 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -130,6 +130,8 @@ trap clean_up EXIT cat $INITFILE > $TMP_FILE +PROCESSED_FILES="" + # Merge files, printing warnings on overridden values for ORIG_MERGE_FILE in $MERGE_LIST ; do echo "Merging $ORIG_MERGE_FILE" @@ -137,6 +139,14 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do echo "The merge file '$ORIG_MERGE_FILE' does not exist. Exit." >&2 exit 1 fi + + # Check for duplicate input files + case " $PROCESSED_FILES " in + *" $ORIG_MERGE_FILE "*) + ${WARNOVERRIDE} "WARNING: Input file provided multiple times: $ORIG_MERGE_FILE" + ;; + esac + # Use awk for single-pass processing instead of per-symbol grep/sed if ! "$AWK" -v prefix="$CONFIG_PREFIX" \ -v warnoverride="$WARNOVERRIDE" \ @@ -259,6 +269,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do STRICT_MODE_VIOLATED=true fi mv "$TMP_FILE.new" "$TMP_FILE" + PROCESSED_FILES="$PROCESSED_FILES $ORIG_MERGE_FILE" done if [ "$STRICT_MODE_VIOLATED" = "true" ]; then echo "The fragment redefined a value and strict mode had been passed." From 76c73cfde7988976474e58c16e14ec3372f8cdaf Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Wed, 21 Jan 2026 11:57:57 +0100 Subject: [PATCH 27/39] kbuild: dummy-tools: Add python3 DRM_MSM_VALIDATE_XML depends on a python feature. Add a dummy python interpreter to make it possible to configure this option with dummy tools. Fixes: b587f413ca47 ("drm/msm/gen_header: allow skipping the validation") Signed-off-by: Michal Suchanek Acked-by: Rob Clark Link: https://patch.msgid.link/20260121105801.1827-1-msuchanek@suse.de [nathan: Remove empty shell comment line] Signed-off-by: Nathan Chancellor --- scripts/dummy-tools/python3 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 scripts/dummy-tools/python3 diff --git a/scripts/dummy-tools/python3 b/scripts/dummy-tools/python3 new file mode 100755 index 000000000000..24c5584861b6 --- /dev/null +++ b/scripts/dummy-tools/python3 @@ -0,0 +1,4 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +true From 72043cf7f100cbd031981a726e31f4b20935902c Mon Sep 17 00:00:00 2001 From: Diego Viola Date: Mon, 2 Feb 2026 02:45:41 -0300 Subject: [PATCH 28/39] streamline_config.pl: remove superfluous exclamation mark In order to make the output cleaner and more consistent with other scripts. Signed-off-by: Diego Viola Link: https://patch.msgid.link/20260202054541.17399-1-diego.viola@gmail.com Signed-off-by: Nathan Chancellor --- scripts/kconfig/streamline_config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 8e23faab5d22..8677d1ca06a7 100755 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -415,7 +415,7 @@ foreach my $module (keys(%modules)) { } } else { # Most likely, someone has a custom (binary?) module loaded. - print STDERR "$module config not found!!\n"; + print STDERR "$module config not found!\n"; } } From 87abe931fbc349d13407a3dd61e6e9a899389141 Mon Sep 17 00:00:00 2001 From: Yao Zi Date: Mon, 2 Feb 2026 04:16:10 +0000 Subject: [PATCH 29/39] MIPS: tools: relocs: Ship a definition of R_MIPS_PC32 R_MIPS_PC32 is a GNU extension, its definition is available in glibc only since 2.39 (released in 2024), and not available in musl libc yet. Provide our own definition for R_MIPS_PC32 and use it if necessary to fix relocs tool building on musl and older glibc systems. Fixes: ff79d31eb536 ("mips: Add support for PC32 relocations in vmlinux") Signed-off-by: Yao Zi Link: https://patch.msgid.link/20260202041610.61389-1-me@ziyao.cc Signed-off-by: Nathan Chancellor --- arch/mips/boot/tools/relocs.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/mips/boot/tools/relocs.h b/arch/mips/boot/tools/relocs.h index 607ff0103064..942981d9ce73 100644 --- a/arch/mips/boot/tools/relocs.h +++ b/arch/mips/boot/tools/relocs.h @@ -29,6 +29,13 @@ void die(char *fmt, ...); #define R_MIPS_PC26_S2 61 #endif +/* + * GNU extension that available in glibc only since 2023, not available on musl. + */ +#ifndef R_MIPS_PC32 +#define R_MIPS_PC32 248 +#endif + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) enum symtype { From 3cd9763ce4ad999d015cf0734e6b968cead95077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Rebe?= Date: Sun, 23 Nov 2025 13:13:30 +0100 Subject: [PATCH 30/39] modpost: Amend ppc64 save/restfpr symnames for -Os build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building a size optimized ppc64 kernel (-Os), gcc emits more FP save/restore symbols, that the linker generates on demand into the .sfpr section. Explicitly allow-list those in scripts/mod/modpost.c, too. They are needed for the amdgpu in-kernel floating point support. MODPOST Module.symvers ERROR: modpost: "_restfpr_20" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_restfpr_26" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_restfpr_22" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_savegpr1_27" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_savegpr1_25" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_restfpr_28" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_savegpr1_29" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_savefpr_20" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_savefpr_22" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: modpost: "_restfpr_15" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! WARNING: modpost: suppressed 56 unresolved symbol warnings because there were too many) Signed-off-by: René Rebe Link: https://patch.msgid.link/20251123.131330.407910684435629198.rene@exactco.de Signed-off-by: Nathan Chancellor --- scripts/mod/modpost.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d042b355c9d6..0c25b5ad497b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -602,6 +602,10 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) /* Special register function linked on all modules during final link of .ko */ if (strstarts(symname, "_restgpr0_") || strstarts(symname, "_savegpr0_") || + strstarts(symname, "_restgpr1_") || + strstarts(symname, "_savegpr1_") || + strstarts(symname, "_restfpr_") || + strstarts(symname, "_savefpr_") || strstarts(symname, "_restvr_") || strstarts(symname, "_savevr_") || strcmp(symname, ".TOC.") == 0) From 1f77593d304e734890bc66bcb2b723c181c698f5 Mon Sep 17 00:00:00 2001 From: Tiezhu Yang Date: Tue, 20 Jan 2026 20:37:28 +0800 Subject: [PATCH 31/39] MAINTAINERS: Add scripts/install.sh into Kbuild entry The common installation code is in scripts/install.sh, add it into Kbuild entry to reflect the reality. With this updated entry, folks running get_maintainer.pl on patches that touch scripts/install.sh will know to send it to linux-kbuild@ as well. Signed-off-by: Tiezhu Yang Link: https://patch.msgid.link/20260120123730.30487-2-yangtiezhu@loongson.cn [nathan: Alphabetize entry] Signed-off-by: Nathan Chancellor --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 643cbdf608ea..74a5ee0f7f88 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13677,6 +13677,7 @@ F: scripts/clang-tools/ F: scripts/container F: scripts/dummy-tools/ F: scripts/include/ +F: scripts/install.sh F: scripts/mk* F: scripts/mod/ F: scripts/package/ From f2445d6f264c64e90b5094d4e8ed33f30cfb7fc4 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Tue, 9 Sep 2025 18:14:20 +0000 Subject: [PATCH 32/39] rust: kconfig: Don't require RUST_IS_AVAILABLE for rustc-option The final version of this macro does not fail in the absence of an invokable `$(RUSTC)`, so we don't need to be careful not to invoke it. Link: https://lore.kernel.org/all/CAGSQo01mQfcU1EiW53be1hcts0c1p-HQAab_HBk6VcVmhq3n2Q@mail.gmail.com/ Signed-off-by: Matthew Maurer Link: https://patch.msgid.link/20250909-docrem-v1-1-dcc69059a5cb@google.com Signed-off-by: Nathan Chancellor --- scripts/Kconfig.include | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index d42042b6c9e2..fc10671c297c 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -73,8 +73,6 @@ rustc-llvm-version := $(shell,$(srctree)/scripts/rustc-llvm-version.sh $(RUSTC)) # $(rustc-option,) # Return y if the Rust compiler supports , n otherwise -# Calls to this should be guarded so that they are not evaluated if -# CONFIG_RUST_IS_AVAILABLE is not set. # If you are testing for unstable features, consider testing RUSTC_VERSION # instead, as features may have different completeness while available. rustc-option = $(success,trap "rm -rf .tmp_$$" EXIT; mkdir .tmp_$$; $(RUSTC) $(1) --crate-type=rlib /dev/null --out-dir=.tmp_$$ -o .tmp_$$/tmp.rlib) From 621fd65adc825b69a59367b97a7c2aa73e382909 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 6 Jan 2026 09:27:31 -0700 Subject: [PATCH 33/39] scripts/make_fit: Speed up operation The kernel is likely at least 16MB so we may as well use that as a step size when reallocating space for the FIT in memory. Pack the FIT at the end, so there is no wasted space. This reduces the time to pack by an order of magnitude, or so. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier Reviewed-by: Ahmad Fatoum Tested-by: Chen-Yu Tsai Link: https://patch.msgid.link/20260106162738.2605574-2-sjg@chromium.org Signed-off-by: Nathan Chancellor --- scripts/make_fit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index 1683e5ec6e67..0f5e7c4b8aed 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -98,7 +98,7 @@ def setup_fit(fsw, name): fsw (libfdt.FdtSw): Object to use for writing name (str): Name of kernel image """ - fsw.INC_SIZE = 65536 + fsw.INC_SIZE = 16 << 20 fsw.finish_reservemap() fsw.begin_node('') fsw.property_string('description', f'{name} with devicetree set') @@ -299,7 +299,9 @@ def build_fit(args): finish_fit(fsw, entries) # Include the kernel itself in the returned file count - return fsw.as_fdt().as_bytearray(), seq + 1, size + fdt = fsw.as_fdt() + fdt.pack() + return fdt.as_bytearray(), seq + 1, size def run_make_fit(): From 26428e7dd6a51e328776dd333f613445d1951658 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 6 Jan 2026 09:27:32 -0700 Subject: [PATCH 34/39] scripts/make_fit: Support an initial ramdisk FIT (Flat Image Tree) allows a ramdisk to be included in each configuration. Add support for this to the script. This feature is not available via 'make image.fit' since the ramdisk likely needs to be built separately anyway, e.g. using modules from the kernel build. Future work may provide support for doing that. Note that the uncompressed size is not correct when a ramdisk is used, since it is too expensive to decompress the ramdisk. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier Reviewed-by: Ahmad Fatoum Link: https://patch.msgid.link/20260106162738.2605574-3-sjg@chromium.org Signed-off-by: Nathan Chancellor --- scripts/make_fit.py | 52 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index 0f5e7c4b8aed..66cd73711506 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -10,10 +10,14 @@ Usage: make_fit.py -A arm64 -n 'Linux-6.6' -O linux -o arch/arm64/boot/image.fit -k /tmp/kern/arch/arm64/boot/image.itk - @arch/arm64/boot/dts/dtbs-list -E -c gzip + -r /boot/initrd.img-6.14.0-27-generic @arch/arm64/boot/dts/dtbs-list + -E -c gzip -Creates a FIT containing the supplied kernel and a set of devicetree files, -either specified individually or listed in a file (with an '@' prefix). +Creates a FIT containing the supplied kernel, an optional ramdisk, and a set of +devicetree files, either specified individually or listed in a file (with an +'@' prefix). + +Use -r to specify an existing ramdisk/initrd file. Use -E to generate an external FIT (where the data is placed after the FIT data structure). This allows parsing of the data without loading @@ -29,8 +33,6 @@ looks at the .cmd files produced by the kernel build. The resulting FIT can be booted by bootloaders which support FIT, such as U-Boot, Linuxboot, Tianocore, etc. - -Note that this tool does not yet support adding a ramdisk / initrd. """ import argparse @@ -81,6 +83,8 @@ def parse_args(): help='Specifies the operating system') parser.add_argument('-k', '--kernel', type=str, required=True, help='Specifies the (uncompressed) kernel input file (.itk)') + parser.add_argument('-r', '--ramdisk', type=str, + help='Specifies the ramdisk/initrd input file') parser.add_argument('-v', '--verbose', action='store_true', help='Enable verbose output') parser.add_argument('dtbs', type=str, nargs='*', @@ -133,7 +137,28 @@ def write_kernel(fsw, data, args): fsw.property_u32('entry', 0) -def finish_fit(fsw, entries): +def write_ramdisk(fsw, data, args): + """Write out the ramdisk image + + Writes a ramdisk node along with the required properties + + Args: + fsw (libfdt.FdtSw): Object to use for writing + data (bytes): Data to write (possibly compressed) + args (Namespace): Contains necessary strings: + arch: FIT architecture, e.g. 'arm64' + fit_os: Operating Systems, e.g. 'linux' + """ + with fsw.add_node('ramdisk'): + fsw.property_string('description', 'Ramdisk') + fsw.property_string('type', 'ramdisk') + fsw.property_string('arch', args.arch) + fsw.property_string('compression', 'none') + fsw.property_string('os', args.os) + fsw.property('data', data) + + +def finish_fit(fsw, entries, has_ramdisk=False): """Finish the FIT ready for use Writes the /configurations node and subnodes @@ -143,6 +168,7 @@ def finish_fit(fsw, entries): entries (list of tuple): List of configurations: str: Description of model str: Compatible stringlist + has_ramdisk (bool): True if a ramdisk is included in the FIT """ fsw.end_node() seq = 0 @@ -154,6 +180,8 @@ def finish_fit(fsw, entries): fsw.property_string('description', model) fsw.property('fdt', bytes(''.join(f'fdt-{x}\x00' for x in files), "ascii")) fsw.property_string('kernel', 'kernel') + if has_ramdisk: + fsw.property_string('ramdisk', 'ramdisk') fsw.end_node() @@ -274,6 +302,14 @@ def build_fit(args): size += os.path.getsize(args.kernel) write_kernel(fsw, comp_data, args) + # Handle the ramdisk if provided. Compression is not supported as it is + # already compressed. + if args.ramdisk: + with open(args.ramdisk, 'rb') as inf: + data = inf.read() + size += len(data) + write_ramdisk(fsw, data, args) + for fname in args.dtbs: # Ignore non-DTB (*.dtb) files if os.path.splitext(fname)[1] != '.dtb': @@ -296,12 +332,12 @@ def build_fit(args): entries.append([model, compat, files_seq]) - finish_fit(fsw, entries) + finish_fit(fsw, entries, bool(args.ramdisk)) # Include the kernel itself in the returned file count fdt = fsw.as_fdt() fdt.pack() - return fdt.as_bytearray(), seq + 1, size + return fdt.as_bytearray(), seq + 1 + bool(args.ramdisk), size def run_make_fit(): From 873c2836982e1f7389d487afca4cc42ed373ba4b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 6 Jan 2026 09:27:33 -0700 Subject: [PATCH 35/39] scripts/make_fit: Move dtb processing into a function Since build_fit() is getting quite long, move the dtb processing into a separate function. Change the double quotes in the write() call to single, to match the rest of the script. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier Reviewed-by: Ahmad Fatoum Reviewed-by: Chen-Yu Tsai Link: https://patch.msgid.link/20260106162738.2605574-4-sjg@chromium.org Signed-off-by: Nathan Chancellor --- scripts/make_fit.py | 67 +++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index 66cd73711506..7ddaf3c0d783 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -277,6 +277,47 @@ def process_dtb(fname, args): return (model, compat, files) + +def _process_dtbs(args, fsw, entries, fdts): + """Process all DTB files and add them to the FIT + + Args: + args: Program arguments + fsw: FIT writer object + entries: List to append entries to + fdts: Dictionary of processed DTBs + + Returns: + tuple: + Number of files processed + Total size of files processed + """ + seq = 0 + size = 0 + for fname in args.dtbs: + # Ignore non-DTB (*.dtb) files + if os.path.splitext(fname)[1] != '.dtb': + continue + + try: + (model, compat, files) = process_dtb(fname, args) + except Exception as e: + sys.stderr.write(f'Error processing {fname}:\n') + raise e + + for fn in files: + if fn not in fdts: + seq += 1 + size += os.path.getsize(fn) + output_dtb(fsw, seq, fn, args.arch, args.compress) + fdts[fn] = seq + + files_seq = [fdts[fn] for fn in files] + entries.append([model, compat, files_seq]) + + return seq, size + + def build_fit(args): """Build the FIT from the provided files and arguments @@ -289,7 +330,6 @@ def build_fit(args): int: Number of configurations generated size: Total uncompressed size of data """ - seq = 0 size = 0 fsw = libfdt.FdtSw() setup_fit(fsw, args.name) @@ -310,34 +350,15 @@ def build_fit(args): size += len(data) write_ramdisk(fsw, data, args) - for fname in args.dtbs: - # Ignore non-DTB (*.dtb) files - if os.path.splitext(fname)[1] != '.dtb': - continue - - try: - (model, compat, files) = process_dtb(fname, args) - except Exception as e: - sys.stderr.write(f"Error processing {fname}:\n") - raise e - - for fn in files: - if fn not in fdts: - seq += 1 - size += os.path.getsize(fn) - output_dtb(fsw, seq, fn, args.arch, args.compress) - fdts[fn] = seq - - files_seq = [fdts[fn] for fn in files] - - entries.append([model, compat, files_seq]) + count, fdt_size = _process_dtbs(args, fsw, entries, fdts) + size += fdt_size finish_fit(fsw, entries, bool(args.ramdisk)) # Include the kernel itself in the returned file count fdt = fsw.as_fdt() fdt.pack() - return fdt.as_bytearray(), seq + 1 + bool(args.ramdisk), size + return fdt.as_bytearray(), count + 1 + bool(args.ramdisk), size def run_make_fit(): From 9a329df6e004190ce7422cc040c09374efa34289 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 6 Jan 2026 09:27:34 -0700 Subject: [PATCH 36/39] kbuild: Support a FIT_EXTRA_ARGS environment variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases it is useful to be able to pass additional flags to the make_fit.py script. For example, since ramdisks are typically large, passing -E to use external data can be helpful. Add a new FIT_EXTRA_ARGS variable for this. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier Reviewed-by: Thomas Weißschuh Link: https://patch.msgid.link/20260106162738.2605574-5-sjg@chromium.org Signed-off-by: Nathan Chancellor --- scripts/Makefile.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 28a1c08e3b22..e8da632d5348 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -400,7 +400,7 @@ FIT_COMPRESSION ?= gzip quiet_cmd_fit = FIT $@ cmd_fit = $(MAKE_FIT) -o $@ --arch $(UIMAGE_ARCH) --os linux \ - --name '$(UIMAGE_NAME)' \ + --name '$(UIMAGE_NAME)' $(FIT_EXTRA_ARGS) \ $(if $(findstring 1,$(KBUILD_VERBOSE)),-v) \ $(if $(FIT_DECOMPOSE_DTBS),--decompose-dtbs) \ --compress $(FIT_COMPRESSION) -k $< @$(word 2,$^) From fcdcf22a34b0768471d6c834254ef041e3d9c3dc Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 6 Jan 2026 09:27:35 -0700 Subject: [PATCH 37/39] scripts/make_fit: Support a few more parallel compressors Add support for pbzip2, xz and plzip which can compress in parallel. This speeds up the ramdisk compression. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260106162738.2605574-6-sjg@chromium.org Signed-off-by: Nathan Chancellor --- scripts/make_fit.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index 7ddaf3c0d783..defb87f223d7 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -50,11 +50,12 @@ import libfdt CompTool = collections.namedtuple('CompTool', 'ext,tools') COMP_TOOLS = { - 'bzip2': CompTool('.bz2', 'bzip2'), + 'bzip2': CompTool('.bz2', 'pbzip2,bzip2'), 'gzip': CompTool('.gz', 'pigz,gzip'), 'lz4': CompTool('.lz4', 'lz4'), - 'lzma': CompTool('.lzma', 'lzma'), + 'lzma': CompTool('.lzma', 'plzip,lzma'), 'lzo': CompTool('.lzo', 'lzop'), + 'xz': CompTool('.xz', 'xz'), 'zstd': CompTool('.zstd', 'zstd'), } @@ -207,7 +208,12 @@ def compress_data(inf, compress): done = False for tool in comp.tools.split(','): try: - subprocess.call([tool, '-c'], stdin=inf, stdout=outf) + # Add parallel flags for tools that support them + cmd = [tool] + if tool in ('zstd', 'xz'): + cmd.extend(['-T0']) # Use all available cores + cmd.append('-c') + subprocess.call(cmd, stdin=inf, stdout=outf) done = True break except FileNotFoundError: From c7c88b20cd4226af0c9fbdb365fb6f221501c7da Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 6 Jan 2026 09:27:36 -0700 Subject: [PATCH 38/39] scripts/make_fit: Compress dtbs in parallel When there are 1500 device tree files it takes quite a while to compress them. Do it in parallel. Signed-off-by: Simon Glass Link: https://patch.msgid.link/20260106162738.2605574-7-sjg@chromium.org Signed-off-by: Nathan Chancellor --- scripts/make_fit.py | 56 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index defb87f223d7..e923cc8b05b7 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -37,6 +37,7 @@ as U-Boot, Linuxboot, Tianocore, etc. import argparse import collections +import multiprocessing import os import subprocess import sys @@ -225,15 +226,31 @@ def compress_data(inf, compress): return comp_data -def output_dtb(fsw, seq, fname, arch, compress): +def compress_dtb(fname, compress): + """Compress a single DTB file + + Args: + fname (str): Filename containing the DTB + compress (str): Compression algorithm, e.g. 'gzip' + + Returns: + tuple: (str: fname, bytes: compressed_data) + """ + with open(fname, 'rb') as inf: + compressed = compress_data(inf, compress) + return fname, compressed + + +def output_dtb(fsw, seq, fname, arch, compress, data=None): """Write out a single devicetree to the FIT Args: fsw (libfdt.FdtSw): Object to use for writing seq (int): Sequence number (1 for first) fname (str): Filename containing the DTB - arch: FIT architecture, e.g. 'arm64' + arch (str): FIT architecture, e.g. 'arm64' compress (str): Compressed algorithm, e.g. 'gzip' + data (bytes): Pre-compressed data (optional) """ with fsw.add_node(f'fdt-{seq}'): fsw.property_string('description', os.path.basename(fname)) @@ -241,9 +258,10 @@ def output_dtb(fsw, seq, fname, arch, compress): fsw.property_string('arch', arch) fsw.property_string('compression', compress) - with open(fname, 'rb') as inf: - compressed = compress_data(inf, compress) - fsw.property('data', compressed) + if data is None: + with open(fname, 'rb') as inf: + data = compress_data(inf, compress) + fsw.property('data', data) def process_dtb(fname, args): @@ -300,6 +318,11 @@ def _process_dtbs(args, fsw, entries, fdts): """ seq = 0 size = 0 + + # First figure out the unique DTB files that need compression + todo = [] + file_info = [] # List of (fname, model, compat, files) tuples + for fname in args.dtbs: # Ignore non-DTB (*.dtb) files if os.path.splitext(fname)[1] != '.dtb': @@ -311,11 +334,32 @@ def _process_dtbs(args, fsw, entries, fdts): sys.stderr.write(f'Error processing {fname}:\n') raise e + file_info.append((fname, model, compat, files)) + for fn in files: + if fn not in fdts and fn not in todo: + todo.append(fn) + + # Compress all DTBs in parallel + cache = {} + if todo and args.compress != 'none': + if args.verbose: + print(f'Compressing {len(todo)} DTBs...') + + with multiprocessing.Pool() as pool: + compress_args = [(fn, args.compress) for fn in todo] + # unpacks each tuple, calls compress_dtb(fn, compress) in parallel + results = pool.starmap(compress_dtb, compress_args) + + cache = dict(results) + + # Now write all DTBs to the FIT using pre-compressed data + for fname, model, compat, files in file_info: for fn in files: if fn not in fdts: seq += 1 size += os.path.getsize(fn) - output_dtb(fsw, seq, fn, args.arch, args.compress) + output_dtb(fsw, seq, fn, args.arch, args.compress, + cache.get(fn)) fdts[fn] = seq files_seq = [fdts[fn] for fn in files] From d8ad80a85b96649a6ef30976762660245ae61a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 5 Feb 2026 21:49:58 +0100 Subject: [PATCH 39/39] kbuild: remove dependency of run-command on config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The run-command target does not always require a kernel configuration to be present. Drop the dependency so it can be executed without one. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260205-kbuild-run-command-v1-1-b8cbbc3db270@weissschuh.net Signed-off-by: Nathan Chancellor --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 93831019c17b..a1f3b7d98188 100644 --- a/Makefile +++ b/Makefile @@ -295,7 +295,8 @@ no-dot-config-targets := $(clean-targets) \ cscope gtags TAGS tags help% %docs check% coccicheck \ $(version_h) headers headers_% archheaders archscripts \ %asm-generic kernelversion %src-pkg dt_binding_check \ - outputmakefile rustavailable rustfmt rustfmtcheck + outputmakefile rustavailable rustfmt rustfmtcheck \ + run-command no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \ image_name single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/