Skip to contentSkip to conversation

kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)

PATCH Superseded Masahiro Yamada 7 participants 41 messages May 13, 2022 – Aug 20, 2022

Subsystems (8)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)

This is the third batch of cleanups in this development cycle.

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.
https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission
https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export
Signature · 1 line
2.32.0
#1 lore raw

PATCH v6 1/10 modpost: extract symbol versions from *.cmd files

Currently, CONFIG_MODVERSIONS needs extra link to embed the symbol versions into ELF objects. Then, modpost extracts the version CRCs from them.

The following figures show how it currently works, and how I am trying to change it.

Current implementation
======================

                                                           |----------|
                 embed CRC      -------------------------->| final    |
       $(CC)       $(LD)       /  |---------|              | link for |
       -----> *.o -------> *.o -->| modpost |              | vmlinux  |
      /              /            |         |-- *.mod.c -->| or       |
     / genksyms     /             |---------|              | module   |
  *.c ------> *.symversions                                |----------|

Genksyms outputs the calculated CRCs in the form of linker script (*.symversions), which is used by $(LD) to update the object.

If CONFIG_LTO_CLANG=y, the build process is much more complex. Embedding the CRCs is postponed until the LLVM bitcode is converted into ELF, creating another intermediate *.prelink.o.

However, this complexity is unneeded. There is no reason why we must embed version CRCs in objects so early.

There is final link stage for vmlinux (scripts/link-vmlinux.sh) and modules (scripts/Makefile.modfinal). We can link CRCs at the very last moment.

New implementation
==================

                                                           |----------|
                   --------------------------------------->| final    |
       $(CC)      /    |---------|                         | link for |
       -----> *.o ---->|         |                         | vmlinux  |
      /                | modpost |--- .vmlinux.export.c -->| or       |
     / genksyms        |         |--- *.mod.c ------------>| module   |
  *.c ------> *.cmd -->|---------|                         |----------|

Pass the symbol versions to modpost as separate text data, which are available in *.cmd files.

This commit changes modpost to extract CRCs from *.cmd files instead of from ELF objects.

---

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)

 scripts/mod/modpost.c | 179 +++++++++++++++++++++++++++++++-----------
 1 file changed, 131 insertions(+), 48 deletions(-)
scripts/mod/modpost.c +131 -48
index fc5db1f73cf1..213a130d1635 100644
@@ -381,19 +381,10 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,
 	return s;
 }
 
-static void sym_set_crc(const char *name, unsigned int crc)
+static void sym_set_crc(struct symbol *sym, unsigned int crc)
 {
-	struct symbol *s = find_symbol(name);
-
-	/*
-	 * Ignore stand-alone __crc_*, which might be auto-generated symbols
-	 * such as __*_veneer in ARM ELF.
-	 */
-	if (!s)
-		return;
-
-	s->crc = crc;
-	s->crc_valid = true;
+	sym->crc = crc;
+	sym->crc_valid = true;
 }
 
 static void *grab_file(const char *filename, size_t *size)
@@ -616,33 +607,6 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
 	return 0;
 }
 
-static void handle_modversion(const struct module *mod,
-			      const struct elf_info *info,
-			      const Elf_Sym *sym, const char *symname)
-{
-	unsigned int crc;
-
-	if (sym->st_shndx == SHN_UNDEF) {
-		warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n"
-		     "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n",
-		     symname, mod->name, mod->is_vmlinux ? "" : ".ko",
-		     symname);
-
-		return;
-	}
-
-	if (sym->st_shndx == SHN_ABS) {
-		crc = sym->st_value;
-	} else {
-		unsigned int *crcp;
-
-		/* symbol points to the CRC in the ELF object */
-		crcp = sym_get_data(info, sym);
-		crc = TO_NATIVE(*crcp);
-	}
-	sym_set_crc(symname, crc);
-}
-
 static void handle_symbol(struct module *mod, struct elf_info *info,
 			  const Elf_Sym *sym, const char *symname)
 {
@@ -760,6 +724,104 @@ static char *remove_dot(char *s)
 	return s;
 }
 
+/*
+ * The CRCs are recorded in .*.cmd files in the form of:
+ * #SYMVER <name> <crc>
+ */
+static void extract_crcs_for_object(const char *object, struct module *mod)
+{
+	char cmd_file[PATH_MAX];
+	char *buf, *p;
+	const char *base;
+	int dirlen, ret;
+
+	base = strrchr(object, '/');
+	if (base) {
+		base++;
+		dirlen = base - object;
+	} else {
+		dirlen = 0;
+		base = object;
+	}
+
+	ret = snprintf(cmd_file, sizeof(cmd_file), "%.*s.%s.cmd",
+		       dirlen, object, base);
+	if (ret >= sizeof(cmd_file)) {
+		error("%s: too long path was truncated\n", cmd_file);
+		return;
+	}
+
+	buf = read_text_file(cmd_file);
+	p = buf;
+
+	while ((p = strstr(p, "\n#SYMVER "))) {
+		char *name;
+		size_t namelen;
+		unsigned int crc;
+		struct symbol *sym;
+
+		name = p + strlen("\n#SYMVER ");
+
+		p = strchr(name, ' ');
+		if (!p)
+			break;
+
+		namelen = p - name;
+		p++;
+
+		if (!isdigit(*p))
+			continue;	/* skip this line */
+
+		crc = strtol(p, &p, 0);
+		if (*p != '\n')
+			continue;	/* skip this line */
+
+		name[namelen] = '\0';
+
+		/*
+		 * sym_find_with_module() may return NULL here.
+		 * It typically occurs when CONFIG_TRIM_UNUSED_KSYMS=y.
+		 * Since commit e1327a127703, genksyms calculates CRCs of all
+		 * symbols, including trimmed ones. Ignore orphan CRCs.
+		 */
+		sym = sym_find_with_module(name, mod);
+		if (sym)
+			sym_set_crc(sym, crc);
+	}
+
+	free(buf);
+}
+
+/*
+ * The symbol versions (CRC) are recorded in the .*.cmd files.
+ * Parse them to retrieve CRCs for the current module.
+ */
+static void mod_set_crcs(struct module *mod)
+{
+	char objlist[PATH_MAX];
+	char *buf, *p, *obj;
+	int ret;
+
+	if (mod->is_vmlinux) {
+		strcpy(objlist, ".vmlinux.objs");
+	} else {
+		/* objects for a module are listed in the *.mod file. */
+		ret = snprintf(objlist, sizeof(objlist), "%s.mod", mod->name);
+		if (ret >= sizeof(objlist)) {
+			error("%s: too long path was truncated\n", objlist);
+			return;
+		}
+	}
+
+	buf = read_text_file(objlist);
+	p = buf;
+
+	while ((obj = strsep(&p, "\n")) && obj[0])
+		extract_crcs_for_object(obj, mod);
+
+	free(buf);
+}
+
 static void read_symbols(const char *modname)
 {
 	const char *symname;
@@ -820,9 +882,6 @@ static void read_symbols(const char *modname)
 		if (strstarts(symname, "__kstrtabns_"))
 			sym_update_namespace(symname + strlen("__kstrtabns_"),
 					     sym_get_data(&info, sym));
-		if (strstarts(symname, "__crc_"))
-			handle_modversion(mod, &info, sym,
-					  symname + strlen("__crc_"));
 	}
 
 	// check for static EXPORT_SYMBOL_* functions && global vars
@@ -850,12 +909,17 @@ static void read_symbols(const char *modname)
 
 	parse_elf_finish(&info);
 
-	/* Our trick to get versioning for module struct etc. - it's
-	 * never passed as an argument to an exported function, so
-	 * the automatic versioning doesn't pick it up, but it's really
-	 * important anyhow */
-	if (modversions)
+	if (modversions) {
+		/*
+		 * Our trick to get versioning for module struct etc. - it's
+		 * never passed as an argument to an exported function, so
+		 * the automatic versioning doesn't pick it up, but it's really
+		 * important anyhow.
+		 */
 		sym_add_unresolved("module_layout", mod, false);
+
+		mod_set_crcs(mod);
+	}
 }
 
 static void read_symbols_from_files(const char *filename)
@@ -1012,6 +1076,23 @@ static void add_header(struct buffer *b, struct module *mod)
 		buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
 }
 
+static void check_symversions(struct module *mod)
+{
+	struct symbol *sym;
+
+	if (!modversions)
+		return;
+
+	list_for_each_entry(sym, &mod->exported_symbols, list) {
+		if (!sym->crc_valid) {
+			warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n"
+			     "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n",
+			     sym->name, mod->name, mod->is_vmlinux ? "" : ".ko",
+			     sym->name);
+		}
+	}
+}
+
 /**
  * Record CRCs for unresolved symbols
  **/
@@ -1227,7 +1308,7 @@ static void read_dump(const char *fname)
 		}
 		s = sym_add_exported(symname, mod, gpl_only);
 		s->is_static = false;
-		sym_set_crc(symname, crc);
+		sym_set_crc(s, crc);
 		sym_update_namespace(symname, namespace);
 	}
 	free(buf);
@@ -1353,6 +1434,8 @@ int main(int argc, char **argv)
 		if (mod->from_dump)
 			continue;
 
+		check_symversions(mod);
+
 		if (!mod->is_vmlinux)
 			write_mod_c_file(mod);
 	}
Signature · 1 line
2.32.0
#2 lore raw

Re: [PATCH v6 01/10] modpost: extract symbol versions from *.cmd files

Hi,

Quoted 4 lines · Masahiro Yamada

Currently, CONFIG_MODVERSIONS needs extra link to embed the symbol versions into ELF objects. Then, modpost extracts the version CRCs from them.

[ ... ]

Quoted 7 lines

This commit changes modpost to extract CRCs from *.cmd files instead of from ELF objects.

This patch results in

._muldi3_di.o.cmd: No such file or directory

when building parisc64:defconfig, and

._divsi3.o.cmd: No such file or directory

when building csky:allmodconfig.

Reverting this patch (and the subsequent kbuild patches to avoid conflicts) fixes the problem for both architectures. In case it helps, the complete build log when rebuilding an image for csky is as follows.

#
# No change to .config
#

  HOSTCC  scripts/mod/modpost.o
  HOSTLD  scripts/mod/modpost
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  SO2S    arch/csky/kernel/vdso/vdso-syms.S
  AS      arch/csky/kernel/vdso/vdso-syms.o
  AR      arch/csky/kernel/vdso/built-in.a
  AR      arch/csky/kernel/built-in.a
  CHK     kernel/kheaders_data.tar.xz
  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
._divsi3.o.cmd: No such file or directory
make[1]: *** [scripts/Makefile.modpost:59: vmlinux.symvers] Error 1
make: *** [Makefile:1159: vmlinux] Error 2

This was seen with gcc 11.2 and 11.3.

Guenter

---
bisect on mainline:

# bad: [9d004b2f4fea97cde123e7f1939b80e77bf2e695] Merge tag 'cxl-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
# good: [4b0986a3613c92f4ec1bdc7f60ec66fea135991f] Linux 5.18
git bisect start 'HEAD' 'v5.18'
# good: [86c87bea6b42100c67418af690919c44de6ede6e] Merge tag 'devicetree-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
git bisect good 86c87bea6b42100c67418af690919c44de6ede6e
# good: [c011dd537ffe47462051930413fed07dbdc80313] Merge tag 'arm-soc-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good c011dd537ffe47462051930413fed07dbdc80313
# bad: [df202b452fe6c6d6f1351bad485e2367ef1e644e] Merge tag 'kbuild-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
git bisect bad df202b452fe6c6d6f1351bad485e2367ef1e644e
# good: [d4dcdc53c492a7b9fa9031cb85e238b21208ada2] Merge tag 'qcom-arm64-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into arm/dt git bisect good d4dcdc53c492a7b9fa9031cb85e238b21208ada2
# good: [ae862183285cbb2ef9032770d98ffa9becffe9d5] Merge tag 'arm-dt-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good ae862183285cbb2ef9032770d98ffa9becffe9d5
# good: [cc3c470ae4ad758b8ddad825ab199f7eaa8b0a9e] Merge tag 'arm-drivers-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good cc3c470ae4ad758b8ddad825ab199f7eaa8b0a9e
# good: [ecf0aa5317b0ad6bb015128a5b763c954fd58708] Merge tag 'arm-multiplatform-5.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good ecf0aa5317b0ad6bb015128a5b763c954fd58708
# good: [4484054816cab940fc2fde23fa989174fec889d0] modpost: use doubly linked list for dump_lists
git bisect good 4484054816cab940fc2fde23fa989174fec889d0
# good: [16477cdfefdb494235a675cc80563d736991d833] Merge tag 'asm-generic-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
git bisect good 16477cdfefdb494235a675cc80563d736991d833
# good: [a44abaca0e196cfeef2374ed663b97daa1ad112a] modpost: move *.mod.c generation to write_mod_c_files()
git bisect good a44abaca0e196cfeef2374ed663b97daa1ad112a
# good: [69c4cc99bbcbf3ef2e1901b569954e9226180840] modpost: add sym_find_with_module() helper
git bisect good 69c4cc99bbcbf3ef2e1901b569954e9226180840
# bad: [7b4537199a4a8480b8c3ba37a2d44765ce76cd9b] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS
git bisect bad 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b
# bad: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files
git bisect bad f292d875d0dc700b3af0bef04c5abc1dc7b3b62c

# first bad commit: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files

---
bisect on kbuild-5.19:

# bad: [5ce2176b81f77366bd02c27509b83049f0020544] genksyms: adjust the output format to modpost
# good: [3123109284176b1532874591f7c81f3837bbdc17] Linux 5.18-rc1
git bisect start 'HEAD' 'v5.18-rc1'
# good: [70ddb48db4aaddd3c2a7d8802463e15b21ce8525] modpost: move struct namespace_list to modpost.c git bisect good 70ddb48db4aaddd3c2a7d8802463e15b21ce8525
# good: [e76cc48d8e6df5d949284132981db73d2dd8c6b5] modpost: make sym_add_exported() always allocate a new symbol git bisect good e76cc48d8e6df5d949284132981db73d2dd8c6b5
# good: [78e9e56af3858bf2c52c065daa6c8bee0d72048c] kbuild: record symbol versions in *.cmd files
git bisect good 78e9e56af3858bf2c52c065daa6c8bee0d72048c
# good: [69c4cc99bbcbf3ef2e1901b569954e9226180840] modpost: add sym_find_with_module() helper
git bisect good 69c4cc99bbcbf3ef2e1901b569954e9226180840
# bad: [7b4537199a4a8480b8c3ba37a2d44765ce76cd9b] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS git bisect bad 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b
# bad: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files git bisect bad f292d875d0dc700b3af0bef04c5abc1dc7b3b62c

# first bad commit: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files
#3 lore raw

Re: [PATCH v6 01/10] modpost: extract symbol versions from *.cmd files

Quoted 23 lines · Guenter Roeck

Hi,

Quoted 4 lines · Masahiro Yamada

Currently, CONFIG_MODVERSIONS needs extra link to embed the symbol versions into ELF objects. Then, modpost extracts the version CRCs from them.

[ ... ]

Quoted 7 lines

This commit changes modpost to extract CRCs from *.cmd files instead of from ELF objects.

This patch results in

._muldi3_di.o.cmd: No such file or directory

when building parisc64:defconfig, and

Quoted 8 lines

._divsi3.o.cmd: No such file or directory

when building csky:allmodconfig.

Reverting this patch (and the subsequent kbuild patches to avoid conflicts) fixes the problem for both architectures. In case it helps, the complete build log when rebuilding an image for csky is as follows.

Thank you for the report!

This commit has been in the tree for a while
but I did not get this kind of report from the 0-day bot.

The wide test coverage from your system is very helpful. I just submitted a fix.

Thank you.

Quoted 80 lines

#
# No change to .config
#

  HOSTCC  scripts/mod/modpost.o
  HOSTLD  scripts/mod/modpost
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  SO2S    arch/csky/kernel/vdso/vdso-syms.S
  AS      arch/csky/kernel/vdso/vdso-syms.o
  AR      arch/csky/kernel/vdso/built-in.a
  AR      arch/csky/kernel/built-in.a
  CHK     kernel/kheaders_data.tar.xz
  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
._divsi3.o.cmd: No such file or directory
make[1]: *** [scripts/Makefile.modpost:59: vmlinux.symvers] Error 1
make: *** [Makefile:1159: vmlinux] Error 2

This was seen with gcc 11.2 and 11.3.

Guenter

---
bisect on mainline:

# bad: [9d004b2f4fea97cde123e7f1939b80e77bf2e695] Merge tag 'cxl-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
# good: [4b0986a3613c92f4ec1bdc7f60ec66fea135991f] Linux 5.18
git bisect start 'HEAD' 'v5.18'
# good: [86c87bea6b42100c67418af690919c44de6ede6e] Merge tag 'devicetree-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
git bisect good 86c87bea6b42100c67418af690919c44de6ede6e
# good: [c011dd537ffe47462051930413fed07dbdc80313] Merge tag 'arm-soc-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good c011dd537ffe47462051930413fed07dbdc80313
# bad: [df202b452fe6c6d6f1351bad485e2367ef1e644e] Merge tag 'kbuild-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
git bisect bad df202b452fe6c6d6f1351bad485e2367ef1e644e
# good: [d4dcdc53c492a7b9fa9031cb85e238b21208ada2] Merge tag 'qcom-arm64-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into arm/dt git bisect good d4dcdc53c492a7b9fa9031cb85e238b21208ada2
# good: [ae862183285cbb2ef9032770d98ffa9becffe9d5] Merge tag 'arm-dt-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good ae862183285cbb2ef9032770d98ffa9becffe9d5
# good: [cc3c470ae4ad758b8ddad825ab199f7eaa8b0a9e] Merge tag 'arm-drivers-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good cc3c470ae4ad758b8ddad825ab199f7eaa8b0a9e
# good: [ecf0aa5317b0ad6bb015128a5b763c954fd58708] Merge tag 'arm-multiplatform-5.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good ecf0aa5317b0ad6bb015128a5b763c954fd58708
# good: [4484054816cab940fc2fde23fa989174fec889d0] modpost: use doubly linked list for dump_lists
git bisect good 4484054816cab940fc2fde23fa989174fec889d0
# good: [16477cdfefdb494235a675cc80563d736991d833] Merge tag 'asm-generic-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
git bisect good 16477cdfefdb494235a675cc80563d736991d833
# good: [a44abaca0e196cfeef2374ed663b97daa1ad112a] modpost: move *.mod.c generation to write_mod_c_files()
git bisect good a44abaca0e196cfeef2374ed663b97daa1ad112a
# good: [69c4cc99bbcbf3ef2e1901b569954e9226180840] modpost: add sym_find_with_module() helper
git bisect good 69c4cc99bbcbf3ef2e1901b569954e9226180840
# bad: [7b4537199a4a8480b8c3ba37a2d44765ce76cd9b] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS
git bisect bad 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b
# bad: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files
git bisect bad f292d875d0dc700b3af0bef04c5abc1dc7b3b62c

# first bad commit: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files

