[PATCH 2/5] kconfig: nconf: fix NORMAL attributes
The lower 8-bit of attributes should be 0, but this code wrongly sets it to NORMAL (=1). The correct one is A_NORMAL. Signed-off-by: Masahiro Yamada --- scripts/kconfig/nconf.gui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 77f525a8617c..a914f81092d7 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -70,7 +70,7 @@ static void normal_color_theme(void) /* automatically add color... */ #define mkattr(name, attr) do { \ attributes[name] = attr | COLOR_PAIR(name); } while (0) - mkattr(NORMAL, NORMAL); + mkattr(NORMAL, A_NORMAL); mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE); mkattr(MAIN_MENU_FORE, A_REVERSE); @@ -102,7 +102,7 @@ static void no_colors_theme(void) /* automatically add highlight, no color */ #define mkattrn(name, attr) { attributes[name] = attr; } - mkattrn(NORMAL, NORMAL); + mkattrn(NORMAL, A_NORMAL); mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE); mkattrn(MAIN_MENU_FORE, A_STANDOUT); -- 2.27.0
[PATCH 1/5] kconfig: mconf,nconf: remove unneeded '\0' termination after snprintf()
snprintf() always terminates the destination buffer with '\0' even if the buffer is not long enough. (In this case, the last element of the buffer becomes '\0'.) The explicit termination is unneeded. Signed-off-by: Masahiro Yamada --- scripts/kconfig/mconf.c | 11 +++ scripts/kconfig/nconf.c | 12 +++- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 4cfbe62938cd..9d3cf510562f 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -299,17 +299,12 @@ static char filename[PATH_MAX+1]; static void set_config_filename(const char *config_filename) { static char menu_backtitle[PATH_MAX+128]; - int size; - size = snprintf(menu_backtitle, sizeof(menu_backtitle), - "%s - %s", config_filename, rootmenu.prompt->text); - if (size >= sizeof(menu_backtitle)) - menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + snprintf(menu_backtitle, sizeof(menu_backtitle), "%s - %s", +config_filename, rootmenu.prompt->text); set_dialog_backtitle(menu_backtitle); - size = snprintf(filename, sizeof(filename), "%s", config_filename); - if (size >= sizeof(filename)) - filename[sizeof(filename)-1] = '\0'; + snprintf(filename, sizeof(filename), "%s", config_filename); } struct subtitle_part { diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 86ca42b5ab80..232eb3011efe 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -635,16 +635,10 @@ static char filename[PATH_MAX+1]; static char menu_backtitle[PATH_MAX+128]; static const char *set_config_filename(const char *config_filename) { - int size; + snprintf(menu_backtitle, sizeof(menu_backtitle), "%s - %s", +config_filename, rootmenu.prompt->text); - size = snprintf(menu_backtitle, sizeof(menu_backtitle), - "%s - %s", config_filename, rootmenu.prompt->text); - if (size >= sizeof(menu_backtitle)) - menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; - - size = snprintf(filename, sizeof(filename), "%s", config_filename); - if (size >= sizeof(filename)) - filename[sizeof(filename)-1] = '\0'; + snprintf(filename, sizeof(filename), "%s", config_filename); return menu_backtitle; } -- 2.27.0
Re: [PATCH 1/2] kbuild: dummy-tools: Add elfedit.
On Fri, Apr 9, 2021 at 6:31 AM Michal Suchanek wrote: > > elfedit is used in Makefile > > Makefile:GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > > which causes this error getting printed > > which: no elfedit in (./scripts/dummy-tools) I am OK with this patch, but how did you reproduce it? > > Add elfedit to dummy-tools to avoid this error. > > Signed-off-by: Michal Suchanek > --- > scripts/dummy-tools/elfedit | 1 + > 1 file changed, 1 insertion(+) > create mode 12 scripts/dummy-tools/elfedit > > diff --git a/scripts/dummy-tools/elfedit b/scripts/dummy-tools/elfedit > new file mode 12 > index ..c0648b38dd42 > --- /dev/null > +++ b/scripts/dummy-tools/elfedit > @@ -0,0 +1 @@ > +ld > \ No newline at end of file > -- > 2.26.2 > -- Best Regards Masahiro Yamada
[PATCH] kconfig: use /boot/config-* etc. as DEFCONFIG_LIST only for native build
When the .config file is missing, 'make config', 'make menuconfig', etc. uses a file listed in DEFCONFIG_LIST as base configuration. Ususally, /boot/config-$(uname -r) exists, and is used as default. However, when you are cross-compiling the kernel, it does not make sense to use /boot/config-* from the build host. It should default to arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG). UML previously did not use DEFCONFIG_LIST at all, but it should be able to use arch/um/configs/$(KBUILD_DEFCONFIG) as a base config file. Signed-off-by: Masahiro Yamada --- Makefile | 5 + scripts/kconfig/Makefile | 8 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f1093b972708..697eaf6c550e 100644 --- a/Makefile +++ b/Makefile @@ -393,6 +393,11 @@ ifeq ($(ARCH),sh64) SRCARCH := sh endif +export cross_compiling := +ifneq ($(SRCARCH),$(SUBARCH)) +cross_compiling := 1 +endif + KCONFIG_CONFIG ?= .config export KCONFIG_CONFIG diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 46f2465177f0..1d1a7f83ee8d 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -18,14 +18,14 @@ silent := -s endif export KCONFIG_DEFCONFIG_LIST := -ifneq ($(SRCARCH),um) +ifndef cross_compiling kernel-release := $(shell uname -r) -KCONFIG_DEFCONFIG_LIST := \ +KCONFIG_DEFCONFIG_LIST += \ /lib/modules/$(kernel-release)/.config \ /etc/kernel-config \ - /boot/config-$(kernel-release) \ - arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) + /boot/config-$(kernel-release) endif +KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) # We need this, in case the user has it in its environment unexport CONFIG_ -- 2.27.0
Re: [PATCH v2] kconfig: nconf: stop endless search-up loops
On Sat, Apr 10, 2021 at 4:00 PM Mihai Moldovan wrote: > > * On 4/10/21 7:47 AM, Masahiro Yamada wrote: > > On Sun, Mar 28, 2021 at 6:52 PM Mihai Moldovan wrote: > >> + if ((index == -1) && (index == match_start)) > >> + return -1; > > > > We know 'index' is -1 in the second comparison. > > So, you can also write like this: > > > >if (match_start == -1 && index == -1) > > return -1; > > I know, but I sided for the other form for semantic reasons - this more > closely > directly describes what we actually care about (both being the same value and > either one being -1). > > > > But, it is not the correct fix, either. > > > > The root cause of the bug is match_start > > becoming -1. > > > > > > The following is the correct way to fix the bug > > without increasing the number of lines. > > > > > > > > diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c > > index e0f965529166..af814b39b876 100644 > > [...] > > + match_start = (match_start + items_num) % items_num; > > index = match_start; > > - index = (index + items_num) % items_num; > > This is probably more elegant and fixes two issues at the same time: > match_start > becoming -1 or n (which is likewise invalid, but was implicitly handled > through > the remainder operation). > > No objections from my side. Could you send v3 please? Then, I will apply it. -- Best Regards Masahiro Yamada
[PATCH] kconfig: change sym_change_count into a boolean flag
sym_change_count has no good reason to be 'int' type. sym_set_change_count() compares the old and new values after casting both of them to (bool). I do not see any practical diffrence between sym_set_change_count(1) and sym_add_change_count(1). Use the boolean flag, 'conf_changed'. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 31 +-- scripts/kconfig/lkc.h | 2 -- scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/mconf.c | 2 +- scripts/kconfig/nconf.c | 2 +- scripts/kconfig/parser.y| 2 +- scripts/kconfig/symbol.c| 2 +- 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index c796d402665e..a8339871ef79 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -366,7 +366,7 @@ int conf_read_simple(const char *name, int def) in = zconf_fopen(name); if (in) goto load; - sym_add_change_count(1); + conf_set_changed(true); env = getenv("KCONFIG_DEFCONFIG_LIST"); if (!env) @@ -444,7 +444,7 @@ int conf_read_simple(const char *name, int def) if (def == S_DEF_USER) { sym = sym_find(line + 2 + strlen(CONFIG_)); if (!sym) { - sym_add_change_count(1); + conf_set_changed(true); continue; } } else { @@ -487,7 +487,7 @@ int conf_read_simple(const char *name, int def) */ conf_touch_dep(line + strlen(CONFIG_)); else - sym_add_change_count(1); + conf_set_changed(true); continue; } @@ -535,7 +535,7 @@ int conf_read(const char *name) int conf_unsaved = 0; int i; - sym_set_change_count(0); + conf_set_changed(false); if (conf_read_simple(name, S_DEF_USER)) { sym_calc_value(modules_sym); @@ -593,7 +593,8 @@ int conf_read(const char *name) } } - sym_add_change_count(conf_warnings || conf_unsaved); + if (conf_warnings || conf_unsaved) + conf_set_changed(true); return 0; } @@ -938,7 +939,7 @@ int conf_write(const char *name) if (is_same(name, tmpname)) { conf_message("No change to %s", name); unlink(tmpname); - sym_set_change_count(0); + conf_set_changed(false); return 0; } @@ -950,7 +951,7 @@ int conf_write(const char *name) conf_message("configuration written to %s", name); - sym_set_change_count(0); + conf_set_changed(false); return 0; } @@ -1118,26 +1119,20 @@ int conf_write_autoconf(int overwrite) return 0; } -static int sym_change_count; +static bool conf_changed; static void (*conf_changed_callback)(void); -void sym_set_change_count(int count) +void conf_set_changed(bool val) { - int _sym_change_count = sym_change_count; - sym_change_count = count; - if (conf_changed_callback && - (bool)_sym_change_count != (bool)count) + if (conf_changed_callback && conf_changed != val) conf_changed_callback(); -} -void sym_add_change_count(int count) -{ - sym_set_change_count(count + sym_change_count); + conf_changed = val; } bool conf_get_changed(void) { - return sym_change_count; + return conf_changed; } void conf_set_changed_callback(void (*fn)(void)) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 246eba37ca0e..f98660fa2c48 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -55,8 +55,6 @@ const char *zconf_curname(void); /* confdata.c */ const char *conf_get_configname(void); -void sym_set_change_count(int count); -void sym_add_change_count(int count); void set_all_choice_values(struct symbol *csym); /* confdata.c and expr.c */ diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 9e81be33c40f..a11626bdc421 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -8,6 +8,7 @@ int conf_read_simple(const char *name, int); int conf_write_defconfig(const char *name); int conf_write(const char *name); int conf_write_autoconf(int overwrite); +void conf_set_changed(bool val); bool conf_get_changed(void); void conf_set_changed_callback(void (*fn)(void)); void conf_set_message_callback(void (*fn)(const char *s)); diff --git a/scr
[PATCH] kconfig: nconf: fix core dump when searching in empty menu
The following code in get_mext_match(): index = (index + items_num) % items_num; ... makes the program crash when items_num is zero (that is, the menu is empty). A menu can be empty when all the options in it are hidden by unmet 'depends on'. For example, menu "This menu will be empty" config FOO bool "foo" depends on BROKEN endmenu If you visit this menu and press a '/' key and then another key, nconf crashes with: Floating point exception (core dumped) When the number of items is zero, it does not make sense to search in the menu. In this case, current_item() returns NULL, and item_index() ERR, but the current get_mext_match() does not check any error. Let's make it just return if items_num is zero, and also check the return value from item_index() just in case. Change items_num from 'int' to 'unsigned int' because it should never become negative. Signed-off-by: Masahiro Yamada --- scripts/kconfig/nconf.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 42d63d7b0c52..7d2ab2944d81 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -282,7 +282,7 @@ static int mwin_max_cols; static MENU *curses_menu; static ITEM *curses_menu_items[MAX_MENU_ITEMS]; static struct mitem k_menu_items[MAX_MENU_ITEMS]; -static int items_num; +static unsigned int items_num; static int global_exit; /* the currently selected button */ static const char *current_instructions = menu_instructions; @@ -510,8 +510,14 @@ typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN, /* return the index of the matched item, or -1 if no such item exists */ static int get_mext_match(const char *match_str, match_f flag) { - int match_start = item_index(current_item(curses_menu)); - int index; + int match_start, index; + + if (items_num == 0) + return -1; + + match_start = item_index(current_item(curses_menu)); + if (match_start == ERR) + return -1; if (flag == FIND_NEXT_MATCH_DOWN) ++match_start; -- 2.27.0
Re: [PATCH v2] kconfig: nconf: stop endless search-up loops
On Sun, Mar 28, 2021 at 6:52 PM Mihai Moldovan wrote: > > If the user selects the very first entry in a page and performs a > search-up operation (e.g., via [/][a][Up Arrow]), nconf will never > terminate searching the page. > > The reason is that in this case, the starting point will be set to -1, > which is then translated into (n - 1) (i.e., the last entry of the > page) and finally the search begins. This continues to work fine until > the index reaches 0, at which point it will be decremented to -1, but > not checked against the starting point right away. Instead, it's > wrapped around to the bottom again, after which the starting point > check occurs... and naturally fails. > > We can easily avoid it by checking against the starting point directly > if the current index is -1 (which should be safe, since it's the only > magic value that can occur) and terminate the matching function. > > Amazingly, nobody seems to have been hit by this for 11 years - or at > the very least nobody bothered to debug and fix this. > > Signed-off-by: Mihai Moldovan > --- > v2: swap constant in comparison to right side, as requested by > Randy Dunlap > > scripts/kconfig/nconf.c | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c > index e0f965529166..db0dc46bc5ee 100644 > --- a/scripts/kconfig/nconf.c > +++ b/scripts/kconfig/nconf.c > @@ -515,6 +515,15 @@ static int get_mext_match(const char *match_str, match_f > flag) > --index; > else > ++index; > + /* > +* It's fine for index to become negative - think of an > +* initial value for match_start of 0 with a match direction > +* of up, eventually making it -1. > +* > +* Handle this as a special case. > +*/ > + if ((index == -1) && (index == match_start)) > + return -1; We know 'index' is -1 in the second comparison. So, you can also write like this: if (match_start == -1 && index == -1) return -1; But, it is not the correct fix, either. The root cause of the bug is match_start becoming -1. The following is the correct way to fix the bug without increasing the number of lines. diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index e0f965529166..af814b39b876 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -504,8 +504,8 @@ static int get_mext_match(const char *match_str, match_f flag) else if (flag == FIND_NEXT_MATCH_UP) --match_start; + match_start = (match_start + items_num) % items_num; index = match_start; - index = (index + items_num) % items_num; while (true) { char *str = k_menu_items[index].str; if (strcasestr(str, match_str) != NULL) -- Best Regards Masahiro Yamada
Re: [PATCH 1/2] linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in
On Fri, Apr 9, 2021 at 6:24 PM Andy Shevchenko wrote: > > On Fri, Apr 9, 2021 at 12:00 AM Masahiro Yamada wrote: > > > > is included from all the kernel-space source files, > > including C, assembly, linker scripts. It is intended to contain minimal > > a minimal > > > set of macros to evaluate CONFIG options. > > > > IF_ENABLED() is an intruder here because (x ? y : z) is C code, which > > should not be included from assembly files or linker scripts. > > > > Also, is no longer self-contained because NULL is > > defined in . > > > > Move IF_ENABLED() out to as PTR_IF(). > > > > PTR_IF(IS_ENABLED(CONFIG_FOO), ...) is slightly longer than > > IF_ENABLED(CONFIG_FOO, ...), but it is not a big deal because > > sub-systems often define dedicated macros such as of_match_ptr(), > > pm_ptr() etc. for common use-cases. > > > include/linux/kernel.h| 2 ++ > > Why kernel.h? Shouldn't it belong to a particular domain with a > respective header file? > > Really what we have in the kernel.h right now is a complete train > wreck of something. > We have to define what exactly is kernel.h for? contains random utility macros. I did not find a good header to put it in otherwise. > > Arnd? Others? Shall we start a wider discussion on the topic? > > -- > With Best Regards, > Andy Shevchenko -- Best Regards Masahiro Yamada
Re: [PATCH][V2] clk: uniphier: Fix potential infinite loop
On Fri, Apr 9, 2021 at 6:01 PM Colin King wrote: > > From: Colin Ian King > > The for-loop iterates with a u8 loop counter i and compares this > with the loop upper limit of num_parents that is an int type. > There is a potential infinite loop if num_parents is larger than > the u8 loop counter. Fix this by making the loop counter the same > type as num_parents. Also make num_parents an unsigned int to > match the return type of the call to clk_hw_get_num_parents. > > Addresses-Coverity: ("Infinite loop") > Fixes: 734d82f4a678 ("clk: uniphier: add core support code for UniPhier clock > driver") > > Signed-off-by: Colin Ian King > --- > > V2: Make num_parents an unsigned int to match return type of > clk_hw_get_num_parents(). Reviewed-by: Masahiro Yamada > --- > drivers/clk/uniphier/clk-uniphier-mux.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/uniphier/clk-uniphier-mux.c > b/drivers/clk/uniphier/clk-uniphier-mux.c > index 462c84321b2d..1998e9d4cfc0 100644 > --- a/drivers/clk/uniphier/clk-uniphier-mux.c > +++ b/drivers/clk/uniphier/clk-uniphier-mux.c > @@ -31,10 +31,10 @@ static int uniphier_clk_mux_set_parent(struct clk_hw *hw, > u8 index) > static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw) > { > struct uniphier_clk_mux *mux = to_uniphier_clk_mux(hw); > - int num_parents = clk_hw_get_num_parents(hw); > + unsigned int num_parents = clk_hw_get_num_parents(hw); > int ret; > unsigned int val; > - u8 i; > + unsigned int i; > > ret = regmap_read(mux->regmap, mux->reg, ); > if (ret) > -- > 2.30.2 > -- Best Regards Masahiro Yamada
Re: [PATCH 1/2] linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in
On Fri, Apr 9, 2021 at 5:15 PM Paul Cercueil wrote: > > Hi Masahiro, > > Le ven. 9 avril 2021 à 5:58, Masahiro Yamada a > écrit : > > is included from all the kernel-space source files, > > including C, assembly, linker scripts. It is intended to contain > > minimal > > set of macros to evaluate CONFIG options. > > > > IF_ENABLED() is an intruder here because (x ? y : z) is C code, which > > should not be included from assembly files or linker scripts. > > > > Also, is no longer self-contained because NULL is > > defined in . > > > > Move IF_ENABLED() out to as PTR_IF(). > > > > PTR_IF(IS_ENABLED(CONFIG_FOO), ...) is slightly longer than > > IF_ENABLED(CONFIG_FOO, ...), but it is not a big deal because > > sub-systems often define dedicated macros such as of_match_ptr(), > > pm_ptr() etc. for common use-cases. > > What's the idea behind changing IF_ENABLED() to PTR_IF()? You didn't > explain that. What's wrong with IF_ENABLED()? PTR_IF() is a more generalized variant, which I believe is a better fit in The first parameter does not need to be a CONFIG option, but any expression. > Cheers, > -Paul > > > Signed-off-by: Masahiro Yamada > > --- > > > > drivers/pinctrl/pinctrl-ingenic.c | 20 ++-- > > include/linux/kconfig.h | 6 -- > > include/linux/kernel.h| 2 ++ > > 3 files changed, 12 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/pinctrl/pinctrl-ingenic.c > > b/drivers/pinctrl/pinctrl-ingenic.c > > index f2746125b077..b21e2ae4528d 100644 > > --- a/drivers/pinctrl/pinctrl-ingenic.c > > +++ b/drivers/pinctrl/pinctrl-ingenic.c > > @@ -2496,43 +2496,43 @@ static int __init > > ingenic_pinctrl_probe(struct platform_device *pdev) > > static const struct of_device_id ingenic_pinctrl_of_match[] = { > > { > > .compatible = "ingenic,jz4740-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_JZ4740, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4740), > > _chip_info) > > }, > > { > > .compatible = "ingenic,jz4725b-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_JZ4725B, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4725B), > > _chip_info) > > }, > > { > > .compatible = "ingenic,jz4760-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_JZ4760, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4760), > > _chip_info) > > }, > > { > > .compatible = "ingenic,jz4760b-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_JZ4760, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4760), > > _chip_info) > > }, > > { > > .compatible = "ingenic,jz4770-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_JZ4770, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4770), > > _chip_info) > > }, > > { > > .compatible = "ingenic,jz4780-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_JZ4780, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4780), > > _chip_info) > > }, > > { > > .compatible = "ingenic,x1000-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_X1000, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1000), > > _chip_info) > > }, > > { > > .compatible = "ingenic,x1000e-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_X1000, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1000), > > _chip_info) > > }, > > { > > .compatible = "ingenic,x1500-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_X1500, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1500), > > _chip_info) > > }, > > { > > .compatible = "ingenic,x1830-pinctrl", > > - .data = IF_ENABLED(CONFIG_MACH_X1830, _chip_info) > > + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1830), > > _chip_info) > > }, > > { /* sentinel */ }, > > }; > > diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h > > index 24a59cb06963..cc8fa109cfa3 10
Re: [PATCH v2 05/13] mmc: sdhci-cadence: Add Pensando Elba SoC support
On Tue, Mar 30, 2021 at 7:31 PM Ulf Hansson wrote: > > + Masahiro Yamada (main author of the driver) > > On Mon, 29 Mar 2021 at 03:59, Brad Larson wrote: > > > > Add support for Pensando Elba SoC which explicitly controls > > byte-lane enables on writes. Refactor to allow platform > > specific write ops. > > > > Signed-off-by: Brad Larson > > --- > > drivers/mmc/host/Kconfig | 15 +++ > > drivers/mmc/host/Makefile | 1 + > > drivers/mmc/host/sdhci-cadence-elba.c | 137 ++ > > By looking at the amount of code changes that seem to be needed to > support the Pensando Elba variant, I don't think it's necessary to > split this into a separate file. > > Unless Yamada-san has a different opinion, I would rather just stick > with using sdhci-cadence.c. I agree with Ulf. BTW, this patch cannot probe "pensando,elba-emmc" when CONFIG_MMC_SDHCI_CADENCE_ELBA=m. > > > drivers/mmc/host/sdhci-cadence.c | 81 --- > > drivers/mmc/host/sdhci-cadence.h | 68 + > > 5 files changed, 260 insertions(+), 42 deletions(-) > > create mode 100644 drivers/mmc/host/sdhci-cadence-elba.c > > create mode 100644 drivers/mmc/host/sdhci-cadence.h > > > > diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig > > index b236dfe2e879..65ea323c06f2 100644 > > --- a/drivers/mmc/host/Kconfig > > +++ b/drivers/mmc/host/Kconfig > > @@ -250,6 +250,21 @@ config MMC_SDHCI_CADENCE > > > > If unsure, say N. > > > > +config MMC_SDHCI_CADENCE_ELBA > > + tristate "SDHCI support for the Pensando/Cadence SD/SDIO/eMMC > > controller" > > + depends on ARCH_PENSANDO_ELBA_SOC > > + depends on MMC_SDHCI > > + depends on OF > > + depends on MMC_SDHCI_CADENCE > > + depends on MMC_SDHCI_PLTFM > > + select MMC_SDHCI_IO_ACCESSORS > > According to the comment above - then you should probably just extend > the conditions for when building MMC_SDHCI_CADENCE, rather than having > to add a new Kconfig for "*_ELBA". > > > + help > > + This selects the Pensando/Cadence SD/SDIO/eMMC controller. > > + > > + If you have a controller with this interface, say Y or M here. > > + > > + If unsure, say N. > > + > > config MMC_SDHCI_CNS3XXX > > tristate "SDHCI support on the Cavium Networks CNS3xxx SoC" > > depends on ARCH_CNS3XXX || COMPILE_TEST > > diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile > > index 6df5c4774260..f2a6d50e64de 100644 > > --- a/drivers/mmc/host/Makefile > > +++ b/drivers/mmc/host/Makefile > > @@ -80,6 +80,7 @@ obj-$(CONFIG_MMC_REALTEK_USB) += rtsx_usb_sdmmc.o > > > > obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o > > obj-$(CONFIG_MMC_SDHCI_CADENCE)+= sdhci-cadence.o > > +obj-$(CONFIG_MMC_SDHCI_CADENCE_ELBA) += sdhci-cadence-elba.o > > obj-$(CONFIG_MMC_SDHCI_CNS3XXX)+= sdhci-cns3xxx.o > > obj-$(CONFIG_MMC_SDHCI_ESDHC_MCF) += sdhci-esdhc-mcf.o > > obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.o > > diff --git a/drivers/mmc/host/sdhci-cadence-elba.c > > b/drivers/mmc/host/sdhci-cadence-elba.c > > new file mode 100644 > > index ..ec23f43de407 > > --- /dev/null > > +++ b/drivers/mmc/host/sdhci-cadence-elba.c > > @@ -0,0 +1,137 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* > > + * Copyright (C) 2020 Pensando Systems, Inc. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "sdhci-pltfm.h" > > +#include "sdhci-cadence.h" > > + > > +// delay regs address > > Please don't use "//" when adding comments, but instead "/* ... */". > This applies to several more places of the patch. > > > +#define SDIO_REG_HRS4 0x10 This is the same as SDHCI_CDNS_HRS04 > > +#define REG_DELAY_HS 0x00 This is the same as SDHCI_CDNS_PHY_DLY_SD_HS > > +#define REG_DELAY_DEFAULT 0x01 This is the same as SDHCI_CDNS_PHY_DLY_SD_DEFAULT > > +#define REG_DELAY_UHSI_SDR50 0x04 This is the same as SDHCI_CDNS_PHY_DLY_UHS_SDR50 > > +#define REG_DELAY_UHSI_DDR50 0x05 This is the same as SDHCI_CDNS_PHY_DLY_UHS_DDR50 > > + > > +static void elba_write_l(struct sdhci_host *host, u32 val,
Re: [PATCH] clk: uniphier: Fix potential infinite loop
On Thu, Apr 8, 2021 at 12:25 AM Colin King wrote: > > From: Colin Ian King > > The for-loop iterates with a u8 loop counter i and compares this > with the loop upper limit of num_parents that is an int type. > There is a potential infinite loop if num_parents is larger than > the u8 loop counter. Fix this by making the loop counter the same > type as num_parents. > > Addresses-Coverity: ("Infinite loop") > Fixes: 734d82f4a678 ("clk: uniphier: add core support code for UniPhier clock > driver") > Signed-off-by: Colin Ian King > --- > drivers/clk/uniphier/clk-uniphier-mux.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/uniphier/clk-uniphier-mux.c > b/drivers/clk/uniphier/clk-uniphier-mux.c > index 462c84321b2d..ce219e0d2a85 100644 > --- a/drivers/clk/uniphier/clk-uniphier-mux.c > +++ b/drivers/clk/uniphier/clk-uniphier-mux.c > @@ -34,7 +34,7 @@ static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw) > int num_parents = clk_hw_get_num_parents(hw); > int ret; > unsigned int val; > - u8 i; > + int i; > > ret = regmap_read(mux->regmap, mux->reg, ); > if (ret) > -- > 2.30.2 > clk_hw_get_num_parents() returns 'unsigned int', so I think 'num_parents' should also have been 'unsigned int'. Maybe, the loop counter 'i' also should be 'unsigned int' then? -- Best Regards Masahiro Yamada
Re: [PATCH V11 3/5] kbuild: Allow .dtso format for overlay source files
On Tue, Mar 16, 2021 at 5:01 PM Geert Uytterhoeven wrote: > > Hi Frank, > > On Tue, Mar 16, 2021 at 6:39 AM Frank Rowand wrote: > > On 3/15/21 5:12 PM, Laurent Pinchart wrote: > > > On Tue, Mar 16, 2021 at 02:43:45AM +0900, Masahiro Yamada wrote: > > >> But how can we fix drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a779*.dts > > >> if these are doing bad things. > > >> They seem to be overlay files even though the file name suffix is .dts > > > > > > That is correct, they are overlays. I have no issue with those files > > > being renamed to .dtso if that can help (but I haven't checked if that > > > would have any adverse effect on the R-Car DU driver). > > > > As Laurent replied, yes these are overlays. They were grandfathered in > > as a deprecated use of overlays. > > > > > These files are there to ensure backward compatibility with older DT > > > bindings. The change was made 3 years ago and I wouldn't object to > > > dropping this completely, but I understand I may not be the most > > > cautious person when it comes to ensuring DT backward compatibility :-) > > > > My memory is that the goal was to eventually remove these overlays > > at some point in the future. If everyone agrees that today is the > > proper time, it would be helpful to go ahead and remove these .dts > > files and the code that uses them. > > Given [1][2][3] were merged in v4.17, and [4] was merged in v4.20, and > all were backported to the old v4.14-based R-Car BSP v3.8.0, I think > it's safe to assume all users have the DTS updates, so the backward > compatibility mode can be removed? > > > >> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts > > >> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts > > >> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts > > >> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts > > >> drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts > > [1] 15a1ff30d8f9bd83 ("ARM: dts: r8a7790: Convert to new LVDS DT bindings") > [2] e5c3f4707f3956a2 ("ARM: dts: r8a7791: Convert to new LVDS DT bindings") > [3] edb0c3affe5214a2 ("ARM: dts: r8a7793: Convert to new LVDS DT bindings") > [4] 58e8ed2ee9abe718 ("arm64: dts: renesas: Convert to new LVDS DT bindings") Can we remove all of drivers/gpu/drm/rcar-du/*.dts ? I see some more under drivers/staging/. masahiro@grover:~/ref/linux-next$ find drivers -name '*.dts' | grep -v drivers/of/unittest-data drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dts drivers/staging/mt7621-dts/gbpc2.dts drivers/staging/mt7621-dts/gbpc1.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts Best Regards Masahiro Yamada
Re: [PATCH 1/7] x86/syscalls: fix -Wmissing-prototypes warnings from COND_SYSCALL()
Hello, x86 maintainers, Thanks for picking up 1/7. Could you check 2/7 - 7/7, please? Thank you. On Thu, Mar 25, 2021 at 11:31 PM Masahiro Yamada wrote: > > On Thu, Mar 25, 2021 at 8:48 PM Mickaël Salaün wrote: > > > > Hi Masahiro, > > > > What is the status of this patch? Could you please push it to -next? > > This would avoid emails from lkp: > > https://lore.kernel.org/linux-security-module/202103191423.jl0jvzfl-...@intel.com/ > > > Hmm, I also want to know the answer. > This is the *third* time that I resent this patch > to the x86 ML. > > This is a territory of the x86 subsystem > because it is only touching > arch/x86/include/asm/syscall_wrapper.h > It is preferred to get this in via the x86 tree. > > x86 Maintainers, > could you take a look please? > > > -- Best Regards Masahiro Yamada
Re: [PATCH 2/2] pm: allow drivers to drop #ifdef and __maybe_unused from pm callbacks
On Fri, Apr 9, 2021 at 6:30 AM Arnd Bergmann wrote: > > On Thu, Apr 8, 2021 at 11:00 PM Masahiro Yamada wrote: > > > > Drivers typically surround suspend and resume callbacks with #ifdef > > CONFIG_PM(_SLEEP) or mark them as __maybe_unused in order to avoid > > -Wunused-const-variable warnings. > > > > With this commit, drivers will be able to remove #ifdef CONFIG_PM(_SLEEP) > > and __maybe_unsed because unused functions are dropped by the compiler > > instead of the preprocessor. > > > > Signed-off-by: Masahiro Yamada > > I tried this before and could not get it to work right. > > > > > -#ifdef CONFIG_PM_SLEEP > > +#define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), _ptr) > > +#define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), _ptr) > > + > > #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ > > - .suspend = suspend_fn, \ > > - .resume = resume_fn, \ > > - .freeze = suspend_fn, \ > > - .thaw = resume_fn, \ > > - .poweroff = suspend_fn, \ > > - .restore = resume_fn, > > -#else > > -#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) > > -#endif > > + .suspend = pm_sleep_ptr(suspend_fn), \ > > + .resume = pm_sleep_ptr(resume_fn), \ > > + .freeze = pm_sleep_ptr(suspend_fn), \ > > + .thaw = pm_sleep_ptr(resume_fn), \ > > + .poweroff = pm_sleep_ptr(suspend_fn), \ > > + .restore = pm_sleep_ptr(resume_fn), > > The problem that I think you inevitably hit is that you run into a missing > declaration for any driver that still uses an #ifdef around a static > function. > > The only way I can see us doing this is to create a new set of > macros that behave like the version you propose here but leave > the old macros in place until the last such #ifdef has been removed. > >Arnd Agh, you are right. We cannot change all the callsites atomically due to the huge amount of users. -- Best Regards Masahiro Yamada
[PATCH 2/2] pm: allow drivers to drop #ifdef and __maybe_unused from pm callbacks
Drivers typically surround suspend and resume callbacks with #ifdef CONFIG_PM(_SLEEP) or mark them as __maybe_unused in order to avoid -Wunused-const-variable warnings. With this commit, drivers will be able to remove #ifdef CONFIG_PM(_SLEEP) and __maybe_unsed because unused functions are dropped by the compiler instead of the preprocessor. Signed-off-by: Masahiro Yamada --- include/linux/pm.h | 67 +- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/include/linux/pm.h b/include/linux/pm.h index 482313a8ccfc..ca764566692a 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -301,50 +301,37 @@ struct dev_pm_ops { int (*runtime_idle)(struct device *dev); }; -#ifdef CONFIG_PM_SLEEP +#define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), _ptr) +#define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), _ptr) + #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ - .suspend = suspend_fn, \ - .resume = resume_fn, \ - .freeze = suspend_fn, \ - .thaw = resume_fn, \ - .poweroff = suspend_fn, \ - .restore = resume_fn, -#else -#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) -#endif + .suspend = pm_sleep_ptr(suspend_fn), \ + .resume = pm_sleep_ptr(resume_fn), \ + .freeze = pm_sleep_ptr(suspend_fn), \ + .thaw = pm_sleep_ptr(resume_fn), \ + .poweroff = pm_sleep_ptr(suspend_fn), \ + .restore = pm_sleep_ptr(resume_fn), -#ifdef CONFIG_PM_SLEEP #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ - .suspend_late = suspend_fn, \ - .resume_early = resume_fn, \ - .freeze_late = suspend_fn, \ - .thaw_early = resume_fn, \ - .poweroff_late = suspend_fn, \ - .restore_early = resume_fn, -#else -#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) -#endif + .suspend_late = pm_sleep_ptr(suspend_fn), \ + .resume_early = pm_sleep_ptr(resume_fn), \ + .freeze_late = pm_sleep_ptr(suspend_fn), \ + .thaw_early= pm_sleep_ptr(resume_fn), \ + .poweroff_late = pm_sleep_ptr(suspend_fn), \ + .restore_early = pm_sleep_ptr(resume_fn), -#ifdef CONFIG_PM_SLEEP #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ - .suspend_noirq = suspend_fn, \ - .resume_noirq = resume_fn, \ - .freeze_noirq = suspend_fn, \ - .thaw_noirq = resume_fn, \ - .poweroff_noirq = suspend_fn, \ - .restore_noirq = resume_fn, -#else -#define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) -#endif + .suspend_noirq = pm_sleep_ptr(suspend_fn), \ + .resume_noirq = pm_sleep_ptr(resume_fn), \ + .freeze_noirq = pm_sleep_ptr(suspend_fn), \ + .thaw_noirq = pm_sleep_ptr(resume_fn), \ + .poweroff_noirq = pm_sleep_ptr(suspend_fn), \ + .restore_noirq = pm_sleep_ptr(resume_fn), -#ifdef CONFIG_PM #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ - .runtime_suspend = suspend_fn, \ - .runtime_resume = resume_fn, \ - .runtime_idle = idle_fn, -#else -#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) -#endif + .runtime_suspend = pm_ptr(suspend_fn), \ + .runtime_resume = pm_ptr(resume_fn), \ + .runtime_idle= pm_ptr(idle_fn), /* * Use this if you want to use the same suspend and resume callbacks for suspend @@ -374,12 +361,6 @@ const struct dev_pm_ops __maybe_unused name = { \ SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ } -#ifdef CONFIG_PM -#define pm_ptr(_ptr) (_ptr) -#else -#define pm_ptr(_ptr) NULL -#endif - /* * PM_EVENT_ messages * -- 2.27.0
[PATCH 0/2] linux/kconfig.h: move IF_ENABLED() out of
I insist on having only minimal set of macros that are needed to evaluate CONFIG options. Everytime somebody added an alien to , I needed to kick it out. I did not notice 1b399bb04837183cecdc1b32ef1cfc7fcfa75d32 because I was not addressed by [1]. [1]: https://lore.kernel.org/lkml/?q=kconfig.h%3A+Add+IF_ENABLED%28%29+macro I like Paul's idea, but if I had noticed the patch in time, I would have tried my best to persuade to implement it outside of (Paul's initial patch was adding it to a new header instead of ) Before it is widely used, I want to fix it. In 2/2, I converted pm.h to allow driver cleanups. Masahiro Yamada (2): linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in pm: allow drivers to drop #ifdef and __maybe_unused from pm callbacks drivers/pinctrl/pinctrl-ingenic.c | 20 - include/linux/kconfig.h | 6 --- include/linux/kernel.h| 2 + include/linux/pm.h| 67 +++ 4 files changed, 36 insertions(+), 59 deletions(-) -- 2.27.0
[PATCH 1/2] linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in
is included from all the kernel-space source files, including C, assembly, linker scripts. It is intended to contain minimal set of macros to evaluate CONFIG options. IF_ENABLED() is an intruder here because (x ? y : z) is C code, which should not be included from assembly files or linker scripts. Also, is no longer self-contained because NULL is defined in . Move IF_ENABLED() out to as PTR_IF(). PTR_IF(IS_ENABLED(CONFIG_FOO), ...) is slightly longer than IF_ENABLED(CONFIG_FOO, ...), but it is not a big deal because sub-systems often define dedicated macros such as of_match_ptr(), pm_ptr() etc. for common use-cases. Signed-off-by: Masahiro Yamada --- drivers/pinctrl/pinctrl-ingenic.c | 20 ++-- include/linux/kconfig.h | 6 -- include/linux/kernel.h| 2 ++ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c index f2746125b077..b21e2ae4528d 100644 --- a/drivers/pinctrl/pinctrl-ingenic.c +++ b/drivers/pinctrl/pinctrl-ingenic.c @@ -2496,43 +2496,43 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev) static const struct of_device_id ingenic_pinctrl_of_match[] = { { .compatible = "ingenic,jz4740-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_JZ4740, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4740), _chip_info) }, { .compatible = "ingenic,jz4725b-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_JZ4725B, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4725B), _chip_info) }, { .compatible = "ingenic,jz4760-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_JZ4760, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4760), _chip_info) }, { .compatible = "ingenic,jz4760b-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_JZ4760, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4760), _chip_info) }, { .compatible = "ingenic,jz4770-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_JZ4770, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4770), _chip_info) }, { .compatible = "ingenic,jz4780-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_JZ4780, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_JZ4780), _chip_info) }, { .compatible = "ingenic,x1000-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_X1000, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1000), _chip_info) }, { .compatible = "ingenic,x1000e-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_X1000, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1000), _chip_info) }, { .compatible = "ingenic,x1500-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_X1500, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1500), _chip_info) }, { .compatible = "ingenic,x1830-pinctrl", - .data = IF_ENABLED(CONFIG_MACH_X1830, _chip_info) + .data = PTR_IF(IS_ENABLED(CONFIG_MACH_X1830), _chip_info) }, { /* sentinel */ }, }; diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index 24a59cb06963..cc8fa109cfa3 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -70,10 +70,4 @@ */ #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) -/* - * IF_ENABLED(CONFIG_FOO, ptr) evaluates to (ptr) if CONFIG_FOO is set to 'y' - * or 'm', NULL otherwise. - */ -#define IF_ENABLED(option, ptr) (IS_ENABLED(option) ? (ptr) : NULL) - #endif /* __LINUX_KCONFIG_H */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5b7ed6dc99ac..8685ca4cf287 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -38,6 +38,8 @@ #define PTR_ALIGN_DOWN(p, a) ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a))) #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) +#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL) + /* generic data direction definitions */ #define READ 0 #define WRITE 1 -- 2.27.0
[PATCH] powerpc: remove old workaround for GCC < 4.9
According to Documentation/process/changes.rst, the minimum supported GCC version is 4.9. This workaround is dead code. Signed-off-by: Masahiro Yamada --- arch/powerpc/Makefile | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 5f8544cf724a..32dd693b4e42 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -181,12 +181,6 @@ CC_FLAGS_FTRACE := -pg ifdef CONFIG_MPROFILE_KERNEL CC_FLAGS_FTRACE += -mprofile-kernel endif -# Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8 -# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199 -# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828 -ifndef CONFIG_CC_IS_CLANG -CC_FLAGS_FTRACE+= $(call cc-ifversion, -lt, 0409, -mno-sched-epilog) -endif endif CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU)) -- 2.27.0
Re: [PATCH v3] kbuild: add support for zstd compressed modules
On Thu, Apr 8, 2021 at 1:09 AM Piotr Gorski wrote: > > kmod 28 supports modules compressed in zstd format so let's add this > possibility to kernel. > > V2 -> V3 > > * Fix a typo > > V1 -> V2 > > * Rebuild against linux-kbuild tree > > Signed-off-by: Piotr Gorski Applied to linux-kbuild. Thanks! I slightly changed to fix the log alignment. diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index f9fa2a3808b2..ff9b09e4cfca 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -96,7 +96,7 @@ quiet_cmd_gzip = GZIP$@ cmd_gzip = $(KGZIP) -n -f $< quiet_cmd_xz = XZ $@ cmd_xz = $(XZ) --lzma2=dict=2MiB -f $< -quiet_cmd_zstd = ZSTD $@ +quiet_cmd_zstd = ZSTD$@ cmd_zstd = $(ZSTD) -T0 --rm -f -q $< $(dst)/%.ko.gz: $(dst)/%.ko FORCE > --- > init/Kconfig | 8 +++- > scripts/Makefile.modinst | 6 ++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/init/Kconfig b/init/Kconfig > index 510f6fcd9b7f..b5744d32c4df 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -2242,7 +2242,7 @@ choice > > Please note that the tool used to load modules needs to support the > corresponding algorithm. module-init-tools MAY support gzip, and > kmod > - MAY support gzip and xz. > + MAY support gzip, xz and zstd. > > Your build system needs to provide the appropriate compression tool > to compress the modules. > @@ -2267,6 +2267,12 @@ config MODULE_COMPRESS_XZ > Compress modules with XZ. The installed modules are suffixed > with .ko.xz. > > +config MODULE_COMPRESS_ZSTD > + bool "ZSTD" > + help > + Compress modules with ZSTD. The installed modules are suffixed > + with .ko.zst. > + > endchoice > > config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS > diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst > index 191408f7a91a..f9fa2a3808b2 100644 > --- a/scripts/Makefile.modinst > +++ b/scripts/Makefile.modinst > @@ -21,6 +21,7 @@ endif > suffix-y := > suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz > suffix-$(CONFIG_MODULE_COMPRESS_XZ):= .xz > +suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst > > modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules)) > > @@ -95,6 +96,8 @@ quiet_cmd_gzip = GZIP$@ >cmd_gzip = $(KGZIP) -n -f $< > quiet_cmd_xz = XZ $@ >cmd_xz = $(XZ) --lzma2=dict=2MiB -f $< > +quiet_cmd_zstd = ZSTD $@ > + cmd_zstd = $(ZSTD) -T0 --rm -f -q $< > > $(dst)/%.ko.gz: $(dst)/%.ko FORCE > $(call cmd,gzip) > @@ -102,6 +105,9 @@ $(dst)/%.ko.gz: $(dst)/%.ko FORCE > $(dst)/%.ko.xz: $(dst)/%.ko FORCE > $(call cmd,xz) > > +$(dst)/%.ko.zst: $(dst)/%.ko FORCE > + $(call cmd,zstd) > + > PHONY += FORCE > FORCE: > > -- > 2.31.0.97.g1424303384 > -- Best Regards Masahiro Yamada
Re: [PATCH] MIPS: select ARCH_KEEP_MEMBLOCK unconditionally
On Thu, Apr 8, 2021 at 2:35 AM Nick Desaulniers wrote: > > While removing allnoconfig_y from Kconfig, ARCH=mips allnoconfig builds > started failing with the error: > > WARNING: modpost: vmlinux.o(.text+0x9c70): Section mismatch in reference > from the function reserve_exception_space() to the function > .meminit.text:memblock_reserve() > The function reserve_exception_space() references the function __meminit > memblock_reserve(). > This is often because reserve_exception_space lacks a __meminit > annotation or the annotation of memblock_reserve is wrong. > ERROR: modpost: Section mismatches detected. > Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them. > > allnoconfig disables DEBUG_KERNEL and thus ARCH_KEEP_MEMBLOCK, which > changes __init_memblock to be equivalent to __meminit triggering the > above error. > > Link: > https://lore.kernel.org/linux-kbuild/20210313194836.372585-11-masahi...@kernel.org/ > Fixes: commit a8c0f1c634507 ("MIPS: Select ARCH_KEEP_MEMBLOCK if > DEBUG_KERNEL to enable sysfs memblock debug") > Cc: Masahiro Yamada Please replace it with: Reviewed-by: Masahiro Yamada Thanks. > Reported-by: Guenter Roeck > Signed-off-by: Nick Desaulniers > --- > arch/mips/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig > index e9893cd34992..702648f60e41 100644 > --- a/arch/mips/Kconfig > +++ b/arch/mips/Kconfig > @@ -12,7 +12,7 @@ config MIPS > select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST > select ARCH_HAS_UBSAN_SANITIZE_ALL > select ARCH_HAS_GCOV_PROFILE_ALL > - select ARCH_KEEP_MEMBLOCK if DEBUG_KERNEL > + select ARCH_KEEP_MEMBLOCK > select ARCH_SUPPORTS_UPROBES > select ARCH_USE_BUILTIN_BSWAP > select ARCH_USE_CMPXCHG_LOCKREF if 64BIT > -- > 2.31.1.295.g9ea45b61b8-goog > -- Best Regards Masahiro Yamada
Re: [PATCH] init: add support for zstd compressed modules
On Tue, Mar 30, 2021 at 8:33 PM Piotr Gorski wrote: > > kmod 28 supports modules compressed in zstd format so let's add this > possibility to kernel. > > Signed-off-by: Piotr Gorski > --- > Makefile | 7 +-- > init/Kconfig | 9 ++--- > 2 files changed, 11 insertions(+), 5 deletions(-) Piort, sorry for bothering you, but could you rebase on top of this clean-up patch set? https://patchwork.kernel.org/project/linux-kbuild/list/?series=458809 or git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild The module compression code should not be placed in the top Makefile. > diff --git a/Makefile b/Makefile > index 5160ff8903c1..82f4f4cc2955 100644 > --- a/Makefile > +++ b/Makefile > @@ -1156,8 +1156,8 @@ endif # INSTALL_MOD_STRIP > export mod_strip_cmd > > # CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed > -# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP > -# or CONFIG_MODULE_COMPRESS_XZ. > +# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP, > +# CONFIG_MODULE_COMPRESS_XZ, or CONFIG_MODULE_COMPRESS_ZSTD. > > mod_compress_cmd = true > ifdef CONFIG_MODULE_COMPRESS > @@ -1167,6 +1167,9 @@ ifdef CONFIG_MODULE_COMPRESS >ifdef CONFIG_MODULE_COMPRESS_XZ > mod_compress_cmd = $(XZ) --lzma2=dict=2MiB -f >endif # CONFIG_MODULE_COMPRESS_XZ > + ifdef CONFIG_MODULE_COMPRESS_ZSTD > +mod_compress_cmd = $(ZSTD) -T0 --rm -f -q > + endif # CONFIG_MODULE_COMPRESS_ZSTD > endif # CONFIG_MODULE_COMPRESS > export mod_compress_cmd > > diff --git a/init/Kconfig b/init/Kconfig > index 8c2cfd88f6ef..86a452bc2747 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -2250,8 +2250,8 @@ config MODULE_COMPRESS > bool "Compress modules on installation" > help > > - Compresses kernel modules when 'make modules_install' is run; gzip > or > - xz depending on "Compression algorithm" below. > + Compresses kernel modules when 'make modules_install' is run; gzip, > + xz, or zstd depending on "Compression algorithm" below. > > module-init-tools MAY support gzip, and kmod MAY support gzip and > xz. > > @@ -2273,7 +2273,7 @@ choice > This determines which sort of compression will be used during > 'make modules_install'. > > - GZIP (default) and XZ are supported. > + GZIP (default), XZ, and ZSTD are supported. > > config MODULE_COMPRESS_GZIP > bool "GZIP" > @@ -2281,6 +2281,9 @@ config MODULE_COMPRESS_GZIP > config MODULE_COMPRESS_XZ > bool "XZ" > > +config MODULE_COMPRESS_ZSTD > + bool "ZSTD" > + > endchoice > > config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS > -- > 2.31.0.97.g1424303384 > -- Best Regards Masahiro Yamada
Re: [PATCH 1/9] kbuild: remove unneeded mkdir for external modules_install
On Wed, Mar 31, 2021 at 10:38 PM Masahiro Yamada wrote: > > scripts/Makefile.modinst creates directories as needed. > > Signed-off-by: Masahiro Yamada > --- Applied to linux-kbuild. > > Makefile | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/Makefile b/Makefile > index ed8bd815e8a3..0e06db5ed9d8 100644 > --- a/Makefile > +++ b/Makefile > @@ -1779,10 +1779,8 @@ $(MODORDER): descend > PHONY += modules_install > modules_install: _emodinst_ _emodinst_post > > -install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) > PHONY += _emodinst_ > _emodinst_: > - $(Q)mkdir -p $(MODLIB)/$(install-dir) > $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst > > PHONY += _emodinst_post > -- > 2.27.0 > -- Best Regards Masahiro Yamada
Re: [PATCH 9/9] kbuild: remove CONFIG_MODULE_COMPRESS
On Wed, Mar 31, 2021 at 10:39 PM Masahiro Yamada wrote: > > CONFIG_MODULE_COMPRESS is only used to activate the choice for module > compression algorithm. It will be simpler to make the choice visible > all the time by adding CONFIG_MODULE_COMPRESS_NONE to allow the user to > disable module compression. > > This is more consistent with the "Kernel compression mode" and "Built-in > initramfs compression mode" choices. > > CONFIG_KERNEL_UNCOMPRESSED and CONFIG_INITRAMFS_COMPRESSION_NONE are > available to choose to not compress the kernel, initrd, respectively. > > Signed-off-by: Masahiro Yamada > --- > > init/Kconfig | 45 ++--- > 1 file changed, 26 insertions(+), 19 deletions(-) > > diff --git a/init/Kconfig b/init/Kconfig > index 019c1874e609..3ca1ffd219c4 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -2225,40 +2225,47 @@ config MODULE_SIG_HASH > default "sha384" if MODULE_SIG_SHA384 > default "sha512" if MODULE_SIG_SHA512 > > -config MODULE_COMPRESS > - bool "Compress modules on installation" > +choice > + prompt "Module compression mode" > help > + This option allows you to choose the algorithm which will be used to > + compress modules when 'make modules_install' is run. (or, you can > + choose to not compress modules at all.) > > - Compresses kernel modules when 'make modules_install' is run; gzip > or > - xz depending on "Compression algorithm" below. > + External modules will also be compressed in the same way during the > + installation. > > - module-init-tools MAY support gzip, and kmod MAY support gzip and > xz. > + For modules inside an initrd or initramfs, it's more efficient to > + compress the whole initrd or initramfs instead. > > - Out-of-tree kernel modules installed using Kbuild will also be > - compressed upon installation. > + This is fully compatible with signed modules. > > - Note: for modules inside an initrd or initramfs, it's more efficient > - to compress the whole initrd or initramfs instead. > + Please note that the tool used to load modules needs to support the > + corresponding algorithm. module-init-tools MAY support gzip, and > kmod > + MAY support gzip and xz. > > - Note: This is fully compatible with signed modules. > + Your build system needs to provide the appropriate compression tool > + to compress the modules. > > - If in doubt, say N. > + If in doubt, select 'None'. > > -choice > - prompt "Compression algorithm" > - depends on MODULE_COMPRESS > - default MODULE_COMPRESS_GZIP > +config MODULE_COMPRESS_NONE > + bool "None" > help > - This determines which sort of compression will be used during > - 'make modules_install'. > - > - GZIP (default) and XZ are supported. > + Do not compress modules. The installed modules are suffixed > + with .ko. > > config MODULE_COMPRESS_GZIP > bool "GZIP" > + help > + Compress modules with XZ. The installed modules are suffixed This should be "Compress modules with GZIP." I will fix it when applied. > + with .ko.gz. > > config MODULE_COMPRESS_XZ > bool "XZ" > + help > + Compress modules with XZ. The installed modules are suffixed > + with .ko.xz. > > endchoice > > -- > 2.27.0 > -- Best Regards Masahiro Yamada
Re: [PATCH] kbuild: merge module sections under CONFIG_LD_DEAD_CODE_DATA_ELIMINATION too
On Tue, Apr 6, 2021 at 11:42 PM Alexander Lobakin wrote: > > On Friday, 2 April 2021, 18:09, Sami > Tolvanen wrote: > > > On Fri, Apr 2, 2021 at 5:40 AM Alexander Lobakin aloba...@pm.me wrote: > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, > > > -fdata-sections and -ffunction-sections are being enabled by the > > > top-level Makefile, and module section merging is also needed. > > > Expand the ifdef (and the comment block) to cover that case too. > > > Fixes: 6a3193cdd5e5 ("kbuild: lto: Merge module sections if and only if > > > CONFIG_LTO_CLANG is enabled") Did you test this patch before submission? See the top Makefile closely: ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections LDFLAGS_vmlinux += --gc-sections endif -ffunction-sections -fdata-sections are passed to only built-in objects, but not to module objects in the first place. KBUILD_CFLAGS_KERNEL is only passed to built-in objects. The situation you claimed never happens. > > Wouldn't this trigger the ld.bfd bug described in the commit message > > when LD_DEAD_CODE_DATA_ELIMINATION is enabled? LTO_CLANG always uses > > LLD, so it won't have this issue. > > LD_DEAD_CODE_DATA_ELIMINATION is marked > “EXPERIMENTAL“ in the config prompt, and > arches have to opt-in > HAS_LD_DEAD_CODE_DATA_ELIMINATION to give > an access to it (only a few does). This > should be relatively safe. > > > Sami > > Thanks, > Al -- Best Regards Masahiro Yamada
Re: [PATCH] init: add support for zstd compressed modules
52bc2747 100644 > >>>> --- a/init/Kconfig > >>>> +++ b/init/Kconfig > >>>> @@ -2250,8 +2250,8 @@ config MODULE_COMPRESS > >>>>bool "Compress modules on installation" > >>>>help > >>>> > >>>> -Compresses kernel modules when 'make modules_install' is run; gzip > >>>> or > >>>> -xz depending on "Compression algorithm" below. > >>>> +Compresses kernel modules when 'make modules_install' is run; gzip, > >>>> +xz, or zstd depending on "Compression algorithm" below. > >>>> > >>>> module-init-tools MAY support gzip, and kmod MAY support gzip and > >>>> xz. > >>>> > >>>> @@ -2273,7 +2273,7 @@ choice > >>>> This determines which sort of compression will be used during > >>>> 'make modules_install'. > >>>> > >>>> -GZIP (default) and XZ are supported. > >>>> +GZIP (default), XZ, and ZSTD are supported. > >>>> > >>>> config MODULE_COMPRESS_GZIP > >>>>bool "GZIP" > >>>> @@ -2281,6 +2281,9 @@ config MODULE_COMPRESS_GZIP > >>>> config MODULE_COMPRESS_XZ > >>>>bool "XZ" > >>>> > >>>> +config MODULE_COMPRESS_ZSTD > >>>> + bool "ZSTD" > >>>> + > >>>> endchoice > >>>> > >>>> config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS > >>>> -- > >>>> 2.31.0.97.g1424303384 > >>>> > >>> > >>> Great! > >>> > >>> Reviewed-by: Oleksandr Natalenko > >>> > >>> This works perfectly fine in Arch Linux if accompanied by the > >>> following mkinitcpio amendment: [1]. > >>> > >>> I'm also Cc'ing other people from get_maintainers output just > >>> to make this submission more visible. > >>> > >>> Thanks. > >>> > >>> [1] https://github.com/archlinux/mkinitcpio/pull/43 > >>> > >>> -- > >>> Oleksandr Natalenko (post-factum) > >> > > > > -- > > Oleksandr Natalenko (post-factum) > -- Best Regards Masahiro Yamada
Re: [PATCH 07/20] kbuild: scripts/install.sh: allow for the version number
On Wed, Apr 7, 2021 at 10:04 PM Greg Kroah-Hartman wrote: > > On Wed, Apr 07, 2021 at 08:05:23PM +0900, Masahiro Yamada wrote: > > On Wed, Apr 7, 2021 at 2:35 PM Greg Kroah-Hartman > > wrote: > > > > > > Some architectures put the version number by default at the end of the > > > files that are copied, so add support for this to be set by arch type. > > > > > > Odds are one day we should change this for x86, but let's not break > > > anyone's systems just yet. > > > > > > Signed-off-by: Greg Kroah-Hartman > > > --- > > > scripts/install.sh | 15 +-- > > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > > > diff --git a/scripts/install.sh b/scripts/install.sh > > > index 72dc4c81013e..934619f81119 100644 > > > --- a/scripts/install.sh > > > +++ b/scripts/install.sh > > > @@ -60,8 +60,19 @@ else > > > base=vmlinux > > > fi > > > > > > -install "$2" "$4"/"$base" > > > -install "$3" "$4"/System.map > > > +# Some architectures name their files based on version number, and > > > +# others do not. Call out the ones that do not to make it obvious. > > > +case "${ARCH}" in > > > + x86) > > > + version="" > > > + ;; > > > + *) > > > + version="-${1}" > > > + ;; > > > +esac > > > + > > > +install "$2" "$4"/"$base""$version" > > > > > > Too many quotes are eye sore. > > > > > > install "$2" "$4/$base$version" > > > > looks cleaner in my opinion. > > > > Shell correctly understands the end of each > > variable because a slash or a dollar > > cannot be a part of a variable name. > > Good idea, I usually just default to "quote everything!" when dealing > with bash variables. I'll fix this up. > > Oh, any preference for "$2" vs. "${2}"? I don't care either way but I > couldn't tell what is the normal kernel style these days. I do not see a well-defined coding style guideline for shell scripts. If you want to know my personal preference, I use "$2" without braces. Thanks. > > thanks for all of the review, much appreciated! My pleasure. > > greg k-h -- Best Regards Masahiro Yamada
Re: [PATCH] kconfig: lxdialog: A spello fix and a punctuation added
On Sat, Mar 27, 2021 at 6:21 AM Bhaskar Chowdhury wrote: > > > s/propperly/properly/ > s/thats/that\'s/ > > Signed-off-by: Bhaskar Chowdhury Applied to linux-kbuild. Thanks. > --- > scripts/kconfig/lxdialog/util.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c > index 1b490d4af0d3..3f78fb265136 100644 > --- a/scripts/kconfig/lxdialog/util.c > +++ b/scripts/kconfig/lxdialog/util.c > @@ -363,7 +363,7 @@ void print_title(WINDOW *dialog, const char *title, int > width) > /* > * Print a string of text in a window, automatically wrap around to the > * next line if the string is too long to fit on one line. Newline > - * characters '\n' are propperly processed. We start on a new line > + * characters '\n' are properly processed. We start on a new line > * if there is no room for at least 4 nonblanks following a double-space. > */ > void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int > x) > @@ -541,7 +541,7 @@ int first_alpha(const char *string, const char *exempt) > * lxdialog suggest which is correctly translated to two > * times esc. But then we need to ignore the second esc to avoid stepping > * out one menu too much. Filter away all escaped key sequences since > - * keypad(FALSE) turn off ncurses support for escape sequences - and thats > + * keypad(FALSE) turn off ncurses support for escape sequences - and that's > * needed to make notimeout() do as expected. > */ > int on_key_esc(WINDOW *win) > -- > 2.26.2 > -- Best Regards Masahiro Yamada
Re: [PATCH] kconfig: streamline_config.pl: Couple of typo fixes
On Fri, Mar 26, 2021 at 3:03 PM Bhaskar Chowdhury wrote: > > > s/configuraton/configuration/ > s/orignal/original/ > > Signed-off-by: Bhaskar Chowdhury Applied to linux-kbuild. Thanks. > --- > scripts/kconfig/streamline_config.pl | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/scripts/kconfig/streamline_config.pl > b/scripts/kconfig/streamline_config.pl > index 1c78ba49ca99..911c72a2dbc4 100755 > --- a/scripts/kconfig/streamline_config.pl > +++ b/scripts/kconfig/streamline_config.pl > @@ -21,7 +21,7 @@ > # 1. Boot up the kernel that you want to stream line the config on. > # 2. Change directory to the directory holding the source of the > # kernel that you just booted. > -# 3. Copy the configuraton file to this directory as .config > +# 3. Copy the configuration file to this directory as .config > # 4. Have all your devices that you need modules for connected and > # operational (make sure that their corresponding modules are loaded) > # 5. Run this script redirecting the output to some other file > @@ -481,7 +481,7 @@ sub parse_config_depends > # The idea is we look at all the configs that select it. If one > # is already in our list of configs to enable, then there's nothing > # else to do. If there isn't, we pick the first config that was > -# enabled in the orignal config and use that. > +# enabled in the original config and use that. > sub parse_config_selects > { > my ($config, $p) = @_; > -- > 2.26.2 > -- Best Regards Masahiro Yamada
Re: [PATCH] scripts: modpost.c: Fix a few typos
On Fri, Mar 26, 2021 at 2:54 PM Bhaskar Chowdhury wrote: > > > s/agorithm/algorithm/ > s/criterias/criteria/ > s/targetting/targeting/ two different places. > > Signed-off-by: Bhaskar Chowdhury > --- Applied to linux-kbuild. Thanks. > scripts/mod/modpost.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 24725e50c7b4..9b971ec9e58d 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -202,7 +202,7 @@ struct symbol { > > static struct symbol *symbolhash[SYMBOL_HASH_SIZE]; > > -/* This is based on the hash agorithm from gdbm, via tdb */ > +/* This is based on the hash algorithm from gdbm, via tdb */ > static inline unsigned int tdb_hash(const char *name) > { > unsigned value; /* Used to compute the hash value. */ > @@ -985,7 +985,7 @@ enum mismatch { > }; > > /** > - * Describe how to match sections on different criterias: > + * Describe how to match sections on different criteria: > * > * @fromsec: Array of sections to be matched. > * > @@ -993,12 +993,12 @@ enum mismatch { > * this array is forbidden (black-list). Can be empty. > * > * @good_tosec: Relocations applied to a section in @fromsec must be > - * targetting sections in this array (white-list). Can be empty. > + * targeting sections in this array (white-list). Can be empty. > * > * @mismatch: Type of mismatch. > * > * @symbol_white_list: Do not match a relocation to a symbol in this list > - * even if it is targetting a section in @bad_to_sec. > + * even if it is targeting a section in @bad_to_sec. > * > * @handler: Specific handler to call when a match is found. If NULL, > * default_mismatch_handler() will be called. > -- > 2.26.2 > -- Best Regards Masahiro Yamada
Re: [PATCH 11/13] kconfig: do not use allnoconfig_y option
On Thu, Apr 1, 2021 at 3:25 AM Nick Desaulniers wrote: > > On Wed, Mar 31, 2021 at 10:12 AM Guenter Roeck wrote: > > > > On Sun, Mar 14, 2021 at 04:48:34AM +0900, Masahiro Yamada wrote: > > > allnoconfig_y is a bad hack that sets a symbol to 'y' by allnoconfig. > > > > > > allnoconfig does not mean a minimum set of CONFIG options because a > > > bunch of prompts are hidden by 'if EMBEDDED' or 'if EXPERT', but I do > > > not like to do a workaround this way. > > > > > > Use the pre-existing feature, KCONFIG_ALLCONFIG, to provide a one > > > liner config fragment. CONFIG_EMBEDDED=y is still forced under > > > allnoconfig. > > > > > > No change in the .config file produced by 'make tinyconfig'. > > > > > > The output of 'make allnoconfig' will be changed; we will get > > > CONFIG_EMBEDDED=n because allnoconfig literally sets all symbols to n. > > > > > > Signed-off-by: Masahiro Yamada > > > > With this patch in place, mips:allnoconfig fails to build with > > the following error. > > > > Error log: > > WARNING: modpost: vmlinux.o(.text+0x9c70): Section mismatch in reference > > from the function reserve_exception_space() to the function > > .meminit.text:memblock_reserve() > > The function reserve_exception_space() references > > the function __meminit memblock_reserve(). > > This is often because reserve_exception_space lacks a __meminit > > annotation or the annotation of memblock_reserve is wrong. > > ERROR: modpost: Section mismatches detected. > > Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them. > > make[2]: *** [scripts/Makefile.modpost:62: vmlinux.symvers] Error 1 > > make[2]: *** Deleting file 'vmlinux.symvers' > > make[1]: *** [Makefile:1292: vmlinux] Error 2 > > make: *** [Makefile:222: __sub-make] Error 2 > > Thanks for the report. I suspect this is related to allnoconfig > disabling CONFIG_ARCH_KEEP_MEMBLOCK, which changes the definition of > __init_memblock in include/linux/memblock.h. > > So allnoconfig would unselect CONFIG_ARCH_KEEP_MEMBLOCK, making > __init_memblock equivalent to __meminit triggering the above warning. > > arch/mips/Kconfig > 14: select ARCH_KEEP_MEMBLOCK if DEBUG_KERNEL > > so DEBUG_KERNEL is probably also disabled by allnoconfig. > > commit a8c0f1c634507 ("MIPS: Select ARCH_KEEP_MEMBLOCK if DEBUG_KERNEL > to enable sysfs memblock debug") > > probably should drop the `if DEBUG_KERNEL` part. Thanks. Could you please send a patch to mips ML? > > > > Guenter > > > > > --- > > > > > > init/Kconfig| 1 - > > > kernel/configs/tiny-base.config | 1 + > > > scripts/kconfig/Makefile| 3 ++- > > > 3 files changed, 3 insertions(+), 2 deletions(-) > > > create mode 100644 kernel/configs/tiny-base.config > > > > > > diff --git a/init/Kconfig b/init/Kconfig > > > index 46b87ad73f6a..beb8314fdf96 100644 > > > --- a/init/Kconfig > > > +++ b/init/Kconfig > > > @@ -1769,7 +1769,6 @@ config DEBUG_RSEQ > > > > > > config EMBEDDED > > > bool "Embedded system" > > > - option allnoconfig_y > > > select EXPERT > > > help > > > This option should be enabled if compiling the kernel for > > > diff --git a/kernel/configs/tiny-base.config > > > b/kernel/configs/tiny-base.config > > > new file mode 100644 > > > index ..2f0e6bf6db2c > > > --- /dev/null > > > +++ b/kernel/configs/tiny-base.config > > > @@ -0,0 +1 @@ > > > +CONFIG_EMBEDDED=y > > > diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile > > > index 7df3c0e4c52e..46f2465177f0 100644 > > > --- a/scripts/kconfig/Makefile > > > +++ b/scripts/kconfig/Makefile > > > @@ -102,7 +102,8 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ > > > $(srctree)/arch/$(SRCARCH)/c > > > > > > PHONY += tinyconfig > > > tinyconfig: > > > - $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config > > > + $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f > > > $(srctree)/Makefile allnoconfig > > > + $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config > > > > > > # CHECK: -o cache_dir= working? > > > PHONY += testconfig > > > -- > > > 2.27.0 > > > > > > > -- > Thanks, > ~Nick Desaulniers -- Best Regards Masahiro Yamada
Re: [PATCH 20/20] kbuild: scripts/install.sh: update documentation
On Wed, Apr 7, 2021 at 2:35 PM Greg Kroah-Hartman wrote: > > Add a proper SPDX line and document the install.sh file a lot better, > explaining exactly what it does, and update the copyright notice and > provide a better message about the lack of LILO being present or not as > really, no one should be using that anymore... > > Signed-off-by: Greg Kroah-Hartman > --- > scripts/install.sh | 33 ++--- > 1 file changed, 26 insertions(+), 7 deletions(-) > > diff --git a/scripts/install.sh b/scripts/install.sh > index 225b19bbbfa6..dd86fb9971e9 100644 > --- a/scripts/install.sh > +++ b/scripts/install.sh > @@ -1,14 +1,14 @@ > #!/bin/sh > -# > -# This file is subject to the terms and conditions of the GNU General Public > -# License. See the file "COPYING" in the main directory of this archive > -# for more details. > +# SPDX-License-Identifier: GPL-2.0 > # > # Copyright (C) 1995 by Linus Torvalds > +# Copyright (C) 2021 Greg Kroah-Hartman > # > # Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin > +# Adapted from code in arch/i386/boot/install.sh by Russell King Perhaps, this line can go to "10/20 kbuild: arm: use common install script" ? > +# Adapted from code in arch/arm/boot/install.sh by Stuart Menefy I think this line came from 18/20, but do we need to keep it? You removed arch/sh/boot/compressed/install.sh entirely. > # > -# "make install" script for i386 architecture > +# "make install" script for Linux to be used by all architectures. > # > # Arguments: > # $1 - kernel version > @@ -16,6 +16,26 @@ > # $3 - kernel map file > # $4 - default install path (blank if root directory) > # > +# Installs the built kernel image and map and symbol file in the specified > +# install location. If no install path is selected, the files will be placed > +# in the root directory. > +# > +# The name of the kernel image will be "vmlinux-VERSION" for uncompressed > +# kernels or "vmlinuz-VERSION' for compressed kernels. > +# > +# The kernel map file will be named "System.map-VERSION" > +# > +# Note, not all architectures seem to like putting the VERSION number in the > +# file name, see below in the script for a list of those that do not. For > +# those that do not the "-VERSION" will not be present in the file name. > +# > +# If there is currently a kernel image or kernel map file present with the > name > +# of the file to be copied to the location, it will be renamed to contain a > +# ".old" suffix. > +# > +# If ~/bin/${INSTALLKERNEL} or /sbin/${INSTALLKERNEL} is executable, > execution > +# will be passed to that program instead of this one to allow for distro or > +# system specific installation scripts to be used. > > verify () { > if [ ! -f "$1" ]; then > @@ -45,7 +65,6 @@ verify "$2" > verify "$3" > > # User may have a custom install script > - > if [ -x ~/bin/"${INSTALLKERNEL}" ]; then exec ~/bin/"${INSTALLKERNEL}" "$@"; > fi > if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; > fi > > @@ -111,7 +130,7 @@ case "${ARCH}" in > elif [ -x /etc/lilo/install ]; then > /etc/lilo/install > else > - echo "Cannot find LILO." > + echo "Cannot find LILO, ensure your bootloader knows > of the new kernel image." Since you soften the message, I guess this is not a warning message. I assume it is intentional to put it in stdout instead of stderr. > fi > ;; > esac > -- > 2.31.1 > -- Best Regards Masahiro Yamada
Re: [PATCH 16/20] kbuild: powerpc: use common install script
| powerpc | x86) > version="" > ;; > *) > @@ -93,6 +93,18 @@ case "${ARCH}" in > /usr/sbin/elilo > fi > ;; > + powerpc) > + # powerpc installation can list other boot targets after the > + # install path that should be copied to the correct location Perhaps, we can remove this if the ppc maintainers approve it ? > + path=$4 > + shift 4 > + while [ $# -ne 0 ]; do > + image_name=$(basename "$1") > + install "$1" "$path"/"$image_name" > + shift > + done; > + sync > + ;; > x86) > if [ -x /sbin/lilo ]; then > /sbin/lilo > -- > 2.31.1 > -- Best Regards Masahiro Yamada
Re: [PATCH 15/20] kbuild: parisc: use common install script
$3 $4/System.map-$1 > diff --git a/arch/parisc/install.sh b/arch/parisc/install.sh > deleted file mode 100644 > index 056d588befdd.. > --- a/arch/parisc/install.sh > +++ /dev/null > @@ -1,66 +0,0 @@ > -#!/bin/sh > -# > -# arch/parisc/install.sh, derived from arch/i386/boot/install.sh > -# > -# This file is subject to the terms and conditions of the GNU General Public > -# License. See the file "COPYING" in the main directory of this archive > -# for more details. > -# > -# Copyright (C) 1995 by Linus Torvalds > -# > -# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin > -# > -# "make install" script for i386 architecture > -# > -# Arguments: > -# $1 - kernel version > -# $2 - kernel image file > -# $3 - kernel map file > -# $4 - default install path (blank if root directory) > -# > - > -verify () { > - if [ ! -f "$1" ]; then > - echo "" 1>&2 > - echo " *** Missing file: $1" 1>&2 > - echo ' *** You need to run "make" before "make install".' 1>&2 > - echo "" 1>&2 > - exit 1 > - fi > -} > - > -# Make sure the files actually exist > - > -verify "$2" > -verify "$3" > - > -# User may have a custom install script > - > -if [ -n "${INSTALLKERNEL}" ]; then > - if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi > - if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi > -fi > - > -# Default install > - > -if [ "$(basename $2)" = "vmlinuz" ]; then > -# Compressed install > - echo "Installing compressed kernel" > - base=vmlinuz > -else > -# Normal install > - echo "Installing normal kernel" > - base=vmlinux > -fi > - > -if [ -f $4/$base-$1 ]; then > - mv $4/$base-$1 $4/$base-$1.old > -fi > -cat $2 > $4/$base-$1 > - > -# Install system map file > -if [ -f $4/System.map-$1 ]; then > - mv $4/System.map-$1 $4/System.map-$1.old > -fi > -cp $3 $4/System.map-$1 > - > diff --git a/scripts/install.sh b/scripts/install.sh > index 407ffa65062c..e0ffb95737d4 100644 > --- a/scripts/install.sh > +++ b/scripts/install.sh > @@ -53,6 +53,7 @@ base=$(basename "$2") > if [ "$base" = "bzImage" ] || > [ "$base" = "Image.gz" ] || > [ "$base" = "vmlinux.gz" ] || > + [ "$base" = "vmlinuz" ] || > [ "$base" = "zImage" ] ; then > # Compressed install > echo "Installing compressed kernel" > -- > 2.31.1 > -- Best Regards Masahiro Yamada
Re: [PATCH 13/20] kbuild: nds32: convert to use the common install scripts
On Wed, Apr 7, 2021 at 2:35 PM Greg Kroah-Hartman wrote: > > It seems that no one ever checked in the nds32 install script so trying > to build a nds32 kernel would never quite work properly as 'make > install' would fail to run. > > Fix that up by having nds32 call the common install.sh script. > > Cc: Nick Hu > Cc: Greentime Hu > Cc: Vincent Chen > Signed-off-by: Greg Kroah-Hartman > --- > arch/nds32/boot/Makefile | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/nds32/boot/Makefile b/arch/nds32/boot/Makefile > index c4cc0c2689f7..8371e02f6091 100644 > --- a/arch/nds32/boot/Makefile > +++ b/arch/nds32/boot/Makefile > @@ -8,9 +8,9 @@ $(obj)/Image.gz: $(obj)/Image FORCE > $(call if_changed,gzip) > > install: $(obj)/Image > - $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ > + $(CONFIG_SHELL) $(srctree)/scripts/install.sh $(KERNELRELEASE) \ > $(obj)/Image System.map "$(INSTALL_PATH)" > > zinstall: $(obj)/Image.gz > - $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ > + $(CONFIG_SHELL) $(srctree)/scripts/install.sh $(KERNELRELEASE) \ > $(obj)/Image.gz System.map "$(INSTALL_PATH)" > -- > 2.31.1 > Even with this patch, the 'install' target does not work. $ make ARCH=nds32 install make: *** No rule to make target 'install'. Stop. If you really want to fix it, you need to add something like follows: diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile index ccdca7142020..3486b78da9ca 100644 --- a/arch/nds32/Makefile +++ b/arch/nds32/Makefile @@ -53,6 +53,9 @@ core-y += $(boot)/dts/ Image: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ +PHONY += install zinstall +install zinstall: + $(Q)$(MAKE) $(build)=$(boot) $@ PHONY += vdso_install vdso_install: Anyway, I agree that nds32 installation targets are terribly broken. -- Best Regards Masahiro Yamada
Re: [PATCH 07/20] kbuild: scripts/install.sh: allow for the version number
On Wed, Apr 7, 2021 at 2:35 PM Greg Kroah-Hartman wrote: > > Some architectures put the version number by default at the end of the > files that are copied, so add support for this to be set by arch type. > > Odds are one day we should change this for x86, but let's not break > anyone's systems just yet. > > Signed-off-by: Greg Kroah-Hartman > --- > scripts/install.sh | 15 +-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/scripts/install.sh b/scripts/install.sh > index 72dc4c81013e..934619f81119 100644 > --- a/scripts/install.sh > +++ b/scripts/install.sh > @@ -60,8 +60,19 @@ else > base=vmlinux > fi > > -install "$2" "$4"/"$base" > -install "$3" "$4"/System.map > +# Some architectures name their files based on version number, and > +# others do not. Call out the ones that do not to make it obvious. > +case "${ARCH}" in > + x86) > + version="" > + ;; > + *) > + version="-${1}" > + ;; > +esac > + > +install "$2" "$4"/"$base""$version" Too many quotes are eye sore. install "$2" "$4/$base$version" looks cleaner in my opinion. Shell correctly understands the end of each variable because a slash or a dollar cannot be a part of a variable name. > +install "$3" "$4"/System.map"$version" > sync > > # Some architectures like to call specific bootloader "helper" programs: > -- > 2.31.1 > -- Best Regards Masahiro Yamada
Re: [PATCH 06/20] kbuild: scripts/install.sh: handle compressed/uncompressed kernel images
On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman wrote: > > For x86, the default kernel image is compressed, but other architectures > allowed both compressed and uncompressed kernel images to be built. Add > a test to detect which one this is, and either name the output file > "vmlinuz" for a compressed image, or "vmlinux" for an uncompressed > image. > > For x86 this change is a no-op, but other architectures depend on this. > > Signed-off-by: Greg Kroah-Hartman > --- > scripts/install.sh | 14 -- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/scripts/install.sh b/scripts/install.sh > index 2adcb993efa2..72dc4c81013e 100644 > --- a/scripts/install.sh > +++ b/scripts/install.sh > @@ -49,8 +49,18 @@ verify "$3" > if [ -x ~/bin/"${INSTALLKERNEL}" ]; then exec ~/bin/"${INSTALLKERNEL}" "$@"; > fi > if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; > fi > > -# Default install - same as make zlilo > -install "$2" "$4"/vmlinuz > +base=$(basename "$2") > +if [ "$base" = "bzImage" ]; then > + # Compressed install > + echo "Installing compressed kernel" After applying this series, I think the excessive "Installing ..." messages are a bit annoying. masahiro@grover:~/workspace/linux-kbuild$ make INSTALL_PATH=~/foo install sh ./scripts/install.sh 5.12.0-rc3+ arch/x86/boot/bzImage \ System.map "/home/masahiro/foo" Installing compressed kernel installing 'arch/x86/boot/bzImage' to '/home/masahiro/foo/vmlinuz' installing 'System.map' to '/home/masahiro/foo/System.map' Cannot find LILO, ensure your bootloader knows of the new kernel image. Since 03/20 added a new log in the 'install' function, can we drop this "Installing compressed kernel" message? > + base=vmlinuz > +else > + # Normal install > + echo "Installing normal kernel" Same here. This message tends to be wrong. For example, arch/arm/boot/uImage is gzip-compressed, but it says "Installing normal kernel". > + base=vmlinux > +fi > + > +install "$2" "$4"/"$base" > install "$3" "$4"/System.map > sync > > -- > 2.31.1 > -- Best Regards Masahiro Yamada
Re: [PATCH 04/20] kbuild: scripts/install.sh: call sync before calling the bootloader installer
On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman wrote: > > It's good to ensure that the files are written out before calling the > bootloader installer, as other architectures do, so call sync after > doing the copying of the kernel and system map files. I see 3 architectures that call 'sync' from install.sh masahiro@grover:~/ref/linux$ find . -name install.sh | xargs grep sync ./arch/nios2/boot/install.sh:sync ./arch/x86/boot/install.sh: sync ./arch/m68k/install.sh:sync As for nios2 and m68k, they do not call any bootloader-specific setups. > Signed-off-by: Greg Kroah-Hartman > --- > scripts/install.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/install.sh b/scripts/install.sh > index af36c0a82f01..92d0d2ade414 100644 > --- a/scripts/install.sh > +++ b/scripts/install.sh > @@ -52,12 +52,12 @@ if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec > /sbin/"${INSTALLKERNEL}" "$@"; fi > # Default install - same as make zlilo > install "$2" "$4"/vmlinuz > install "$3" "$4"/System.map > +sync > > if [ -x /sbin/lilo ]; then > /sbin/lilo > elif [ -x /etc/lilo/install ]; then > /etc/lilo/install > else > - sync > echo "Cannot find LILO." > fi > -- > 2.31.1 > Why do we need 'sync' before lilo invocation? If you want to ensure everything is flushed to a disk before this scripts exits, adding 'sync' at the end of the script makes more sense, in my opinion. if [ -x /sbin/lilo ]; then /sbin/lilo elif [ -x /etc/lilo/install ]; then /etc/lilo/install else echo "Cannot find LILO." fi sync This goes aligned with nios2 and m68k. -- Best Regards Masahiro Yamada
Re: [PATCH 03/20] kbuild: scripts/install.sh: provide a "install" function
On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman wrote: > > Instead of open-coding the "test for file, if present make a backup, > then copy the file to the new location" in multiple places, make a > single function, install(), to do all of this in one place. > > Note, this does change the default x86 kernel map file saved name from > "System.old" to "System.map.old". This brings it into unification with > the other architectures as to what they call their backup file for the > kernel map file. As this is a text file, and nothing parses this from a > backup file, there should not be any operational differences. > > Signed-off-by: Greg Kroah-Hartman > --- > scripts/install.sh | 26 +++--- > 1 file changed, 15 insertions(+), 11 deletions(-) > > diff --git a/scripts/install.sh b/scripts/install.sh > index c183d6ddd00c..af36c0a82f01 100644 > --- a/scripts/install.sh > +++ b/scripts/install.sh > @@ -27,6 +27,19 @@ verify () { > fi > } > > +install () { > + install_source=${1} > + install_target=${2} You double-quoted all variables in 02/20. For consistency and safety here, install_source="${1}" or install_source="$1" so that it will work even if $1 contains spaces. > + > + echo "installing '${install_source}' to '${install_target}'" > + > + # if the target is already present, move it to a .old filename > + if [ -f "${install_target}" ]; then > + mv "${install_target}" "${install_target}".old > + fi > + cat "${install_source}" > "${install_target}" > +} > + > # Make sure the files actually exist > verify "$2" > verify "$3" > @@ -37,17 +50,8 @@ if [ -x ~/bin/"${INSTALLKERNEL}" ]; then exec > ~/bin/"${INSTALLKERNEL}" "$@"; fi > if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; > fi > > # Default install - same as make zlilo > - > -if [ -f "$4"/vmlinuz ]; then > - mv "$4"/vmlinuz "$4"/vmlinuz.old > -fi > - > -if [ -f "$4"/System.map ]; then > - mv "$4"/System.map "$4"/System.old > -fi > - > -cat "$2" > "$4"/vmlinuz > -cp "$3" "$4"/System.map > +install "$2" "$4"/vmlinuz > +install "$3" "$4"/System.map > > if [ -x /sbin/lilo ]; then > /sbin/lilo > -- > 2.31.1 > -- Best Regards Masahiro Yamada
Re: [PATCH 02/20] kbuild: scripts/install.sh: properly quote all variables
On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman wrote: > > A few variables are quoted to handle spaces in directory names, but not > all of them. Properly quote everything so that the kernel build can > handle working correctly with directory names with spaces. > > This change makes the script "shellcheck" clean now. > > Signed-off-by: Greg Kroah-Hartman > --- > scripts/install.sh | 16 > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/scripts/install.sh b/scripts/install.sh > index d13ec1c38640..c183d6ddd00c 100644 > --- a/scripts/install.sh > +++ b/scripts/install.sh > @@ -33,21 +33,21 @@ verify "$3" > > # User may have a custom install script > > -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi > -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi > +if [ -x ~/bin/"${INSTALLKERNEL}" ]; then exec ~/bin/"${INSTALLKERNEL}" "$@"; > fi > +if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; > fi > > # Default install - same as make zlilo > > -if [ -f $4/vmlinuz ]; then > - mv $4/vmlinuz $4/vmlinuz.old > +if [ -f "$4"/vmlinuz ]; then > + mv "$4"/vmlinuz "$4"/vmlinuz.old > fi Another way of quoting is doing like this: if [ -f "$4/vmlinuz" ]; then mv "$4/vmlinuz" "$4/vmlinuz.old" fi shellcheck is still satisfied. Because you will add more quotes, quoting the whole of each parameter might be cleaner. See my comment in 07/20. > -if [ -f $4/System.map ]; then > - mv $4/System.map $4/System.old > +if [ -f "$4"/System.map ]; then > + mv "$4"/System.map "$4"/System.old > fi > > -cat $2 > $4/vmlinuz > -cp $3 $4/System.map > +cat "$2" > "$4"/vmlinuz > +cp "$3" "$4"/System.map > > if [ -x /sbin/lilo ]; then > /sbin/lilo > -- > 2.31.1 > -- Best Regards Masahiro Yamada
Re: [PATCH 00/20] kbuild: unify the install.sh script usage
On Wed, Apr 7, 2021 at 5:37 PM Greg Kroah-Hartman wrote: > > On Wed, Apr 07, 2021 at 09:14:36AM +0100, Russell King - ARM Linux admin > wrote: > > On Wed, Apr 07, 2021 at 10:07:29AM +0200, Greg Kroah-Hartman wrote: > > > On Wed, Apr 07, 2021 at 09:02:29AM +0100, Russell King - ARM Linux admin > > > wrote: > > > > On Wed, Apr 07, 2021 at 09:46:18AM +0200, Greg Kroah-Hartman wrote: > > > > > On Wed, Apr 07, 2021 at 09:18:11AM +0200, Geert Uytterhoeven wrote: > > > > > > Hi Greg, > > > > > > > > > > > > Thanks for your series! > > > > > > > > > > > > On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman > > > > > > wrote: > > > > > > > Almost every architecture has copied the "install.sh" script that > > > > > > > originally came with i386, and modified it in very tiny ways. > > > > > > > This > > > > > > > patch series unifies all of these scripts into one single script > > > > > > > to > > > > > > > allow people to understand how to correctly install a kernel, and > > > > > > > fixes > > > > > > > up some issues regarding trying to install a kernel to a path with > > > > > > > spaces in it. > > > > > > > > > > > > > > Note that not all architectures actually seem to have any type of > > > > > > > way to > > > > > > > install a kernel, they must rely on external scripts or tools > > > > > > > which > > > > > > > feels odd as everything should be included here in the main > > > > > > > repository. > > > > > > > I'll work on trying to figure out the missing architecture issues > > > > > > > afterward. > > > > > > > > > > > > I'll bite ;-) > > > > > > > > > > > > Does anyone actually use these scripts (outside of x86)? > > > > > > > > Yes, every time I build a kernel. My kernel build system involves > > > > typing "kbuild " and the kernel gets > > > > built in ../build/. When the build completes, it gets > > > > installed into ~/systems/, tar'd up, and copied to the > > > > destination machines, unpacked, installed as appropriate, and > > > > the machine rebooted if requested. > > > > > > > > The installation step is done via the ~/bin/installkernel script. > > > > > > So you don't use install.sh at all except to invoke your local script. > > > > It depends where the kernel is being built; it has been used in the > > past (one will notice that the arm32 version is not a direct copy of > > the x86 version, and never was - it was modified from day 1.) It's > > placement and naming of the files in /boot is still used today, which > > is slightly different from the x86 version. > > The placement depends on the caller to the script, so that's not an > issue here. The name for the output does differ from x86, but the > "common" script handles all of that (or it should, if not I messed up.) > > Attached below is the common scripts/install.sh that this patch series > produces at the end of it, if you want to check to see if I missed > anything for your arch. > > thanks, > > greg k-h Thanks for nice cleanups! I will give some nit-picking comments to individual patches. Overall, this series looks nice. -- Best Regards Masahiro Yamada
Re: [PATCH] Kbuild: Update config_data.gz only if KCONFIG_CONFIG materially changed
On Fri, Apr 2, 2021 at 7:45 AM Elliot Berman wrote: > > If you update the timestamp of KCONFIG_CONFIG without actually changing > anything, config_data.gz is re-generated and causes vmlinux to re-link. > When Link Time Optimization is enabled, unnecessary re-linking of > vmlinux is highly desirable since it adds several minutes to build time. > > Avoid touching config_data.gz by using filechk to compare the existing > config_data.gz and update only if it changed. > > The .config can be touched, for instance, by a build script which > installs the default defconfig and then applies a defconfig fragment on > top. > > For a simple example on my x86 machine, I modified x86 default defconfig to > set > CONFIG_IKCONFIG=y and run: > make -j50 defconfig tiny.config vmlinux > make -j50 defconfig tiny.config vmlinux > With this patch, vmlinux is not re-built as a result of config_data.gz > change. > > Signed-off-by: Elliot Berman > --- > kernel/Makefile | 2 +- > scripts/Makefile.lib | 2 ++ > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/Makefile b/kernel/Makefile > index 320f1f3..bd4e558 100644 > --- a/kernel/Makefile > +++ b/kernel/Makefile > @@ -140,7 +140,7 @@ $(obj)/configs.o: $(obj)/config_data.gz > > targets += config_data.gz > $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE > - $(call if_changed,gzip) > + $(call filechk,gzip) I do not think this is the right approach because gzip is executed every time, even if the time stamp is not changed. > > $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz > > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index a4fbaf8..81d3ec1 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -282,6 +282,8 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) > $(OBJCOPYFLAGS_$(@F)) $< $@ > quiet_cmd_gzip = GZIP$@ >cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@ > > +filechk_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > + > # DTC > # --- > DTC ?= $(objtree)/scripts/dtc/dtc > -- > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > a Linux Foundation Collaborative Project > -- Best Regards Masahiro Yamada
Re: allmodconfig not working with dummy-tools
On Thu, Apr 1, 2021 at 9:39 PM Michal Suchánek wrote: > > Hello, > > running allmodconfig with dumy-tools I get: > > which: no elfedit in (./scripts/dummy-tools) > scripts/dummy-tools/gcc: unknown assembler invoked > scripts/Kconfig.include:50: Sorry, this assembler is not supported. > scripts/kconfig/Makefile:77: recipe for target 'allmodconfig' failed > make[1]: *** [allmodconfig] Error 1 > Makefile:648: recipe for target 'allmodconfig' failed > make: *** [allmodconfig] Error 2 > > I use allmodconfig to enable any unknown options on new kernel version > automaticallly so it can be build-tested. > > Can this be fixed or is there some other way of automatically udating > the config after new options are added? > > Thanks > > Michal Thanks for the report. I squashed the following. Please wait for tomorrow's linux-next. diff --git a/scripts/dummy-tools/gcc b/scripts/dummy-tools/gcc index 39e65fee59bd..f6d543725f1e 100755 --- a/scripts/dummy-tools/gcc +++ b/scripts/dummy-tools/gcc @@ -67,6 +67,12 @@ if arg_contain -E "$@"; then fi fi +# To set CONFIG_AS_IS_GNU +if arg_contain -Wa,--version "$@"; then + echo "GNU assembler (scripts/dummy-tools) 2.50" + exit 0 +fi + if arg_contain -S "$@"; then # For scripts/gcc-x86-*-has-stack-protector.sh if arg_contain -fstack-protector "$@"; then -- Best Regards Masahiro Yamada
[PATCH 1/2] mips: replace deprecated EXTRA_CFLAGS with ccflags-y
As Documentation/kbuild/makefiles.rst says, EXTRA_CFLAGS is deprecated. Replace it with ccflags-y. Signed-off-by: Masahiro Yamada --- arch/mips/kvm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kvm/Makefile b/arch/mips/kvm/Makefile index 506c4ac0ba1c..7d42d624a7b9 100644 --- a/arch/mips/kvm/Makefile +++ b/arch/mips/kvm/Makefile @@ -4,7 +4,7 @@ common-objs-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o eventfd.o) -EXTRA_CFLAGS += -Ivirt/kvm -Iarch/mips/kvm +ccflags-y += -Ivirt/kvm -Iarch/mips/kvm common-objs-$(CONFIG_CPU_HAS_MSA) += msa.o -- 2.27.0
[PATCH 2/2] mips: clean up kvm Makefile
You can use kvm-y instead of kvm-objs to create the composite module. kvm-$(CONFIG_...) looks cleaner. Signed-off-by: Masahiro Yamada --- arch/mips/kvm/Makefile | 21 + 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/mips/kvm/Makefile b/arch/mips/kvm/Makefile index 7d42d624a7b9..6bc5da6faf0e 100644 --- a/arch/mips/kvm/Makefile +++ b/arch/mips/kvm/Makefile @@ -2,26 +2,23 @@ # Makefile for KVM support for MIPS # -common-objs-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o eventfd.o) - ccflags-y += -Ivirt/kvm -Iarch/mips/kvm -common-objs-$(CONFIG_CPU_HAS_MSA) += msa.o +kvm-y := $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o eventfd.o) +kvm-$(CONFIG_CPU_HAS_MSA) += msa.o -kvm-objs := $(common-objs-y) mips.o emulate.o entry.o \ +kvm-y +=mips.o emulate.o entry.o \ interrupt.o stats.o commpage.o \ fpu.o -kvm-objs += hypcall.o -kvm-objs += mmu.o -ifdef CONFIG_CPU_LOONGSON64 -kvm-objs += loongson_ipi.o -endif +kvm-y += hypcall.o +kvm-y += mmu.o +kvm-$(CONFIG_CPU_LOONGSON64) += loongson_ipi.o ifdef CONFIG_KVM_MIPS_VZ -kvm-objs += vz.o +kvm-y += vz.o else -kvm-objs += dyntrans.o -kvm-objs += trap_emul.o +kvm-y += dyntrans.o +kvm-y += trap_emul.o endif obj-$(CONFIG_KVM) += kvm.o obj-y += callback.o tlb.o -- 2.27.0
[PATCH 2/2] m68k: remove meaningless EXTRA_LDFLAGS
These two Makefiles contain only built-in objects (i.e. obj-y), which are collected by $(AR) into a thin-archive. EXTRA_LDFLAGS is meaningless because $(LD) is not used here. Signed-off-by: Masahiro Yamada --- arch/m68k/fpsp040/Makefile | 2 -- arch/m68k/ifpsp060/Makefile | 2 -- 2 files changed, 4 deletions(-) diff --git a/arch/m68k/fpsp040/Makefile b/arch/m68k/fpsp040/Makefile index 5537807457fb..834ae9471b88 100644 --- a/arch/m68k/fpsp040/Makefile +++ b/arch/m68k/fpsp040/Makefile @@ -10,5 +10,3 @@ obj-y:= bindec.o binstr.o decbin.o do_func.o gen_except.o get_op.o \ ssin.o ssinh.o stan.o stanh.o sto_res.o stwotox.o tbldo.o util.o \ x_bsun.o x_fline.o x_operr.o x_ovfl.o x_snan.o x_store.o \ x_unfl.o x_unimp.o x_unsupp.o bugfix.o skeleton.o - -EXTRA_LDFLAGS := -x diff --git a/arch/m68k/ifpsp060/Makefile b/arch/m68k/ifpsp060/Makefile index 43b435049452..56b530a96c2f 100644 --- a/arch/m68k/ifpsp060/Makefile +++ b/arch/m68k/ifpsp060/Makefile @@ -5,5 +5,3 @@ # for more details. obj-y := fskeleton.o iskeleton.o os.o - -EXTRA_LDFLAGS := -x -- 2.27.0
[PATCH 1/2] m68k: remove meaningless $(OS_OBJS)
'git grep OS_OBJS' hits only this line. $(OS_OBJS) is just empty. Signed-off-by: Masahiro Yamada --- arch/m68k/fpsp040/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/m68k/fpsp040/Makefile b/arch/m68k/fpsp040/Makefile index aab04d372ae7..5537807457fb 100644 --- a/arch/m68k/fpsp040/Makefile +++ b/arch/m68k/fpsp040/Makefile @@ -12,5 +12,3 @@ obj-y:= bindec.o binstr.o decbin.o do_func.o gen_except.o get_op.o \ x_unfl.o x_unimp.o x_unsupp.o bugfix.o skeleton.o EXTRA_LDFLAGS := -x - -$(OS_OBJS): fpsp.h -- 2.27.0
Re: [PATCH] docs: Remove make headers_check from checklist in translations
Hi Jon, On Tue, Mar 2, 2021 at 11:19 PM Masahiro Yamada wrote: > > Commit 1a63f9cce7b7 ("docs: Remove make headers_check from checklist") > fixed only the English version. > > Let's fix the translated variants too. > > Signed-off-by: Masahiro Yamada ping? > --- > > .../it_IT/process/submit-checklist.rst | 14 ++ > Documentation/translations/ja_JP/SubmitChecklist | 8 +++- > .../zh_CN/process/submit-checklist.rst | 14 ++ > 3 files changed, 15 insertions(+), 21 deletions(-) > > diff --git a/Documentation/translations/it_IT/process/submit-checklist.rst > b/Documentation/translations/it_IT/process/submit-checklist.rst > index 614fc17d9086..62ba471921b6 100644 > --- a/Documentation/translations/it_IT/process/submit-checklist.rst > +++ b/Documentation/translations/it_IT/process/submit-checklist.rst > @@ -95,31 +95,29 @@ sottomissione delle patch, in particolare > informazioni. Le patch che modificano le interfacce utente dovrebbero > essere inviate in copia anche a linux-...@vger.kernel.org. > > -20) Verifica che il kernel passi con successo ``make headers_check`` > - > -21) La patch è stata verificata con l'iniezione di fallimenti in slab e > +20) La patch è stata verificata con l'iniezione di fallimenti in slab e > nell'allocazione di pagine. Vedere ``Documentation/fault-injection/``. > > Se il nuovo codice è corposo, potrebbe essere opportuno aggiungere > l'iniezione di fallimenti specifici per il sottosistema. > > -22) Il nuovo codice è stato compilato con ``gcc -W`` (usate > +21) Il nuovo codice è stato compilato con ``gcc -W`` (usate > ``make KCFLAGS=-W``). Questo genererà molti avvisi, ma è ottimo > per scovare bachi come "warning: comparison between signed and > unsigned". > > -23) La patch è stata verificata dopo essere stata inclusa nella serie di > patch > +22) La patch è stata verificata dopo essere stata inclusa nella serie di > patch > -mm; questo al fine di assicurarsi che continui a funzionare assieme a > tutte le altre patch in coda e i vari cambiamenti nei sottosistemi VM, > VFS > e altri. > > -24) Tutte le barriere di sincronizzazione {per esempio, ``barrier()``, > +23) Tutte le barriere di sincronizzazione {per esempio, ``barrier()``, > ``rmb()``, ``wmb()``} devono essere accompagnate da un commento nei > sorgenti che ne spieghi la logica: cosa fanno e perché. > > -25) Se la patch aggiunge nuove chiamate ioctl, allora aggiornate > +24) Se la patch aggiunge nuove chiamate ioctl, allora aggiornate > ``Documentation/userspace-api/ioctl/ioctl-number.rst``. > > -26) Se il codice che avete modificato dipende o usa una qualsiasi > interfaccia o > +25) Se il codice che avete modificato dipende o usa una qualsiasi > interfaccia o > funzionalità del kernel che è associata a uno dei seguenti simboli > ``Kconfig``, allora verificate che il kernel compili con diverse > configurazioni dove i simboli sono disabilitati e/o ``=m`` (se c'è la > diff --git a/Documentation/translations/ja_JP/SubmitChecklist > b/Documentation/translations/ja_JP/SubmitChecklist > index b42220d3d46c..4429447b0965 100644 > --- a/Documentation/translations/ja_JP/SubmitChecklist > +++ b/Documentation/translations/ja_JP/SubmitChecklist > @@ -88,20 +88,18 @@ Linux カーネルパッチ投稿者向けチェックリスト > 18: 新しいuserspaceインタフェースを作成した場合には、Documentation/ABI/ に > Documentation/ABI/README を参考にして必ずドキュメントを追加してください。 > > -19: 'make headers_check'を実行して全く問題がないことを確認してください。 > - > -20: 少なくともslabアロケーションとpageアロケーションに失敗した場合の > +19: 少なくともslabアロケーションとpageアロケーションに失敗した場合の > 挙動について、fault-injectionを利用して確認してください。 > Documentation/fault-injection/ を参照してください。 > > 追加したコードがかなりの量であったならば、サブシステム特有の > fault-injectionを追加したほうが良いかもしれません。 > > -21: 新たに追加したコードは、`gcc -W'でコンパイルしてください。 > +20: 新たに追加したコードは、`gcc -W'でコンパイルしてください。 > このオプションは大量の不要なメッセージを出力しますが、 > "warning: comparison between signed and unsigned" のようなメッセージは、 > バグを見つけるのに役に立ちます。 > > -22: 投稿したパッチが -mm パッチセットにマージされた後、全ての既存のパッチや > +21: 投稿したパッチが -mm パッチセットにマージされた後、全ての既存のパッチや > VM, VFS およびその他のサブシステムに関する様々な変更と、現時点でも共存 > できることを確認するテストを行ってください。 > diff --git a/Documentation/translations/zh_CN/process/submit-checklist.rst > b/Documentation/translations/zh_CN/process/submit-checklist.rst > index 50386e0e42e7..a64858d321fc 100644 > --- a/Documentation/translations/zh_CN/process/submit-checklist.rst > +++ b/Documentation/translations/zh_CN/process/submit-checklist.rst > @@ -82,24 +82,22 @@ Linux内核补丁提交清单 > 请参阅 ``Documentation/ABI/README`` 。更改用户空间接口的补丁应该抄送 > linux-...@vger.kernel.org。 > > -20) 检查是否全部通过 ``
[PATCH 9/9] kbuild: remove CONFIG_MODULE_COMPRESS
CONFIG_MODULE_COMPRESS is only used to activate the choice for module compression algorithm. It will be simpler to make the choice visible all the time by adding CONFIG_MODULE_COMPRESS_NONE to allow the user to disable module compression. This is more consistent with the "Kernel compression mode" and "Built-in initramfs compression mode" choices. CONFIG_KERNEL_UNCOMPRESSED and CONFIG_INITRAMFS_COMPRESSION_NONE are available to choose to not compress the kernel, initrd, respectively. Signed-off-by: Masahiro Yamada --- init/Kconfig | 45 ++--- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 019c1874e609..3ca1ffd219c4 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2225,40 +2225,47 @@ config MODULE_SIG_HASH default "sha384" if MODULE_SIG_SHA384 default "sha512" if MODULE_SIG_SHA512 -config MODULE_COMPRESS - bool "Compress modules on installation" +choice + prompt "Module compression mode" help + This option allows you to choose the algorithm which will be used to + compress modules when 'make modules_install' is run. (or, you can + choose to not compress modules at all.) - Compresses kernel modules when 'make modules_install' is run; gzip or - xz depending on "Compression algorithm" below. + External modules will also be compressed in the same way during the + installation. - module-init-tools MAY support gzip, and kmod MAY support gzip and xz. + For modules inside an initrd or initramfs, it's more efficient to + compress the whole initrd or initramfs instead. - Out-of-tree kernel modules installed using Kbuild will also be - compressed upon installation. + This is fully compatible with signed modules. - Note: for modules inside an initrd or initramfs, it's more efficient - to compress the whole initrd or initramfs instead. + Please note that the tool used to load modules needs to support the + corresponding algorithm. module-init-tools MAY support gzip, and kmod + MAY support gzip and xz. - Note: This is fully compatible with signed modules. + Your build system needs to provide the appropriate compression tool + to compress the modules. - If in doubt, say N. + If in doubt, select 'None'. -choice - prompt "Compression algorithm" - depends on MODULE_COMPRESS - default MODULE_COMPRESS_GZIP +config MODULE_COMPRESS_NONE + bool "None" help - This determines which sort of compression will be used during - 'make modules_install'. - - GZIP (default) and XZ are supported. + Do not compress modules. The installed modules are suffixed + with .ko. config MODULE_COMPRESS_GZIP bool "GZIP" + help + Compress modules with XZ. The installed modules are suffixed + with .ko.gz. config MODULE_COMPRESS_XZ bool "XZ" + help + Compress modules with XZ. The installed modules are suffixed + with .ko.xz. endchoice -- 2.27.0
[PATCH 5/9] kbuild: rename extmod-prefix to extmod_prefix
This seems to be useful in sub-make as well. As a preparation of exporting it, rename extmod-prefix to extmod_prefix because exported variables cannot contain hyphens. Signed-off-by: Masahiro Yamada --- Makefile | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index b5ff4753eba8..e3c2bd1b6f42 100644 --- a/Makefile +++ b/Makefile @@ -919,7 +919,7 @@ endif ifdef CONFIG_LTO_CLANG ifdef CONFIG_LTO_CLANG_THIN CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit -KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache +KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod_prefix).thinlto-cache else CC_FLAGS_LTO := -flto endif @@ -1141,9 +1141,9 @@ endif # CONFIG_BPF PHONY += prepare0 -extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) -export MODORDER := $(extmod-prefix)modules.order -export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps +extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) +export MODORDER := $(extmod_prefix)modules.order +export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps ifeq ($(KBUILD_EXTMOD),) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ @@ -1742,7 +1742,7 @@ build-dirs := $(KBUILD_EXTMOD) $(MODORDER): descend @: -compile_commands.json: $(extmod-prefix)compile_commands.json +compile_commands.json: $(extmod_prefix)compile_commands.json PHONY += compile_commands.json clean-dirs := $(KBUILD_EXTMOD) @@ -1832,12 +1832,12 @@ endif PHONY += single_modpost single_modpost: $(single-no-ko) modules_prepare - $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER) + $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost KBUILD_MODULES := 1 -export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko)) +export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod_prefix), $(single-no-ko)) # trim unrelated directories build-dirs := $(foreach d, $(build-dirs), \ @@ -1906,12 +1906,12 @@ nsdeps: modules quiet_cmd_gen_compile_commands = GEN $@ cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs)) -$(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ +$(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \ $(if $(CONFIG_MODULES), $(MODORDER)) FORCE $(call if_changed,gen_compile_commands) -targets += $(extmod-prefix)compile_commands.json +targets += $(extmod_prefix)compile_commands.json PHONY += clang-tidy clang-analyzer @@ -1919,7 +1919,7 @@ ifdef CONFIG_CC_IS_CLANG quiet_cmd_clang_tools = CHECK $< cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $< -clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json +clang-tidy clang-analyzer: $(extmod_prefix)compile_commands.json $(call cmd,clang_tools) else clang-tidy clang-analyzer: -- 2.27.0
[PATCH 8/9] kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst
scripts/Makefile.modsign is a subset of scripts/Makefile.modinst, and duplicates the code. Let's merge them. By the way, you do not need to run 'make modules_sign' explicitly because modules are signed as a part of 'make modules_install' when CONFIG_MODULE_SIG_ALL=y. If CONFIG_MODULE_SIG_ALL=n, mod_sign_cmd is set to 'true', so 'make modules_sign' is not functional. In my understanding, the reason of still keeping this is to handle corner cases like commit 64178cb62c32 ("builddeb: fix stripped module signatures if CONFIG_DEBUG_INFO and CONFIG_MODULE_SIG_ALL are set"). Signed-off-by: Masahiro Yamada --- Makefile | 36 scripts/Makefile.modinst | 9 + scripts/Makefile.modsign | 29 - 3 files changed, 29 insertions(+), 45 deletions(-) delete mode 100644 scripts/Makefile.modsign diff --git a/Makefile b/Makefile index f96ae09d111b..b14483742a67 100644 --- a/Makefile +++ b/Makefile @@ -1063,15 +1063,6 @@ export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE) MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) export MODLIB -ifdef CONFIG_MODULE_SIG_ALL -$(eval $(call config_filename,MODULE_SIG_KEY)) - -mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 -else -mod_sign_cmd = true -endif -export mod_sign_cmd - HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) has_libelf = $(call try-run,\ @@ -1439,7 +1430,26 @@ PHONY += modules_prepare modules_prepare: prepare $(Q)$(MAKE) $(build)=scripts scripts/module.lds -modules_install: __modinst_pre +export modules_sign_only := + +ifeq ($(CONFIG_MODULE_SIG),y) +PHONY += modules_sign +modules_sign: modules_install + @: + +# modules_sign is a subset of modules_install. +# 'make modules_install modules_sign' is equivalent to 'make modules_install'. +ifeq ($(filter modules_install,$(MAKECMDGOALS)),) +modules_sign_only := y +endif +endif + +modinst_pre := +ifneq ($(filter modules_install,$(MAKECMDGOALS)),) +modinst_pre := __modinst_pre +endif + +modules_install: $(modinst_pre) PHONY += __modinst_pre __modinst_pre: @rm -rf $(MODLIB)/kernel @@ -1454,12 +1464,6 @@ __modinst_pre: @cp -f modules.builtin $(MODLIB)/ @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ -ifeq ($(CONFIG_MODULE_SIG), y) -PHONY += modules_sign -modules_sign: - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign -endif - endif # CONFIG_MODULES ### diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 943806b0abb5..156eb8239abc 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -76,11 +76,20 @@ quiet_cmd_sign := cmd_sign := : endif +ifeq ($(modules_sign_only),) + $(dst)/%.ko: $(extmod_prefix)%.ko FORCE $(call cmd,install) $(call cmd,strip) $(call cmd,sign) +else + +$(dst)/%.ko: FORCE + $(call cmd,sign) + +endif + # # Compression # diff --git a/scripts/Makefile.modsign b/scripts/Makefile.modsign deleted file mode 100644 index ddf9b5ca77d7.. --- a/scripts/Makefile.modsign +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# == -# Signing modules -# == - -PHONY := __modsign -__modsign: - -include $(srctree)/scripts/Kbuild.include - -modules := $(sort $(shell cat modules.order)) - -PHONY += $(modules) -__modsign: $(modules) - @: - -quiet_cmd_sign_ko = SIGN [M] $(2)/$(notdir $@) -cmd_sign_ko = $(mod_sign_cmd) $(2)/$(notdir $@) - -# Modules built outside the kernel source tree go into extra by default -INSTALL_MOD_DIR ?= extra -ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) - -modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) - -$(modules): - $(call cmd,sign_ko,$(MODLIB)/$(modinst_dir)) - -.PHONY: $(PHONY) -- 2.27.0
[PATCH 3/9] kbuild: show the target directory for depmod log
It is clearer to show the directory which depmod will work on. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 99a2bd51c02d..a6f73335757d 100644 --- a/Makefile +++ b/Makefile @@ -1778,7 +1778,7 @@ ifdef CONFIG_MODULES modules: $(MODORDER) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost -quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) +quiet_cmd_depmod = DEPMOD $(MODLIB) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ $(KERNELRELEASE) -- 2.27.0
[PATCH 6/9] kbuild: refactor scripts/Makefile.modinst
scripts/Makefile.modinst is ugly and weird in multiple ways; it specifies real files $(modules) as phony, makes directory manipulation needlessly too complicated. Clean up the Makefile code, and show the full path of installed modules in the log. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/Makefile.modinst | 42 +++- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index e3c2bd1b6f42..88e5c15e1186 100644 --- a/Makefile +++ b/Makefile @@ -1141,7 +1141,7 @@ endif # CONFIG_BPF PHONY += prepare0 -extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) +export extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) export MODORDER := $(extmod_prefix)modules.order export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index ad1981233d0b..3b2d0380504d 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -8,28 +8,34 @@ __modinst: include $(srctree)/scripts/Kbuild.include -modules := $(sort $(shell cat $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order)) +modules := $(sort $(shell cat $(MODORDER))) + +ifeq ($(KBUILD_EXTMOD),) +subdir := kernel +else +INSTALL_MOD_DIR ?= extra +subdir := $(INSTALL_MOD_DIR) +endif + +dst := $(MODLIB)/$(subdir) + +modules := $(patsubst $(extmod_prefix)%, $(dst)/%, $(modules)) -PHONY += $(modules) __modinst: $(modules) @: # Don't stop modules_install if we can't sign external modules. -quiet_cmd_modules_install = INSTALL $@ - cmd_modules_install = \ -mkdir -p $(2) ; \ -cp $@ $(2) ; \ -$(mod_strip_cmd) $(2)/$(notdir $@) ; \ -$(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \ -$(mod_compress_cmd) $(2)/$(notdir $@) - -# Modules built outside the kernel source tree go into extra by default -INSTALL_MOD_DIR ?= extra -ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) - -modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) - -$(modules): - $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) +quiet_cmd_install = INSTALL $@ + cmd_install = \ +mkdir -p $(dir $@); cp $< $@; \ +$(mod_strip_cmd) $@; \ +$(mod_sign_cmd) $@ $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \ +$(mod_compress_cmd) $@ + +$(modules): $(dst)/%: $(extmod_prefix)% FORCE + $(call cmd,install) + +PHONY += FORCE +FORCE: .PHONY: $(PHONY) -- 2.27.0
[PATCH 4/9] kbuild: check module name conflict for external modules as well
If there are multiple modules with the same name in the same external module tree, there is ambiguity about which one will be loaded, and very likely something odd is happening. Signed-off-by: Masahiro Yamada --- Makefile | 10 +- scripts/modules-check.sh | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a6f73335757d..b5ff4753eba8 100644 --- a/Makefile +++ b/Makefile @@ -1459,10 +1459,6 @@ endif PHONY += modules modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare -PHONY += modules_check -modules_check: modules.order - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< - cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@ modules.order: $(subdir-modorder) FORCE @@ -1775,9 +1771,13 @@ PHONY += modules modules_install ifdef CONFIG_MODULES -modules: $(MODORDER) +modules: modules_check $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost +PHONY += modules_check +modules_check: $(MODORDER) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< + quiet_cmd_depmod = DEPMOD $(MODLIB) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ $(KERNELRELEASE) diff --git a/scripts/modules-check.sh b/scripts/modules-check.sh index 43de226071ae..e06327722263 100755 --- a/scripts/modules-check.sh +++ b/scripts/modules-check.sh @@ -13,10 +13,10 @@ exit_code=0 # Check uniqueness of module names check_same_name_modules() { - for m in $(sed 's:.*/::' $1 | sort | uniq -d) + for m in $(sed 's:.*/::' "$1" | sort | uniq -d) do echo "error: the following would cause module name conflict:" >&2 - sed -n "/\/$m/s:^: :p" modules.order >&2 + sed -n "/\/$m/s:^: :p" "$1" >&2 exit_code=1 done } -- 2.27.0
[PATCH 2/9] kbuild: unify modules(_install) for in-tree and external modules
If you attempt to build/install modules ('make modules(_install)' with CONFIG_MODULES disabled, you will get a clear error message, but nothing for external module builds. Factor out the modules and modules_install rules into the common part, then you will get the same error message when you try to build external modules with CONFIG_MODULES=n. Signed-off-by: Masahiro Yamada --- Makefile | 85 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index 0e06db5ed9d8..99a2bd51c02d 100644 --- a/Makefile +++ b/Makefile @@ -1458,7 +1458,6 @@ endif PHONY += modules modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost PHONY += modules_check modules_check: modules.order @@ -1476,12 +1475,9 @@ PHONY += modules_prepare modules_prepare: prepare $(Q)$(MAKE) $(build)=scripts scripts/module.lds -# Target to install modules -PHONY += modules_install -modules_install: _modinst_ _modinst_post - -PHONY += _modinst_ -_modinst_: +modules_install: __modinst_pre +PHONY += __modinst_pre +__modinst_pre: @rm -rf $(MODLIB)/kernel @rm -f $(MODLIB)/source @mkdir -p $(MODLIB)/kernel @@ -1493,14 +1489,6 @@ _modinst_: @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order @cp -f modules.builtin $(MODLIB)/ @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst - -# This depmod is only for convenience to give the initial -# boot a modules.dep even before / is mounted read-write. However the -# boot script depmod is the master version. -PHONY += _modinst_post -_modinst_post: _modinst_ - $(call cmd,depmod) ifeq ($(CONFIG_MODULE_SIG), y) PHONY += modules_sign @@ -1508,20 +1496,6 @@ modules_sign: $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign endif -else # CONFIG_MODULES - -# Modules not configured -# --- - -PHONY += modules modules_install -modules modules_install: - @echo >&2 - @echo >&2 "The present kernel configuration has modules disabled." - @echo >&2 "Type 'make config' and enable loadable module support." - @echo >&2 "Then build a kernel with module support enabled." - @echo >&2 - @exit 1 - endif # CONFIG_MODULES ### @@ -1769,24 +1743,9 @@ KBUILD_BUILTIN := KBUILD_MODULES := 1 build-dirs := $(KBUILD_EXTMOD) -PHONY += modules -modules: $(MODORDER) - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost - $(MODORDER): descend @: -PHONY += modules_install -modules_install: _emodinst_ _emodinst_post - -PHONY += _emodinst_ -_emodinst_: - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst - -PHONY += _emodinst_post -_emodinst_post: _emodinst_ - $(call cmd,depmod) - compile_commands.json: $(extmod-prefix)compile_commands.json PHONY += compile_commands.json @@ -1809,6 +1768,39 @@ PHONY += prepare modules_prepare endif # KBUILD_EXTMOD +# --- +# Modules + +PHONY += modules modules_install + +ifdef CONFIG_MODULES + +modules: $(MODORDER) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ + $(KERNELRELEASE) + +modules_install: + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst + $(call cmd,depmod) + +else # CONFIG_MODULES + +# Modules not configured +# --- + +modules modules_install: + @echo >&2 '***' + @echo >&2 '*** The present kernel configuration has modules disabled.' + @echo >&2 '*** To use the module feature, please run "make menuconfig" etc.' + @echo >&2 '*** to enable CONFIG_MODULES.' + @echo >&2 '***' + @exit 1 + +endif # CONFIG_MODULES + # Single targets # --- # To build individual files in subdirectories, you can do like this: @@ -1997,11 +1989,6 @@ tools/%: FORCE quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) cmd_rmfiles = rm -rf $(rm-files) -# Run depmod only if we have System.map and depmod is executable -quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) - cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) - # read saved command lines for existing targets existing-targets := $(wildcard $(sort $(targets))) -- 2.27.0
[PATCH 7/9] kbuild: move module strip/compression code into scripts/Makefile.modinst
Both mod_strip_cmd and mod_compress_cmd are only used in scripts/Makefile.modinst, hence there is no good reason to define them in the top Makefile. Move the relevant code to scripts/Makefile.modinst. Also, show separate log messages for each of install, strip, sign, and compress. Signed-off-by: Masahiro Yamada --- Makefile | 32 - scripts/Makefile.modinst | 76 +++- 2 files changed, 68 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 88e5c15e1186..f96ae09d111b 100644 --- a/Makefile +++ b/Makefile @@ -1063,38 +1063,6 @@ export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE) MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) export MODLIB -# -# INSTALL_MOD_STRIP, if defined, will cause modules to be -# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then -# the default option --strip-debug will be used. Otherwise, -# INSTALL_MOD_STRIP value will be used as the options to the strip command. - -ifdef INSTALL_MOD_STRIP -ifeq ($(INSTALL_MOD_STRIP),1) -mod_strip_cmd = $(STRIP) --strip-debug -else -mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) -endif # INSTALL_MOD_STRIP=1 -else -mod_strip_cmd = true -endif # INSTALL_MOD_STRIP -export mod_strip_cmd - -# CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed -# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP -# or CONFIG_MODULE_COMPRESS_XZ. - -mod_compress_cmd = true -ifdef CONFIG_MODULE_COMPRESS - ifdef CONFIG_MODULE_COMPRESS_GZIP -mod_compress_cmd = $(KGZIP) -n -f - endif # CONFIG_MODULE_COMPRESS_GZIP - ifdef CONFIG_MODULE_COMPRESS_XZ -mod_compress_cmd = $(XZ) --lzma2=dict=2MiB -f - endif # CONFIG_MODULE_COMPRESS_XZ -endif # CONFIG_MODULE_COMPRESS -export mod_compress_cmd - ifdef CONFIG_MODULE_SIG_ALL $(eval $(call config_filename,MODULE_SIG_KEY)) diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 3b2d0380504d..943806b0abb5 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -6,6 +6,7 @@ PHONY := __modinst __modinst: +include include/config/auto.conf include $(srctree)/scripts/Kbuild.include modules := $(sort $(shell cat $(MODORDER))) @@ -19,21 +20,80 @@ endif dst := $(MODLIB)/$(subdir) -modules := $(patsubst $(extmod_prefix)%, $(dst)/%, $(modules)) +suffix-y := +suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz +suffix-$(CONFIG_MODULE_COMPRESS_XZ):= .xz + +modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules)) __modinst: $(modules) @: -# Don't stop modules_install if we can't sign external modules. +quiet_cmd_none = + cmd_none = : + +# +# Installation +# quiet_cmd_install = INSTALL $@ - cmd_install = \ -mkdir -p $(dir $@); cp $< $@; \ -$(mod_strip_cmd) $@; \ -$(mod_sign_cmd) $@ $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \ -$(mod_compress_cmd) $@ + cmd_install = mkdir -p $(dir $@); cp $< $@ + +# Strip +# +# INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they +# are installed. If INSTALL_MOD_STRIP is '1', then the default option +# --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used +# as the options to the strip command. +ifdef INSTALL_MOD_STRIP + +ifeq ($(INSTALL_MOD_STRIP),1) +strip-option := --strip-debug +else +strip-option := $(INSTALL_MOD_STRIP) +endif + +quiet_cmd_strip = STRIP $@ + cmd_strip = $(STRIP) $(strip-option) $@ + +else -$(modules): $(dst)/%: $(extmod_prefix)% FORCE +quiet_cmd_strip = + cmd_strip = : + +endif + +# +# Signing +# Don't stop modules_install even if we can't sign external modules. +# +ifeq ($(CONFIG_MODULE_SIG_ALL),y) +quiet_cmd_sign = SIGN$@ +$(eval $(call config_filename,MODULE_SIG_KEY)) + cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 $@ \ + $(if $(KBUILD_EXTMOD),|| true) +else +quiet_cmd_sign := + cmd_sign := : +endif + +$(dst)/%.ko: $(extmod_prefix)%.ko FORCE $(call cmd,install) + $(call cmd,strip) + $(call cmd,sign) + +# +# Compression +# +quiet_cmd_gzip = GZIP$@ + cmd_gzip = $(KGZIP) -n -f $< +quiet_cmd_xz = XZ $@ + cmd_xz = $(XZ) --lzma2=dict=2MiB -f $< + +$(dst)/%.ko.gz: $(dst)/%.ko FORCE + $(call cmd,gzip) + +$(dst)/%.ko.xz: $(dst)/%.ko FORCE + $(call cmd,xz) PHONY += FORCE FORCE: -- 2.27.0
[PATCH 1/9] kbuild: remove unneeded mkdir for external modules_install
scripts/Makefile.modinst creates directories as needed. Signed-off-by: Masahiro Yamada --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index ed8bd815e8a3..0e06db5ed9d8 100644 --- a/Makefile +++ b/Makefile @@ -1779,10 +1779,8 @@ $(MODORDER): descend PHONY += modules_install modules_install: _emodinst_ _emodinst_post -install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) PHONY += _emodinst_ _emodinst_: - $(Q)mkdir -p $(MODLIB)/$(install-dir) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst PHONY += _emodinst_post -- 2.27.0
Kbuild fix for today's linux-next
Hi Stephen, I noticed Clang build breakage for kbuild/for-next. Please apply the following, or use the old branch for kbuild tree. Thanks. diff --git a/scripts/as-version.sh b/scripts/as-version.sh index 11f1e7b24bff..8b9410e329df 100755 --- a/scripts/as-version.sh +++ b/scripts/as-version.sh @@ -45,7 +45,7 @@ orig_args="$@" # Get the first line of the --version output. IFS=' ' -set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler /dev/null -o /dev/null 2>&1) +set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler /dev/null -o /dev/null 2>/dev/null) # Split the line on spaces. IFS=' ' -- Best Regards Masahiro Yamada
Re: [PATCH] arm64: move --fix-cortex-a53-843419 linker test to Kconfig
On Fri, Mar 26, 2021 at 11:36 PM Catalin Marinas wrote: > > Hi Masahiro, > > On Wed, Mar 24, 2021 at 04:11:28PM +0900, Masahiro Yamada wrote: > > $(call ld-option, --fix-cortex-a53-843419) in arch/arm64/Makefile is > > evaluated every time even for Make targets that do not need the linker, > > such as "make ARCH=arm64 install". > > > > Recently, the Kbuild tree queued up a patch to avoid needless > > compiler/linker flag evaluation. I beleive it is a good improvement > > itself, but causing a false-positive warning for arm64 installation > > in linux-next. (Thanks to Nathan for the report) > > > > Kconfig can test the linker capability just once, and store it in the > > .config file. The build and installation steps that follow do not need > > to test the liniker over again. > > > > Reported-by: Nathan Chancellor > > Signed-off-by: Masahiro Yamada > > --- > > > > I was not sure what the preferred CONFIG option name is. > > Please suggest a one if you have a better idea. > > > > > > arch/arm64/Kconfig | 3 +++ > > arch/arm64/Makefile | 2 +- > > 2 files changed, 4 insertions(+), 1 deletion(-) > > Would you like this patch to go in via the arm64 tree or you will queue > it via the kbuild tree? I applied this to linux-kbuild with Will's Ack. Thanks. -- Best Regards Masahiro Yamada
[PATCH 1/3] kbuild: generate Module.symvers only when vmlinux exists
The external module build shows the following warning if Module.symvers is missing in the kernel tree. WARNING: Symbol version dump "Module.symvers" is missing. Modules may not have dependencies or modversions. I think this is an important heads-up because the resulting modules may not work as expected. This happens when you did not build the entire kernel tree, for example, you might have prepared the minimal setups for external modules by 'make defconfig && make modules_preapre'. A problem is that 'make modules' creates Module.symvers even without vmlinux. In this case, that warning is suppressed since Module.symvers already exists in spite of its incomplete content. The incomplete (i.e. invalid) Module.symvers should not be created. This commit changes the second pass of modpost to dump symbols into modules-only.symvers. The final Module.symvers is created by concatenating vmlinux.symvers and modules-only.symvers if both exist. Module.symvers is supposed to contain all the symbols from both vmlinux and modules. It might be a bit confusing, and I am not quite sure if it is an official interface, but presumably it is difficult to rename it because some projects (e.g. kmod) parse it. Signed-off-by: Masahiro Yamada --- .gitignore | 1 + Documentation/dontdiff | 1 + Makefile | 2 +- scripts/Makefile.modpost | 15 ++- scripts/mod/modpost.c| 15 +-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 3adea59847ce..df8d3146a43f 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,7 @@ modules.order /tags /TAGS /linux +/modules-only.symvers /vmlinux /vmlinux.32 /vmlinux.map diff --git a/Documentation/dontdiff b/Documentation/dontdiff index ac42ad8d430d..910b30a2a7d9 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -178,6 +178,7 @@ mktables mktree mkutf8data modpost +modules-only.symvers modules.builtin modules.builtin.modinfo modules.nsdeps diff --git a/Makefile b/Makefile index 2b161f5a5a66..ed8bd815e8a3 100644 --- a/Makefile +++ b/Makefile @@ -1532,7 +1532,7 @@ endif # CONFIG_MODULES # make distclean Remove editor backup files, patch leftover files and the like # Directories & files removed with 'make clean' -CLEAN_FILES += include/ksym vmlinux.symvers \ +CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ modules.builtin modules.builtin.modinfo modules.nsdeps \ compile_commands.json .thinlto-cache diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index df57e259fac3..3f5b09a09aef 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -68,7 +68,20 @@ else ifeq ($(KBUILD_EXTMOD),) input-symdump := vmlinux.symvers -output-symdump := Module.symvers +output-symdump := modules-only.symvers + +quiet_cmd_cat = GEN $@ + cmd_cat = cat $(real-prereqs) > $@ + +ifneq ($(wildcard vmlinux.symvers),) + +__modpost: Module.symvers +Module.symvers: vmlinux.symvers modules-only.symvers FORCE + $(call if_changed,cat) + +targets += Module.symvers + +endif else diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 24725e50c7b4..10c3fba26f03 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2423,19 +2423,6 @@ static void read_dump(const char *fname) fatal("parse error in symbol dump file\n"); } -/* For normal builds always dump all symbols. - * For external modules only dump symbols - * that are not read from kernel Module.symvers. - **/ -static int dump_sym(struct symbol *sym) -{ - if (!external_module) - return 1; - if (sym->module->from_dump) - return 0; - return 1; -} - static void write_dump(const char *fname) { struct buffer buf = { }; @@ -2446,7 +2433,7 @@ static void write_dump(const char *fname) for (n = 0; n < SYMBOL_HASH_SIZE ; n++) { symbol = symbolhash[n]; while (symbol) { - if (dump_sym(symbol)) { + if (!symbol->module->from_dump) { namespace = symbol->namespace; buf_printf(, "0x%08x\t%s\t%s\t%s\t%s\n", symbol->crc, symbol->name, -- 2.27.0
[PATCH 2/3] kbuild: do not set -w for vmlinux.o modpost
The -w option is meaningless for the first pass of modpost (vmlinux.o). We know there are unresolved symbols in vmlinux.o, hence we skip check_exports() and other checks when mod->is_vmlinux is set. See the following part in the for-loop. if (mod->is_vmlinux || mod->from_dump) continue; Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 3f5b09a09aef..b3e08fb1fd56 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -32,8 +32,6 @@ # Step 4 is solely used to allow module versioning in external modules, # where the CRC of each module is retrieved from the Module.symvers file. -# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined -# symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely useful to speed up test compiles @@ -50,7 +48,6 @@ MODPOST = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ - $(if $(KBUILD_MODPOST_WARN),-w) \ -o $@ ifdef MODPOST_VMLINUX @@ -136,6 +133,11 @@ endif modules := $(sort $(shell cat $(MODORDER))) +# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined symbols +ifneq ($(KBUILD_MODPOST_WARN),) +MODPOST += -w +endif + # Read out modules.order to pass in modpost. # Otherwise, allmodconfig would fail with "Argument list too long". quiet_cmd_modpost = MODPOST $@ -- 2.27.0
[PATCH 3/3] kbuild: fix false-positive modpost warning when all symbols are trimmed
Nathan reports that the mips defconfig emits the following warning: WARNING: modpost: Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped. This false-positive happens under the following combination: - CONFIG_TRIM_UNUSED_KSYMS=y - CONFIG_MODULES=y - No CONFIG option is set to 'm' Commit a0590473c5e6 ("nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default") turned the last 'm' into 'y' for the mips defconfig, and uncovered this issue. In this case, the module feature itself is enabled, but we have no module. As a result, CONFIG_TRIM_UNUSED_KSYMS drops all the instances of EXPORT_SYMBOL. Then, modpost wrongly assumes vmlinux is missing because vmlinux.symvers is empty. (Or, you can create a module that does not use any symbol of vmlinux). The current behavior is to entirely suppress the unresolved symbol warnings when vmlinux is missing just because there are too many. I found the origin of this code in the historical git tree. [1] If this is a matter of noisiness, I think modpost can display the first 10 warnings, and the number of suppressed warnings at the end. You will get a bit noisier logs when you run 'make modules' without vmlinux, but such warnings are better to show because you never know the resulting modules are actually loadable or not. This commit changes as follows: - If any of input *.symver files is missing, pass -w option to let the module build keep going with warnings instead of errors. - If there are too many (10+) unresolved symbol warnings, show only the first 10, and also the number of suppressed warnings. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=1cc0e0529569bf6a94f6d49770aa6d4b599d2c46 Reported-by: Nathan Chancellor Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 7 +-- scripts/mod/modpost.c| 25 - 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index b3e08fb1fd56..c383ba33d837 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -98,9 +98,11 @@ output-symdump := $(KBUILD_EXTMOD)/Module.symvers endif +existing-input-symdump := $(wildcard $(input-symdump)) + # modpost options for modules (both in-kernel and external) MODPOST += \ - $(addprefix -i ,$(wildcard $(input-symdump))) \ + $(addprefix -i ,$(existing-input-symdump)) \ $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) @@ -114,6 +116,7 @@ VPATH := $(input-symdump): @echo >&2 'WARNING: Symbol version dump "$@" is missing.' @echo >&2 ' Modules may not have dependencies or modversions.' + @echo >&2 ' You may get many unresolved symbol warnings.' ifdef CONFIG_LTO_CLANG # With CONFIG_LTO_CLANG, .o files might be LLVM bitcode, so we need to run @@ -134,7 +137,7 @@ endif modules := $(sort $(shell cat $(MODORDER))) # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined symbols -ifneq ($(KBUILD_MODPOST_WARN),) +ifneq ($(KBUILD_MODPOST_WARN)$(filter-out $(existing-input-symdump), $(input-symdump)),) MODPOST += -w endif diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 10c3fba26f03..7c6bec78fa34 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -23,8 +23,6 @@ /* Are we using CONFIG_MODVERSIONS? */ static int modversions = 0; -/* Warn about undefined symbols? (do so if we have vmlinux) */ -static int have_vmlinux = 0; /* Is CONFIG_MODULE_SRCVERSION_ALL set? */ static int all_versions = 0; /* If we are modposting external module set to 1 */ @@ -41,6 +39,13 @@ static int allow_missing_ns_imports; static bool error_occurred; +/* + * Cut off the warnings when there are too many. This typically occurs when + * vmlinux is missing. ('make modules' without building vmlinux.) + */ +#define MAX_UNRESOLVED_REPORTS 10 +static unsigned int nr_unresolved; + enum export { export_plain, export_gpl, @@ -177,9 +182,6 @@ static struct module *new_module(const char *modname) mod->next = modules; modules = mod; - if (mod->is_vmlinux) - have_vmlinux = 1; - return mod; } @@ -2141,7 +2143,7 @@ static void check_exports(struct module *mod) const char *basename; exp = find_symbol(s->name); if (!exp || exp->module == mod) { - if (have_vmlinux && !s->weak) + if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS) modpost_log(warn_unresolved ? LOG_WARN : LOG_ERROR, "\"%s\" [%s.ko] undefined!\n", s->name, mod->name); @@ -2545,13 +254
Re: [PATCH v2] kbuild: enforce -Werror=unused-result
On Fri, Mar 26, 2021 at 2:07 AM Olaf Hering wrote: > > Am Fri, 26 Mar 2021 01:55:41 +0900 > schrieb Masahiro Yamada : > > > What about drivers/net/ethernet/lantiq_etop.c ? > > Nothing complained about it. I guess there is a build-bot for alpha, but none > for mips. > > > I got a lot of complaints in the last trial. > > Why did you get complains, instead of me? > > > What is the "must" in "__must_check" worth if it is not enforced... > > Olaf In hindsight, __must_check may not be a perfect name. Miguel suggested __nodiscard to get along with: https://en.cppreference.com/w/c/language/attributes/nodiscard It is not enforcing. Just a compiler warning. -- Best Regards Masahiro Yamada
Re: [PATCH v2] kbuild: enforce -Werror=unused-result
On Thu, Mar 25, 2021 at 8:16 PM Olaf Hering wrote: > > Am Fri, 19 Mar 2021 15:32:31 +0100 > schrieb Olaf Hering : > > > It is a hard error if a return value is ignored. > > The automated builds found only a single error, in load_em86(). What about drivers/net/ethernet/lantiq_etop.c ? > Let me know if there are other reasons why the patch was rejected. > > Olaf I got a lot of complaints in the last trial. It is easy to send a patch like this, but difficult to make sure that I will not break any CI tests. Over time, I started to believe keeping this as a warning is OK. The same problem happens when you add a new __must_check annotation. You end up with fixing all the call-sites in advance. -- Best Regards Masahiro Yamada
[tip: x86/cleanups] x86/syscalls: Fix -Wmissing-prototypes warnings from COND_SYSCALL()
The following commit has been merged into the x86/cleanups branch of tip: Commit-ID: 7dfe553affd0d003c7535b7ba60d09193471ea9d Gitweb: https://git.kernel.org/tip/7dfe553affd0d003c7535b7ba60d09193471ea9d Author:Masahiro Yamada AuthorDate:Mon, 01 Mar 2021 22:15:26 +09:00 Committer: Ingo Molnar CommitterDate: Thu, 25 Mar 2021 16:20:41 +01:00 x86/syscalls: Fix -Wmissing-prototypes warnings from COND_SYSCALL() Building kernel/sys_ni.c with W=1 emits tons of -Wmissing-prototypes warnings: $ make W=1 kernel/sys_ni.o [ snip ] CC kernel/sys_ni.o ./arch/x86/include/asm/syscall_wrapper.h:83:14: warning: no previous prototype for '__ia32_sys_io_setup' [-Wmissing-prototypes] ... The problem is in __COND_SYSCALL(), the __SYS_STUB0() and __SYS_STUBx() macros defined a few lines above already have forward declarations. Let's do likewise for __COND_SYSCALL() to fix the warnings. Signed-off-by: Masahiro Yamada Signed-off-by: Ingo Molnar Tested-by: Mickaël Salaün Link: https://lore.kernel.org/r/20210301131533.64671-2-masahi...@kernel.org --- arch/x86/include/asm/syscall_wrapper.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h index a84333a..80c08c7 100644 --- a/arch/x86/include/asm/syscall_wrapper.h +++ b/arch/x86/include/asm/syscall_wrapper.h @@ -80,6 +80,7 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs *regs); } #define __COND_SYSCALL(abi, name) \ + __weak long __##abi##_##name(const struct pt_regs *__unused); \ __weak long __##abi##_##name(const struct pt_regs *__unused)\ { \ return sys_ni_syscall();\
Re: [PATCH 1/7] x86/syscalls: fix -Wmissing-prototypes warnings from COND_SYSCALL()
On Thu, Mar 25, 2021 at 8:48 PM Mickaël Salaün wrote: > > Hi Masahiro, > > What is the status of this patch? Could you please push it to -next? > This would avoid emails from lkp: > https://lore.kernel.org/linux-security-module/202103191423.jl0jvzfl-...@intel.com/ Hmm, I also want to know the answer. This is the *third* time that I resent this patch to the x86 ML. This is a territory of the x86 subsystem because it is only touching arch/x86/include/asm/syscall_wrapper.h It is preferred to get this in via the x86 tree. x86 Maintainers, could you take a look please? > Thanks, > Mickaël > > On 01/03/2021 14:15, Masahiro Yamada wrote: > > Building kernel/sys_ni.c with W=1 emits tons of -Wmissing-prototypes > > warnings. > > > > $ make W=1 kernel/sys_ni.o > > [ snip ] > > CC kernel/sys_ni.o > > In file included from kernel/sys_ni.c:10: > > ./arch/x86/include/asm/syscall_wrapper.h:83:14: warning: no previous > > prototype for '__x64_sys_io_setup' [-Wmissing-prototypes] > >83 | __weak long __##abi##_##name(const struct pt_regs *__unused) \ > > | ^~ > > ./arch/x86/include/asm/syscall_wrapper.h:100:2: note: in expansion of macro > > '__COND_SYSCALL' > > 100 | __COND_SYSCALL(x64, sys_##name) > > | ^~ > > ./arch/x86/include/asm/syscall_wrapper.h:256:2: note: in expansion of macro > > '__X64_COND_SYSCALL' > > 256 | __X64_COND_SYSCALL(name) \ > > | ^~ > > kernel/sys_ni.c:39:1: note: in expansion of macro 'COND_SYSCALL' > >39 | COND_SYSCALL(io_setup); > > | ^~~~ > > ./arch/x86/include/asm/syscall_wrapper.h:83:14: warning: no previous > > prototype for '__ia32_sys_io_setup' [-Wmissing-prototypes] > >83 | __weak long __##abi##_##name(const struct pt_regs *__unused) \ > > | ^~ > > ./arch/x86/include/asm/syscall_wrapper.h:120:2: note: in expansion of macro > > '__COND_SYSCALL' > > 120 | __COND_SYSCALL(ia32, sys_##name) > > | ^~ > > ./arch/x86/include/asm/syscall_wrapper.h:257:2: note: in expansion of macro > > '__IA32_COND_SYSCALL' > > 257 | __IA32_COND_SYSCALL(name) > > | ^~~ > > kernel/sys_ni.c:39:1: note: in expansion of macro 'COND_SYSCALL' > >39 | COND_SYSCALL(io_setup); > > | ^~~~ > > ... > > > > __SYS_STUB0() and __SYS_STUBx() defined a few lines above have forward > > declarations. Let's do likewise for __COND_SYSCALL() to fix the > > warnings. > > > > Signed-off-by: Masahiro Yamada > > Tested-by: Mickaël Salaün > > --- > > > > arch/x86/include/asm/syscall_wrapper.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/arch/x86/include/asm/syscall_wrapper.h > > b/arch/x86/include/asm/syscall_wrapper.h > > index a84333adeef2..80c08c7d5e72 100644 > > --- a/arch/x86/include/asm/syscall_wrapper.h > > +++ b/arch/x86/include/asm/syscall_wrapper.h > > @@ -80,6 +80,7 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs > > *regs); > > } > > > > #define __COND_SYSCALL(abi, name)\ > > + __weak long __##abi##_##name(const struct pt_regs *__unused); \ > > __weak long __##abi##_##name(const struct pt_regs *__unused)\ > > { \ > > return sys_ni_syscall();\ > > -- Best Regards Masahiro Yamada
Re: [PATCH 2/2] streamline_config.pl: Add softtabstop=4 for vim users
On Thu, Mar 25, 2021 at 10:50 PM Steven Rostedt wrote: > > On Thu, 25 Mar 2021 15:20:13 +0900 > Masahiro Yamada wrote: > > > > > The root cause of inconsistency is that > > you mix up space-indentation and tab-indentation. > > I do not know if it is a standard way either. > > This is the default way emacs has edited perl files for as long as I can > remember (back to 1996). It became my standard of editing perl files just > because of that. For everything else, I use tabs. > > > > > For example, scripts/checkpatch.pl uses only tabs, > > which I think is more robust. > > Probably because Joe probably uses vim ;-) > > > > > Unfortunately, we do not have standardized indentation style > > for scripts yet, and people can go in any direction. > > > > The editorconfig patch [1] proposed to always use 4-space > > indentation for *.pl files. > > (that is, do not replace 8 spaces with a tab). > > I rather have all tabs, or the tab and spaces. I find 8 spaces to be a > waste of memory and disk space. > > > > > I do not know whether the kernel will adopt .editorconfig or not, > > but if that patch is applied, your 1/2 will be a step backward. > > My 1/2 only made it consistent, as the original code had the tab/spaces mix > and just a few lines that were modified by others broke it by adding all > spaces. > > > > > My got-feeling is, you will never reach the goal as long as > > you adopt a strange indentation style, which is obscure > > to other contributors. > > I'm guessing this is not strange to other perl developers who uses emacs. > > > > > Not all people use vim. > > I don't use it either. I was trying to make vim match emacs. Of course for > those that use something else, it wont help. I'm curious, what's your main > editor that you use? I use emacs. I have some setups in my ~/.emacs although I am not an expert of emacs lisp. (defalias 'perl-mode 'cperl-mode) (add-hook 'cperl-mode-hook (lambda() (setq cperl-indent-level 8) (setq cperl-tab-always-indent t) (setq tab-width 8) (setq indent-tabs-mode t) )) Then, emacs can understand that my preference is tab-indentation with 8 character width. > > > I am not interested in 1/2 either. > > OK. > > > > > If you insist on this patch set, apply it to your tree > > and send a pull request by yourself. > > I'm fine with that. > > > > > > > [1]: https://lore.kernel.org/lkml/20200703073143.423557-1-da...@kdrag0n.dev/ > > Thanks for the link. > > -- Steve -- Best Regards Masahiro Yamada
Re: [PATCH v2] editorconfig: Add automatic editor configuration file
On Wed, Mar 24, 2021 at 8:01 PM Rasmus Villemoes wrote: > > On 03/07/2020 14.29, Jonathan Corbet wrote: > > [doing a bit of necromancy here] > > > On Fri, 3 Jul 2020 00:31:43 -0700 > > Danny Lin wrote: > > > >> EditorConfig is a standard for defining basic editor configuration in > >> projects. There is support available for 47 code editors as of writing, > >> including both built-in and extension support. Many notable projects > >> have adopted the standard already, including zsh, htop, and qemu. > >> > >> While this isn't a full-fledged C code style specifier, it does set some > >> basic ground rules that make it more convenient for contributors to use > >> any editor of their choice and not have to worry about indentation, line > >> endings, encoding, final newlines, etc. This should make it > >> significantly easier to conform to the kernel's general code style when > >> used in combination with clang-format. > >> > >> For more information, check the official EditorConfig website: > >> https://editorconfig.org/ > >> > >> Signed-off-by: Danny Lin > >> --- > > > > So I worry a bit that not everybody will welcome the addition of a dotfile > > that may be magically interpreted by their editor. > > I would suppose that one would have to enable editorconfig support > explicitly in one's editor, so this would have no effect for people that > haven't done so (though there are almost certainly exceptions). > > > I also worry that the > > file itself could become a battleground for people wanting to argue about > > style issues. > > I don't think so, not any more than the coding-style document is, and > that seems to be pretty solid (but as doc maintainer, you'd know better). > > > > > Perhaps I worry a bit too much...? > > As someone who regularly needs to submit patches to random upstream > projects to fix bugs or implement minor features, I for one would really > welcome more widespread use of editorconfig. While I mostly work with > the linux kernel (and other projects using the same C style), so my > default C style setting is "linux", even for the kernel this would be > helpful to me when I poke around in none-C files (shell scripts, for > example). > > Rasmus Just from my curiosity, I just checked the behavior when the language is specified by a shebang line. For example, scripts/diffconfig has no file suffix, but specifies '#!/usr/bin/env python3' at the very top line. This is sensible for tools that interface to users. Users have no interest in which language is used internally. As far as I test this patch on Emacs, it follows the rule of [*] rather than [*.{pl,pm,py,tc,json,tc}]. This is the correct behavior but not what we want in general. I do not mean I am negative to this patch. Rather, I very much like this patch, but I just wondered how this case could be handled. I found this: https://github.com/editorconfig/editorconfig/issues/404 I did not read through it, though. -- Best Regards Masahiro Yamada
Re: [PATCH 2/2] streamline_config.pl: Add softtabstop=4 for vim users
On Wed, Mar 24, 2021 at 10:54 PM Steven Rostedt wrote: > > On Wed, 24 Mar 2021 15:01:13 +0900 > Masahiro Yamada wrote: > > > On Tue, Mar 23, 2021 at 6:40 AM Steven Rostedt wrote: > > > > > > From: "Steven Rostedt (VMware)" > > > > > > The tab stop for Perl files is by default (at least in emacs) to be 4 > > > spaces, where a tab is used for all 8 spaces. Add a local variable comment > > > to make vim do the same by default, and this will help keep the file > > > consistent in the future when others edit it via vim and not emacs. > > > > > > Signed-off-by: Steven Rostedt (VMware) > > > > > > Documentation/process/coding-style.rst says "do not do this". > > I take that file more as for C code, never took it for Perl ;-) > > > > > Rather, I want to remove this ugly stuff entirely. > > https://lore.kernel.org/patchwork/patch/1401439/ > > And I totally agree it does not belong in C code. > > > > > Adding .editorconfig seems OK to me, but > > Doing this in individual files in an editor-specific > > manner is a horror. > > Is there a way to add this for the directory? > > The reason I added this was because of the different ways that vim and > emacs handle Perl files. I just added this to ktest.pl because I want it to > be consistent. > > The emacs way to edit Perl is to have 4 space indentation, but use tabs for > every 8 spaces. That is, you have: > > (4 spaces) > (1 tab) > (1 tab and 4 spaces) > (2 tabs) > (2 tabs and 4 spaces) > > etc. The root cause of inconsistency is that you mix up space-indentation and tab-indentation. I do not know if it is a standard way either. For example, scripts/checkpatch.pl uses only tabs, which I think is more robust. Unfortunately, we do not have standardized indentation style for scripts yet, and people can go in any direction. The editorconfig patch [1] proposed to always use 4-space indentation for *.pl files. (that is, do not replace 8 spaces with a tab). I do not know whether the kernel will adopt .editorconfig or not, but if that patch is applied, your 1/2 will be a step backward. My got-feeling is, you will never reach the goal as long as you adopt a strange indentation style, which is obscure to other contributors. Not all people use vim. I am not interested in 1/2 either. If you insist on this patch set, apply it to your tree and send a pull request by yourself. [1]: https://lore.kernel.org/lkml/20200703073143.423557-1-da...@kdrag0n.dev/ > > What I found from people who edit Perl code is that they will either just > indent 8 (with tabs), or just use all spaces. Then you have: > > (1 tab and 4 spaces) > (followed by 12 spaces!) > > The way to make vim work the same is to add the softtabspace=4 command. > > We can not add this, but then have to either police the patches coming in, > or constantly clean up the code after the fact. > > This code doesn't change much, so I'm fine with that. But for ktest.pl, I'm > adding it. > > -- Steve -- Best Regards Masahiro Yamada
Re: [PATCH 01/13] kconfig: split randconfig setup code into set_randconfig_seed()
On Sun, Mar 14, 2021 at 4:48 AM Masahiro Yamada wrote: > > This code is too big to be placed in the switch statement. > > Move the code into a new helper function. I slightly refactor the code > without changing the behavior. > > Signed-off-by: Masahiro Yamada > --- All applied to linux-kbuild/kconfig. > scripts/kconfig/conf.c | 54 -- > 1 file changed, 31 insertions(+), 23 deletions(-) > > diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c > index 957d2a0832f7..063c9e7a34c1 100644 > --- a/scripts/kconfig/conf.c > +++ b/scripts/kconfig/conf.c > @@ -82,6 +82,36 @@ static void xfgets(char *str, int size, FILE *in) > printf("%s", str); > } > > +static void set_randconfig_seed(void) > +{ > + unsigned int seed; > + char *env; > + bool seed_set = false; > + > + env = getenv("KCONFIG_SEED"); > + if (env && *env) { > + char *endp; > + > + seed = strtol(env, , 0); > + if (*endp == '\0') > + seed_set = true; > + } > + > + if (!seed_set) { > + struct timeval now; > + > + /* > +* Use microseconds derived seed, compensate for systems > where it may > +* be zero. > +*/ > + gettimeofday(, NULL); > + seed = (now.tv_sec + 1) * (now.tv_usec + 1); > + } > + > + printf("KCONFIG_SEED=0x%X\n", seed); > + srand(seed); > +} > + > static int conf_askvalue(struct symbol *sym, const char *def) > { > if (!sym_has_value(sym)) > @@ -515,30 +545,8 @@ int main(int ac, char **av) > defconfig_file = optarg; > break; > case randconfig: > - { > - struct timeval now; > - unsigned int seed; > - char *seed_env; > - > - /* > -* Use microseconds derived seed, > -* compensate for systems where it may be zero > -*/ > - gettimeofday(, NULL); > - seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec > + 1)); > - > - seed_env = getenv("KCONFIG_SEED"); > - if( seed_env && *seed_env ) { > - char *endp; > - int tmp = (int)strtol(seed_env, , 0); > - if (*endp == '\0') { > - seed = tmp; > - } > - } > - fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed ); > - srand(seed); > + set_randconfig_seed(); > break; > - } > case oldaskconfig: > case oldconfig: > case allnoconfig: > -- > 2.27.0 > -- Best Regards Masahiro Yamada
Re: [PATCH] kconfig: use true and false for bool variable
On Mon, Mar 15, 2021 at 3:55 PM Yang Li wrote: > > fixed the following coccicheck: > ./scripts/kconfig/confdata.c:36:9-10: WARNING: return of 0/1 in function > 'is_dir' with return type bool > > Reported-by: Abaci Robot > Signed-off-by: Yang Li > --- Applied. Thanks. > scripts/kconfig/confdata.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c > index 2568dbe..b65b8c3 100644 > --- a/scripts/kconfig/confdata.c > +++ b/scripts/kconfig/confdata.c > @@ -33,7 +33,7 @@ static bool is_dir(const char *path) > struct stat st; > > if (stat(path, )) > - return 0; > + return false; > > return S_ISDIR(st.st_mode); > } > -- > 1.8.3.1 > -- Best Regards Masahiro Yamada
[PATCH] arm64: move --fix-cortex-a53-843419 linker test to Kconfig
$(call ld-option, --fix-cortex-a53-843419) in arch/arm64/Makefile is evaluated every time even for Make targets that do not need the linker, such as "make ARCH=arm64 install". Recently, the Kbuild tree queued up a patch to avoid needless compiler/linker flag evaluation. I beleive it is a good improvement itself, but causing a false-positive warning for arm64 installation in linux-next. (Thanks to Nathan for the report) Kconfig can test the linker capability just once, and store it in the .config file. The build and installation steps that follow do not need to test the liniker over again. Reported-by: Nathan Chancellor Signed-off-by: Masahiro Yamada --- I was not sure what the preferred CONFIG option name is. Please suggest a one if you have a better idea. arch/arm64/Kconfig | 3 +++ arch/arm64/Makefile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 5656e7aacd69..4a33428de8ac 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -521,6 +521,9 @@ config ARM64_ERRATUM_843419 If unsure, say Y. +config ARM64_LD_HAS_FIX_ERRATUM_843419 + def_bool $(ld-option,--fix-cortex-a53-843419) + config ARM64_ERRATUM_1024718 bool "Cortex-A55: 1024718: Update of DBM/AP bits without break before make might result in incorrect update" default y diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 5b84aec31ed3..7ef44478560d 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -21,7 +21,7 @@ LDFLAGS_vmlinux += -shared -Bsymbolic -z notext \ endif ifeq ($(CONFIG_ARM64_ERRATUM_843419),y) - ifeq ($(call ld-option, --fix-cortex-a53-843419),) + ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y) $(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum) else LDFLAGS_vmlinux+= --fix-cortex-a53-843419 -- 2.27.0
Re: [PATCH] scripts: Fix incremental build header re-generation
On Thu, Mar 18, 2021 at 11:55 AM Jeevan Shriram wrote: > > > On 3/1/2021 7:36 PM, Masahiro Yamada wrote: > > On Mon, Mar 1, 2021 at 11:23 PM Jeevan Shriram > > wrote: > >> compile.h and autoconf.h are ignored when checking headers sha as they > >> are always re-generated for every kernel compilation. However, > >> these two headers are packaged into kheaders tar. During incremental > >> compilation of kernel, kheaders tar file is always generated and > >> re-packaged > >> irrespective of the changes in headers. > > > > I do not see this problem. > > Could you describe the steps to reproduce it, please? > > > Without making any changes in the kernel or it's headers, re-compile the > kernel. i.e.,incremental kernel build without any changes. > I have added following log in gen_kheaders.sh script for confirming the hash > differences. Of course they are different because you are comparing the hashes of two different files. > > diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh > index b7425a0..ee542a0 100755 > --- a/kernel/gen_kheaders.sh > +++ b/kernel/gen_kheaders.sh > @@ -40,6 +40,10 @@ obj_files_md5="$(find $dir_list -name "*.h" > | > # Any changes to this script will also cause a rebuild of the archive. > this_file_md5="$(ls -l $sfile | md5sum | cut -d ' ' -f1)" > if [ -f $tarfile ]; then tarfile_md5="$(md5sum $tarfile | cut -d ' ' -f1)"; > fi > + > +echo "Old Tar file $tarfile_md5" This is the hash of kernel/kheaders_data.tar.xz > +echo "New Tar file hash $this_file_md5" This is the hash of kernel/gen_kheaders.sh > + > if [ -f kernel/kheaders.md5 ] && > [ "$(cat kernel/kheaders.md5|head -1)" == "$src_files_md5" ] && > [ "$(cat kernel/kheaders.md5|head -2|tail -1)" == "$obj_files_md5" ] > && > > log output : > 89306 19:29:02.109961 CHK kernel/kheaders_data.tar.xz > 89307 19:29:02.109971 Old Tar file 2aa6990e4183c31a862951f4bcac037e > 89308 19:29:02.109982 New Tar file hash ecf84e700c7cacfe8b35a0905859582d I do not understand what your claim is. CHK kernel/kheaders_data.tar.xz is displayed when it is checking the hash in order to determine if the tarball should be updated. GEN kernel/kheaders_data.tar.xz is displayed when the tarball is really updated. [Incremental build with no change] masahiro@oscar:~/ref/linux$ make -j24 DESCEND objtool CALLscripts/atomic/check-atomics.sh CALLscripts/checksyscalls.sh CHK include/generated/compile.h CHK kernel/kheaders_data.tar.xz Kernel: arch/x86/boot/bzImage is ready (#2) [Touch one header and rebuild] masahiro@oscar:~/ref/linux$ touch include/uapi/drm/exynos_drm.h masahiro@oscar:~/ref/linux$ make -j24 DESCEND objtool CALLscripts/atomic/check-atomics.sh CALLscripts/checksyscalls.sh CHK include/generated/compile.h CHK kernel/kheaders_data.tar.xz GEN kernel/kheaders_data.tar.xz CC kernel/kheaders.o AR kernel/built-in.a GEN .version CHK include/generated/compile.h UPD include/generated/compile.h CC init/version.o AR init/built-in.a LD vmlinux.o MODPOST vmlinux.symvers MODINFO modules.builtin.modinfo GEN modules.builtin LD .tmp_vmlinux.kallsyms1 KSYMS .tmp_vmlinux.kallsyms1.S AS .tmp_vmlinux.kallsyms1.S LD .tmp_vmlinux.kallsyms2 KSYMS .tmp_vmlinux.kallsyms2.S AS .tmp_vmlinux.kallsyms2.S LD vmlinux SORTTAB vmlinux SYSMAP System.map MODPOST Module.symvers CC arch/x86/boot/version.o VOFFSET arch/x86/boot/compressed/../voffset.h OBJCOPY arch/x86/boot/compressed/vmlinux.bin RELOCS arch/x86/boot/compressed/vmlinux.relocs CC arch/x86/boot/compressed/kaslr.o CC arch/x86/boot/compressed/misc.o GZIParch/x86/boot/compressed/vmlinux.bin.gz MKPIGGY arch/x86/boot/compressed/piggy.S AS arch/x86/boot/compressed/piggy.o LD arch/x86/boot/compressed/vmlinux ZOFFSET arch/x86/boot/zoffset.h OBJCOPY arch/x86/boot/vmlinux.bin AS arch/x86/boot/header.o LD arch/x86/boot/setup.elf OBJCOPY arch/x86/boot/setup.bin BUILD arch/x86/boot/bzImage Kernel: arch/x86/boot/bzImage is ready (#3) > >> Change-Id: I7a64faebb81df44c32230b0fea1d6df09d7ce66f > >> Signed-off-by: Jeevan Shriram > >> --- > >> kernel/gen_kheaders.sh | 3 +-- > >> 1 file changed, 1 insertion(+), 2 deletions(-) > >> > >> diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh > >> index c1510f0..5499f72 100755 > >> --- a/kernel/gen_kheaders.sh > >> +++ b/ke
Re: [PATCH 2/2] streamline_config.pl: Add softtabstop=4 for vim users
On Tue, Mar 23, 2021 at 6:40 AM Steven Rostedt wrote: > > From: "Steven Rostedt (VMware)" > > The tab stop for Perl files is by default (at least in emacs) to be 4 > spaces, where a tab is used for all 8 spaces. Add a local variable comment > to make vim do the same by default, and this will help keep the file > consistent in the future when others edit it via vim and not emacs. > > Signed-off-by: Steven Rostedt (VMware) Documentation/process/coding-style.rst says "do not do this". Rather, I want to remove this ugly stuff entirely. https://lore.kernel.org/patchwork/patch/1401439/ Adding .editorconfig seems OK to me, but Doing this in individual files in an editor-specific manner is a horror. > --- > scripts/kconfig/streamline_config.pl | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/scripts/kconfig/streamline_config.pl > b/scripts/kconfig/streamline_config.pl > index 059061b6daef..044829972ba5 100755 > --- a/scripts/kconfig/streamline_config.pl > +++ b/scripts/kconfig/streamline_config.pl > @@ -702,3 +702,5 @@ foreach my $module (keys(%modules)) { > print STDERR "\n"; > } > } > + > +# vim: softtabstop=4 > -- > 2.30.1 > > -- Best Regards Masahiro Yamada
[PATCH] treewide: remove editor modelines and cruft
The section "19) Editor modelines and other cruft" in Documentation/process/coding-style.rst clearly says, "Do not include any of these in source files." I recently receive a patch to explicitly add a new one. Let's do treewide cleanups, otherwise some people follow the existing code and attempt to upstream their favoriate editor setups. It is even nicer if scripts/checkpatch.pl can check it. If we like to impose coding style in an editor-independent manner, I think editorconfig (patch [1]) is a saner solution. [1] https://lore.kernel.org/lkml/20200703073143.423557-1-da...@kdrag0n.dev/ Signed-off-by: Masahiro Yamada --- You might wonder if I worked on this huge patch manually or generated it by a tool. I wrote a Python script to generate this patch, but not from a scratch. I contributed a similar tool to U-Boot some years ago. (https://github.com/u-boot/u-boot/commit/8ba1f5de4571566be12efaffdad404a506b978e3) I reused and modified it. For completeness, this is the code I wrote (ugly since this is not intended for upstream) #!/usr/bin/env python3 import copy import os import re import sys pattern_local_variables = re.compile(r'Local (V|v)ariables') pattern_end = re.compile(r'End:') pattern_blank = re.compile(r'^\s*$')# empty line pattern_comment_begin = re.compile(r'^(\s*)/\*') pattern_comment_end = re.compile(r'\*/$') pattern_comment_null = re.compile(r' \*$') pattern_dash = re.compile(r'---') def extend_matched_lines(lines, matched, pre_patterns, post_patterns, extend_pre, extend_post): extended_matched = [] j = matched[0] for i in matched: if i == 0 or i < j: continue j = i while j in matched: j += 1 if j >= len(lines): break for p in pre_patterns: if p.search(lines[i - 1]): break else: # not matched continue for p in post_patterns: if p.search(lines[j]): break else: # not matched continue if extend_pre: extended_matched.append(i - 1) if extend_post: extended_matched.append(j) matched += extended_matched matched.sort() def cleanup_one_file(filepath, patterns): #print(filepath) with open(filepath) as f: lines = f.readlines() matched = [] for i, line in enumerate(lines): if i - 1 in matched and lines[i - 1][-2:] == '\\\n': matched.append(i) continue for pattern in patterns: if pattern.search(line): #print("hit {}".format(line), end='') m = pattern_comment_begin.match(line) if m and not pattern_comment_end.search(line): #print("replace {}".format(line), end='') lines[i] = m.group(1) + '/*\n' if i + 1 < len(lines) and pattern_comment_end.search(lines[i + 1]): matched.append(i) matched.append(i + 1) else: matched.append(i) break if not matched: return while True: old_matched = copy.copy(matched) extend_matched_lines(lines, matched, [pattern_local_variables], [pattern_end], True, True) extend_matched_lines(lines, matched, [pattern_comment_begin], [pattern_comment_end], True, True) extend_matched_lines(lines, matched, [pattern_blank, pattern_dash], [pattern_comment_end], True, False) extend_matched_lines(lines, matched, [pattern_comment_begin, pattern_comment_null], [pattern_comment_null], False, True) extend_matched_lines(lines, matched, [pattern_blank], [pattern_blank], False, True) if matched == old_matched: break # remove blank lines at the end of file if matched and matched[-1] == len(lines) -1: i = matched[-1] - 1 while i >= 0 and (i in matched or pattern_blank.search(lines[i])): matched.append(i) i -= 1 matched.sort() with open(filepath, 'w') as f: for i, line in enumerate(lines): if i not in matched: f.write(line) def main(): cwd = os.getcwd() if len(sys.argv) > 1: topdir = os.path.join(cwd, sys.argv[1]) else: topdir = cwd exclude_dirs = [ os.path.join(cwd, d) for d in ('.git', 'Documentation') ] # patterns to remove strings = ('c-indent-level:', 'tab-width:', 'vim:', 'version-control:', 'c-basic-offset:', 'indent-tabs-mode:', 'c-file-style:', 'fill-column:', 'kept-new-versions:', 'ispell-local-dictionary'
Re: [PATCH 4/4] kbuild: include Makefile.compiler only when compiler is required
(CC: Will and ARM ML) On Fri, Mar 19, 2021 at 6:14 AM Nathan Chancellor wrote: > > On Sun, Feb 28, 2021 at 03:10:28PM +0900, Masahiro Yamada wrote: > > Since commit f2f02ebd8f38 ("kbuild: improve cc-option to clean up all > > temporary files"), running 'make kernelversion' in a read-only source > > tree emits a bunch of warnings: > > > > mkdir: cannot create directory '.tmp_12345': Permission denied > > > > Non-build targets such as kernelversion, clean, help, etc. do not > > need to evaluate $(call cc-option,) and friends. Do not include > > Makefile.compiler so $(call cc-option,) becomes no-op. > > > > This not only fix the warnings, but also runs non-build targets much > > faster. > > > > Basically, all installation targets should also be non-build targets. > > Unfortunately, vdso_install requires the compiler because it builds > > vdso before installtion. This is a problem that must be fixed by a > > separate patch. > > > > Signed-off-by: Masahiro Yamada > > --- > > > > I am not adding Reported-by for now because a reporter sent me > > an email privately. > > > > If he allows me to add Reported-by, I will add it to record > > the credit. > > > > (Perhaps, another person might have reported a similar issue > > somewhere, but my memory is obsure. I cannot recall it.) > > > > > > Makefile | 13 + > > 1 file changed, 13 insertions(+) > > > > diff --git a/Makefile b/Makefile > > index eec7a94f5c33..20724711dc71 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -263,6 +263,10 @@ no-dot-config-targets := $(clean-targets) \ > >$(version_h) headers headers_% archheaders > > archscripts \ > >%asm-generic kernelversion %src-pkg dt_binding_check > > \ > >outputmakefile > > +# Installation targets should not require compiler. Unfortunately, > > vdso_install > > +# is an exception where build artifacts may be updated. This must be fixed. > > +no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ > > + headers_install modules_install kernelrelease > > image_name > > no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ > > image_name > > single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/ > > @@ -270,6 +274,7 @@ single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod > > %.o %.s %.symtypes %/ > > config-build := > > mixed-build := > > need-config := 1 > > +need-compiler:= 1 > > may-sync-config := 1 > > single-build := > > > > @@ -279,6 +284,12 @@ ifneq ($(filter $(no-dot-config-targets), > > $(MAKECMDGOALS)),) > > endif > > endif > > > > +ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),) > > + ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),) > > + need-compiler := > > + endif > > +endif > > + > > ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) > > ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) > > may-sync-config := > > @@ -584,7 +595,9 @@ endif > > > > # Include this also for config targets because some architectures need > > # cc-cross-prefix to determine CROSS_COMPILE. > > +ifdef need-compiler > > include $(srctree)/scripts/Makefile.compiler > > +endif > > > > ifdef config-build > > # > > === > > -- > > 2.27.0 > > > > Hi Masahiro, > > I see a new warning in my builds on arm64 now when running > 'modules_install' or 'dtbs_install' because ld-option evaluates to > nothing, which triggers the warning in arch/arm64/Makefile: > > $ make -skj"$(nproc)" \ > ARCH=arm64 \ > CROSS_COMPILE=aarch64-linux- \ > INSTALL_DTBS_PATH=rootfs \ > INSTALL_MOD_PATH=rootfs \ > O=build/arm64 \ > distclean defconfig all modules_install dtbs_install > ... > /home/nathan/cbl/src/linux-next/arch/arm64/Makefile:25: ld does not support > --fix-cortex-a53-843419; kernel may be susceptible to erratum > /home/nathan/cbl/src/linux-next/arch/arm64/Makefile:25: ld does not support > --fix-cortex-a53-843419; kernel may be susceptible to erratum > > $ sed -n '23,29p' arch/arm64/Makefile > ifeq ($(CONFIG_ARM64_ERRATUM_843419),y) > ifeq ($(call ld-option, --fix-cortex-a53-843419),) > $(warning ld does not support --fix-corte
Re: [PATCH RESEND] gcc-plugins: avoid errors with -std=gnu++11 on old gcc
On Thu, Mar 18, 2021 at 3:26 PM Miguel Ojeda wrote: > > On Thu, Mar 18, 2021 at 7:03 AM Valdis Klētnieks > wrote: > > > > Or declare that gcc6 is the minimum for building the kernel. > > Cc'ing some interested people in raising GCC's version for one reason > or another, so that we put this as another one in the pile of reasons > :-) > > https://lore.kernel.org/lkml/CAHk-=wjgvt1ei72btreh5fgfqykvh-ayt56-7ybt8lcprj7...@mail.gmail.com/ > > Cheers, > Miguel Previously we were discussing raising the min GCC version 5.x, but not further at this point of time. We can require GCC 6+ for building GCC plugins. --- a/scripts/gcc-plugins/Kconfig +++ b/scripts/gcc-plugins/Kconfig @@ -8,7 +8,7 @@ config HAVE_GCC_PLUGINS menuconfig GCC_PLUGINS bool "GCC plugins" depends on HAVE_GCC_PLUGINS - depends on CC_IS_GCC + depends on CC_IS_GCC && GCC_VERSION >= 6 depends on $(success,test -e $(shell,$(CC) -print-file-name=plugin)/include/plugin-version.h) default y help BTW, the commit message mentions that the issues only happen on GCC 4 and 5, but the added code was: GCC_FLAVOR = $(call cc-ifversion, -ge, 1100, 11, 98) instead of GCC_FLAVOR = $(call cc-ifversion, -ge, 600, 11, 98) So, this patch is also requiring to cover two standards: GCC_VERSION >= 11 : -std=gnu++11 GCC_VERSION < 11 : -std=gnu++98 -- Best Regards Masahiro Yamada
Re: [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag
On Tue, Mar 16, 2021 at 1:42 AM Sedat Dilek wrote: > > On Mon, Mar 15, 2021 at 5:22 PM Masahiro Yamada wrote: > > > > On Wed, Mar 10, 2021 at 5:59 AM Nathan Chancellor wrote: > > > > > > This flag was originally added to allow clang to find the GNU cross > > > tools in commit 785f11aa595b ("kbuild: Add better clang cross build > > > support"). This flag was not enough to find the tools at times so > > > '--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow > > > to use GCC toolchain not in Clang search path") and improved upon in > > > commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang > > > cross compilation"). Now that '--prefix' specifies a full path and > > > prefix, '--gcc-toolchain' serves no purpose because the kernel builds > > > with '-nostdinc' and '-nostdlib'. > > > > > > This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as > > > well as a distribution version of LLVM 11.1.0 without binutils in the > > > LLVM toolchain locations. > > > > > > Link: https://reviews.llvm.org/D97902 > > > Signed-off-by: Nathan Chancellor > > > --- > > > > > > v1 -> v2: > > > > > > * Improve commit message (add history behind flag and link to Fangrui's > > > documentation improvement). > > > > > > Both applied to linux-kbuild. Thanks. > > > > Sorry for being pedantic: This misses my Tested-by#s (see [1]). > > Tested-by: Sedat Dilek # LLVM/Clang v13-git > > AFAICS v2 changes some comments in the commit only but not code? For 1/2, yes. The difference is only comments. For 2/2, the code was changed. Actually, v1 was wrong. That is why the tags were dropped. I will re-add the tags to 1/2 since there is no code diff. If you re-test 2/2, I will add your tag again. > - Sedat - > > [1] https://marc.info/?l=linux-kernel=161480031518629=2 > [2] > https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=kbuild=d4aa405bc9cd506532f075456645716cdd1739c1 > > > > > > > > > > > > I did not carry tags forward so that people could re-review and test. > > > > > > Makefile | 4 > > > 1 file changed, 4 deletions(-) > > > > > > diff --git a/Makefile b/Makefile > > > index 31dcdb3d61fa..182e93d91198 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > > > CLANG_FLAGS+= --target=$(notdir $(CROSS_COMPILE:%-=%)) > > > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > > > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > > > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > > > -endif > > > -ifneq ($(GCC_TOOLCHAIN),) > > > -CLANG_FLAGS+= --gcc-toolchain=$(GCC_TOOLCHAIN) > > > endif > > > ifneq ($(LLVM_IAS),1) > > > CLANG_FLAGS+= -no-integrated-as > > > > > > base-commit: a38fd8748464831584a19438cbb3082b5a2dab15 > > > -- > > > 2.31.0.rc1 > > > > > > > > > -- > > Best Regards > > Masahiro Yamada -- Best Regards Masahiro Yamada
Re: [PATCH v2 2/3] kbuild: check the minimum assembler version in Kconfig
On Tue, Mar 16, 2021 at 1:14 AM Masahiro Yamada wrote: > > Documentation/process/changes.rst defines the minimum assembler version > (binutils version), but we have never checked it in the build time. > > Kbuild never invokes 'as' directly because all assembly files in the > kernel tree are *.S, hence must be preprocessed. I do not expect > raw assembly source files (*.s) would be added to the kernel tree. > > Therefore, we always use $(CC) as the assembler driver, and commit > aa824e0c962b ("kbuild: remove AS variable") removed 'AS'. However, > we are still interested in the version of the assembler acting behind. > > As usual, the --version option prints the version string. > > $ as --version | head -n 1 > GNU assembler (GNU Binutils for Ubuntu) 2.35.1 > > But, we do not have $(AS). So, we can add the -Wa prefix so that > $(CC) passes --version down to the backing assembler. > > $ gcc -Wa,--version | head -n 1 > gcc: fatal error: no input files > compilation terminated. > > OK, we need to input something to satisfy gcc. > > $ gcc -Wa,--version -c -x assembler /dev/null -o /dev/null | head -n 1 > GNU assembler (GNU Binutils for Ubuntu) 2.35.1 > > The combination of Clang and GNU assembler works in the same way: > > $ clang -no-integrated-as -Wa,--version -c -x assembler /dev/null -o > /dev/null | head -n 1 > GNU assembler (GNU Binutils for Ubuntu) 2.35.1 > > Clang with the integrated assembler fails like this: > > $ clang -integrated-as -Wa,--version -c -x assembler /dev/null -o /dev/null > | head -n 1 > clang: error: unsupported argument '--version' to option 'Wa,' > > For the last case, checking the error message is fragile. If the > proposal for -Wa,--version support [1] is accepted, this may not be > even an error in the future. > > One easy way is to check if -integrated-as is present in the passed > arguments. We did not pass -integrated-as to CLANG_FLAGS before, but > we can make it explicit. > > Nathan pointed out -integrated-as is the default for all of the > architectures/targets that the kernel cares about, but it goes > along with "explicit is better than implicit" policy. [2] > > With all this in my mind, I implemented scripts/as-version.sh to > check the assembler version in Kconfig time. > > $ scripts/as-version.sh gcc > GNU 23501 > $ scripts/as-version.sh clang -no-integrated-as > GNU 23501 > $ scripts/as-version.sh clang -integrated-as > LLVM 0 > > [1]: https://github.com/ClangBuiltLinux/linux/issues/1320 > [2]: > https://lore.kernel.org/linux-kbuild/20210307044253.v3h47ucq6ng25iay@archlinux-ax161/ > > Signed-off-by: Masahiro Yamada > --- > > Changes in v2: > - Check -integrated-as option instead of error message. > - Add LC_ALL=C just in case. > > The Italian locale did not tweak the message from 'as --version' > but we never know what would happen on locale. > > $ LC_MESSAGES=it_IT.UTF-8 ld --version | head -n 1 > ld di GNU (GNU Binutils for Debian) 2.35.2 > $ LC_MESSAGES=it_IT.UTF-8 as --version | head -n 1 > GNU assembler (GNU Binutils for Debian) 2.35.2 > > Makefile| 4 +- > arch/Kconfig| 3 +- > init/Kconfig| 12 ++ > scripts/Kconfig.include | 6 +++ > scripts/as-version.sh | 82 + > 5 files changed, 104 insertions(+), 3 deletions(-) > create mode 100755 scripts/as-version.sh > > diff --git a/Makefile b/Makefile > index cc5b7e39fde4..2b161f5a5a66 100644 > --- a/Makefile > +++ b/Makefile > @@ -580,7 +580,9 @@ ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) > ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS+= --target=$(notdir $(CROSS_COMPILE:%-=%)) > endif > -ifneq ($(LLVM_IAS),1) > +ifeq ($(LLVM_IAS),1) > +CLANG_FLAGS+= -integrated-as > +else > CLANG_FLAGS+= -no-integrated-as > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS+= --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > diff --git a/arch/Kconfig b/arch/Kconfig > index ecfd3520b676..555b4f09a9b2 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -631,8 +631,7 @@ config ARCH_SUPPORTS_LTO_CLANG_THIN > config HAS_LTO_CLANG > def_bool y > # Clang >= 11: https://github.com/ClangBuiltLinux/linux/issues/510 > - depends on CC_IS_CLANG && CLANG_VERSION >= 11 && LD_IS_LLD > - depends on $(success,test $(LLVM_IAS) -eq 1) > + depends on CC_IS_CLANG && CLANG_VERSION >= 11 && LD_IS_LLD && > AS_IS_LLVM > depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) >
Re: [PATCH V11 3/5] kbuild: Allow .dtso format for overlay source files
On Mon, Mar 15, 2021 at 3:40 PM Viresh Kumar wrote: > > On 14-03-21, 20:16, Frank Rowand wrote: > > On 3/12/21 11:11 PM, Frank Rowand wrote: > > > On 3/12/21 1:13 AM, Viresh Kumar wrote: > > >> On 12-03-21, 01:09, Frank Rowand wrote: > > >>> I suggested having the .dtso files include the .dts file because that > > >>> is a relatively > > >>> small and easy change to test. What would probably make more sense is > > >>> the rename > > >>> the existing overlay .dts files to be .dtso files and then for each > > >>> overlay .dtso > > >>> file create a new .dts file that #includes the corresponding .dtso > > >>> file. This is > > >>> more work and churn, but easier to document that the .dts files are a > > >>> hack that is > > >>> needed so that the corresponding .dtb.S files will be generated. > > >> > > >> What about creating links instead then ? > > >> > > > > > > I don't really like the idea of using links here. > > > > > > Maybe it is best to make the changes needed to allow the unittest > > > overlays to be .dtso instead of .dts. > > > > > > Off the top of my head: > > > > > > scripts/Makefile.lib: > > > The rule for %.dtb.S invokes cmd_dt_S_dtb, which puts the > > > overlay data in section .dtb.init.rodata, with a label > > > pointing to the beginning of the overlay __dtb_XXX_begin and > > > a label pointing to the end of the overlay __dtb_XXX_end, > > > for the overlay named XXX. I _think_ that you could simply > > > add a corresponding rule for %.dtbo.S using a new command > > > cmd_dt_S_dtbo (the same as cmd_dt_S_dtb, except use labels > > > __dtbo_XXX_begin and __dtbo_XXX_end). > > > > If you do the above, please put it in drivers/of/unittest-data/Makefile > > instead of scripts/Makefile.lib because it is unittest.c specific and > > not meant to be anywhere else in the kernel. > > What about doing this then in unittest's Makefile instead (which I > already suggested earlier), that will make everything work just fine > without any other changes ? > > +# Required for of unittest files as they can't be renamed to .dtso > +$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE > + $(call if_changed_dep,dtc) > > -- > viresh If those rules are only needed by drivers/of/unittest-data/Makefile, they should not be located in scripts/Makefile.lib. But how can we fix drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a779*.dts if these are doing bad things. They seem to be overlay files even though the file name suffix is .dts $ find drivers -name '*.dts' drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dts drivers/staging/mt7621-dts/gbpc2.dts drivers/staging/mt7621-dts/gbpc1.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts drivers/of/unittest-data/overlay_1.dts drivers/of/unittest-data/testcases.dts drivers/of/unittest-data/overlay_bad_add_dup_node.dts drivers/of/unittest-data/overlay_bad_symbol.dts drivers/of/unittest-data/overlay_0.dts drivers/of/unittest-data/overlay_11.dts drivers/of/unittest-data/overlay_gpio_03.dts drivers/of/unittest-data/overlay_gpio_04a.dts drivers/of/unittest-data/overlay_gpio_04b.dts drivers/of/unittest-data/overlay_5.dts drivers/of/unittest-data/overlay_bad_add_dup_prop.dts drivers/of/unittest-data/overlay_gpio_01.dts drivers/of/unittest-data/overlay_10.dts drivers/of/unittest-data/overlay_7.dts drivers/of/unittest-data/overlay_bad_phandle.dts drivers/of/unittest-data/overlay_3.dts drivers/of/unittest-data/overlay_6.dts drivers/of/unittest-data/overlay_8.dts drivers/of/unittest-data/overlay_12.dts drivers/of/unittest-data/overlay_gpio_02a.dts drivers/of/unittest-data/overlay_gpio_02b.dts drivers/of/unittest-data/overlay_4.dts drivers/of/unittest-data/overlay.dts drivers/of/unittest-data/overlay_9.dts drivers/of/unittest-data/overlay_2.dts drivers/of/unittest-data/overlay_15.dts drivers/of/unittest-data/overlay_base.dts drivers/of/unittest-data/overlay_13.dts -- Best Regards Masahiro Yamada
Re: [PATCH] docs: kbuild: Fix a typo in the file Kconfig.recursion-issue-02
On Sun, Mar 14, 2021 at 1:33 PM Bhaskar Chowdhury wrote: > > > s/sematics/semantics/ > > Signed-off-by: Bhaskar Chowdhury > --- Applied to linux-kbuild. Thanks. > Documentation/kbuild/Kconfig.recursion-issue-02 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Documentation/kbuild/Kconfig.recursion-issue-02 > b/Documentation/kbuild/Kconfig.recursion-issue-02 > index df245fd7670d..0034eb494d11 100644 > --- a/Documentation/kbuild/Kconfig.recursion-issue-02 > +++ b/Documentation/kbuild/Kconfig.recursion-issue-02 > @@ -6,7 +6,7 @@ > # make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 > allnoconfig > # > # The recursive limitations with Kconfig has some non intuitive implications > on > -# kconfig sematics which are documented here. One known practical implication > +# kconfig semantics which are documented here. One known practical > implication > # of the recursive limitation is that drivers cannot negate features from > other > # drivers if they share a common core requirement and use disjoint semantics > to > # annotate those requirements, ie, some drivers use "depends on" while others > -- > 2.26.2 > -- Best Regards Masahiro Yamada
Re: [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag
On Wed, Mar 10, 2021 at 5:59 AM Nathan Chancellor wrote: > > This flag was originally added to allow clang to find the GNU cross > tools in commit 785f11aa595b ("kbuild: Add better clang cross build > support"). This flag was not enough to find the tools at times so > '--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow > to use GCC toolchain not in Clang search path") and improved upon in > commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang > cross compilation"). Now that '--prefix' specifies a full path and > prefix, '--gcc-toolchain' serves no purpose because the kernel builds > with '-nostdinc' and '-nostdlib'. > > This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as > well as a distribution version of LLVM 11.1.0 without binutils in the > LLVM toolchain locations. > > Link: https://reviews.llvm.org/D97902 > Signed-off-by: Nathan Chancellor > --- > > v1 -> v2: > > * Improve commit message (add history behind flag and link to Fangrui's > documentation improvement). Both applied to linux-kbuild. Thanks. > I did not carry tags forward so that people could re-review and test. > > Makefile | 4 > 1 file changed, 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 31dcdb3d61fa..182e93d91198 100644 > --- a/Makefile > +++ b/Makefile > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS+= --target=$(notdir $(CROSS_COMPILE:%-=%)) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS+= --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > -endif > -ifneq ($(GCC_TOOLCHAIN),) > -CLANG_FLAGS+= --gcc-toolchain=$(GCC_TOOLCHAIN) > endif > ifneq ($(LLVM_IAS),1) > CLANG_FLAGS+= -no-integrated-as > > base-commit: a38fd8748464831584a19438cbb3082b5a2dab15 > -- > 2.31.0.rc1 > -- Best Regards Masahiro Yamada
[PATCH v2 2/3] kbuild: check the minimum assembler version in Kconfig
Documentation/process/changes.rst defines the minimum assembler version (binutils version), but we have never checked it in the build time. Kbuild never invokes 'as' directly because all assembly files in the kernel tree are *.S, hence must be preprocessed. I do not expect raw assembly source files (*.s) would be added to the kernel tree. Therefore, we always use $(CC) as the assembler driver, and commit aa824e0c962b ("kbuild: remove AS variable") removed 'AS'. However, we are still interested in the version of the assembler acting behind. As usual, the --version option prints the version string. $ as --version | head -n 1 GNU assembler (GNU Binutils for Ubuntu) 2.35.1 But, we do not have $(AS). So, we can add the -Wa prefix so that $(CC) passes --version down to the backing assembler. $ gcc -Wa,--version | head -n 1 gcc: fatal error: no input files compilation terminated. OK, we need to input something to satisfy gcc. $ gcc -Wa,--version -c -x assembler /dev/null -o /dev/null | head -n 1 GNU assembler (GNU Binutils for Ubuntu) 2.35.1 The combination of Clang and GNU assembler works in the same way: $ clang -no-integrated-as -Wa,--version -c -x assembler /dev/null -o /dev/null | head -n 1 GNU assembler (GNU Binutils for Ubuntu) 2.35.1 Clang with the integrated assembler fails like this: $ clang -integrated-as -Wa,--version -c -x assembler /dev/null -o /dev/null | head -n 1 clang: error: unsupported argument '--version' to option 'Wa,' For the last case, checking the error message is fragile. If the proposal for -Wa,--version support [1] is accepted, this may not be even an error in the future. One easy way is to check if -integrated-as is present in the passed arguments. We did not pass -integrated-as to CLANG_FLAGS before, but we can make it explicit. Nathan pointed out -integrated-as is the default for all of the architectures/targets that the kernel cares about, but it goes along with "explicit is better than implicit" policy. [2] With all this in my mind, I implemented scripts/as-version.sh to check the assembler version in Kconfig time. $ scripts/as-version.sh gcc GNU 23501 $ scripts/as-version.sh clang -no-integrated-as GNU 23501 $ scripts/as-version.sh clang -integrated-as LLVM 0 [1]: https://github.com/ClangBuiltLinux/linux/issues/1320 [2]: https://lore.kernel.org/linux-kbuild/20210307044253.v3h47ucq6ng25iay@archlinux-ax161/ Signed-off-by: Masahiro Yamada --- Changes in v2: - Check -integrated-as option instead of error message. - Add LC_ALL=C just in case. The Italian locale did not tweak the message from 'as --version' but we never know what would happen on locale. $ LC_MESSAGES=it_IT.UTF-8 ld --version | head -n 1 ld di GNU (GNU Binutils for Debian) 2.35.2 $ LC_MESSAGES=it_IT.UTF-8 as --version | head -n 1 GNU assembler (GNU Binutils for Debian) 2.35.2 Makefile| 4 +- arch/Kconfig| 3 +- init/Kconfig| 12 ++ scripts/Kconfig.include | 6 +++ scripts/as-version.sh | 82 + 5 files changed, 104 insertions(+), 3 deletions(-) create mode 100755 scripts/as-version.sh diff --git a/Makefile b/Makefile index cc5b7e39fde4..2b161f5a5a66 100644 --- a/Makefile +++ b/Makefile @@ -580,7 +580,9 @@ ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) ifneq ($(CROSS_COMPILE),) CLANG_FLAGS+= --target=$(notdir $(CROSS_COMPILE:%-=%)) endif -ifneq ($(LLVM_IAS),1) +ifeq ($(LLVM_IAS),1) +CLANG_FLAGS+= -integrated-as +else CLANG_FLAGS+= -no-integrated-as GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS+= --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) diff --git a/arch/Kconfig b/arch/Kconfig index ecfd3520b676..555b4f09a9b2 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -631,8 +631,7 @@ config ARCH_SUPPORTS_LTO_CLANG_THIN config HAS_LTO_CLANG def_bool y # Clang >= 11: https://github.com/ClangBuiltLinux/linux/issues/510 - depends on CC_IS_CLANG && CLANG_VERSION >= 11 && LD_IS_LLD - depends on $(success,test $(LLVM_IAS) -eq 1) + depends on CC_IS_CLANG && CLANG_VERSION >= 11 && LD_IS_LLD && AS_IS_LLVM depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm) depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm) depends on ARCH_SUPPORTS_LTO_CLANG diff --git a/init/Kconfig b/init/Kconfig index 5f5c776ef192..019c1874e609 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -41,6 +41,18 @@ config CLANG_VERSION default $(cc-version) if CC_IS_CLANG default 0 +config AS_IS_GNU + def_bool $(success,test "$(as-name)" = GNU) + +config AS_IS_LLVM + def_bool $(success,test "$(as-name)" = LLVM) + +config AS_VERSION + int + # Use clang version if this is the integrated assembler + default CLANG_VERSION i
[PATCH v2 3/3] kbuild: dwarf: use AS_VERSION instead of test_dwarf5_support.sh
The test code in scripts/test_dwarf5_support.sh is somewhat difficult to understand, but after all, we want to check binutils >= 2.35.2 >From the former discussion, the requirement for generating DWARF v5 from C code is as follows: - gcc + gnu as -> requires gcc 5.0+ (but 7.0+ for full support) - clang + gnu as-> requires binutils 2.35.2+ - clang + integrated as -> OK Signed-off-by: Masahiro Yamada Reviewed-by: Nathan Chancellor --- Changes in v2: - fix typos - simplify the dependency expression lib/Kconfig.debug | 3 +-- scripts/test_dwarf5_support.sh | 8 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100755 scripts/test_dwarf5_support.sh diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index b479ae609a31..c85d5f7a1aeb 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -284,8 +284,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" - depends on GCC_VERSION >= 5 || CC_IS_CLANG - depends on CC_IS_GCC || $(success,$(srctree)/scripts/test_dwarf5_support.sh $(CC) $(CLANG_FLAGS)) + depends on GCC_VERSION >= 5 || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502))) depends on !DEBUG_INFO_BTF help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc diff --git a/scripts/test_dwarf5_support.sh b/scripts/test_dwarf5_support.sh deleted file mode 100755 index c46e2456b47a.. --- a/scripts/test_dwarf5_support.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 - -# Test that the assembler doesn't need -Wa,-gdwarf-5 when presented with DWARF -# v5 input, such as `.file 0` and `md5 0x00`. Should be fixed in GNU binutils -# 2.35.2. https://sourceware.org/bugzilla/show_bug.cgi?id=25611 -echo '.file 0 "filename" md5 0x7a0b65214090b6693bd1dc24dd248245' | \ - $* -gdwarf-5 -Wno-unused-command-line-argument -c -x assembler -o /dev/null - -- 2.27.0
[PATCH v2 1/3] kbuild: collect minimum tool versions into scripts/min-tool-version.sh
The kernel build uses various tools, many of which are provided by the same software suite, for example, LLVM and Binutils. When you raise the minimum version of Clang/LLVM, you need to update clang_min_version in scripts/cc-version.sh and also lld_min_version in scripts/ld-version.sh. Kbuild can handle CC=clang and LD=ld.lld independently, but it does not make much sense to maintain their versions separately. Let's create a central place of minimum tool versions so you do not need to touch multiple files. scripts/min-tool-version.sh prints the minimum version of the given tool. Signed-off-by: Masahiro Yamada Reviewed-by: Nathan Chancellor Acked-by: Miguel Ojeda Tested-by: Sedat Dilek --- Changes in v2: - Use case ... esac scripts/cc-version.sh | 20 +-- scripts/ld-version.sh | 11 --- scripts/min-tool-version.sh | 39 + 3 files changed, 48 insertions(+), 22 deletions(-) create mode 100755 scripts/min-tool-version.sh diff --git a/scripts/cc-version.sh b/scripts/cc-version.sh index 3f2ee885b116..f1952c522466 100755 --- a/scripts/cc-version.sh +++ b/scripts/cc-version.sh @@ -6,18 +6,6 @@ set -e -# When you raise the minimum compiler version, please update -# Documentation/process/changes.rst as well. -gcc_min_version=4.9.0 -clang_min_version=10.0.1 -icc_min_version=16.0.3 # temporary - -# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293 -# https://lore.kernel.org/r/20210107111841.gn1...@shell.armlinux.org.uk -if [ "$SRCARCH" = arm64 ]; then - gcc_min_version=5.1.0 -fi - # Print the compiler name and some version components. get_compiler_info() { @@ -48,18 +36,20 @@ set -- $(get_compiler_info "$@") name=$1 +min_tool_version=$(dirname $0)/min-tool-version.sh + case "$name" in GCC) version=$2.$3.$4 - min_version=$gcc_min_version + min_version=$($min_tool_version gcc) ;; Clang) version=$2.$3.$4 - min_version=$clang_min_version + min_version=$($min_tool_version llvm) ;; ICC) version=$(($2 / 100)).$(($2 % 100)).$3 - min_version=$icc_min_version + min_version=$($min_tool_version icc) ;; *) echo "$orig_args: unknown compiler" >&2 diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh index 1bf3aadde9de..a78b804b680c 100755 --- a/scripts/ld-version.sh +++ b/scripts/ld-version.sh @@ -6,11 +6,6 @@ set -e -# When you raise the minimum linker version, please update -# Documentation/process/changes.rst as well. -bfd_min_version=2.23.0 -lld_min_version=10.0.1 - # Convert the version string x.y.z to a canonical 5 or 6-digit form. get_canonical_version() { @@ -35,10 +30,12 @@ set -- $(LC_ALL=C "$@" --version) IFS=' ' set -- $1 +min_tool_version=$(dirname $0)/min-tool-version.sh + if [ "$1" = GNU -a "$2" = ld ]; then shift $(($# - 1)) version=$1 - min_version=$bfd_min_version + min_version=$($min_tool_version binutils) name=BFD disp_name="GNU ld" elif [ "$1" = GNU -a "$2" = gold ]; then @@ -51,7 +48,7 @@ else if [ "$1" = LLD ]; then version=$2 - min_version=$lld_min_version + min_version=$($min_tool_version llvm) name=LLD disp_name=LLD else diff --git a/scripts/min-tool-version.sh b/scripts/min-tool-version.sh new file mode 100755 index ..d22cf91212b0 --- /dev/null +++ b/scripts/min-tool-version.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only +# +# Print the minimum supported version of the given tool. +# When you raise the minimum version, please update +# Documentation/process/changes.rst as well. + +set -e + +if [ $# != 1 ]; then + echo "Usage: $0 toolname" >&2 + exit 1 +fi + +case "$1" in +binutils) + echo 2.23.0 + ;; +gcc) + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293 + # https://lore.kernel.org/r/20210107111841.gn1...@shell.armlinux.org.uk + if [ "$SRCARCH" = arm64 ]; then + echo 5.1.0 + else + echo 4.9.0 + fi + ;; +icc) + # temporary + echo 16.0.3 + ;; +llvm) + echo 10.0.1 + ;; +*) + echo "$1: unknown tool" >&2 + exit 1 + ;; +esac -- 2.27.0
Re: [PATCH 07/13] kconfig: move conf_set_all_new_symbols() to conf.c
On Mon, Mar 15, 2021 at 7:07 PM Boris Kolpackov wrote: > > Masahiro Yamada writes: > > > This function is only used in conf.c. Move it there together with the > > randomize_choice_values() helper. > > > > [...] > > > > diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h > > index f946ab49ef50..d0d5acecb530 100644 > > --- a/scripts/kconfig/lkc.h > > +++ b/scripts/kconfig/lkc.h > > @@ -57,7 +57,6 @@ const char *zconf_curname(void); > > const char *conf_get_configname(void); > > void sym_set_change_count(int count); > > void sym_add_change_count(int count); > > -bool conf_set_all_new_symbols(enum conf_def_mode mode); > > void set_all_choice_values(struct symbol *csym); > > A number of people package kconfig as a library that is then used > in various projects outside of the Linux kernel. Removing this > function breaks the library ABI and potentially such project. For > example, I call conf_set_all_new_symbols() from my libbuild2-kconfig > build system module[1]. There is no such ABI in Kconfig. > I know you don't care much for such out-of-kernel usage, still, this > (and the previous commit) feels like superficial reshuffling of code > and perhaps it's worth not breaking things unless there is something > substantial to gain? > > [1] > https://github.com/build2/libbuild2-kconfig/blob/master/libbuild2-kconfig/libbuild2/kconfig/init.cxx#L938 confdata.c is linked to all flavors of Kconfig (conf, mconf, gconf, and qconf). conf_set_all_new_symbols() and randomize_choice_values() are apparently only used by the text-base conf. They need to go to the correct location. -- Best Regards Masahiro Yamada
[PATCH] kbuild: replace sed with $(subst ) or $(patsubst )
For simple text replacement, it is better to use a built-in function instead of sed if possible. You can save one process forking. I do not mean to replace all sed invocations because GNU Make itself does not support regular expression (unless you use guile). I just replaced simple ones. Signed-off-by: Masahiro Yamada --- Documentation/devicetree/bindings/Makefile | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/Makefile b/Documentation/devicetree/bindings/Makefile index 780e5618ec0a..ac446c62fbc3 100644 --- a/Documentation/devicetree/bindings/Makefile +++ b/Documentation/devicetree/bindings/Makefile @@ -48,7 +48,7 @@ define rule_chkdt $(call cmd,mk_schema) endef -DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||') +DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_cmd))) override DTC_FLAGS := \ -Wno-avoid_unnecessary_addr_size \ diff --git a/Makefile b/Makefile index 70fc39e6b677..0be138adae74 100644 --- a/Makefile +++ b/Makefile @@ -574,7 +574,7 @@ endif # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. # CC_VERSION_TEXT is referenced from Kconfig (so it needs export), # and from include/config/auto.conf.cmd to detect the compiler upgrade. -CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g') +CC_VERSION_TEXT = $(subst $(pound),,$(shell $(CC) --version 2>/dev/null | head -n 1)) ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) ifneq ($(CROSS_COMPILE),) -- 2.27.0
Re: Why is the bit size different between a syscall and its wrapper?
Willy, Thanks for the explanation. On Fri, Mar 12, 2021 at 12:27 PM Willy Tarreau wrote: > > On Fri, Mar 12, 2021 at 11:48:11AM +0900, Masahiro Yamada wrote: > > Hi. > > > > I think I am missing something, but > > is there any particular reason to > > use a different bit size between > > a syscall and its userspace wrapper? > > > > > > > > For example, for the unshare syscall, > > > > unshare(2) says the parameter is int. > > > > > > SYNOPSIS > >#define _GNU_SOURCE > >#include > > > >int unshare(int flags); > > > > > > > > > > In the kernel, it is unsigned long. > > > > > > SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags) > > { > > return ksys_unshare(unshare_flags); > > } > > The syscalls must have a well defined interface for a given architecture. > Thus in practice the ABI will define that arg1 goes into this register, > arg2 into this one etc, regardless of their type (plenty of them are > pointers for example). The long is the size of a register so it can carry > any of the types we care about. So by defining each syscall as a function > taking 1 to 6 fixed-size arguments you can implement about all syscalls. > > Regarding the libc, it has to offer an interface which is compatible with > the standard definition of the syscalls as defined by POSIX or as commonly > found on other OSes, and this regardless of the platform. > > For example look at recv(), it takes an int, a pointer, a size_t and an > int. It requires to be defined like this for portability, but at the OS > level all these will typically be passed as a register each. > You are right. Functions in POSIX such as 'recv' should be portable with other OSes. For the syscall ABI level, we have more freedom to choose parameter types more convenient for the kernel. IIUC, 'unshare' seems to be Linux-specific, and I think "other OSes" do not exist. Using types that have the same width as registers avoids the ambiguity about the upper 32-bits in 64-bit registers anyway. This is a benefit. Historically, it caused a issue: https://nvd.nist.gov/vuln/detail/CVE-2009-0029 We do not need to be worried since commit 1a94bc34768e463a93cb3751819709ab0ea80a01. All parameters are properly sign-extended by forcibly casting to (long). -- Best Regards Masahiro Yamada
[PATCH 13/13] kconfig: change "modules" from sub-option to first-level attribute
Now "modules" is the only member of the "option" property. Remove "option", and move "modules" to the top level property. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/kconfig-language.rst | 14 -- init/Kconfig | 2 +- scripts/kconfig/lexer.l| 1 - scripts/kconfig/lkc.h | 1 - scripts/kconfig/menu.c | 8 scripts/kconfig/parser.y | 8 +--- scripts/kconfig/tests/choice/Kconfig | 2 +- .../kconfig/tests/choice_value_with_m_dep/Kconfig | 2 +- scripts/kconfig/tests/inter_choice/Kconfig | 2 +- 9 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst index 4a796c601446..98c24183d8c3 100644 --- a/Documentation/kbuild/kconfig-language.rst +++ b/Documentation/kbuild/kconfig-language.rst @@ -223,16 +223,10 @@ applicable everywhere (see syntax). the indentation level, this means it ends at the first line which has a smaller indentation than the first line of the help text. -- misc options: "option" [=] - - Various less common options can be defined via this option syntax, - which can modify the behaviour of the menu entry and its config - symbol. These options are currently possible: - - - "modules" -This declares the symbol to be used as the MODULES symbol, which -enables the third modular state for all config symbols. -At most one symbol may have the "modules" option set. +- module attribute: "modules" + This declares the symbol to be used as the MODULES symbol, which + enables the third modular state for all config symbols. + At most one symbol may have the "modules" option set. Menu dependencies - diff --git a/init/Kconfig b/init/Kconfig index beb8314fdf96..5b71e1c0edb4 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2043,7 +2043,7 @@ config MODULE_SIG_FORMAT menuconfig MODULES bool "Enable loadable module support" - option modules + modules help Kernel modules are small pieces of compiled code which can be inserted in the running kernel, rather than being diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 08c96a6ffe05..312cbad2d34d 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -112,7 +112,6 @@ n [A-Za-z0-9_-] "menuconfig" return T_MENUCONFIG; "modules" return T_MODULES; "on" return T_ON; -"option" return T_OPTION; "optional" return T_OPTIONAL; "prompt" return T_PROMPT; "range"return T_RANGE; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index c1ab05f73ca2..246eba37ca0e 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -105,7 +105,6 @@ void menu_add_visibility(struct expr *dep); struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); -void menu_add_option_modules(void); void menu_finalize(struct menu *parent); void menu_set_type(int type); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index d50d0de55222..8b2108b74821 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -211,14 +211,6 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) menu_add_prop(type, expr_alloc_symbol(sym), dep); } -void menu_add_option_modules(void) -{ - if (modules_sym) - zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'", - current_entry->sym->name, modules_sym->name); - modules_sym = current_entry->sym; -} - static int menu_validate_number(struct symbol *sym, struct symbol *sym2) { return sym2->type == S_INT || sym2->type == S_HEX || diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 2ada169c8b5d..e46ce21a2fc4 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -69,7 +69,6 @@ static struct menu *current_menu, *current_entry; %token T_MODULES %token T_ON %token T_OPEN_PAREN -%token T_OPTION %token T_OPTIONAL %token T_PLUS_EQUAL %token T_PROMPT @@ -216,9 +215,12 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; -config_option: T_OPTION T_MODULES T_EOL +config_option: T_MODULES T_EOL { - menu_add_option_modules(); + if (
[PATCH 11/13] kconfig: do not use allnoconfig_y option
allnoconfig_y is a bad hack that sets a symbol to 'y' by allnoconfig. allnoconfig does not mean a minimum set of CONFIG options because a bunch of prompts are hidden by 'if EMBEDDED' or 'if EXPERT', but I do not like to do a workaround this way. Use the pre-existing feature, KCONFIG_ALLCONFIG, to provide a one liner config fragment. CONFIG_EMBEDDED=y is still forced under allnoconfig. No change in the .config file produced by 'make tinyconfig'. The output of 'make allnoconfig' will be changed; we will get CONFIG_EMBEDDED=n because allnoconfig literally sets all symbols to n. Signed-off-by: Masahiro Yamada --- init/Kconfig| 1 - kernel/configs/tiny-base.config | 1 + scripts/kconfig/Makefile| 3 ++- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 kernel/configs/tiny-base.config diff --git a/init/Kconfig b/init/Kconfig index 46b87ad73f6a..beb8314fdf96 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1769,7 +1769,6 @@ config DEBUG_RSEQ config EMBEDDED bool "Embedded system" - option allnoconfig_y select EXPERT help This option should be enabled if compiling the kernel for diff --git a/kernel/configs/tiny-base.config b/kernel/configs/tiny-base.config new file mode 100644 index ..2f0e6bf6db2c --- /dev/null +++ b/kernel/configs/tiny-base.config @@ -0,0 +1 @@ +CONFIG_EMBEDDED=y diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 7df3c0e4c52e..46f2465177f0 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -102,7 +102,8 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/c PHONY += tinyconfig tinyconfig: - $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config + $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig + $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config # CHECK: -o cache_dir= working? PHONY += testconfig -- 2.27.0
[PATCH 09/13] kconfig: change defconfig_list option to environment variable
"defconfig_list" is a weird option that defines static symbol that declares the list of base config files in case the .config does not exist yet. This is quite different from other normal symbols; we just abused the "string" type and the "default" properties to list out the input files. They must be fixed values since these are searched for and loaded in the parse stage. It is an ugly hack, and should not exist in the first place. Providing this features as an environment variable is a saner approach. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/kconfig-language.rst | 5 --- Documentation/kbuild/kconfig.rst | 8 + init/Kconfig | 9 -- scripts/kconfig/Makefile | 10 ++ scripts/kconfig/confdata.c| 38 +-- scripts/kconfig/expr.h| 1 - scripts/kconfig/lexer.l | 1 - scripts/kconfig/lkc.h | 1 - scripts/kconfig/menu.c| 9 -- scripts/kconfig/parser.y | 6 scripts/kconfig/symbol.c | 1 - scripts/kconfig/tests/conftest.py | 4 +++ 12 files changed, 50 insertions(+), 43 deletions(-) diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst index 226ae072da7d..3cbccfc42798 100644 --- a/Documentation/kbuild/kconfig-language.rst +++ b/Documentation/kbuild/kconfig-language.rst @@ -229,11 +229,6 @@ applicable everywhere (see syntax). which can modify the behaviour of the menu entry and its config symbol. These options are currently possible: - - "defconfig_list" -This declares a list of default entries which can be used when -looking for the default configuration (which is used when the main -.config doesn't exists yet.) - - "modules" This declares the symbol to be used as the MODULES symbol, which enables the third modular state for all config symbols. diff --git a/Documentation/kbuild/kconfig.rst b/Documentation/kbuild/kconfig.rst index dce6801d66c9..5967c79c3baa 100644 --- a/Documentation/kbuild/kconfig.rst +++ b/Documentation/kbuild/kconfig.rst @@ -41,6 +41,14 @@ KCONFIG_CONFIG This environment variable can be used to specify a default kernel config file name to override the default name of ".config". +KCONFIG_DEFCONFIG_LIST +-- + +This environment variable specifies a list of config files which can be used +as a base configuration in case the .config does not exist yet. Entries in +the list are separated with whitespaces to each other, and the first one +that exists is used. + KCONFIG_OVERWRITECONFIG --- If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not diff --git a/init/Kconfig b/init/Kconfig index 22946fe5ded9..46b87ad73f6a 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1,13 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -config DEFCONFIG_LIST - string - depends on !UML - option defconfig_list - default "/lib/modules/$(shell,uname -r)/.config" - default "/etc/kernel-config" - default "/boot/config-$(shell,uname -r)" - default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)" - config CC_VERSION_TEXT string default "$(CC_VERSION_TEXT)" diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 8c19b82c6035..31c5735663c8 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -13,6 +13,16 @@ ifeq ($(quiet),silent_) silent := -s endif +export KCONFIG_DEFCONFIG_LIST := +ifneq ($(SRCARCH),um) +kernel-release := $(shell uname -r) +KCONFIG_DEFCONFIG_LIST := \ + /lib/modules/$(kernel-release)/.config \ + /etc/kernel-config \ + /boot/config-$(kernel-release) \ + arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) +endif + # We need this, in case the user has it in its environment unexport CONFIG_ diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 198f70957fbf..f3998d5ddd02 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -360,28 +360,46 @@ int conf_read_simple(const char *name, int def) if (name) { in = zconf_fopen(name); } else { - struct property *prop; + char *env; name = conf_get_configname(); in = zconf_fopen(name); if (in) goto load; sym_add_change_count(1); - if (!sym_defconfig_list) + + env = getenv("KCONFIG_DEFCONFIG_LIST"); + if (!env) return 1; - for_all_defaults(sym_defconfig_list, prop) { - if (expr_calc_value(prop->visible.expr) == no || - prop->
[PATCH 08/13] kconfig: move JUMP_NB to mconf.c
This macro is only used in mconf.c. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 2 -- scripts/kconfig/mconf.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 5c3443692f34..bbca80a0dc24 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -281,8 +281,6 @@ struct jump_key { int index; }; -#define JUMP_NB9 - extern struct file *file_list; extern struct file *current_file; struct file *lookup_file(const char *name); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 4063dbc1b927..01b6c27224e2 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -22,6 +22,8 @@ #include "lkc.h" #include "lxdialog/dialog.h" +#define JUMP_NB9 + static const char mconf_readme[] = "Overview\n" "\n" -- 2.27.0
[PATCH 05/13] kconfig: remove assignment for Kconfig file
Pass av[optind] to conf_parse() directly. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9ebc1acaf1ae..42d35da86604 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -571,8 +571,7 @@ int main(int ac, char **av) conf_usage(progname); exit(1); } - name = av[optind]; - conf_parse(name); + conf_parse(av[optind]); //zconfdump(stdout); switch (input_mode) { -- 2.27.0
[PATCH 07/13] kconfig: move conf_set_all_new_symbols() to conf.c
This function is only used in conf.c. Move it there together with the randomize_choice_values() helper. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 183 + scripts/kconfig/confdata.c | 176 --- scripts/kconfig/lkc.h | 1 - 3 files changed, 183 insertions(+), 177 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 89c9ba83f9e7..caad875da483 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -112,6 +112,189 @@ static void set_randconfig_seed(void) srand(seed); } +static bool randomize_choice_values(struct symbol *csym) +{ + struct property *prop; + struct symbol *sym; + struct expr *e; + int cnt, def; + + /* +* If choice is mod then we may have more items selected +* and if no then no-one. +* In both cases stop. +*/ + if (csym->curr.tri != yes) + return false; + + prop = sym_get_choice_prop(csym); + + /* count entries in choice block */ + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) + cnt++; + + /* +* find a random value and set it to yes, +* set the rest to no so we have only one set +*/ + def = rand() % cnt; + + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) { + if (def == cnt++) { + sym->def[S_DEF_USER].tri = yes; + csym->def[S_DEF_USER].val = sym; + } else { + sym->def[S_DEF_USER].tri = no; + } + sym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + sym->flags &= ~SYMBOL_VALID; + } + csym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + csym->flags &= ~SYMBOL_VALID; + + return true; +} + +static bool conf_set_all_new_symbols(enum conf_def_mode mode) +{ + struct symbol *sym, *csym; + int i, cnt; + /* +* can't go as the default in switch-case below, otherwise gcc whines +* about -Wmaybe-uninitialized +*/ + int pby = 50; /* probability of bool = y */ + int pty = 33; /* probability of tristate = y */ + int ptm = 33; /* probability of tristate = m */ + bool has_changed = false; + + if (mode == def_random) { + int n, p[3]; + char *env = getenv("KCONFIG_PROBABILITY"); + + n = 0; + while (env && *env) { + char *endp; + int tmp = strtol(env, , 10); + + if (tmp >= 0 && tmp <= 100) { + p[n++] = tmp; + } else { + errno = ERANGE; + perror("KCONFIG_PROBABILITY"); + exit(1); + } + env = (*endp == ':') ? endp + 1 : endp; + if (n >= 3) + break; + } + switch (n) { + case 1: + pby = p[0]; + ptm = pby / 2; + pty = pby - ptm; + break; + case 2: + pty = p[0]; + ptm = p[1]; + pby = pty + ptm; + break; + case 3: + pby = p[0]; + pty = p[1]; + ptm = p[2]; + break; + } + + if (pty + ptm > 100) { + errno = ERANGE; + perror("KCONFIG_PROBABILITY"); + exit(1); + } + } + + for_all_symbols(i, sym) { + if (sym_has_value(sym) || sym->flags & SYMBOL_VALID) + continue; + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + has_changed = true; + switch (mode) { + case def_yes: + sym->def[S_DEF_USER].tri = yes; + break; + case def_mod: + sym->def[S_DEF_USER].tri = mod; + break; + case def_no: + if (sym->flags & SYMBOL_ALLNOCONFIG_Y) + sym->def[S_DEF_USER].tri = yes; + else + sym->def[S_DEF_USER].tri = no; +
[PATCH 03/13] kconfig: add long options --help and --silent
They are long options for -h and -s, respectively. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index dc1a67fd35a9..aac76acfd100 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -474,6 +474,8 @@ static void check_conf(struct menu *menu) } static struct option long_opts[] = { + {"help", no_argument, NULL,'h'}, + {"silent",no_argument, NULL,'s'}, {"oldaskconfig", no_argument, _mode_opt, oldaskconfig}, {"oldconfig", no_argument, _mode_opt, oldconfig}, {"syncconfig",no_argument, _mode_opt, syncconfig}, -- 2.27.0
[PATCH 12/13] kconfig: remove allnoconfig_y option
Now that the only user CONFIG_EMBEDDED has stopped using this option, remove it entirely. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/kconfig-language.rst | 4 scripts/kconfig/conf.c| 5 + scripts/kconfig/expr.h| 3 --- scripts/kconfig/lexer.l | 1 - scripts/kconfig/lkc.h | 1 - scripts/kconfig/menu.c| 5 - scripts/kconfig/parser.y | 6 -- 7 files changed, 1 insertion(+), 24 deletions(-) diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst index 3cbccfc42798..4a796c601446 100644 --- a/Documentation/kbuild/kconfig-language.rst +++ b/Documentation/kbuild/kconfig-language.rst @@ -234,10 +234,6 @@ applicable everywhere (see syntax). enables the third modular state for all config symbols. At most one symbol may have the "modules" option set. - - "allnoconfig_y" -This declares the symbol as one that should have the value y when -using "allnoconfig". Used for symbols that hide other symbols. - Menu dependencies - diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index caad875da483..06901120a9ea 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -232,10 +232,7 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) sym->def[S_DEF_USER].tri = mod; break; case def_no: - if (sym->flags & SYMBOL_ALLNOCONFIG_Y) - sym->def[S_DEF_USER].tri = yes; - else - sym->def[S_DEF_USER].tri = no; + sym->def[S_DEF_USER].tri = no; break; case def_random: sym->def[S_DEF_USER].tri = no; diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index dc17152b1f14..9c9caca5bd5f 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -156,9 +156,6 @@ struct symbol { /* choice values need to be set before calculating this symbol value */ #define SYMBOL_NEED_SET_CHOICE_VALUES 0x10 -/* Set symbol to y if allnoconfig; used for symbols that hide others */ -#define SYMBOL_ALLNOCONFIG_Y 0x20 - #define SYMBOL_MAXLENGTH 256 #define SYMBOL_HASHSIZE9973 diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index e918950f94a6..08c96a6ffe05 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -91,7 +91,6 @@ n [A-Za-z0-9_-] [ \t]* /* whitespaces */ \\\n /* escaped new line */ \n return T_EOL; -"allnoconfig_y"return T_ALLNOCONFIG_Y; "bool" return T_BOOL; "choice" return T_CHOICE; "comment" return T_COMMENT; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 8d89a6275197..c1ab05f73ca2 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -106,7 +106,6 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); void menu_add_option_modules(void); -void menu_add_option_allnoconfig_y(void); void menu_finalize(struct menu *parent); void menu_set_type(int type); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 5dcfc173da41..d50d0de55222 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -219,11 +219,6 @@ void menu_add_option_modules(void) modules_sym = current_entry->sym; } -void menu_add_option_allnoconfig_y(void) -{ - current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; -} - static int menu_validate_number(struct symbol *sym, struct symbol *sym2) { return sym2->type == S_INT || sym2->type == S_HEX || diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index f11d8382e9e6..2ada169c8b5d 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -45,7 +45,6 @@ static struct menu *current_menu, *current_entry; %token T_HELPTEXT %token T_WORD %token T_WORD_QUOTE -%token T_ALLNOCONFIG_Y %token T_BOOL %token T_CHOICE %token T_CLOSE_PAREN @@ -222,11 +221,6 @@ config_option: T_OPTION T_MODULES T_EOL menu_add_option_modules(); }; -config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL -{ - menu_add_option_allnoconfig_y(); -}; - /* choice entry */ choice: T_CHOICE word_opt T_EOL -- 2.27.0
[PATCH 04/13] kconfig: add help messages for --help (-h) and --silent (-s)
Add missing options and make the help message more readable. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index aac76acfd100..9ebc1acaf1ae 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -496,9 +496,13 @@ static struct option long_opts[] = { static void conf_usage(const char *progname) { - - printf("Usage: %s [-s] [option] \n", progname); - printf("[option] is _one_ of the following:\n"); + printf("Usage: %s [options] \n", progname); + printf("\n"); + printf("Generic options:\n"); + printf(" -h, --help Print this message and exit.\n"); + printf(" -s, --silentDo not print log.\n"); + printf("\n"); + printf("Mode options:\n"); printf(" --listnewconfig List new options\n"); printf(" --helpnewconfig List new options and help text\n"); printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); -- 2.27.0
[PATCH 06/13] kconfig: move conf_rewrite_mod_or_yes() to conf.c
This function is only used in conf.c. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 15 +++ scripts/kconfig/confdata.c | 15 --- scripts/kconfig/lkc.h | 1 - 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 42d35da86604..89c9ba83f9e7 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -112,6 +112,21 @@ static void set_randconfig_seed(void) srand(seed); } +static void conf_rewrite_mod_or_yes(enum conf_def_mode mode) +{ + struct symbol *sym; + int i; + tristate old_val = (mode == def_y2m) ? yes : mod; + tristate new_val = (mode == def_y2m) ? mod : yes; + + for_all_symbols(i, sym) { + if (sym_get_type(sym) == S_TRISTATE && + sym->def[S_DEF_USER].tri == old_val) + sym->def[S_DEF_USER].tri = new_val; + } + sym_clear_all_valid(); +} + static int conf_askvalue(struct symbol *sym, const char *def) { if (!sym_has_value(sym)) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2568dbe16ed6..a828622cb2d0 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -1322,18 +1322,3 @@ bool conf_set_all_new_symbols(enum conf_def_mode mode) return has_changed; } - -void conf_rewrite_mod_or_yes(enum conf_def_mode mode) -{ - struct symbol *sym; - int i; - tristate old_val = (mode == def_y2m) ? yes : mod; - tristate new_val = (mode == def_y2m) ? mod : yes; - - for_all_symbols(i, sym) { - if (sym_get_type(sym) == S_TRISTATE && - sym->def[S_DEF_USER].tri == old_val) - sym->def[S_DEF_USER].tri = new_val; - } - sym_clear_all_valid(); -} diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index bee2413bda63..f946ab49ef50 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -58,7 +58,6 @@ const char *conf_get_configname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); bool conf_set_all_new_symbols(enum conf_def_mode mode); -void conf_rewrite_mod_or_yes(enum conf_def_mode mode); void set_all_choice_values(struct symbol *csym); /* confdata.c and expr.c */ -- 2.27.0
[PATCH 01/13] kconfig: split randconfig setup code into set_randconfig_seed()
This code is too big to be placed in the switch statement. Move the code into a new helper function. I slightly refactor the code without changing the behavior. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 54 -- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 957d2a0832f7..063c9e7a34c1 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -82,6 +82,36 @@ static void xfgets(char *str, int size, FILE *in) printf("%s", str); } +static void set_randconfig_seed(void) +{ + unsigned int seed; + char *env; + bool seed_set = false; + + env = getenv("KCONFIG_SEED"); + if (env && *env) { + char *endp; + + seed = strtol(env, , 0); + if (*endp == '\0') + seed_set = true; + } + + if (!seed_set) { + struct timeval now; + + /* +* Use microseconds derived seed, compensate for systems where it may +* be zero. +*/ + gettimeofday(, NULL); + seed = (now.tv_sec + 1) * (now.tv_usec + 1); + } + + printf("KCONFIG_SEED=0x%X\n", seed); + srand(seed); +} + static int conf_askvalue(struct symbol *sym, const char *def) { if (!sym_has_value(sym)) @@ -515,30 +545,8 @@ int main(int ac, char **av) defconfig_file = optarg; break; case randconfig: - { - struct timeval now; - unsigned int seed; - char *seed_env; - - /* -* Use microseconds derived seed, -* compensate for systems where it may be zero -*/ - gettimeofday(, NULL); - seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); - - seed_env = getenv("KCONFIG_SEED"); - if( seed_env && *seed_env ) { - char *endp; - int tmp = (int)strtol(seed_env, , 0); - if (*endp == '\0') { - seed = tmp; - } - } - fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed ); - srand(seed); + set_randconfig_seed(); break; - } case oldaskconfig: case oldconfig: case allnoconfig: -- 2.27.0