---
bisect on kbuild-5.19:

# bad: [5ce2176b81f77366bd02c27509b83049f0020544] genksyms: adjust the output format to modpost
# good: [3123109284176b1532874591f7c81f3837bbdc17] Linux 5.18-rc1
git bisect start 'HEAD' 'v5.18-rc1'
# good: [70ddb48db4aaddd3c2a7d8802463e15b21ce8525] modpost: move struct namespace_list to modpost.c git bisect good 70ddb48db4aaddd3c2a7d8802463e15b21ce8525
# good: [e76cc48d8e6df5d949284132981db73d2dd8c6b5] modpost: make sym_add_exported() always allocate a new symbol git bisect good e76cc48d8e6df5d949284132981db73d2dd8c6b5
# good: [78e9e56af3858bf2c52c065daa6c8bee0d72048c] kbuild: record symbol versions in *.cmd files
git bisect good 78e9e56af3858bf2c52c065daa6c8bee0d72048c
# good: [69c4cc99bbcbf3ef2e1901b569954e9226180840] modpost: add sym_find_with_module() helper
git bisect good 69c4cc99bbcbf3ef2e1901b569954e9226180840
# bad: [7b4537199a4a8480b8c3ba37a2d44765ce76cd9b] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS git bisect bad 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b
# bad: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files git bisect bad f292d875d0dc700b3af0bef04c5abc1dc7b3b62c

Quoted 1 line
# first bad commit: [f292d875d0dc700b3af0bef04c5abc1dc7b3b62c] modpost: extract symbol versions from *.cmd files

--
Best Regards
Masahiro Yamada

#4 lore raw

PATCH v6 2/10 kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS

In reply to Masahiro Yamada

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

---

(no changes since v5)

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.

Changes in v3:
- New patch

 arch/m68k/include/asm/Kbuild    |  1 +
 arch/m68k/include/asm/export.h  |  2 --
 arch/powerpc/Kconfig            |  1 -
 arch/s390/Kconfig               |  1 -
 arch/um/Kconfig                 |  1 -
 include/asm-generic/export.h    | 22 ++++++++--------------
 include/linux/export-internal.h | 16 ++++++++++++++++
 include/linux/export.h          | 30 ++++++++----------------------
 init/Kconfig                    |  4 ----
 kernel/module.c                 | 10 +---------
 scripts/Makefile.build          | 27 ++++-----------------------
 scripts/genksyms/genksyms.c     | 18 ++++--------------
 scripts/link-vmlinux.sh         | 14 +++++++++++++-
 scripts/mod/modpost.c           | 28 ++++++++++++++++++++++++----
 14 files changed, 79 insertions(+), 96 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
arch/m68k/include/asm/Kbuild +1 -0
index 0dbf9c5c6fae..1b720299deb1 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 generated-y += syscall_table.h
+generic-y += export.h
 generic-y += extable.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
arch/m68k/include/asm/export.h deleted +0 -2
deleted file mode 100644
index b53008b67ce1..000000000000
@@ -1,2 +0,0 @@
-#define KCRC_ALIGN 2
-#include <asm-generic/export.h>
arch/powerpc/Kconfig +0 -1
index 174edabb74fa..a4e8dd889e29 100644
@@ -566,7 +566,6 @@ config RELOCATABLE
 	bool "Build a relocatable kernel"
 	depends on PPC64 || (FLATMEM && (44x || FSL_BOOKE))
 	select NONSTATIC_KERNEL
-	select MODULE_REL_CRCS if MODVERSIONS
 	help
 	  This builds a kernel image that is capable of running at the
 	  location the kernel is loaded at. For ppc32, there is no any
arch/s390/Kconfig +0 -1
index 77b5a03de13a..aa5848004c76 100644
@@ -567,7 +567,6 @@ endchoice
 
 config RELOCATABLE
 	bool "Build a relocatable kernel"
-	select MODULE_REL_CRCS if MODVERSIONS
 	default y
 	help
 	  This builds a kernel image that retains relocation information
arch/um/Kconfig +0 -1
index 4d398b80aea8..e8983d098e73 100644
@@ -106,7 +106,6 @@ config LD_SCRIPT_DYN
 	bool
 	default y
 	depends on !LD_SCRIPT_STATIC
-	select MODULE_REL_CRCS if MODVERSIONS
 
 config LD_SCRIPT_DYN_RPATH
 	bool "set rpath in the binary" if EXPERT
include/asm-generic/export.h +8 -14
index 07a36a874dca..5e4b1f2369d2 100644
@@ -2,6 +2,14 @@
 #ifndef __ASM_GENERIC_EXPORT_H
 #define __ASM_GENERIC_EXPORT_H
 
+/*
+ * This comment block is used by fixdep. Please do not remove.
+ *
+ * When CONFIG_MODVERSIONS is changed from n to y, all source files having
+ * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
+ * side effect of the *.o build rule.
+ */
+
 #ifndef KSYM_FUNC
 #define KSYM_FUNC(x) x
 #endif
@@ -12,9 +20,6 @@
 #else
 #define KSYM_ALIGN 4
 #endif
-#ifndef KCRC_ALIGN
-#define KCRC_ALIGN 4
-#endif
 
 .macro __put, val, name
 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
@@ -43,17 +48,6 @@ __ksymtab_\name:
 __kstrtab_\name:
 	.asciz "\name"
 	.previous
-#ifdef CONFIG_MODVERSIONS
-	.section ___kcrctab\sec+\name,"a"
-	.balign KCRC_ALIGN
-#if defined(CONFIG_MODULE_REL_CRCS)
-	.long __crc_\name - .
-#else
-	.long __crc_\name
-#endif
-	.weak __crc_\name
-	.previous
-#endif
 #endif
 .endm
 
include/linux/export-internal.h new file +16 -0
new file mode 100644
index 000000000000..77175d561058
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Please do not include this explicitly.
+ * This is used by C files generated by modpost.
+ */
+
+#ifndef __LINUX_EXPORT_INTERNAL_H__
+#define __LINUX_EXPORT_INTERNAL_H__
+
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#define SYMBOL_CRC(sym, crc, sec)   \
+	u32 __section("___kcrctab" sec "+" #sym) __crc_##sym = crc
+
+#endif /* __LINUX_EXPORT_INTERNAL_H__ */
include/linux/export.h +8 -22
index 27d848712b90..565c5ffcb26f 100644
@@ -11,6 +11,14 @@
  * hackers place grumpy comments in header files.
  */
 
+/*
+ * This comment block is used by fixdep. Please do not remove.
+ *
+ * When CONFIG_MODVERSIONS is changed from n to y, all source files having
+ * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
+ * side effect of the *.o build rule.
+ */
+
 #ifndef __ASSEMBLY__
 #ifdef MODULE
 extern struct module __this_module;
@@ -19,26 +27,6 @@ extern struct module __this_module;
 #define THIS_MODULE ((struct module *)0)
 #endif
 
-#ifdef CONFIG_MODVERSIONS
-/* Mark the CRC weak since genksyms apparently decides not to
- * generate a checksums for some symbols */
-#if defined(CONFIG_MODULE_REL_CRCS)
-#define __CRC_SYMBOL(sym, sec)						\
-	asm("	.section \"___kcrctab" sec "+" #sym "\", \"a\"	\n"	\
-	    "	.weak	__crc_" #sym "				\n"	\
-	    "	.long	__crc_" #sym " - .			\n"	\
-	    "	.previous					\n")
-#else
-#define __CRC_SYMBOL(sym, sec)						\
-	asm("	.section \"___kcrctab" sec "+" #sym "\", \"a\"	\n"	\
-	    "	.weak	__crc_" #sym "				\n"	\
-	    "	.long	__crc_" #sym "				\n"	\
-	    "	.previous					\n")
-#endif
-#else
-#define __CRC_SYMBOL(sym, sec)
-#endif
-
 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
 #include <linux/compiler.h>
 /*
@@ -85,7 +73,6 @@ struct kernel_symbol {
 /*
  * For every exported symbol, do the following:
  *
- * - If applicable, place a CRC entry in the __kcrctab section.
  * - Put the name of the symbol and namespace (empty string "" for none) in
  *   __ksymtab_strings.
  * - Place a struct kernel_symbol entry in the __ksymtab section.
@@ -98,7 +85,6 @@ struct kernel_symbol {
 	extern typeof(sym) sym;							\
 	extern const char __kstrtab_##sym[];					\
 	extern const char __kstrtabns_##sym[];					\
-	__CRC_SYMBOL(sym, sec);							\
 	asm("	.section \"__ksymtab_strings\",\"aMS\",%progbits,1	\n"	\
 	    "__kstrtab_" #sym ":					\n"	\
 	    "	.asciz 	\"" #sym "\"					\n"	\
init/Kconfig +0 -4
index ddcbefe535e9..f5b14318dfcb 100644
@@ -2136,10 +2136,6 @@ config ASM_MODVERSIONS
 	  assembly. This can be enabled only when the target architecture
 	  supports it.
 
-config MODULE_REL_CRCS
-	bool
-	depends on MODVERSIONS
-
 config MODULE_SRCVERSION_ALL
 	bool "Source checksum for all modules"
 	help
kernel/module.c +1 -9
index 6cea788fd965..c9e2342da28e 100644
@@ -1231,11 +1231,6 @@ static int try_to_force_load(struct module *mod, const char *reason)
 
 #ifdef CONFIG_MODVERSIONS
 
-static u32 resolve_rel_crc(const s32 *crc)
-{
-	return *(u32 *)((void *)crc + *crc);
-}
-
 static int check_version(const struct load_info *info,
 			 const char *symname,
 			 struct module *mod,
@@ -1264,10 +1259,7 @@ static int check_version(const struct load_info *info,
 		if (strcmp(versions[i].name, symname) != 0)
 			continue;
 
-		if (IS_ENABLED(CONFIG_MODULE_REL_CRCS))
-			crcval = resolve_rel_crc(crc);
-		else
-			crcval = *crc;
+		crcval = *crc;
 		if (versions[i].crc == crcval)
 			return 1;
 		pr_debug("Found checksum %X vs module %lX\n",
scripts/Makefile.build +4 -23
index a1023868775f..ddd9080fc028 100644
@@ -128,7 +128,6 @@ $(obj)/%.i: $(src)/%.c FORCE
 
 genksyms = scripts/genksyms/genksyms		\
 	$(if $(1), -T $(2))			\
-	$(if $(CONFIG_MODULE_REL_CRCS), -R)	\
 	$(if $(KBUILD_PRESERVE), -p)		\
 	-r $(or $(wildcard $(2:.symtypes=.symref)), /dev/null)
 
@@ -162,19 +161,11 @@ ifdef CONFIG_MODVERSIONS
 # o if <file>.o doesn't contain a __ksymtab version, i.e. does
 #   not export symbols, it's done.
 # o otherwise, we calculate symbol versions using the good old
-#   genksyms on the preprocessed source and postprocess them in a way
-#   that they are usable as a linker script
-# o generate .tmp_<file>.o from <file>.o using the linker to
-#   replace the unresolved symbols __crc_exported_symbol with
-#   the actual value of the checksum generated by genksyms
-# o remove .tmp_<file>.o to <file>.o
+#   genksyms on the preprocessed source and dump them into the .cmd file.
+# o modpost will extract versions from that file and create *.c files that will
+#   be compiled and linked to the kernel and/or modules.
 
-# Generate .o.symversions files for each .o with exported symbols, and link these
-# to the kernel and/or modules at the end.
-
-genksyms_format_rel_crc := [^_]*__crc_\([^ ]*\) = \.; LONG(\([^)]*\)).*
-genksyms_format_normal := __crc_\(.*\) = \(.*\);
-genksyms_format := $(if $(CONFIG_MODULE_REL_CRCS),$(genksyms_format_rel_crc),$(genksyms_format_normal))
+genksyms_format := __crc_\(.*\) = \(.*\);
 
 gen_symversions =								\
 	if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then			\
@@ -188,12 +179,6 @@ gen_symversions =								\
 
 cmd_gen_symversions_c =	$(call gen_symversions,c)
 
-cmd_modversions =								\
-	if [ -r [email protected] ]; then						\
-		$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ 		\
-			-T [email protected];					\
-		mv -f $(@D)/.tmp_$(@F) $@;					\
-	fi
 endif
 
 ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
@@ -273,7 +258,6 @@ define rule_cc_o_c
 	$(call cmd,checkdoc)
 	$(call cmd,gen_objtooldep)
 	$(call cmd,gen_symversions_c)
-	$(if $(CONFIG_LTO_CLANG),,$(call cmd,modversions))
 	$(call cmd,record_mcount)
 endef
 
@@ -282,7 +266,6 @@ define rule_as_o_S
 	$(call cmd,gen_ksymdeps)
 	$(call cmd,gen_objtooldep)
 	$(call cmd,gen_symversions_S)
-	$(call cmd,modversions)
 endef
 
 # Built-in and composite module parts
@@ -296,8 +279,6 @@ ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
 quiet_cmd_cc_prelink_modules = LD [M]  $@
       cmd_cc_prelink_modules =						\
 	$(LD) $(ld_flags) -r -o $@					\
-               $(shell [ -s $(@:.prelink.o=.o.symversions) ] &&		\
-                       echo -T $(@:.prelink.o=.o.symversions))		\
 		--whole-archive $(filter-out FORCE,$^)			\
 		$(cmd_objtool)
 
scripts/genksyms/genksyms.c +4 -14
index 4827c5abe5b7..67b23cc0df0f 100644
@@ -33,7 +33,7 @@ char *cur_filename;
 int in_source_file;
 
 static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
-	   flag_preserve, flag_warnings, flag_rel_crcs;
+	   flag_preserve, flag_warnings;
 
 static int errors;
 static int nsyms;
@@ -680,11 +680,7 @@ void export_symbol(const char *name)
 		if (flag_dump_defs)
 			fputs(">\n", debugfile);
 
-		/* Used as a linker script. */
-		printf(!flag_rel_crcs ? "__crc_%s = 0x%08lx;\n" :
-		       "SECTIONS { .rodata : ALIGN(4) { "
-		       "__crc_%s = .; LONG(0x%08lx); } }\n",
-		       name, crc);
+		printf("__crc_%s = 0x%08lx;\n", name, crc);
 	}
 }
 
@@ -733,7 +729,6 @@ static void genksyms_usage(void)
 	      "  -q, --quiet           Disable warnings (default)\n"
 	      "  -h, --help            Print this message\n"
 	      "  -V, --version         Print the release version\n"
-	      "  -R, --relative-crc    Emit section relative symbol CRCs\n"
 #else				/* __GNU_LIBRARY__ */
 	      "  -s                    Select symbol prefix\n"
 	      "  -d                    Increment the debug level (repeatable)\n"
@@ -745,7 +740,6 @@ static void genksyms_usage(void)
 	      "  -q                    Disable warnings (default)\n"
 	      "  -h                    Print this message\n"
 	      "  -V                    Print the release version\n"
-	      "  -R                    Emit section relative symbol CRCs\n"
 #endif				/* __GNU_LIBRARY__ */
 	      , stderr);
 }
@@ -766,14 +760,13 @@ int main(int argc, char **argv)
 		{"preserve", 0, 0, 'p'},
 		{"version", 0, 0, 'V'},
 		{"help", 0, 0, 'h'},
-		{"relative-crc", 0, 0, 'R'},
 		{0, 0, 0, 0}
 	};
 
-	while ((o = getopt_long(argc, argv, "s:dwqVDr:T:phR",
+	while ((o = getopt_long(argc, argv, "s:dwqVDr:T:ph",
 				&long_opts[0], NULL)) != EOF)
 #else				/* __GNU_LIBRARY__ */
-	while ((o = getopt(argc, argv, "s:dwqVDr:T:phR")) != EOF)
+	while ((o = getopt(argc, argv, "s:dwqVDr:T:ph")) != EOF)
 #endif				/* __GNU_LIBRARY__ */
 		switch (o) {
 		case 'd':
@@ -813,9 +806,6 @@ int main(int argc, char **argv)
 		case 'h':
 			genksyms_usage();
 			return 0;
-		case 'R':
-			flag_rel_crcs = 1;
-			break;
 		default:
 			genksyms_usage();
 			return 1;
scripts/link-vmlinux.sh +13 -1
index eceb3ee7ec06..7313cbd755df 100755
@@ -90,7 +90,6 @@ modpost_link()
 
 		if is_enabled CONFIG_MODVERSIONS; then
 			gen_symversions
-			lds="${lds} -T .tmp_symversions.lds"
 		fi
 
 		# This might take a while, so indicate that we're doing
@@ -183,6 +182,10 @@ vmlinux_link()
 		libs="${KBUILD_VMLINUX_LIBS}"
 	fi
 
+	if is_enabled CONFIG_MODULES; then
+		objs="${objs} .vmlinux.export.o"
+	fi
+
 	if [ "${SRCARCH}" = "um" ]; then
 		wl=-Wl,
 		ld="${CC}"
@@ -312,6 +315,7 @@ cleanup()
 	rm -f vmlinux.o
 	rm -f .vmlinux.d
 	rm -f .vmlinux.objs
+	rm -f .vmlinux.export.c
 }
 
 # Use "make V=1" to debug this script
@@ -363,6 +367,14 @@ info GEN modules.builtin
 tr '\0' '\n' < modules.builtin.modinfo | sed -n 's/^[[:alnum:]:_]*\.file=//p' |
 	tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$/.ko/' > modules.builtin
 
+if is_enabled CONFIG_MODULES; then
+	info CC .vmlinux.export.c
+	${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} \
+	      ${KBUILD_CPPFLAGS} ${KBUILD_CFLAGS} \
+	      ${KBUILD_CFLAGS_KERNEL} ${CFLAGS_KERNEL} \
+	      -c -o .vmlinux.export.o .vmlinux.export.c
+fi
+
 btf_vmlinux_bin_o=""
 if is_enabled CONFIG_DEBUG_INFO_BTF; then
 	btf_vmlinux_bin_o=.btf.vmlinux.bin.o
scripts/mod/modpost.c +24 -4
index 213a130d1635..2313bdae91bf 100644
@@ -1042,6 +1042,7 @@ static void add_header(struct buffer *b, struct module *mod)
 	buf_printf(b, "#define INCLUDE_VERMAGIC\n");
 	buf_printf(b, "#include <linux/build-salt.h>\n");
 	buf_printf(b, "#include <linux/elfnote-lto.h>\n");
+	buf_printf(b, "#include <linux/export-internal.h>\n");
 	buf_printf(b, "#include <linux/vermagic.h>\n");
 	buf_printf(b, "#include <linux/compiler.h>\n");
 	buf_printf(b, "\n");
@@ -1076,20 +1077,26 @@ static void add_header(struct buffer *b, struct module *mod)
 		buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
 }
 
-static void check_symversions(struct module *mod)
+static void add_exported_symbols(struct buffer *buf, struct module *mod)
 {
 	struct symbol *sym;
 
 	if (!modversions)
 		return;
 
+	/* record CRCs for exported symbols */
+	buf_printf(buf, "\n");
 	list_for_each_entry(sym, &mod->exported_symbols, list) {
 		if (!sym->crc_valid) {
 			warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n"
 			     "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n",
 			     sym->name, mod->name, mod->is_vmlinux ? "" : ".ko",
 			     sym->name);
+			continue;
 		}
+
+		buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x, \"%s\");\n",
+			   sym->name, sym->crc, sym->is_gpl_only ? "_gpl" : "");
 	}
 }
 
@@ -1226,6 +1233,18 @@ static void write_if_changed(struct buffer *b, const char *fname)
 	write_buf(b, fname);
 }
 
+static void write_vmlinux_export_c_file(struct module *mod)
+{
+	struct buffer buf = { };
+
+	buf_printf(&buf,
+		   "#include <linux/export-internal.h>\n");
+
+	add_exported_symbols(&buf, mod);
+	write_if_changed(&buf, ".vmlinux.export.c");
+	free(buf.p);
+}
+
 /* do sanity checks, and generate *.mod.c file */
 static void write_mod_c_file(struct module *mod)
 {
@@ -1237,6 +1256,7 @@ static void write_mod_c_file(struct module *mod)
 	check_exports(mod);
 
 	add_header(&buf, mod);
+	add_exported_symbols(&buf, mod);
 	add_versions(&buf, mod);
 	add_depends(&buf, mod);
 	add_moddevtable(&buf, mod);
@@ -1434,9 +1454,9 @@ int main(int argc, char **argv)
 		if (mod->from_dump)
 			continue;
 
-		check_symversions(mod);
-
-		if (!mod->is_vmlinux)
+		if (mod->is_vmlinux)
+			write_vmlinux_export_c_file(mod);
+		else
 			write_mod_c_file(mod);
 	}
 
Signature · 1 line
2.32.0
#5 lore raw

Build/boot problem with 7b4537199a4a (Re: [PATCH v6 02/10] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS)

Hi,

Le 13/05/2022 à 13:39, Masahiro Yamada a écrit :

Quoted 25 lines

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Quoted 7 lines

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

Problem with v6.0-rc1
Problem with v5.19
No problem with v5.18

Bisected to 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")

The above patch leads to the following problem building mpc85xx_defconfig + CONFIG_RELOCATABLE

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

c0b0f26d R_PPC_UADDR32     .head.text-0x3ff9f2bc
c0b0f271 R_PPC_UADDR32     .head.text-0x3ffac300
c0b0f275 R_PPC_UADDR32     .head.text-0x3ffb0bdc
c0b0f279 R_PPC_UADDR32     .head.text-0x3fe1e080
c0b0f27d R_PPC_UADDR32     .head.text-0x3fe1df4c
c0b0f281 R_PPC_UADDR32     .head.text-0x3fe21514
c0b0f285 R_PPC_UADDR32     .head.text-0x3fe211c0
c0b0f289 R_PPC_UADDR32     .head.text-0x3ffabda0
c0b0f28d R_PPC_UADDR32     .head.text-0x3fe21258
c0b0f291 R_PPC_UADDR32     .head.text-0x3fe074d0
c0b0f295 R_PPC_UADDR32     .head.text-0x3fe07ad4
c0b0f299 R_PPC_UADDR32     .head.text-0x3fe13470
c0b0f29d R_PPC_UADDR32     .head.text-0x3fe22700
c0b0f2a1 R_PPC_UADDR32     .head.text-0x3ff4b8e0
c0b0f2a5 R_PPC_UADDR32     .head.text-0x3fe08320
c0b0f2a9 R_PPC_UADDR32     .head.text-0x3fe220dc
c0b0f2ad R_PPC_UADDR32     .head.text-0x3fe21da0
c0b0f2b1 R_PPC_UADDR32     .head.text-0x3ff89dc0
c0b0f2b5 R_PPC_UADDR32     .head.text-0x3fe16524
c0b0f2b9 R_PPC_UADDR32     .head.text-0x3fe1ef74
c0b0f2bd R_PPC_UADDR32     .head.text-0x3ff98b84
c0b0f2c1 R_PPC_UADDR32     .head.text-0x3fdef9a0
c0b0f2c5 R_PPC_UADDR32     .head.text-0x3fdf21ac
c0b0f2c9 R_PPC_UADDR32     .head.text-0x3ff993c4
...
c0b0f969 R_PPC_UADDR32     .head.text-0x3ff89dc0
c0b0f96d R_PPC_UADDR32     .head.text-0x3fe9ad40
c0b0f971 R_PPC_UADDR32     .head.text-0x3ff2eb00
c0b0f975 R_PPC_UADDR32     .head.text-0x3ff89dc0

And boot fails:

Run /init as init process
kernel tried to execute user page (0) - exploit attempt? (uid: 0)

BUG: Unable to handle kernel instruction fetch (NULL pointer?)
Faulting instruction address: 0x00000000
Oops: Kernel access of bad area, sig: 11 [#1]
BE PAGE_SIZE=4K MPC8544 DS
Modules linked in:
CPU: 0 PID: 1 Comm: init Not tainted 5.18.0-rc1-00054-g7b4537199a4a #1523
NIP:  00000000 LR: c00150e4 CTR: 00000000
REGS: c3091e10 TRAP: 0400   Not tainted  (5.18.0-rc1-00054-g7b4537199a4a)
MSR:  00009000 <EE,ME>  CR: 88000422  XER: 20000000

GPR00: 00004000 c3091f00 c30c8000 00000000 00000013 b7bb9f4c b7bd8f60 bfee6650
GPR08: 00000054 00000000 c0b0f26d 00000000 c13b0000 00000000 bfee6668 00000000
GPR16: 84e08000 00000000 08000000 00000064 00000000 00102000 00000001 00000001
GPR24: 00000001 00000001 b7b9c7d0 10000034 00000009 b7bd8f38 b7bd9854 b7bd8688
NIP [00000000] 0x0
LR [c00150e4] ret_from_syscall+0x0/0x28

Call Trace:
[c3091f00] [c0000af0] InstructionStorage+0x150/0x160 (unreliable)
--- interrupt: c00 at 0xb7bb28e8
NIP:  b7bb28e8 LR: b7bb1384 CTR: b7bb1218
REGS: c3091f10 TRAP: 0c00   Not tainted  (5.18.0-rc1-00054-g7b4537199a4a)
MSR:  0002d000 <CE,EE,PR,ME>  CR: 28000422  XER: 20000000

GPR00: 0000002d bfee61f0 00000000 00000000 00000013 b7bb9f4c b7bd8f60 bfee6650
GPR08: 00000054 00000020 bfee6648 00000000 00000001 00000000 bfee6668 00000000
GPR16: 84e08000 00000000 08000000 00000064 00000000 00102000 00000001 00000001
GPR24: 00000001 00000001 b7b9c7d0 10000034 00000009 b7bd8f38 b7bd9854 b7bd8688
NIP [b7bb28e8] 0xb7bb28e8
LR [b7bb1384] 0xb7bb1384
--- interrupt: c00
Instruction dump:
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX

---[ end trace 0000000000000000 ]---

Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

Christophe

#6 lore raw

Re: Build/boot problem with 7b4537199a4a (Re: [PATCH v6 02/10] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS)

Quoted 37 lines · Christophe Leroy

Hi,

Quoted 25 lines · Masahiro Yamada

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Quoted 7 lines

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

Quoted 7 lines

Problem with v6.0-rc1
Problem with v5.19
No problem with v5.18

Bisected to 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")

What you are looking for is...

commit 7d13fd96df875a9d786ee6dcc8fec460d35d4b12 ("modpost: fix module versioning when a symbol lacks valid CRC")

It's pending in kbuild.git#fixes.

-Sedat-

[1] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=fixes&id=7d13fd96df875a9d786ee6dcc8fec460d35d4b12
[2] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/log/?h=fixes

Quoted 90 lines

The above patch leads to the following problem building mpc85xx_defconfig + CONFIG_RELOCATABLE

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

c0b0f26d R_PPC_UADDR32     .head.text-0x3ff9f2bc
c0b0f271 R_PPC_UADDR32     .head.text-0x3ffac300
c0b0f275 R_PPC_UADDR32     .head.text-0x3ffb0bdc
c0b0f279 R_PPC_UADDR32     .head.text-0x3fe1e080
c0b0f27d R_PPC_UADDR32     .head.text-0x3fe1df4c
c0b0f281 R_PPC_UADDR32     .head.text-0x3fe21514
c0b0f285 R_PPC_UADDR32     .head.text-0x3fe211c0
c0b0f289 R_PPC_UADDR32     .head.text-0x3ffabda0
c0b0f28d R_PPC_UADDR32     .head.text-0x3fe21258
c0b0f291 R_PPC_UADDR32     .head.text-0x3fe074d0
c0b0f295 R_PPC_UADDR32     .head.text-0x3fe07ad4
c0b0f299 R_PPC_UADDR32     .head.text-0x3fe13470
c0b0f29d R_PPC_UADDR32     .head.text-0x3fe22700
c0b0f2a1 R_PPC_UADDR32     .head.text-0x3ff4b8e0
c0b0f2a5 R_PPC_UADDR32     .head.text-0x3fe08320
c0b0f2a9 R_PPC_UADDR32     .head.text-0x3fe220dc
c0b0f2ad R_PPC_UADDR32     .head.text-0x3fe21da0
c0b0f2b1 R_PPC_UADDR32     .head.text-0x3ff89dc0
c0b0f2b5 R_PPC_UADDR32     .head.text-0x3fe16524
c0b0f2b9 R_PPC_UADDR32     .head.text-0x3fe1ef74
c0b0f2bd R_PPC_UADDR32     .head.text-0x3ff98b84
c0b0f2c1 R_PPC_UADDR32     .head.text-0x3fdef9a0
c0b0f2c5 R_PPC_UADDR32     .head.text-0x3fdf21ac
c0b0f2c9 R_PPC_UADDR32     .head.text-0x3ff993c4
...
c0b0f969 R_PPC_UADDR32     .head.text-0x3ff89dc0
c0b0f96d R_PPC_UADDR32     .head.text-0x3fe9ad40
c0b0f971 R_PPC_UADDR32     .head.text-0x3ff2eb00
c0b0f975 R_PPC_UADDR32     .head.text-0x3ff89dc0

And boot fails:

Run /init as init process
kernel tried to execute user page (0) - exploit attempt? (uid: 0)

BUG: Unable to handle kernel instruction fetch (NULL pointer?)
Faulting instruction address: 0x00000000
Oops: Kernel access of bad area, sig: 11 [#1]
BE PAGE_SIZE=4K MPC8544 DS
Modules linked in:
CPU: 0 PID: 1 Comm: init Not tainted 5.18.0-rc1-00054-g7b4537199a4a #1523
NIP:  00000000 LR: c00150e4 CTR: 00000000
REGS: c3091e10 TRAP: 0400   Not tainted  (5.18.0-rc1-00054-g7b4537199a4a)
MSR:  00009000 <EE,ME>  CR: 88000422  XER: 20000000

GPR00: 00004000 c3091f00 c30c8000 00000000 00000013 b7bb9f4c b7bd8f60 bfee6650
GPR08: 00000054 00000000 c0b0f26d 00000000 c13b0000 00000000 bfee6668 00000000
GPR16: 84e08000 00000000 08000000 00000064 00000000 00102000 00000001 00000001
GPR24: 00000001 00000001 b7b9c7d0 10000034 00000009 b7bd8f38 b7bd9854 b7bd8688
NIP [00000000] 0x0
LR [c00150e4] ret_from_syscall+0x0/0x28

Call Trace:
[c3091f00] [c0000af0] InstructionStorage+0x150/0x160 (unreliable)
--- interrupt: c00 at 0xb7bb28e8
NIP:  b7bb28e8 LR: b7bb1384 CTR: b7bb1218
REGS: c3091f10 TRAP: 0c00   Not tainted  (5.18.0-rc1-00054-g7b4537199a4a)
MSR:  0002d000 <CE,EE,PR,ME>  CR: 28000422  XER: 20000000

GPR00: 0000002d bfee61f0 00000000 00000000 00000013 b7bb9f4c b7bd8f60 bfee6650
GPR08: 00000054 00000020 bfee6648 00000000 00000001 00000000 bfee6668 00000000
GPR16: 84e08000 00000000 08000000 00000064 00000000 00102000 00000001 00000001
GPR24: 00000001 00000001 b7b9c7d0 10000034 00000009 b7bd8f38 b7bd9854 b7bd8688
NIP [b7bb28e8] 0xb7bb28e8
LR [b7bb1384] 0xb7bb1384
--- interrupt: c00
Instruction dump:
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX

---[ end trace 0000000000000000 ]---

Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

Christophe

#7 lore raw

Re: Build/boot problem with 7b4537199a4a (Re: [PATCH v6 02/10] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS)

Le 20/08/2022 à 14:05, Sedat Dilek a écrit :

Quoted 52 lines
Quoted 37 lines · Christophe Leroy

Hi,

Quoted 25 lines · Masahiro Yamada

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Quoted 7 lines

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

Quoted 7 lines

Problem with v6.0-rc1
Problem with v5.19
No problem with v5.18

Bisected to 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")

What you are looking for is...

commit 7d13fd96df875a9d786ee6dcc8fec460d35d4b12 ("modpost: fix module versioning when a symbol lacks valid CRC")

Quoted 7 lines

It's pending in kbuild.git#fixes.

-Sedat-

[1] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=fixes&id=7d13fd96df875a9d786ee6dcc8fec460d35d4b12
[2] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/log/?h=fixes

That patch doesn't fix the problem.

Christophe

#8 lore raw

Re: Build/boot problem with 7b4537199a4a (Re: [PATCH v6 02/10] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS)

In reply to Christophe Leroy
Quoted 41 lines · Christophe Leroy

Hi,

Quoted 25 lines · Masahiro Yamada

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Quoted 7 lines

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

Problem with v6.0-rc1
Problem with v5.19
No problem with v5.18

Quoted 5 lines

Bisected to 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")

The above patch leads to the following problem building mpc85xx_defconfig + CONFIG_RELOCATABLE

Is this because the relocation implementation on ppc is incomplete? (and is it the reason why relock_check.sh exists?)

arch/powerpc/kernel/reloc_32.S does not support R_PPC_UADDR32

Signature · 2 lines
Best Regards
Masahiro Yamada
#9 lore raw

Re: Build/boot problem with 7b4537199a4a (Re: [PATCH v6 02/10] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS)

Le 20/08/2022 à 14:51, Masahiro Yamada a écrit :

Quoted 51 lines
Quoted 41 lines · Christophe Leroy

Hi,

Quoted 25 lines · Masahiro Yamada

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Quoted 7 lines

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

Problem with v6.0-rc1
Problem with v5.19
No problem with v5.18

Quoted 5 lines

Bisected to 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")

The above patch leads to the following problem building mpc85xx_defconfig + CONFIG_RELOCATABLE

Quoted 6 lines

Is this because the relocation implementation on ppc is incomplete? (and is it the reason why relock_check.sh exists?)

arch/powerpc/kernel/reloc_32.S does not support R_PPC_UADDR32

Might be the reason.

Is it expected that your patch adds an unsupported relocation ?

Why was that relocation type unneeded before ?

Thanks
Christophe

#10 lore raw

Re: Build/boot problem with 7b4537199a4a (Re: [PATCH v6 02/10] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS)

Quoted 62 lines · Christophe Leroy
Quoted 51 lines · Masahiro Yamada
Quoted 41 lines · Christophe Leroy

Hi,

Quoted 25 lines · Masahiro Yamada

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Quoted 7 lines

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

Problem with v6.0-rc1
Problem with v5.19
No problem with v5.18

Quoted 5 lines

Bisected to 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")

The above patch leads to the following problem building mpc85xx_defconfig + CONFIG_RELOCATABLE

Quoted 6 lines

Is this because the relocation implementation on ppc is incomplete? (and is it the reason why relock_check.sh exists?)

arch/powerpc/kernel/reloc_32.S does not support R_PPC_UADDR32

Quoted 8 lines

Might be the reason.

Is it expected that your patch adds an unsupported relocation ?

Why was that relocation type unneeded before ?

Thanks
Christophe

I posted a patch (although I believe my commit is innocent).

https://lore.kernel.org/lkml/[email protected]/T/#u

The relocs_check.sh warnings are gone.
Please do a boot test.
Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada
#11 lore raw

Re: Build/boot problem with 7b4537199a4a (Re: [PATCH v6 02/10] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS)

Le 20/08/2022 à 19:01, Masahiro Yamada a écrit :

Quoted 74 lines
Quoted 62 lines · Christophe Leroy
Quoted 51 lines · Masahiro Yamada
Quoted 41 lines · Christophe Leroy

Hi,

Quoted 25 lines · Masahiro Yamada

include/{linux,asm-generic}/export.h defines a weak symbol, __crc_* as a placeholder.

Genksyms writes the version CRCs into the linker script, which will be used for filling the __crc_* symbols. The linker script format depends on CONFIG_MODULE_REL_CRCS. If it is enabled, __crc_* holds the offset to the reference of CRC.

It is time to get rid of this complexity.

Now that modpost parses text files (.*.cmd) to collect all the CRCs, it can generate C code that will be linked to the vmlinux or modules.

Generate a new C file, .vmlinux.export.c, which contains the CRCs of symbols exported by vmlinux. It is compiled and linked to vmlinux in scripts/link-vmlinux.sh.

Put the CRCs of symbols exported by modules into the existing *.mod.c files. No additional build step is needed for modules. As before, *.mod.c are compiled and linked to *.ko in scripts/Makefile.modfinal.

No linker magic is used here. The new C implementation works in the same way, whether CONFIG_RELOCATABLE is enabled or not. CONFIG_MODULE_REL_CRCS is no longer needed.

Quoted 7 lines

Previously, Kbuild invoked additional $(LD) to update the CRCs in objects, but this step is unneeded too.

Problem with v6.0-rc1
Problem with v5.19
No problem with v5.18

Quoted 5 lines

Bisected to 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")

The above patch leads to the following problem building mpc85xx_defconfig + CONFIG_RELOCATABLE

Quoted 6 lines

Is this because the relocation implementation on ppc is incomplete? (and is it the reason why relock_check.sh exists?)

arch/powerpc/kernel/reloc_32.S does not support R_PPC_UADDR32

Quoted 8 lines

Might be the reason.

Is it expected that your patch adds an unsupported relocation ?

Why was that relocation type unneeded before ?

Thanks
Christophe

Quoted 8 lines

I posted a patch (although I believe my commit is innocent).

https://lore.kernel.org/lkml/[email protected]/T/#u

The relocs_check.sh warnings are gone.
Please do a boot test.
Thanks.

Yes it works, many Thanks.

The fixes tag should probably be c857c43b34ec ("powerpc: Don't use a function descriptor for system call table")

Christophe

#12 lore raw

PATCH v6 3/10 kbuild: stop merging *.symversions

In reply to Masahiro Yamada

Now modpost reads symbol versions from .*.cmd files.

The merged *.symversions are no longer needed.

---

(no changes since v1)

 scripts/Makefile.build  | 21 ++-------------------
 scripts/link-vmlinux.sh | 19 -------------------
 2 files changed, 2 insertions(+), 38 deletions(-)
scripts/Makefile.build +2 -19
index ddd9080fc028..dff9220135c4 100644
@@ -390,17 +390,6 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
 $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
 $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
 
-# combine symversions for later processing
-ifeq ($(CONFIG_LTO_CLANG) $(CONFIG_MODVERSIONS),y y)
-      cmd_update_lto_symversions =					\
-	rm -f [email protected]						\
-	$(foreach n, $(filter-out FORCE,$^),				\
-		$(if $(shell test -s $(n).symversions && echo y),	\
-			; cat $(n).symversions >> [email protected]))
-else
-      cmd_update_lto_symversions = echo >/dev/null
-endif
-
 #
 # Rule to compile a set of .o files into one .a file (without symbol table)
 #
@@ -408,11 +397,8 @@ endif
 quiet_cmd_ar_builtin = AR      $@
       cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
 
-quiet_cmd_ar_and_symver = AR      $@
-      cmd_ar_and_symver = $(cmd_update_lto_symversions); $(cmd_ar_builtin)
-
 $(obj)/built-in.a: $(real-obj-y) FORCE
-	$(call if_changed,ar_and_symver)
+	$(call if_changed,ar_builtin)
 
 #
 # Rule to create modules.order file
@@ -432,16 +418,13 @@ $(obj)/modules.order: $(obj-m) FORCE
 #
 # Rule to compile a set of .o files into one .a file (with symbol table)
 #
-quiet_cmd_ar_lib = AR      $@
-      cmd_ar_lib = $(cmd_update_lto_symversions); $(cmd_ar)
 
 $(obj)/lib.a: $(lib-y) FORCE
-	$(call if_changed,ar_lib)
+	$(call if_changed,ar)
 
 ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
 quiet_cmd_link_multi-m = AR [M]  $@
 cmd_link_multi-m =						\
-	$(cmd_update_lto_symversions);				\
 	rm -f $@; 						\
 	$(AR) cDPrsT $@ @$(patsubst %.o,%.mod,$@)
 else
scripts/link-vmlinux.sh +0 -19
index 7313cbd755df..47e5336d0c75 100755
@@ -56,20 +56,6 @@ gen_initcalls()
 		> .tmp_initcalls.lds
 }
 
-# If CONFIG_LTO_CLANG is selected, collect generated symbol versions into
-# .tmp_symversions.lds
-gen_symversions()
-{
-	info GEN .tmp_symversions.lds
-	rm -f .tmp_symversions.lds
-
-	for o in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
-		if [ -f ${o}.symversions ]; then
-			cat ${o}.symversions >> .tmp_symversions.lds
-		fi
-	done
-}
-
 # Link of vmlinux.o used for section mismatch analysis
 # ${1} output file
 modpost_link()
@@ -88,10 +74,6 @@ modpost_link()
 		gen_initcalls
 		lds="-T .tmp_initcalls.lds"
 
-		if is_enabled CONFIG_MODVERSIONS; then
-			gen_symversions
-		fi
-
 		# This might take a while, so indicate that we're doing
 		# an LTO link
 		info LTO ${1}
@@ -307,7 +289,6 @@ cleanup()
 	rm -f .btf.*
 	rm -f .tmp_System.map
 	rm -f .tmp_initcalls.lds
-	rm -f .tmp_symversions.lds
 	rm -f .tmp_vmlinux*
 	rm -f System.map
 	rm -f vmlinux
Signature · 1 line
2.32.0
#13 lore raw

PATCH v6 4/10 genksyms: adjust the output format to modpost

In reply to Masahiro Yamada

Make genksyms output symbol versions in the format modpost expects, so the 'sed' is unneeded.

This commit makes *.symversions completely unneeded.

I will keep *.symversions in .gitignore and 'make clean' for a while. Otherwise, 'git status' might be surprising.

---

(no changes since v2)

Changes in v2:
- New patch

 scripts/Makefile.build      | 6 ------
 scripts/genksyms/genksyms.c | 2 +-
 2 files changed, 1 insertion(+), 7 deletions(-)
scripts/Makefile.build +0 -6
index dff9220135c4..461998a2ad2b 100644
@@ -165,16 +165,10 @@ ifdef CONFIG_MODVERSIONS
 # o modpost will extract versions from that file and create *.c files that will
 #   be compiled and linked to the kernel and/or modules.
 
-genksyms_format := __crc_\(.*\) = \(.*\);
-
 gen_symversions =								\
 	if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then			\
 		$(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
-		    > [email protected];						\
-		sed -n 's/$(genksyms_format)/$(pound)SYMVER \1 \2/p' [email protected] \
 			>> $(dot-target).cmd;					\
-	else									\
-		rm -f [email protected];						\
 	fi
 
 cmd_gen_symversions_c =	$(call gen_symversions,c)
scripts/genksyms/genksyms.c +1 -1
index 67b23cc0df0f..f5dfdb9d80e9 100644
@@ -680,7 +680,7 @@ void export_symbol(const char *name)
 		if (flag_dump_defs)
 			fputs(">\n", debugfile);
 
-		printf("__crc_%s = 0x%08lx;\n", name, crc);
+		printf("#SYMVER %s 0x%08lx\n", name, crc);
 	}
 }
 
Signature · 1 line
2.32.0
#14 lore raw

PATCH v6 5/10 kbuild: do not create *.prelink.o for Clang LTO or IBT

In reply to Masahiro Yamada

When CONFIG_LTO_CLANG=y, additional intermediate *.prelink.o is created for each module. Also, objtool is postponed until LLVM IR is converted to ELF.

CONFIG_X86_KERNEL_IBT works in a similar way to postpone objtool until objects are merged together.

This commit stops generating *.prelink.o, so the build flow will look similar with/without LTO.

The following figures show how the LTO build currently works, and how this commit is changing it.

Current build flow
==================

[1] single-object module

                                      $(LD)
           $(CC)                     +objtool              $(LD)
    foo.c --------------------> foo.o -----> foo.prelink.o -----> foo.ko
                              (LLVM IR)          (ELF)       |
                                                             |
                                                 foo.mod.o --/

[2] multi-object module

                                      $(LD)
           $(CC)         $(AR)       +objtool               $(LD)
    foo1.c -----> foo1.o -----> foo.o -----> foo.prelink.o -----> foo.ko
                           |  (archive)          (ELF)       |
    foo2.c -----> foo2.o --/                                 |
                 (LLVM IR)                       foo.mod.o --/

One confusion is foo.o in multi-object module is an archive despite of its suffix.

New build flow
==============

[1] single-object module

  Since there is only one object, there is no need to keep the LLVM IR.
  Use $(CC)+$(LD) to generate an ELF object in one build rule. When LTO
  is disabled, $(LD) is unneeded because $(CC) produces an ELF object.
               $(CC)+$(LD)+objtool              $(LD)
    foo.c ----------------------------> foo.o ---------> foo.ko
                                        (ELF)     |
                                                  |
                                      foo.mod.o --/

[2] multi-object module

  Previously, $(AR) was used to combine LLVM bitcode into an archive,
  but there was no technical reason to do so. Use $(LD) to merge them
  into a single ELF object.
                               $(LD)
             $(CC)            +objtool          $(LD)
    foo1.c ---------> foo1.o ---------> foo.o ---------> foo.ko
                                 |      (ELF)     |
    foo2.c ---------> foo2.o ----/                |
                     (LLVM IR)        foo.mod.o --/

---

(no changes since v2)

Changes in v2:
- replace the chain of $(if ...) with $(and )

 scripts/Kbuild.include    |  4 +++
 scripts/Makefile.build    | 58 ++++++++++++---------------------------
 scripts/Makefile.lib      |  7 -----
 scripts/Makefile.modfinal |  5 ++--
 scripts/Makefile.modpost  |  9 ++----
 scripts/mod/modpost.c     |  7 -----
 6 files changed, 25 insertions(+), 65 deletions(-)
scripts/Kbuild.include +4 -0
index 3514c2149e9d..455a0a6ce12d 100644
@@ -15,6 +15,10 @@ pound := \#
 # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
 dot-target = $(dir $@).$(notdir $@)
 
+###
+# Name of target with a '.tmp_' as filename prefix. foo/bar.o => foo/.tmp_bar.o
+tmp-target = $(dir $@).tmp_$(notdir $@)
+
 ###
 # The temporary file to save gcc -MMD generated dependencies must not
 # contain a comma
scripts/Makefile.build +17 -41

103 lines not on this page · raw message

scripts/Makefile.lib +0 -7
index 0453a1904646..f75138385449 100644
@@ -225,13 +225,6 @@ dtc_cpp_flags  = -Wp,-MMD,$(depfile).pre.tmp -nostdinc                    \
 		 $(addprefix -I,$(DTC_INCLUDE))                          \
 		 -undef -D__DTS__
 
-ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
-# With CONFIG_LTO_CLANG, .o files in modules might be LLVM bitcode, so we
-# need to run LTO to compile them into native code (.lto.o) before further
-# processing.
-mod-prelink-ext := .prelink
-endif
-
 # Useful for describing the dependency of composite objects
 # Usage:
 #   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
scripts/Makefile.modfinal +2 -3
index 7f39599e9fae..35100e981f4a 100644
@@ -9,7 +9,7 @@ __modfinal:
 include include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
 
-# for c_flags and mod-prelink-ext
+# for c_flags
 include $(srctree)/scripts/Makefile.lib
 
 # find all modules listed in modules.order
@@ -54,9 +54,8 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check),      \
 	$(cmd);                                                              \
 	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
 
-
 # Re-generate module BTFs if either module's .ko or vmlinux changed
-$(modules): %.ko: %$(mod-prelink-ext).o %.mod.o scripts/module.lds $(if $(KBUILD_BUILTIN),vmlinux) FORCE
+$(modules): %.ko: %.o %.mod.o scripts/module.lds $(if $(KBUILD_BUILTIN),vmlinux) FORCE
 	+$(call if_changed_except,ld_ko_o,vmlinux)
 ifdef CONFIG_DEBUG_INFO_BTF_MODULES
 	+$(if $(newer-prereqs),$(call cmd,btf_ko))
scripts/Makefile.modpost +2 -7
index 48585c4d04ad..f2ce411acd59 100644
@@ -41,9 +41,6 @@ __modpost:
 include include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
 
-# for mod-prelink-ext
-include $(srctree)/scripts/Makefile.lib
-
 MODPOST = scripts/mod/modpost								\
 	$(if $(CONFIG_MODVERSIONS),-m)							\
 	$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a)					\
@@ -118,8 +115,6 @@ $(input-symdump):
 	@echo >&2 '         Modules may not have dependencies or modversions.'
 	@echo >&2 '         You may get many unresolved symbol warnings.'
 
-modules := $(sort $(shell cat $(MODORDER)))
-
 # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined symbols
 ifneq ($(KBUILD_MODPOST_WARN)$(filter-out $(existing-input-symdump), $(input-symdump)),)
 MODPOST += -w
@@ -128,9 +123,9 @@ endif
 # Read out modules.order to pass in modpost.
 # Otherwise, allmodconfig would fail with "Argument list too long".
 quiet_cmd_modpost = MODPOST $@
-      cmd_modpost = sed 's/\.ko$$/$(mod-prelink-ext)\.o/' $< | $(MODPOST) -T -
+      cmd_modpost = sed 's/ko$$/o/' $< | $(MODPOST) -T -
 
-$(output-symdump): $(MODORDER) $(input-symdump) $(modules:.ko=$(mod-prelink-ext).o) FORCE
+$(output-symdump): $(MODORDER) $(input-symdump) FORCE
 	$(call if_changed,modpost)
 
 targets += $(output-symdump)
scripts/mod/modpost.c +0 -7
index 2313bdae91bf..27c45427d989 100644
@@ -716,10 +716,6 @@ static char *remove_dot(char *s)
 		size_t m = strspn(s + n + 1, "0123456789");
 		if (m && (s[n + m] == '.' || s[n + m] == 0))
 			s[n] = 0;
-
-		/* strip trailing .prelink */
-		if (strends(s, ".prelink"))
-			s[strlen(s) - 8] = '\0';
 	}
 	return s;
 }
@@ -841,9 +837,6 @@ static void read_symbols(const char *modname)
 		/* strip trailing .o */
 		tmp = NOFAIL(strdup(modname));
 		tmp[strlen(tmp) - 2] = '\0';
-		/* strip trailing .prelink */
-		if (strends(tmp, ".prelink"))
-			tmp[strlen(tmp) - 8] = '\0';
 		mod = new_module(tmp);
 		free(tmp);
 	}
Signature · 1 line
2.32.0
#15 lore raw

PATCH v6 6/10 kbuild: check static EXPORT_SYMBOL* by script instead of modpost

In reply to Masahiro Yamada

The 'static' specifier and EXPORT_SYMBOL() are an odd combination.

Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") tried to detect it, but this check has false negatives.

Here is the sample code.

Makefile:

    obj-y += foo1.o foo2.o

foo1.c:

    #include <linux/export.h>
    static void foo(void) {}
    EXPORT_SYMBOL(foo);

foo2.c:

    void foo(void) {}

foo1.c exports the static symbol 'foo', but modpost cannot catch it because it is fooled by foo2.c, which has a global symbol with the same name.

s->is_static is cleared if a global symbol with the same name is found somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily belong to the same compilation unit.

This check should be done per compilation unit, but I do not know how to do it in modpost. modpost runs against vmlinux.o or modules, which merges multiple objects, then forgets their origin.

It is true modpost gets access to the lists of all the member objects (.vmlinux.objs and *.mod), but modpost cannot parse individual objects because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y.

Add a simple bash script to parse the output from ${NM}. This works for CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.

Revert 15bfc2348d54.

---

(no changes since v5)

Changes in v5:
- Add more comments in the script

Changes in v4:
- New patch

 scripts/Makefile.build     |  4 +++
 scripts/check-local-export | 64 ++++++++++++++++++++++++++++++++++++++
 scripts/mod/modpost.c      | 28 +----------------
 3 files changed, 69 insertions(+), 27 deletions(-)
 create mode 100755 scripts/check-local-export
scripts/Makefile.build +4 -0
index 838ea5e83174..c2a173b3fd60 100644
@@ -244,9 +244,12 @@ cmd_gen_ksymdeps = \
 	$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
 endif
 
+cmd_check_local_export = $(srctree)/scripts/check-local-export $@
+
 define rule_cc_o_c
 	$(call cmd_and_fixdep,cc_o_c)
 	$(call cmd,gen_ksymdeps)
+	$(call cmd,check_local_export)
 	$(call cmd,checksrc)
 	$(call cmd,checkdoc)
 	$(call cmd,gen_objtooldep)
@@ -257,6 +260,7 @@ endef
 define rule_as_o_S
 	$(call cmd_and_fixdep,as_o_S)
 	$(call cmd,gen_ksymdeps)
+	$(call cmd,check_local_export)
 	$(call cmd,gen_objtooldep)
 	$(call cmd,gen_symversions_S)
 endef
scripts/check-local-export new file +64 -0

64 lines not on this page · raw message

scripts/mod/modpost.c +1 -27
index 27c45427d989..2328522f8a78 100644
@@ -212,7 +212,6 @@ struct symbol {
 	unsigned int crc;
 	bool crc_valid;
 	bool weak;
-	bool is_static;		/* true if symbol is not global */
 	bool is_gpl_only;	/* exported by EXPORT_SYMBOL_GPL */
 	char name[];
 };
@@ -242,7 +241,7 @@ static struct symbol *alloc_symbol(const char *name)
 
 	memset(s, 0, sizeof(*s));
 	strcpy(s->name, name);
-	s->is_static = true;
+
 	return s;
 }
 
@@ -877,20 +876,6 @@ static void read_symbols(const char *modname)
 					     sym_get_data(&info, sym));
 	}
 
-	// check for static EXPORT_SYMBOL_* functions && global vars
-	for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
-		unsigned char bind = ELF_ST_BIND(sym->st_info);
-
-		if (bind == STB_GLOBAL || bind == STB_WEAK) {
-			struct symbol *s =
-				find_symbol(remove_dot(info.strtab +
-						       sym->st_name));
-
-			if (s)
-				s->is_static = false;
-		}
-	}
-
 	check_sec_ref(mod, modname, &info);
 
 	if (!mod->is_vmlinux) {
@@ -1320,7 +1305,6 @@ static void read_dump(const char *fname)
 			mod->from_dump = true;
 		}
 		s = sym_add_exported(symname, mod, gpl_only);
-		s->is_static = false;
 		sym_set_crc(s, crc);
 		sym_update_namespace(symname, namespace);
 	}
@@ -1385,7 +1369,6 @@ int main(int argc, char **argv)
 	char *missing_namespace_deps = NULL;
 	char *dump_write = NULL, *files_source = NULL;
 	int opt;
-	int n;
 	LIST_HEAD(dump_lists);
 	struct dump_list *dl, *dl2;
 
@@ -1461,15 +1444,6 @@ int main(int argc, char **argv)
 	if (sec_mismatch_count && !sec_mismatch_warn_only)
 		error("Section mismatches detected.\n"
 		      "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n");
-	for (n = 0; n < SYMBOL_HASH_SIZE; n++) {
-		struct symbol *s;
-
-		for (s = symbolhash[n]; s; s = s->next) {
-			if (s->is_static)
-				error("\"%s\" [%s] is a static EXPORT_SYMBOL\n",
-				      s->name, s->module->name);
-		}
-	}
 
 	if (nr_unresolved > MAX_UNRESOLVED_REPORTS)
 		warn("suppressed %u unresolved symbol warnings because there were too many)\n",
Signature · 1 line
2.32.0
#16 lore raw

Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script instead of modpost

Quoted 33 lines · Masahiro Yamada

The 'static' specifier and EXPORT_SYMBOL() are an odd combination.

Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") tried to detect it, but this check has false negatives.

Here is the sample code.

Makefile:

    obj-y += foo1.o foo2.o

foo1.c:

    #include <linux/export.h>
    static void foo(void) {}
    EXPORT_SYMBOL(foo);

foo2.c:

    void foo(void) {}

foo1.c exports the static symbol 'foo', but modpost cannot catch it because it is fooled by foo2.c, which has a global symbol with the same name.

s->is_static is cleared if a global symbol with the same name is found somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily belong to the same compilation unit.

This check should be done per compilation unit, but I do not know how to do it in modpost. modpost runs against vmlinux.o or modules, which merges multiple objects, then forgets their origin.

Quoted 7 lines

It is true modpost gets access to the lists of all the member objects (.vmlinux.objs and *.mod), but modpost cannot parse individual objects because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y.

Add a simple bash script to parse the output from ${NM}. This works for CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.

On parisc builds, this patch results in:

Building parisc:allnoconfig ... failed
--------------
Error log:
scripts/check-local-export: sh /opt/buildbot/slave/next-next/build/arch/parisc/nm failed

Guenter

#17 lore raw

Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script instead of modpost

Quoted 43 lines · Guenter Roeck
Quoted 33 lines · Masahiro Yamada

The 'static' specifier and EXPORT_SYMBOL() are an odd combination.

Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") tried to detect it, but this check has false negatives.

Here is the sample code.

Makefile:

    obj-y += foo1.o foo2.o

foo1.c:

    #include <linux/export.h>
    static void foo(void) {}
    EXPORT_SYMBOL(foo);

foo2.c:

    void foo(void) {}

foo1.c exports the static symbol 'foo', but modpost cannot catch it because it is fooled by foo2.c, which has a global symbol with the same name.

s->is_static is cleared if a global symbol with the same name is found somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily belong to the same compilation unit.

This check should be done per compilation unit, but I do not know how to do it in modpost. modpost runs against vmlinux.o or modules, which merges multiple objects, then forgets their origin.

Quoted 7 lines

It is true modpost gets access to the lists of all the member objects (.vmlinux.objs and *.mod), but modpost cannot parse individual objects because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y.

Add a simple bash script to parse the output from ${NM}. This works for CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.

Quoted 8 lines

On parisc builds, this patch results in:

Building parisc:allnoconfig ... failed
--------------
Error log:
scripts/check-local-export: sh /opt/buildbot/slave/next-next/build/arch/parisc/nm failed

Guenter

Thanks for the report.

parisc overrides NM:

NM = sh $(srctree)/arch/parisc/nm

I will fix the script to return the correct exit code.

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#18 lore raw

Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script instead of modpost

In reply to Masahiro Yamada
Quoted 37 lines · Masahiro Yamada

The 'static' specifier and EXPORT_SYMBOL() are an odd combination.

Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") tried to detect it, but this check has false negatives.

Here is the sample code.

   Makefile:

     obj-y += foo1.o foo2.o

   foo1.c:

     #include <linux/export.h>
     static void foo(void) {}
     EXPORT_SYMBOL(foo);

   foo2.c:

     void foo(void) {}

foo1.c exports the static symbol 'foo', but modpost cannot catch it because it is fooled by foo2.c, which has a global symbol with the same name.

s->is_static is cleared if a global symbol with the same name is found somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily belong to the same compilation unit.

This check should be done per compilation unit, but I do not know how to do it in modpost. modpost runs against vmlinux.o or modules, which merges multiple objects, then forgets their origin.

It is true modpost gets access to the lists of all the member objects (.vmlinux.objs and *.mod), but modpost cannot parse individual objects because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y.

Quoted 8 lines

Add a simple bash script to parse the output from ${NM}. This works for CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.

Revert 15bfc2348d54.

One some older build machines this is causing some builds (ARM/ARM64) to fail ...

/dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/check-local-export: line 54: wait: pid 48433 is not a child of this shell /dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/Makefile.build:250: recipe for target 'scripts/mod/empty.o' failed make[2]: *** [scripts/mod/empty.o] Error 127
make[2]: *** Deleting file 'scripts/mod/empty.o'
make[2]: *** Waiting for unfinished jobs....
/dvs/git/dirty/git-master_l4t-upstream/kernel/Makefile:1285: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory '/dvs/git/dirty/git-master_l4t-upstream/artifacts/linux/arm64-defconfig-jetson' Makefile:228: recipe for target '__sub-make' failed
make: *** [__sub-make] Error 2

Any ideas?

Thanks
Jon

Signature · 1 line
nvpublic
#19 lore raw

Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script instead of modpost

Quoted 63 lines · Jon Hunter
Quoted 37 lines · Masahiro Yamada

The 'static' specifier and EXPORT_SYMBOL() are an odd combination.

Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") tried to detect it, but this check has false negatives.

Here is the sample code.

   Makefile:

     obj-y += foo1.o foo2.o

   foo1.c:

     #include <linux/export.h>
     static void foo(void) {}
     EXPORT_SYMBOL(foo);

   foo2.c:

     void foo(void) {}

foo1.c exports the static symbol 'foo', but modpost cannot catch it because it is fooled by foo2.c, which has a global symbol with the same name.

s->is_static is cleared if a global symbol with the same name is found somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily belong to the same compilation unit.

This check should be done per compilation unit, but I do not know how to do it in modpost. modpost runs against vmlinux.o or modules, which merges multiple objects, then forgets their origin.

It is true modpost gets access to the lists of all the member objects (.vmlinux.objs and *.mod), but modpost cannot parse individual objects because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y.

Quoted 8 lines

Add a simple bash script to parse the output from ${NM}. This works for CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.

Revert 15bfc2348d54.

One some older build machines this is causing some builds (ARM/ARM64) to fail ...

/dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/check-local-export: line 54: wait: pid 48433 is not a child of this shell /dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/Makefile.build:250: recipe for target 'scripts/mod/empty.o' failed make[2]: *** [scripts/mod/empty.o] Error 127
make[2]: *** Deleting file 'scripts/mod/empty.o'
make[2]: *** Waiting for unfinished jobs....
/dvs/git/dirty/git-master_l4t-upstream/kernel/Makefile:1285: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory '/dvs/git/dirty/git-master_l4t-upstream/artifacts/linux/arm64-defconfig-jetson' Makefile:228: recipe for target '__sub-make' failed
make: *** [__sub-make] Error 2

Quoted 1 line

Any ideas?

https://lore.kernel.org/[email protected]/
should resolve it if you wanted to give it a test.

Cheers,
Nathan

maintainer Tested-by
#20 lore raw

Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script instead of modpost

Quoted 64 lines · Nathan Chancellor
Quoted 63 lines · Jon Hunter
Quoted 37 lines · Masahiro Yamada

The 'static' specifier and EXPORT_SYMBOL() are an odd combination.

Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions") tried to detect it, but this check has false negatives.

Here is the sample code.

    Makefile:

      obj-y += foo1.o foo2.o

    foo1.c:

      #include <linux/export.h>
      static void foo(void) {}
      EXPORT_SYMBOL(foo);

    foo2.c:

      void foo(void) {}

foo1.c exports the static symbol 'foo', but modpost cannot catch it because it is fooled by foo2.c, which has a global symbol with the same name.

s->is_static is cleared if a global symbol with the same name is found somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily belong to the same compilation unit.

This check should be done per compilation unit, but I do not know how to do it in modpost. modpost runs against vmlinux.o or modules, which merges multiple objects, then forgets their origin.

It is true modpost gets access to the lists of all the member objects (.vmlinux.objs and *.mod), but modpost cannot parse individual objects because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y.

Quoted 8 lines

Add a simple bash script to parse the output from ${NM}. This works for CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.

Revert 15bfc2348d54.

One some older build machines this is causing some builds (ARM/ARM64) to fail ...

/dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/check-local-export: line 54: wait: pid 48433 is not a child of this shell /dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/Makefile.build:250: recipe for target 'scripts/mod/empty.o' failed make[2]: *** [scripts/mod/empty.o] Error 127
make[2]: *** Deleting file 'scripts/mod/empty.o'
make[2]: *** Waiting for unfinished jobs....
/dvs/git/dirty/git-master_l4t-upstream/kernel/Makefile:1285: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory '/dvs/git/dirty/git-master_l4t-upstream/artifacts/linux/arm64-defconfig-jetson' Makefile:228: recipe for target '__sub-make' failed
make: *** [__sub-make] Error 2

Quoted 4 lines
Quoted 1 line

Any ideas?

https://lore.kernel.org/[email protected]/
should resolve it if you wanted to give it a test.

Thanks! Works for me.

Cheers
Jon

Signature · 1 line
nvpublic
#21 lore raw

PATCH v6 7/10 kbuild: make built-in.a rule robust against too long argument error

In reply to Masahiro Yamada

Kbuild runs at the top of objtree instead of changing the working directory to subdirectories. I think this design is nice overall but some commands have a scalability issue.

The build command of built-in.a is one of them whose length scales with:

    O(D * N)

Here, D is the length of the directory path (i.e. $(obj)/ prefix), N is the number of objects in the Makefile, O() is the big O notation.

The deeper directory the Makefile directory is located, the more easily it will hit the too long argument error.

We can make it better. Trim the $(obj)/ by Make's builtin function, and restore it by a shell command (sed).

With this, the command length scales with:

    O(D + N)

In-tree modules still have some room to the limit (ARG_MAX=2097152), but this is more future-proof for big modules in a deep directory.

For example, you can build i915 as builtin (CONFIG_DRM_I915=y) and compare drivers/gpu/drm/i915/.built-in.a.cmd with/without this commit.

---

(no changes since v2)

Changes in v2:
- New patch

 scripts/Makefile.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/Makefile.build +4 -1
index c2a173b3fd60..8f1a355df7aa 100644
@@ -374,7 +374,10 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
 #
 
 quiet_cmd_ar_builtin = AR      $@
-      cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
+      cmd_ar_builtin = rm -f $@; \
+		echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \
+		sed -E 's:([^ ]+):$(obj)/\1:g' | \
+		xargs $(AR) cDPrST $@
 
 $(obj)/built-in.a: $(real-obj-y) FORCE
 	$(call if_changed,ar_builtin)
Signature · 1 line
2.32.0
#22 lore raw

PATCH v6 8/10 kbuild: make *.mod rule robust against too long argument error

In reply to Masahiro Yamada

Like built-in.a, the command length of the *.mod rule scales with the depth of the directory times the number of objects in the Makefile.

Add $(obj)/ by the shell command (awk) instead of by Make's builtin function.

In-tree modules still have some room to the limit (ARG_MAX=2097152), but this is more future-proof for big modules in a deep directory.

For example, you can build i915 as a module (CONFIG_DRM_I915=m) and compare drivers/gpu/drm/i915/.i915.mod.cmd with/without this commit.

The issue is more critical for external modules because the M= path can be very long as Jeff Johnson reported before [1].

[1] https://lore.kernel.org/linux-kbuild/[email protected]/

---

(no changes since v2)

Changes in v2:
- New patch

 scripts/Makefile.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +2 -2
index 8f1a355df7aa..f546b5f1f33f 100644
@@ -270,8 +270,8 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
 	$(call if_changed_rule,cc_o_c)
 	$(call cmd,force_checksrc)
 
-cmd_mod = echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)) | \
-	$(AWK) -v RS='( |\n)' '!x[$$0]++' > $@
+cmd_mod = echo $(call real-search, $*.o, .o, -objs -y -m) | \
+	$(AWK) -v RS='( |\n)' '!x[$$0]++ { print("$(obj)/"$$0) }' > $@
 
 $(obj)/%.mod: FORCE
 	$(call if_changed,mod)
Signature · 1 line
2.32.0
#23 lore raw

PATCH v6 9/10 kbuild: add cmd_and_savecmd macro

In reply to Masahiro Yamada

Separate out the command execution part of if_changed, as we did for if_changed_dep.

This allows us to reuse it in if_changed_rule.

  define rule_foo
          $(call cmd_and_savecmd,foo)
          $(call cmd,bar)
  endef

---

(no changes since v4)

Changes in v4:
- New.
Resent of my previous submission.
https://lore.kernel.org/all/[email protected]/

 scripts/Kbuild.include | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/Kbuild.include +4 -2
index 455a0a6ce12d..ece44b735061 100644
@@ -142,9 +142,11 @@ check-FORCE = $(if $(filter FORCE, $^),,$(warning FORCE prerequisite is missing)
 if-changed-cond = $(newer-prereqs)$(cmd-check)$(check-FORCE)
 
 # Execute command if command has changed or prerequisite(s) are updated.
-if_changed = $(if $(if-changed-cond),                                        \
+if_changed = $(if $(if-changed-cond),$(cmd_and_savecmd),@:)
+
+cmd_and_savecmd =                                                            \
 	$(cmd);                                                              \
-	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
+	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd
 
 # Execute the command and also postprocess generated .d dependencies file.
 if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)
Signature · 1 line
2.32.0
#24 lore raw

PATCH v6 10/10 kbuild: rebuild multi-object modules when objtool is updated

In reply to Masahiro Yamada

When CONFIG_LTO_CLANG or CONFIG_X86_KERNEL_IBT is enabled, objtool for multi-object modules is postponed until the objects are linked together.

Make sure to re-run objtool and re-link multi-object modules when objtool is updated.

---

(no changes since v4)

Changes in v4:
- New
Resent of my previous submission
https://lore.kernel.org/linux-kbuild/[email protected]/

 scripts/Makefile.build | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
scripts/Makefile.build +8 -3
index f546b5f1f33f..4e6902e099e8 100644
@@ -404,13 +404,18 @@ $(obj)/modules.order: $(obj-m) FORCE
 $(obj)/lib.a: $(lib-y) FORCE
 	$(call if_changed,ar)
 
-quiet_cmd_link_multi-m = LD [M]  $@
-      cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool)
+quiet_cmd_ld_multi_m = LD [M]  $@
+      cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool)
+
+define rule_ld_multi_m
+	$(call cmd_and_savecmd,ld_multi_m)
+	$(call cmd,gen_objtooldep)
+endef
 
 $(multi-obj-m): objtool-enabled := $(delay-objtool)
 $(multi-obj-m): part-of-module := y
 $(multi-obj-m): %.o: %.mod FORCE
-	$(call if_changed,link_multi-m)
+	$(call if_changed_rule,ld_multi_m)
 $(call multi_depend, $(multi-obj-m), .o, -objs -y -m)
 
 targets := $(filter-out $(PHONY), $(targets))
Signature · 1 line
2.32.0
#25 lore raw
In reply to Masahiro Yamada
Quoted 4 lines · Masahiro Yamada

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Quoted 72 lines

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.
https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission
https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export

--
2.32.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#26 lore raw
Quoted 4 lines · Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
Quoted 8 lines
Quoted 2 lines

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Hi Masahiro,

I cloned the repository on top of latest Linus Git.

Not able to boot in Quemu - Not able to boot on bare metal.

$ grep module_layout log_quemu-5.18.0-rc7-2-amd64-clang14-lto.txt
366:[    2.173265] floppy: disagrees about version of symbol module_layout
367:[    2.198746] scsi_common: disagrees about version of symbol module_layout
368:[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
369:[    2.210610] psmouse: disagrees about version of symbol module_layout
370:[    2.225138] scsi_common: disagrees about version of symbol module_layout
371:[    2.235536] scsi_common: disagrees about version of symbol module_layout
375:Begin: Running /scripts/local-premount ... [    2.298555]
crc32c_intel: disagrees about version of symbol module_layout
376:[    2.303335] crc32c_generic: disagrees about version of symbol
module_layout
377:[    2.306667] libcrc32c: disagrees about version of symbol module_layout

Infos: LLVM-14 + CONFIG_LTO_CLANG_THIN=y

My linux-config and qemu-log are attached.

Regards,
-Sedat-

Quoted 70 lines
Quoted 70 lines

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.
https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission
https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export
Quoted 8 lines
Quoted 3 lines

--
2.32.0

--
Best Regards
Masahiro Yamada

$ ./run_qemu.sh 
Probing EDD (edd=off to disable)... ok
Wrong EFI loader signature.
early console in extract_kernel
input_data: 0x0000000003ac94cc
input_len: 0x00000000008639d6
output: 0x0000000001000000
output_len: 0x00000000032d9248
kernel_total_size: 0x000000000282c000
needed_size: 0x0000000003400000
trampoline_32bit: 0x000000000009d000
Physical KASLR using RDTSC...
Virtual KASLR using RDTSC...

Decompressing Linux... Parsing ELF... Performing relocations... done. Booting the kernel.

[    0.000000] Linux version 5.18.0-rc7-2-amd64-clang14-lto ([email protected]@iniza) (Debian clang version 14.0.4-++20220520113054+5f66e721ec1d-1~exp1~20220520113136.138, Debian LLD 14.0.4) #2~bookworm+dileks1 SMP PREEMPT_DYNAMIC 2022-05-21
[    0.000000] Command line: root=/dev/ram0 console=ttyS0 hung_task_panic=1 earlyprintk=ttyS0,115200
[    0.000000] x86/fpu: x87 FPU will use FXSAVE
[    0.000000] signal: max sigframe size: 1440
[    0.000000] BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000001ffdffff] usable
[    0.000000] BIOS-e820: [mem 0x000000001ffe0000-0x000000001fffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] printk: bootconsole [earlyser0] enabled
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.8 present.
[    0.000000] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-debian-1.16.0-4 04/01/2014
[    0.000000] Hypervisor detected: KVM
[    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
[    0.000054] kvm-clock: using sched offset of 1418469981 cycles
[    0.005104] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[    0.009895] tsc: Detected 1596.373 MHz processor
[    0.012299] last_pfn = 0x1ffe0 max_arch_pfn = 0x400000000
[    0.014674] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT  
Memory KASLR using RDTSC...
[    0.034939] found SMP MP-table at [mem 0x000f5ba0-0x000f5baf]
[    0.038362] RAMDISK: [mem 0x1db42000-0x1ffdffff]
[    0.040603] ACPI: Early table checksum verification disabled
[    0.043328] ACPI: RSDP 0x00000000000F59D0 000014 (v00 BOCHS )
[    0.046017] ACPI: RSDT 0x000000001FFE18FE 000034 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[    0.051875] ACPI: FACP 0x000000001FFE17B2 000074 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[    0.054405] ACPI: DSDT 0x000000001FFE0040 001772 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[    0.056879] ACPI: FACS 0x000000001FFE0000 000040
[    0.058312] ACPI: APIC 0x000000001FFE1826 000078 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[    0.060994] ACPI: HPET 0x000000001FFE189E 000038 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[    0.063710] ACPI: WAET 0x000000001FFE18D6 000028 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[    0.069474] ACPI: Reserving FACP table memory at [mem 0x1ffe17b2-0x1ffe1825]
[    0.072778] ACPI: Reserving DSDT table memory at [mem 0x1ffe0040-0x1ffe17b1]
[    0.076021] ACPI: Reserving FACS table memory at [mem 0x1ffe0000-0x1ffe003f]
[    0.079420] ACPI: Reserving APIC table memory at [mem 0x1ffe1826-0x1ffe189d]
[    0.084418] ACPI: Reserving HPET table memory at [mem 0x1ffe189e-0x1ffe18d5]
[    0.087696] ACPI: Reserving WAET table memory at [mem 0x1ffe18d6-0x1ffe18fd]
[    0.091654] No NUMA configuration found
[    0.093427] Faking a node at [mem 0x0000000000000000-0x000000001ffdffff]
[    0.096312] NODE_DATA(0) allocated [mem 0x1db17000-0x1db41fff]
[    0.099032] Zone ranges:
[    0.101341]   DMA      [mem 0x0000000000001000-0x0000000000ffffff]
[    0.103132]   DMA32    [mem 0x0000000001000000-0x000000001ffdffff]
[    0.104928]   Normal   empty
[    0.105753]   Device   empty
[    0.106577] Movable zone start for each node
[    0.107844] Early memory node ranges
[    0.109020]   node   0: [mem 0x0000000000001000-0x000000000009efff]
[    0.110907]   node   0: [mem 0x0000000000100000-0x000000001ffdffff]
[    0.112724] Initmem setup node 0 [mem 0x0000000000001000-0x000000001ffdffff]
[    0.117346] On node 0, zone DMA: 1 pages in unavailable ranges
[    0.117416] On node 0, zone DMA: 97 pages in unavailable ranges
[    0.121116] On node 0, zone DMA32: 32 pages in unavailable ranges
[    0.123645] ACPI: PM-Timer IO Port: 0x608
[    0.126814] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.128560] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23
[    0.133357] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.135215] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.137139] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.139046] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.141013] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.143194] ACPI: Using ACPI (MADT) for SMP configuration information
[    0.145057] ACPI: HPET id: 0x8086a201 base: 0xfed00000
[    0.146621] smpboot: Allowing 1 CPUs, 0 hotplug CPUs
[    0.148519] PM: hibernation: Registered nosave memory: [mem 0x00000000-0x00000fff]
[    0.153001] PM: hibernation: Registered nosave memory: [mem 0x0009f000-0x0009ffff]
[    0.155177] PM: hibernation: Registered nosave memory: [mem 0x000a0000-0x000effff]
[    0.157361] PM: hibernation: Registered nosave memory: [mem 0x000f0000-0x000fffff]
[    0.159777] [mem 0x20000000-0xfeffbfff] available for PCI devices
[    0.161536] Booting paravirtualized kernel on KVM
[    0.162899] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
[    0.176562] setup_percpu: NR_CPUS:8192 nr_cpumask_bits:1 nr_cpu_ids:1 nr_node_ids:1
[    0.179934] percpu: Embedded 61 pages/cpu s212992 r8192 d28672 u2097152
[    0.182370] kvm-guest: PV spinlocks disabled, no host support
[    0.186072] Fallback order for Node 0: 0 
[    0.187245] Built 1 zonelists, mobility grouping on.  Total pages: 128736
[    0.189236] Policy zone: DMA32
[    0.190124] Kernel command line: root=/dev/ram0 console=ttyS0 hung_task_panic=1 earlyprintk=ttyS0,115200
[    0.193156] Unknown kernel command line parameters "hung_task_panic=1", will be passed to user space.
[    0.195918] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.200308] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.202601] mem auto-init: stack:off, heap alloc:on, heap free:off
[    0.207095] Memory: 219848K/523768K available (14342K kernel code, 2705K rwdata, 8664K rodata, 2584K init, 4976K bss, 88584K reserved, 0K cma-reserved)
[    0.211581] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.213697] Kernel/User page tables isolation: enabled
[    0.217316] ftrace: allocating 38953 entries in 153 pages
[    0.219186] ftrace: allocated 153 pages with 4 groups
[    0.223755] Dynamic Preempt: voluntary
[    0.225517] rcu: Preemptible hierarchical RCU implementation.
[    0.227564] rcu:     RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=1.
[    0.229902]  Trampoline variant of Tasks RCU enabled.
[    0.231639]  Rude variant of Tasks RCU enabled.
[    0.233211]  Tracing variant of Tasks RCU enabled.
[    0.236785] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.239032] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.244878] NR_IRQS: 524544, nr_irqs: 256, preallocated irqs: 16
[    0.264937] Console: colour VGA+ 80x25
[    0.266814] printk: console [ttyS0] enabled
[    0.266814] printk: console [ttyS0] enabled
[    0.272082] printk: bootconsole [earlyser0] disabled
[    0.272082] printk: bootconsole [earlyser0] disabled
[    0.275128] ACPI: Core revision 20211217
[    0.276839] clocksource: hpet: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604467 ns
[    0.279713] APIC: Switch to symmetric I/O mode setup
[    0.283847] x2apic enabled
[    0.285197] Switched APIC routing to physical x2apic.
[    0.288988] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.290767] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x1702c2a0637, max_idle_ns: 440795222505 ns
[    0.293874] Calibrating delay loop (skipped) preset value.. 3192.74 BogoMIPS (lpj=6385492)
[    0.297863] pid_max: default: 32768 minimum: 301
[    0.301988] LSM: Security Framework initializing
[    0.303637] Yama: becoming mindful.
[    0.304997] AppArmor: AppArmor initialized
[    0.305874] TOMOYO Linux initialized
[    0.307273] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.309868] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
Poking KASLR using RDTSC...
[    0.314866] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.316735] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0
[    0.317874] Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization
[    0.321864] Spectre V2 : Mitigation: Retpolines
[    0.323154] Spectre V2 : Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch
[    0.325862] Speculative Store Bypass: Vulnerable
[    0.327471] MDS: Vulnerable: Clear CPU buffers attempted, no microcode
[    0.351564] Freeing SMP alternatives memory: 40K
[    0.462870] smpboot: CPU0: Intel QEMU Virtual CPU version 2.5+ (family: 0xf, model: 0x6b, stepping: 0x1)
[    0.465860] cblist_init_generic: Setting adjustable number of callback queues.
[    0.465865] cblist_init_generic: Setting shift to 0 and lim to 1.
[    0.469945] cblist_init_generic: Setting shift to 0 and lim to 1.
[    0.473903] cblist_init_generic: Setting shift to 0 and lim to 1.
[    0.476069] Performance Events: unsupported Netburst CPU model 107 no PMU driver, software events only.
[    0.477968] rcu: Hierarchical SRCU implementation.
[    0.482177] NMI watchdog: Perf NMI watchdog permanently disabled
[    0.485508] smp: Bringing up secondary CPUs ...
[    0.485868] smp: Brought up 1 node, 1 CPU
[    0.487025] smpboot: Max logical packages: 1
[    0.488407] smpboot: Total of 1 processors activated (3192.74 BogoMIPS)
[    0.491688] node 0 deferred pages initialised in 0ms
[    0.494162] devtmpfs: initialized
[    0.495437] x86/mm: Memory block size: 128MB
[    0.498368] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.501900] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.505975] pinctrl core: initialized pinctrl subsystem
[    0.508492] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.510009] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.512196] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    0.513916] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.517894] audit: initializing netlink subsys (disabled)
[    0.522126] thermal_sys: Registered thermal governor 'fair_share'
[    0.522128] thermal_sys: Registered thermal governor 'bang_bang'
[    0.524285] thermal_sys: Registered thermal governor 'step_wise'
[    0.525868] audit: type=2000 audit(1653183210.407:1): state=initialized audit_enabled=0 res=1
[    0.529868] thermal_sys: Registered thermal governor 'user_space'
[    0.529870] thermal_sys: Registered thermal governor 'power_allocator'
[    0.533920] cpuidle: using governor ladder
[    0.539785] cpuidle: using governor menu
[    0.541959] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[    0.545203] PCI: Using configuration type 1 for base access
[    0.550909] kprobes: kprobe jump-optimization is enabled. All kprobes are optimized if possible.
[    0.554202] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    0.558369] ACPI: Added _OSI(Module Device)
[    0.560321] ACPI: Added _OSI(Processor Device)
[    0.561877] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.564214] ACPI: Added _OSI(Processor Aggregator Device)
[    0.565877] ACPI: Added _OSI(Linux-Dell-Video)
[    0.569867] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[    0.573866] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics)
[    0.577091] ACPI: 1 ACPI AML tables successfully acquired and loaded
[    0.579294] ACPI: Interpreter enabled
[    0.581924] ACPI: PM: (supports S0 S3 S4 S5)
[    0.583924] ACPI: Using IOAPIC for interrupt routing
[    0.585903] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.590054] ACPI: Enabled 2 GPEs in block 00 to 0F
[    0.602095] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[    0.605017] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI HPX-Type3]
[    0.605867] acpi PNP0A03:00: _OSC: not requesting OS control; OS requires [ExtendedConfig ASPM ClockPM MSI]
[    0.609896] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.614354] acpiphp: Slot [3] registered
[    0.615510] acpiphp: Slot [4] registered
[    0.617900] acpiphp: Slot [5] registered
[    0.619054] acpiphp: Slot [6] registered
[    0.620226] acpiphp: Slot [7] registered
[    0.621900] acpiphp: Slot [8] registered
[    0.623439] acpiphp: Slot [9] registered
[    0.625933] acpiphp: Slot [10] registered
[    0.627125] acpiphp: Slot [11] registered
[    0.628328] acpiphp: Slot [12] registered
[    0.629908] acpiphp: Slot [13] registered
[    0.631088] acpiphp: Slot [14] registered
[    0.632290] acpiphp: Slot [15] registered
[    0.633897] acpiphp: Slot [16] registered
[    0.635191] acpiphp: Slot [17] registered
[    0.636391] acpiphp: Slot [18] registered
[    0.637939] acpiphp: Slot [19] registered
[    0.639153] acpiphp: Slot [20] registered
[    0.640781] acpiphp: Slot [21] registered
[    0.641934] acpiphp: Slot [22] registered
[    0.645897] acpiphp: Slot [23] registered
[    0.647301] acpiphp: Slot [24] registered
[    0.648737] acpiphp: Slot [25] registered
[    0.649897] acpiphp: Slot [26] registered
[    0.651425] acpiphp: Slot [27] registered
[    0.652865] acpiphp: Slot [28] registered
[    0.653896] acpiphp: Slot [29] registered
[    0.655319] acpiphp: Slot [30] registered
[    0.657928] acpiphp: Slot [31] registered
[    0.661329] PCI host bridge to bus 0000:00
[    0.661870] pci_bus 0000:00: root bus resource [io  0x0000-0x0cf7 window]
[    0.663806] pci_bus 0000:00: root bus resource [io  0x0d00-0xffff window]
[    0.665864] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window]
[    0.668246] pci_bus 0000:00: root bus resource [mem 0x20000000-0xfebfffff window]
[    0.669864] pci_bus 0000:00: root bus resource [mem 0x100000000-0x17fffffff window]
[    0.672210] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.673988] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000
[    0.679251] pci 0000:00:01.0: [8086:7000] type 00 class 0x060100
[    0.683126] pci 0000:00:01.1: [8086:7010] type 00 class 0x010180
[    0.688938] pci 0000:00:01.1: reg 0x20: [io  0xc000-0xc00f]
[    0.691429] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io  0x01f0-0x01f7]
[    0.693870] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io  0x03f6]
[    0.697864] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io  0x0170-0x0177]
[    0.699887] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io  0x0376]
[    0.702181] pci 0000:00:01.3: [8086:7113] type 00 class 0x068000
[    0.705978] pci 0000:00:01.3: quirk: [io  0x0600-0x063f] claimed by PIIX4 ACPI
[    0.709897] pci 0000:00:01.3: quirk: [io  0x0700-0x070f] claimed by PIIX4 SMB
[    0.712407] pci 0000:00:02.0: [1234:1111] type 00 class 0x030000
[    0.715848] pci 0000:00:02.0: reg 0x10: [mem 0xfd000000-0xfdffffff pref]
[    0.721908] pci 0000:00:02.0: reg 0x18: [mem 0xfebf0000-0xfebf0fff]
[    0.732149] pci 0000:00:02.0: reg 0x30: [mem 0xfebe0000-0xfebeffff pref]
[    0.734084] pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
[    0.739875] ACPI: PCI: Interrupt link LNKA configured for IRQ 10
[    0.742116] ACPI: PCI: Interrupt link LNKB configured for IRQ 10
[    0.746058] ACPI: PCI: Interrupt link LNKC configured for IRQ 11
[    0.748269] ACPI: PCI: Interrupt link LNKD configured for IRQ 11
[    0.749972] ACPI: PCI: Interrupt link LNKS configured for IRQ 9
[    0.754315] iommu: Default domain type: Translated 
[    0.755773] iommu: DMA domain TLB invalidation policy: lazy mode 
[    0.757965] EDAC MC: Ver: 3.0.0
[    0.761699] NetLabel: Initializing
[    0.761864] NetLabel:  domain hash size = 128
[    0.763373] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.765907] NetLabel:  unlabeled traffic allowed by default
[    0.767505] PCI: Using ACPI for IRQ routing
[    0.769255] pci 0000:00:02.0: vgaarb: setting as boot VGA device
[    0.769860] pci 0000:00:02.0: vgaarb: bridge control possible
[    0.769860] pci 0000:00:02.0: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none
[    0.769868] vgaarb: loaded
[    0.771788] hpet: 3 channels of 0 reserved for per-cpu timers
[    0.773891] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
[    0.775339] hpet0: 3 comparators, 64-bit 100.000000 MHz counter
[    0.780091] clocksource: Switched to clocksource kvm-clock
[    0.795594] VFS: Disk quotas dquot_6.6.0
[    0.805055] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.808528] AppArmor: AppArmor Filesystem Enabled
[    0.810778] pnp: PnP ACPI init
[    0.812789] pnp: PnP ACPI: found 6 devices
[    0.823695] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns
[    0.827974] NET: Registered PF_INET protocol family
[    0.833200] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.839253] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.842940] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.846105] TCP bind hash table entries: 4096 (order: 4, 65536 bytes, linear)
[    0.852329] TCP: Hash tables configured (established 4096 bind 4096)
[    0.855435] MPTCP token hash table entries: 512 (order: 1, 12288 bytes, linear)
[    0.858884] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.861986] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.868227] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.870927] NET: Registered PF_XDP protocol family
[    0.873168] pci_bus 0000:00: resource 4 [io  0x0000-0x0cf7 window]
[    0.876102] pci_bus 0000:00: resource 5 [io  0x0d00-0xffff window]
[    0.879004] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff window]
[    0.885179] pci_bus 0000:00: resource 7 [mem 0x20000000-0xfebfffff window]
[    0.888479] pci_bus 0000:00: resource 8 [mem 0x100000000-0x17fffffff window]
[    0.891483] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[    0.893840] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[    0.898522] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[    0.901440] PCI: CLS 0 bytes, default 64
[    0.903448] Trying to unpack rootfs image as initramfs...
[    0.909975] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x1702c2a0637, max_idle_ns: 440795222505 ns
[    0.926529] Initialise system trusted keyrings
[    0.928650] Key type blacklist registered
[    0.938615] workingset: timestamp_bits=36 max_order=17 bucket_order=0
[    0.948107] zbud: loaded
[    0.954702] integrity: Platform Keyring initialized
[    0.956244] Key type asymmetric registered
[    0.957512] Asymmetric key parser 'x509' registered
[    1.490500] Freeing initrd memory: 37496K
[    1.503594] alg: self-tests for CTR-KDF (hmac(sha256)) passed
[    1.505703] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    1.508437] io scheduler mq-deadline registered
[    1.511147] shpchp: Standard Hot Plug PCI Controller Driver version: 0.4
[    1.513501] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    1.521714] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    1.524605] Linux agpgart interface v0.103
[    1.525978] AMD-Vi: AMD IOMMUv2 functionality not available on this system - This is not a bug.
[    1.528627] i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[    1.537219] serio: i8042 KBD port at 0x60,0x64 irq 1
[    1.538698] serio: i8042 AUX port at 0x60,0x64 irq 12
[    1.540343] mousedev: PS/2 mouse device common for all mice
[    1.542674] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input0
[    1.546105] rtc_cmos 00:05: RTC can wake from S4
[    1.552966] rtc_cmos 00:05: registered as rtc0
[    1.554706] rtc_cmos 00:05: setting system clock to 2022-05-22T01:33:30 UTC (1653183210)
[    1.557557] rtc_cmos 00:05: alarms up to one day, y3k, 242 bytes nvram, hpet irqs
[    1.560287] intel_pstate: CPU model not supported
[    1.561971] ledtrig-cpu: registered to indicate activity on CPUs
[    1.584189] NET: Registered PF_INET6 protocol family
[    1.593604] Segment Routing with IPv6
[    1.594846] In-situ OAM (IOAM) with IPv6
[    1.596137] mip6: Mobile IPv6
[    1.597160] NET: Registered PF_PACKET protocol family
[    1.599139] mpls_gso: MPLS GSO support
[    1.602712] IPI shorthand broadcast: enabled
[    1.604100] sched_clock: Marking stable (1567587348, 34829305)->(1620357583, -17940930)
[    1.606641] registered taskstats version 1
[    1.607823] Loading compiled-in X.509 certificates
[    1.610801] zswap: loaded using pool zstd/zbud
[    1.612616] Key type ._fscrypt registered
[    1.614001] Key type .fscrypt registered
[    1.617096] Key type fscrypt-provisioning registered
[    1.626217] Key type encrypted registered
[    1.627424] AppArmor: AppArmor sha1 policy hashing enabled
[    1.629480] ima: No TPM chip found, activating TPM-bypass!
[    1.633367] ima: Allocated hash algorithm: sha256
[    1.634817] ima: No architecture policies found
[    1.636147] evm: Initialising EVM extended attributes:
[    1.637612] evm: security.selinux
[    1.638587] evm: security.SMACK64 (disabled)
[    1.639797] evm: security.SMACK64EXEC (disabled)
[    1.641104] evm: security.SMACK64TRANSMUTE (disabled)
[    1.642658] evm: security.SMACK64MMAP (disabled)
[    1.644067] evm: security.apparmor
[    1.645046] evm: security.ima
[    1.645934] evm: security.capability
[    1.647100] evm: HMAC attrs: 0x1
[    1.849917] Freeing unused decrypted memory: 2036K
[    1.852742] Freeing unused kernel image (initmem) memory: 2584K
[    1.861996] Write protecting the kernel read-only data: 26624k
[    1.866136] Freeing unused kernel image (text/rodata gap) memory: 2040K
[    1.868537] Freeing unused kernel image (rodata/data gap) memory: 1576K
[    1.935294] x86/mm: Checked W+X mappings: passed, no W+X pages found.
[    1.937268] x86/mm: Checking user space page tables
[    2.001605] x86/mm: Checked W+X mappings: passed, no W+X pages found.
[    2.013960] Run /init as init process
Loading, please wait...
Starting version 250.4-1
[    2.173265] floppy: disagrees about version of symbol module_layout
[    2.198746] scsi_common: disagrees about version of symbol module_layout
[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
[    2.210610] psmouse: disagrees about version of symbol module_layout
[    2.225138] scsi_common: disagrees about version of symbol module_layout
[    2.235536] scsi_common: disagrees about version of symbol module_layout

Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... [ 2.298555] crc32c_intel: disagrees about version of symbol module_layout

[    2.303335] crc32c_generic: disagrees about version of symbol module_layout
[    2.306667] libcrc32c: disagrees about version of symbol module_layout

Scanning for Btrfs filesystems
done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.

-dileks // 22-May-2022

#27 lore raw
Quoted 34 lines · Sedat Dilek
Quoted 4 lines · Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
Quoted 8 lines
Quoted 2 lines

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Hi Masahiro,

I cloned the repository on top of latest Linus Git.

Not able to boot in Quemu - Not able to boot on bare metal.

$ grep module_layout log_quemu-5.18.0-rc7-2-amd64-clang14-lto.txt
366:[    2.173265] floppy: disagrees about version of symbol module_layout
367:[    2.198746] scsi_common: disagrees about version of symbol module_layout
368:[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
369:[    2.210610] psmouse: disagrees about version of symbol module_layout
370:[    2.225138] scsi_common: disagrees about version of symbol module_layout
371:[    2.235536] scsi_common: disagrees about version of symbol module_layout
375:Begin: Running /scripts/local-premount ... [    2.298555]
crc32c_intel: disagrees about version of symbol module_layout
376:[    2.303335] crc32c_generic: disagrees about version of symbol
module_layout
377:[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 4 lines

Infos: LLVM-14 + CONFIG_LTO_CLANG_THIN=y

My linux-config and qemu-log are attached.

Thanks for your testing.

I was also able to reproduce this issue.

The problematic parts are:

[    2.298555] crc32c_intel: disagrees about version of symbol module_layout
[    2.303335] crc32c_generic: disagrees about version of symbol module_layout
[    2.306667] libcrc32c: disagrees about version of symbol module_layout

When CONFIG_LTO_CLANG_THIN=y,
I cannot see any __crc_* symbols in "nm vmlinux".

Perhaps, LTO might have discarded all the __crc_* symbols from vmlinux, but I am still checking the details...

Signature · 2 lines
Best Regards
Masahiro Yamada
#28 lore raw
Quoted 55 lines · Masahiro Yamada
Quoted 34 lines · Sedat Dilek
Quoted 4 lines · Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
Quoted 8 lines
Quoted 2 lines

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Hi Masahiro,

I cloned the repository on top of latest Linus Git.

Not able to boot in Quemu - Not able to boot on bare metal.

$ grep module_layout log_quemu-5.18.0-rc7-2-amd64-clang14-lto.txt
366:[    2.173265] floppy: disagrees about version of symbol module_layout
367:[    2.198746] scsi_common: disagrees about version of symbol module_layout
368:[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
369:[    2.210610] psmouse: disagrees about version of symbol module_layout
370:[    2.225138] scsi_common: disagrees about version of symbol module_layout
371:[    2.235536] scsi_common: disagrees about version of symbol module_layout
375:Begin: Running /scripts/local-premount ... [    2.298555]
crc32c_intel: disagrees about version of symbol module_layout
376:[    2.303335] crc32c_generic: disagrees about version of symbol
module_layout
377:[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 4 lines

Infos: LLVM-14 + CONFIG_LTO_CLANG_THIN=y

My linux-config and qemu-log are attached.

Thanks for your testing.

I was also able to reproduce this issue.

The problematic parts are:

[    2.298555] crc32c_intel: disagrees about version of symbol module_layout
[    2.303335] crc32c_generic: disagrees about version of symbol module_layout
[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 6 lines

When CONFIG_LTO_CLANG_THIN=y,
I cannot see any __crc_* symbols in "nm vmlinux".

Perhaps, LTO might have discarded all the __crc_* symbols from vmlinux, but I am still checking the details...

Thanks for taking care.

Just for the records:

$ grep CONFIG_MODVERSIONS /boot/config-5.18.0-rc7-2-amd64-clang14-lto
CONFIG_MODVERSIONS=y

-Sedat-

#29 lore raw
Quoted 64 lines · Sedat Dilek
Quoted 55 lines · Masahiro Yamada
Quoted 34 lines · Sedat Dilek
Quoted 4 lines · Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
Quoted 8 lines
Quoted 2 lines

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Hi Masahiro,

I cloned the repository on top of latest Linus Git.

Not able to boot in Quemu - Not able to boot on bare metal.

$ grep module_layout log_quemu-5.18.0-rc7-2-amd64-clang14-lto.txt
366:[    2.173265] floppy: disagrees about version of symbol module_layout
367:[    2.198746] scsi_common: disagrees about version of symbol module_layout
368:[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
369:[    2.210610] psmouse: disagrees about version of symbol module_layout
370:[    2.225138] scsi_common: disagrees about version of symbol module_layout
371:[    2.235536] scsi_common: disagrees about version of symbol module_layout
375:Begin: Running /scripts/local-premount ... [    2.298555]
crc32c_intel: disagrees about version of symbol module_layout
376:[    2.303335] crc32c_generic: disagrees about version of symbol
module_layout
377:[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 4 lines

Infos: LLVM-14 + CONFIG_LTO_CLANG_THIN=y

My linux-config and qemu-log are attached.

Thanks for your testing.

I was also able to reproduce this issue.

The problematic parts are:

[    2.298555] crc32c_intel: disagrees about version of symbol module_layout
[    2.303335] crc32c_generic: disagrees about version of symbol module_layout
[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 6 lines

When CONFIG_LTO_CLANG_THIN=y,
I cannot see any __crc_* symbols in "nm vmlinux".

Perhaps, LTO might have discarded all the __crc_* symbols from vmlinux, but I am still checking the details...

Quoted 7 lines

Thanks for taking care.

Just for the records:

$ grep CONFIG_MODVERSIONS /boot/config-5.18.0-rc7-2-amd64-clang14-lto
CONFIG_MODVERSIONS=y

Did not try CONFIG_MODVERSIONS=n.

We have a new file:

[ include/linux/export-internal.h ]
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Please do not include this explicitly.
* This is used by C files generated by modpost.
*/

#ifndef __LINUX_EXPORT_INTERNAL_H__
#define __LINUX_EXPORT_INTERNAL_H__

#include <linux/compiler.h>
#include <linux/types.h>

#define SYMBOL_CRC(sym, crc, sec)   \
       u32 __section("___kcrctab" sec "+" #sym) __crc_##sym = crc

#endif /* __LINUX_EXPORT_INTERNAL_H__ */

But we discard __kcrctab in scripts/module.lds.S file.

Maybe we need:

$ git diff scripts/module.lds.S
scripts/module.lds.S +0 -2
index 1d0e1e4dc3d2..c04b596c364b 100644
@@ -21,8 +21,6 @@ SECTIONS {
 
       __ksymtab               0 : { *(SORT(___ksymtab+*)) }
       __ksymtab_gpl           0 : { *(SORT(___ksymtab_gpl+*)) }
-       __kcrctab               0 : { *(SORT(___kcrctab+*)) }
-       __kcrctab_gpl           0 : { *(SORT(___kcrctab_gpl+*)) }
 
       .ctors                  0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
       .init_array             0 : ALIGN(8) { *(SORT(.init_array.*))

*(.init_array) }

Or even?

$ git diff scripts/kallsyms.c
scripts/kallsyms.c +0 -0
index 8caabddf817c..fb3601fe8aa3 100644
@@ -109,7 +109,6 @@ static bool is_ignored_symbol(const char *name, char type)
       static const char * const ignored_prefixes[] = {
               "$",                    /* local symbols for ARM, MIPS, etc. */
               ".L",                   /* local labels,

.LBB,.Ltmpxxx,.L__unnamed_xx,.LASANPC, etc. */
- "__crc_", /* modversions */

               "__efistub_",           /* arm64 EFI stub namespace */
               "__kvm_nvhe_",          /* arm64 non-VHE KVM namespace */
               "__AArch64ADRPThunk_",  /* arm64 lld */

- Sedat -

#30 lore raw
Quoted 91 lines · Sedat Dilek
Quoted 64 lines · Sedat Dilek
Quoted 55 lines · Masahiro Yamada
Quoted 34 lines · Sedat Dilek
Quoted 4 lines · Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
Quoted 8 lines
Quoted 2 lines

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Hi Masahiro,

I cloned the repository on top of latest Linus Git.

Not able to boot in Quemu - Not able to boot on bare metal.

$ grep module_layout log_quemu-5.18.0-rc7-2-amd64-clang14-lto.txt
366:[    2.173265] floppy: disagrees about version of symbol module_layout
367:[    2.198746] scsi_common: disagrees about version of symbol module_layout
368:[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
369:[    2.210610] psmouse: disagrees about version of symbol module_layout
370:[    2.225138] scsi_common: disagrees about version of symbol module_layout
371:[    2.235536] scsi_common: disagrees about version of symbol module_layout
375:Begin: Running /scripts/local-premount ... [    2.298555]
crc32c_intel: disagrees about version of symbol module_layout
376:[    2.303335] crc32c_generic: disagrees about version of symbol
module_layout
377:[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 4 lines

Infos: LLVM-14 + CONFIG_LTO_CLANG_THIN=y

My linux-config and qemu-log are attached.

Thanks for your testing.

I was also able to reproduce this issue.

The problematic parts are:

[    2.298555] crc32c_intel: disagrees about version of symbol module_layout
[    2.303335] crc32c_generic: disagrees about version of symbol module_layout
[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 6 lines

When CONFIG_LTO_CLANG_THIN=y,
I cannot see any __crc_* symbols in "nm vmlinux".

Perhaps, LTO might have discarded all the __crc_* symbols from vmlinux, but I am still checking the details...

Quoted 7 lines

Thanks for taking care.

Just for the records:

$ grep CONFIG_MODVERSIONS /boot/config-5.18.0-rc7-2-amd64-clang14-lto
CONFIG_MODVERSIONS=y

Did not try CONFIG_MODVERSIONS=n.

We have a new file:

[ include/linux/export-internal.h ]
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Please do not include this explicitly.
* This is used by C files generated by modpost.
*/

#ifndef __LINUX_EXPORT_INTERNAL_H__
#define __LINUX_EXPORT_INTERNAL_H__

#include <linux/compiler.h>
#include <linux/types.h>

Quoted 6 lines
#define SYMBOL_CRC(sym, crc, sec)   \
       u32 __section("___kcrctab" sec "+" #sym) __crc_##sym = crc

#endif /* __LINUX_EXPORT_INTERNAL_H__ */

But we discard __kcrctab in scripts/module.lds.S file.

No.
scripts/module.lds.S keeps __kcrctab.

The discarded sections are specified a few lines above:

/DISCARD/ : {
         *(.discard)
         *(.discard.*)
         SANITIZER_DISCARDS
}
Quoted 1 line

Maybe we need:

No.

The problem is __crc_* symbols are dropped from vmlinux when CONFIG_LTO_CLANG=y.

Please try this fixup:
https://lore.kernel.org/linux-kbuild/[email protected]/T/#u

Quoted 35 lines
$ git diff scripts/module.lds.S
scripts/module.lds.S +0 -2
index 1d0e1e4dc3d2..c04b596c364b 100644
@@ -21,8 +21,6 @@ SECTIONS {
 
       __ksymtab               0 : { *(SORT(___ksymtab+*)) }
       __ksymtab_gpl           0 : { *(SORT(___ksymtab_gpl+*)) }
-       __kcrctab               0 : { *(SORT(___kcrctab+*)) }
-       __kcrctab_gpl           0 : { *(SORT(___kcrctab_gpl+*)) }
 
       .ctors                  0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
       .init_array             0 : ALIGN(8) { *(SORT(.init_array.*))

*(.init_array) }

Or even?

$ git diff scripts/kallsyms.c
scripts/kallsyms.c +0 -0
index 8caabddf817c..fb3601fe8aa3 100644
@@ -109,7 +109,6 @@ static bool is_ignored_symbol(const char *name, char type)
       static const char * const ignored_prefixes[] = {
               "$",                    /* local symbols for ARM, MIPS, etc. */
               ".L",                   /* local labels,

.LBB,.Ltmpxxx,.L__unnamed_xx,.LASANPC, etc. */
- "__crc_", /* modversions */

               "__efistub_",           /* arm64 EFI stub namespace */
               "__kvm_nvhe_",          /* arm64 non-VHE KVM namespace */
               "__AArch64ADRPThunk_",  /* arm64 lld */

- Sedat -

Signature · 2 lines
Best Regards
Masahiro Yamada
#31 lore raw
Quoted 124 lines · Masahiro Yamada
Quoted 91 lines · Sedat Dilek
Quoted 64 lines · Sedat Dilek
Quoted 55 lines · Masahiro Yamada
Quoted 34 lines · Sedat Dilek
Quoted 4 lines · Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
Quoted 8 lines
Quoted 2 lines

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Hi Masahiro,

I cloned the repository on top of latest Linus Git.

Not able to boot in Quemu - Not able to boot on bare metal.

$ grep module_layout log_quemu-5.18.0-rc7-2-amd64-clang14-lto.txt
366:[    2.173265] floppy: disagrees about version of symbol module_layout
367:[    2.198746] scsi_common: disagrees about version of symbol module_layout
368:[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
369:[    2.210610] psmouse: disagrees about version of symbol module_layout
370:[    2.225138] scsi_common: disagrees about version of symbol module_layout
371:[    2.235536] scsi_common: disagrees about version of symbol module_layout
375:Begin: Running /scripts/local-premount ... [    2.298555]
crc32c_intel: disagrees about version of symbol module_layout
376:[    2.303335] crc32c_generic: disagrees about version of symbol
module_layout
377:[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 4 lines

Infos: LLVM-14 + CONFIG_LTO_CLANG_THIN=y

My linux-config and qemu-log are attached.

Thanks for your testing.

I was also able to reproduce this issue.

The problematic parts are:

[    2.298555] crc32c_intel: disagrees about version of symbol module_layout
[    2.303335] crc32c_generic: disagrees about version of symbol module_layout
[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 6 lines

When CONFIG_LTO_CLANG_THIN=y,
I cannot see any __crc_* symbols in "nm vmlinux".

Perhaps, LTO might have discarded all the __crc_* symbols from vmlinux, but I am still checking the details...

Quoted 7 lines

Thanks for taking care.

Just for the records:

$ grep CONFIG_MODVERSIONS /boot/config-5.18.0-rc7-2-amd64-clang14-lto
CONFIG_MODVERSIONS=y

Did not try CONFIG_MODVERSIONS=n.

We have a new file:

[ include/linux/export-internal.h ]
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Please do not include this explicitly.
* This is used by C files generated by modpost.
*/

#ifndef __LINUX_EXPORT_INTERNAL_H__
#define __LINUX_EXPORT_INTERNAL_H__

#include <linux/compiler.h>
#include <linux/types.h>

Quoted 6 lines
#define SYMBOL_CRC(sym, crc, sec)   \
       u32 __section("___kcrctab" sec "+" #sym) __crc_##sym = crc

#endif /* __LINUX_EXPORT_INTERNAL_H__ */

But we discard __kcrctab in scripts/module.lds.S file.

No.
scripts/module.lds.S keeps __kcrctab.

The discarded sections are specified a few lines above:

/DISCARD/ : {
         *(.discard)
         *(.discard.*)
         SANITIZER_DISCARDS
}
Quoted 1 line

Maybe we need:

Quoted 9 lines

No.

The problem is __crc_* symbols are dropped from vmlinux when CONFIG_LTO_CLANG=y.

Please try this fixup:
https://lore.kernel.org/linux-kbuild/[email protected]/T/#u

Thanks!

Will give it a try - will report in a few hours.

-Sedat-

Quoted 46 lines
Quoted 35 lines





$ git diff scripts/module.lds.S
scripts/module.lds.S +0 -2
index 1d0e1e4dc3d2..c04b596c364b 100644
@@ -21,8 +21,6 @@ SECTIONS {
 
       __ksymtab               0 : { *(SORT(___ksymtab+*)) }
       __ksymtab_gpl           0 : { *(SORT(___ksymtab_gpl+*)) }
-       __kcrctab               0 : { *(SORT(___kcrctab+*)) }
-       __kcrctab_gpl           0 : { *(SORT(___kcrctab_gpl+*)) }
 
       .ctors                  0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
       .init_array             0 : ALIGN(8) { *(SORT(.init_array.*))

*(.init_array) }

Or even?

$ git diff scripts/kallsyms.c
scripts/kallsyms.c +0 -0
index 8caabddf817c..fb3601fe8aa3 100644
@@ -109,7 +109,6 @@ static bool is_ignored_symbol(const char *name, char type)
       static const char * const ignored_prefixes[] = {
               "$",                    /* local symbols for ARM, MIPS, etc. */
               ".L",                   /* local labels,

.LBB,.Ltmpxxx,.L__unnamed_xx,.LASANPC, etc. */
- "__crc_", /* modversions */

Quoted 5 lines
               "__efistub_",           /* arm64 EFI stub namespace */
               "__kvm_nvhe_",          /* arm64 non-VHE KVM namespace */
               "__AArch64ADRPThunk_",  /* arm64 lld */

- Sedat -

--
Best Regards
Masahiro Yamada

Tested-by
#32 lore raw
Quoted 136 lines · Sedat Dilek
Quoted 124 lines · Masahiro Yamada
Quoted 91 lines · Sedat Dilek
Quoted 64 lines · Sedat Dilek
Quoted 55 lines · Masahiro Yamada
Quoted 34 lines · Sedat Dilek
Quoted 4 lines · Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
Quoted 8 lines
Quoted 2 lines

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Hi Masahiro,

I cloned the repository on top of latest Linus Git.

Not able to boot in Quemu - Not able to boot on bare metal.

$ grep module_layout log_quemu-5.18.0-rc7-2-amd64-clang14-lto.txt
366:[    2.173265] floppy: disagrees about version of symbol module_layout
367:[    2.198746] scsi_common: disagrees about version of symbol module_layout
368:[    2.205573] i2c_piix4: disagrees about version of symbol module_layout
369:[    2.210610] psmouse: disagrees about version of symbol module_layout
370:[    2.225138] scsi_common: disagrees about version of symbol module_layout
371:[    2.235536] scsi_common: disagrees about version of symbol module_layout
375:Begin: Running /scripts/local-premount ... [    2.298555]
crc32c_intel: disagrees about version of symbol module_layout
376:[    2.303335] crc32c_generic: disagrees about version of symbol
module_layout
377:[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 4 lines

Infos: LLVM-14 + CONFIG_LTO_CLANG_THIN=y

My linux-config and qemu-log are attached.

Thanks for your testing.

I was also able to reproduce this issue.

The problematic parts are:

[    2.298555] crc32c_intel: disagrees about version of symbol module_layout
[    2.303335] crc32c_generic: disagrees about version of symbol module_layout
[    2.306667] libcrc32c: disagrees about version of symbol module_layout
Quoted 6 lines

When CONFIG_LTO_CLANG_THIN=y,
I cannot see any __crc_* symbols in "nm vmlinux".

Perhaps, LTO might have discarded all the __crc_* symbols from vmlinux, but I am still checking the details...

Quoted 7 lines

Thanks for taking care.

Just for the records:

$ grep CONFIG_MODVERSIONS /boot/config-5.18.0-rc7-2-amd64-clang14-lto
CONFIG_MODVERSIONS=y

Did not try CONFIG_MODVERSIONS=n.

We have a new file:

[ include/linux/export-internal.h ]
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Please do not include this explicitly.
* This is used by C files generated by modpost.
*/

#ifndef __LINUX_EXPORT_INTERNAL_H__
#define __LINUX_EXPORT_INTERNAL_H__

#include <linux/compiler.h>
#include <linux/types.h>

Quoted 6 lines
#define SYMBOL_CRC(sym, crc, sec)   \
       u32 __section("___kcrctab" sec "+" #sym) __crc_##sym = crc

#endif /* __LINUX_EXPORT_INTERNAL_H__ */

But we discard __kcrctab in scripts/module.lds.S file.

No.
scripts/module.lds.S keeps __kcrctab.

The discarded sections are specified a few lines above:

/DISCARD/ : {
         *(.discard)
         *(.discard.*)
         SANITIZER_DISCARDS
}
Quoted 1 line

Maybe we need:

Quoted 9 lines

No.

The problem is __crc_* symbols are dropped from vmlinux when CONFIG_LTO_CLANG=y.

Please try this fixup:
https://lore.kernel.org/linux-kbuild/[email protected]/T/#u

Quoted 5 lines

Thanks!

Will give it a try - will report in a few hours.

-Sedat-

I was able to build and boot on bare metal.

Feel free to add my...

-Sedat-

Quoted 47 lines
Quoted 47 lines
Quoted 36 lines






$ git diff scripts/module.lds.S
scripts/module.lds.S +0 -2
index 1d0e1e4dc3d2..c04b596c364b 100644
@@ -21,8 +21,6 @@ SECTIONS {
 
       __ksymtab               0 : { *(SORT(___ksymtab+*)) }
       __ksymtab_gpl           0 : { *(SORT(___ksymtab_gpl+*)) }
-       __kcrctab               0 : { *(SORT(___kcrctab+*)) }
-       __kcrctab_gpl           0 : { *(SORT(___kcrctab_gpl+*)) }
 
       .ctors                  0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
       .init_array             0 : ALIGN(8) { *(SORT(.init_array.*))

*(.init_array) }

Or even?

$ git diff scripts/kallsyms.c
scripts/kallsyms.c +0 -0
index 8caabddf817c..fb3601fe8aa3 100644
@@ -109,7 +109,6 @@ static bool is_ignored_symbol(const char *name, char type)
       static const char * const ignored_prefixes[] = {
               "$",                    /* local symbols for ARM, MIPS, etc. */
               ".L",                   /* local labels,

.LBB,.Ltmpxxx,.L__unnamed_xx,.LASANPC, etc. */
- "__crc_", /* modversions */

Quoted 5 lines
               "__efistub_",           /* arm64 EFI stub namespace */
               "__kvm_nvhe_",          /* arm64 non-VHE KVM namespace */
               "__AArch64ADRPThunk_",  /* arm64 lld */

- Sedat -

--
Best Regards
Masahiro Yamada

#33 lore raw
In reply to Masahiro Yamada

Hi Masahiro, I'm sorry to raise this after release but this seems to be broken on SOME architectures. So far I have tested:

Affected - sparc, alpha
Unaffected - riscv, ia64

The affected systems are unable to load modules, similar to the previously reported issue. All module loading fails with "disagrees about version of symbol module_layout".

Bisect blames 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b, but this does not revert cleanly. Presumably CONFIG_MODVERSIONS=n would fix, but this is a pretty core feature.

Unlike the issue Sedat reported, this is on a GNU toolchain, no clang involved.

Here are the configs I am using (with make olddefconfig on upgrade to 5.19):

Broken - sparc - https://dpaste.com/5A8F2JD6U
Broken - alpha - https://dpaste.com/FYKK23L9X
Working - riscv - https://dpaste.com/HV6Y4V6NT
Working - ia64 - https://dpaste.com/HDLDNEAK4

Please let me know if there's anything I can do to help track down this regression.

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-05-13 08:20
From: Masahiro Yamada <[email protected]>
To: Linux Kbuild mailing list <[email protected]>

Quoted 4 lines · Masahiro Yamada

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Quoted 75 lines

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by
Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.

https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission

https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export

--
2.32.0

#34 lore raw
Quoted 7 lines · matoro

Hi Masahiro, I'm sorry to raise this after release but this seems to be broken on SOME architectures. So far I have tested:

Affected - sparc, alpha
Unaffected - riscv, ia64

What do you mean by "release"?

Checking the kernel-version from your paste-URLs:

# Automatically generated file; DO NOT EDIT. # Linux/sparc64 5.18.16-gentoo Kernel Configuration

# Automatically generated file; DO NOT EDIT.
# Linux/alpha 5.18.15-gentoo Kernel Configuration

# Automatically generated file; DO NOT EDIT.
# Linux/riscv 5.19.0-gentoo Kernel Configuration

# Automatically generated file; DO NOT EDIT.
# Linux/ia64 5.19.0-gentoo Kernel Configuration

Maybe you should try "Affected - sparc, alpha" with Linux v5.19.0 instead of 5.18.x :-)?

-Sedat-

Quoted 119 lines

The affected systems are unable to load modules, similar to the previously reported issue. All module loading fails with "disagrees about version of symbol module_layout".

Bisect blames 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b, but this does not revert cleanly. Presumably CONFIG_MODVERSIONS=n would fix, but this is a pretty core feature.

Unlike the issue Sedat reported, this is on a GNU toolchain, no clang involved.

Here are the configs I am using (with make olddefconfig on upgrade to 5.19):

Broken - sparc - https://dpaste.com/5A8F2JD6U
Broken - alpha - https://dpaste.com/FYKK23L9X
Working - riscv - https://dpaste.com/HV6Y4V6NT
Working - ia64 - https://dpaste.com/HDLDNEAK4

Please let me know if there's anything I can do to help track down this regression.

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-05-13 08:20
From: Masahiro Yamada <[email protected]>
To: Linux Kbuild mailing list <[email protected]>

Quoted 4 lines · Masahiro Yamada

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Quoted 75 lines

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by
Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.

https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission

https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export

--
2.32.0

#35 lore raw

Hi Sedat - I pulled these configs from the running systems, but I used "make olddefconfig" on these working 5.18 configs to generate the corresponding 5.19 configs that failed to boot. I'll see if I can go back in and repeat this process to regen the 5.19 configs (I deleted it all after 5.19 failed to boot).

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-08-06 03:23
From: Sedat Dilek <[email protected]>
To: matoro <[email protected]>

Quoted 7 lines · matoro

Hi Masahiro, I'm sorry to raise this after release but this seems to be broken on SOME architectures. So far I have tested:

Affected - sparc, alpha
Unaffected - riscv, ia64

What do you mean by "release"?

Checking the kernel-version from your paste-URLs:

# Automatically generated file; DO NOT EDIT. # Linux/sparc64 5.18.16-gentoo Kernel Configuration

# Automatically generated file; DO NOT EDIT.
# Linux/alpha 5.18.15-gentoo Kernel Configuration

# Automatically generated file; DO NOT EDIT.
# Linux/riscv 5.19.0-gentoo Kernel Configuration

# Automatically generated file; DO NOT EDIT.
# Linux/ia64 5.19.0-gentoo Kernel Configuration

Maybe you should try "Affected - sparc, alpha" with Linux v5.19.0 instead of 5.18.x :-)?

-Sedat-

Quoted 119 lines

The affected systems are unable to load modules, similar to the previously reported issue. All module loading fails with "disagrees about version of symbol module_layout".

Bisect blames 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b, but this does not revert cleanly. Presumably CONFIG_MODVERSIONS=n would fix, but this is a pretty core feature.

Unlike the issue Sedat reported, this is on a GNU toolchain, no clang involved.

Here are the configs I am using (with make olddefconfig on upgrade to 5.19):

Broken - sparc - https://dpaste.com/5A8F2JD6U
Broken - alpha - https://dpaste.com/FYKK23L9X
Working - riscv - https://dpaste.com/HV6Y4V6NT
Working - ia64 - https://dpaste.com/HDLDNEAK4

Please let me know if there's anything I can do to help track down this regression.

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-05-13 08:20
From: Masahiro Yamada <[email protected]>
To: Linux Kbuild mailing list <[email protected]>

Quoted 4 lines · Masahiro Yamada

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Quoted 75 lines

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by
Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.

https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission

https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export

--
2.32.0

#36 lore raw
In reply to matoro

Hi Matoro,

Thanks for the report.

I have qemu-system-sparc installed on my Ubuntu machine, so I think I will be able to test it on sparc, at least.

How did you test these 4 architectures (sparc, alpha, riscv, ia64)? QEMU?

Thanks

Quoted 126 lines · matoro

Hi Masahiro, I'm sorry to raise this after release but this seems to be broken on SOME architectures. So far I have tested:

Affected - sparc, alpha
Unaffected - riscv, ia64

The affected systems are unable to load modules, similar to the previously reported issue. All module loading fails with "disagrees about version of symbol module_layout".

Bisect blames 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b, but this does not revert cleanly. Presumably CONFIG_MODVERSIONS=n would fix, but this is a pretty core feature.

Unlike the issue Sedat reported, this is on a GNU toolchain, no clang involved.

Here are the configs I am using (with make olddefconfig on upgrade to 5.19):

Broken - sparc - https://dpaste.com/5A8F2JD6U
Broken - alpha - https://dpaste.com/FYKK23L9X
Working - riscv - https://dpaste.com/HV6Y4V6NT
Working - ia64 - https://dpaste.com/HDLDNEAK4

Please let me know if there's anything I can do to help track down this regression.

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-05-13 08:20
From: Masahiro Yamada <[email protected]>
To: Linux Kbuild mailing list <[email protected]>

Quoted 4 lines · Masahiro Yamada

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Quoted 75 lines

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by
Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.

https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission

https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export

--
2.32.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#37 lore raw

I have real hardware for all these arches in my collection. I use it for testing the latest kernel and toolchains on as many of the less-popular arches as possible, exactly to find issues like this one :)

Specifically we support all of these in Gentoo. To double-check this wasn't a config issue, I asked another user who also runs sparc to try building 5.19 with his config (not copying mine), and he observed the same problem. You can reach us in #gentoo-sparc on Libera.

As for testing, I make all this hardware available on an as-needed basis. So if you can't or don't want to fiddle with qemu, just let me know (email or IRC, same username on Libera), and I will get you direct access to my hardware. Thanks!!

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-08-08 01:54
From: Masahiro Yamada <[email protected]>
To: matoro <[email protected]>

Hi Matoro,

Thanks for the report.

I have qemu-system-sparc installed on my Ubuntu machine, so I think I will be able to test it on sparc, at least.

How did you test these 4 architectures (sparc, alpha, riscv, ia64)? QEMU?

Thanks

Quoted 126 lines · matoro

Hi Masahiro, I'm sorry to raise this after release but this seems to be broken on SOME architectures. So far I have tested:

Affected - sparc, alpha
Unaffected - riscv, ia64

The affected systems are unable to load modules, similar to the previously reported issue. All module loading fails with "disagrees about version of symbol module_layout".

Bisect blames 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b, but this does not revert cleanly. Presumably CONFIG_MODVERSIONS=n would fix, but this is a pretty core feature.

Unlike the issue Sedat reported, this is on a GNU toolchain, no clang involved.

Here are the configs I am using (with make olddefconfig on upgrade to 5.19):

Broken - sparc - https://dpaste.com/5A8F2JD6U
Broken - alpha - https://dpaste.com/FYKK23L9X
Working - riscv - https://dpaste.com/HV6Y4V6NT
Working - ia64 - https://dpaste.com/HDLDNEAK4

Please let me know if there's anything I can do to help track down this regression.

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-05-13 08:20
From: Masahiro Yamada <[email protected]>
To: Linux Kbuild mailing list <[email protected]>

Quoted 4 lines · Masahiro Yamada

This is the third batch of cleanups in this development cycle.

This series is available at
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
lto-cleanup-v6

Quoted 75 lines

Changes in v6:
- Fix false-positive warnings when CONFIG_TRIM_UNUSED_KSYMS=y

Changes in v5:
- Fix the build error when CONFIG_DEBUG_INFO_BTF=y (reported by
Nathan)
- Clean up arch/m68k/include/asm/export.h (Nick)
- Keep gen_symversions (and will be removed by a later patch)
- Add more comments in the script

Changes in v4:
- Rename .vmlinux-symver.c to .vmlinux.export.c because I notice this approach is useful for further cleanups, not only for modversioning but also for overall EXPORT_SYMBOL.
- New patch
- New.
Resent of my previous submission.

https://lore.kernel.org/all/[email protected]/
- New
Resent of my previous submission

https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v3:
- New patch

Changes in v2:
- Simplify the implementation (parse .cmd files after ELF)
- New patch
- replace the chain of $(if ...) with $(and )
- New patch
- New patch

Masahiro Yamada (10):
modpost: extract symbol versions from *.cmd files
kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS
kbuild: stop merging *.symversions
genksyms: adjust the output format to modpost
kbuild: do not create *.prelink.o for Clang LTO or IBT
kbuild: check static EXPORT_SYMBOL* by script instead of modpost
kbuild: make built-in.a rule robust against too long argument error
kbuild: make *.mod rule robust against too long argument error
kbuild: add cmd_and_savecmd macro
kbuild: rebuild multi-object modules when objtool is updated

 arch/m68k/include/asm/Kbuild    |   1 +
 arch/m68k/include/asm/export.h  |   2 -
 arch/powerpc/Kconfig            |   1 -
 arch/s390/Kconfig               |   1 -
 arch/um/Kconfig                 |   1 -
 include/asm-generic/export.h    |  22 ++-
 include/linux/export-internal.h |  16 +++
 include/linux/export.h          |  30 ++--
 init/Kconfig                    |   4 -
 kernel/module.c                 |  10 +-
 scripts/Kbuild.include          |  10 +-
 scripts/Makefile.build          | 134 ++++++------------
 scripts/Makefile.lib            |   7 -
 scripts/Makefile.modfinal       |   5 +-
 scripts/Makefile.modpost        |   9 +-
 scripts/check-local-export      |  64 +++++++++
 scripts/genksyms/genksyms.c     |  18 +--
 scripts/link-vmlinux.sh         |  33 ++---
 scripts/mod/modpost.c           | 236 +++++++++++++++++++++-----------
 19 files changed, 320 insertions(+), 284 deletions(-)
 delete mode 100644 arch/m68k/include/asm/export.h
 create mode 100644 include/linux/export-internal.h
 create mode 100755 scripts/check-local-export

--
2.32.0

#38 lore raw
Quoted 10 lines · matoro

I have real hardware for all these arches in my collection. I use it for testing the latest kernel and toolchains on as many of the less-popular arches as possible, exactly to find issues like this one :)

Specifically we support all of these in Gentoo. To double-check this wasn't a config issue, I asked another user who also runs sparc to try building 5.19 with his config (not copying mine), and he observed the same problem. You can reach us in #gentoo-sparc on Libera.

Quoted 4 lines

As for testing, I make all this hardware available on an as-needed basis. So if you can't or don't want to fiddle with qemu, just let me know (email or IRC, same username on Libera), and I will get you direct access to my hardware. Thanks!!

I found the root cause.

When I build the sparc kernel, I see a warning

WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned.

Then, modpost missed to write out the entry.

With the following patch, you will be able to load the module.

I will send a patch with a proper commit log tomorrow. I need some sleep now.

scripts/mod/modpost.c +0 -0
index 29474cee10b1..337bd36a890a 100644
@@ -2206,13 +2206,11 @@ static void add_exported_symbols(struct buffer

*buf, struct module *mod)

        /* record CRCs for exported symbols */
        buf_printf(buf, "\n");
        list_for_each_entry(sym, &mod->exported_symbols, list) {
-               if (!sym->crc_valid) {
+               if (!sym->crc_valid)
                        warn("EXPORT symbol \"%s\" [%s%s] version
generation failed, symbol will not be versioned.\n"
                             "Is \"%s\" prototyped in
<asm/asm-prototypes.h>?\n",
                             sym->name, mod->name, mod->is_vmlinux ? "" : ".ko",
                             sym->name);

- continue;
- }

                buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x, \"%s\");\n",
                           sym->name, sym->crc, sym->is_gpl_only ? "_gpl" : "");
Signature · 2 lines
Best Regards
Masahiro Yamada
#39 lore raw

That patch doesn't apply to the v5.19 stable tag, so I just manually edited and it worked perfect! Thank you!!

Sorry I didn't mention that warning - I did see it, but it still showed up even on the old kernel, so I thought it was irrelevant. Much appreciated!

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-08-08 13:36
From: Masahiro Yamada <[email protected]>
To: matoro <[email protected]>

Quoted 10 lines · matoro

I have real hardware for all these arches in my collection. I use it for testing the latest kernel and toolchains on as many of the less-popular arches as possible, exactly to find issues like this one :)

Specifically we support all of these in Gentoo. To double-check this wasn't a config issue, I asked another user who also runs sparc to try building 5.19 with his config (not copying mine), and he observed the same problem. You can reach us in #gentoo-sparc on Libera.

Quoted 4 lines

As for testing, I make all this hardware available on an as-needed basis. So if you can't or don't want to fiddle with qemu, just let me know (email or IRC, same username on Libera), and I will get you direct access to my hardware. Thanks!!

I found the root cause.

When I build the sparc kernel, I see a warning

WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned.

Then, modpost missed to write out the entry.

With the following patch, you will be able to load the module.

I will send a patch with a proper commit log tomorrow. I need some sleep now.

scripts/mod/modpost.c +0 -0
index 29474cee10b1..337bd36a890a 100644
@@ -2206,13 +2206,11 @@ static void add_exported_symbols(struct buffer

*buf, struct module *mod)

        /* record CRCs for exported symbols */
        buf_printf(buf, "\n");
        list_for_each_entry(sym, &mod->exported_symbols, list) {
-               if (!sym->crc_valid) {
+               if (!sym->crc_valid)
                        warn("EXPORT symbol \"%s\" [%s%s] version
generation failed, symbol will not be versioned.\n"
                             "Is \"%s\" prototyped in
<asm/asm-prototypes.h>?\n",
                             sym->name, mod->name, mod->is_vmlinux ? "" 
: ".ko",
                             sym->name);

- continue;
- }

                buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x, \"%s\");\n",
                           sym->name, sym->crc, sym->is_gpl_only ? 

"_gpl" : "");

#40 lore raw
Quoted 42 lines · matoro

That patch doesn't apply to the v5.19 stable tag, so I just manually edited and it worked perfect! Thank you!!

Sorry I didn't mention that warning - I did see it, but it still showed up even on the old kernel, so I thought it was irrelevant. Much appreciated!

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-08-08 13:36
From: Masahiro Yamada <[email protected]>
To: matoro <[email protected]>

Quoted 11 lines · matoro

I have real hardware for all these arches in my collection. I use it for testing the latest kernel and toolchains on as many of the less-popular arches as possible, exactly to find issues like this one :)

Specifically we support all of these in Gentoo. To double-check this wasn't a config issue, I asked another user who also runs sparc to try building 5.19 with his config (not copying mine), and he observed the same problem. You can reach us in #gentoo-sparc on Libera.

Quoted 4 lines

As for testing, I make all this hardware available on an as-needed basis. So if you can't or don't want to fiddle with qemu, just let me know (email or IRC, same username on Libera), and I will get you direct access to my hardware. Thanks!!

I found the root cause.

When I build the sparc kernel, I see a warning

WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned.

Quoted 6 lines

Then, modpost missed to write out the entry.

With the following patch, you will be able to load the module.

I will send a patch with a proper commit log tomorrow. I need some sleep now.

I posted a patch:

https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/

If you want me to record your full name in Reported/Tested-by, please let me know.

Signature · 2 lines
Best Regards
Masahiro Yamada