All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] busybox: Exclude .debug from depmod
@ 2022-03-31 22:21 Saul Wold
  2022-03-31 22:21 ` [PATCH v2 2/3] kmod: Add an exclude directive to depmod Saul Wold
  2022-03-31 22:21 ` [PATCH v2 3/3] depmodwrapper: Use nonarch_base_libdir for depmod.d Saul Wold
  0 siblings, 2 replies; 5+ messages in thread
From: Saul Wold @ 2022-03-31 22:21 UTC (permalink / raw)
  To: openembedded-core; +Cc: Saul Wold

As with the kmod version of depmod, exclude .debug from being
searched. Since busybox does not use the depmod.d and any 
configuration file option is ignored we just hardcode it.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
---
 ...001-depmod-Ignore-.debug-directories.patch | 32 +++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.35.0.bb   |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 meta/recipes-core/busybox/busybox/0001-depmod-Ignore-.debug-directories.patch

diff --git a/meta/recipes-core/busybox/busybox/0001-depmod-Ignore-.debug-directories.patch b/meta/recipes-core/busybox/busybox/0001-depmod-Ignore-.debug-directories.patch
new file mode 100644
index 00000000000..354f83a4a5f
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-depmod-Ignore-.debug-directories.patch
@@ -0,0 +1,32 @@
+From 5f6ed003f10ee0bd4a508d5f59129a29f0920dfc Mon Sep 17 00:00:00 2001
+From: Saul Wold <saul.wold@windriver.com>
+Date: Thu, 31 Mar 2022 11:21:45 -0700
+Subject: [PATCH] depmod: Ignore .debug directories
+
+The .debug/<module>.ko files do not have the correct symbol information
+since it's split away from the actual <module>.ko file. Just ignore it.
+
+Upstream-Status: Pending
+
+Signed-off-by: Saul Wold <saul.wold@windriver.com>
+---
+ modutils/depmod.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/modutils/depmod.c b/modutils/depmod.c
+index bb42bbe..aa5a2de 100644
+--- a/modutils/depmod.c
++++ b/modutils/depmod.c
+@@ -43,6 +43,9 @@ static int FAST_FUNC parse_module(struct recursive_state *state,
+ 	/* Arbitrary. Was sb->st_size, but that breaks .gz etc */
+ 	size_t len = (64*1024*1024 - 4096);
+ 
++	if (strstr(fname, ".debug") == NULL)
++		return TRUE;
++
+ 	if (strrstr(fname, ".ko") == NULL)
+ 		return TRUE;
+ 
+-- 
+2.31.1
+
diff --git a/meta/recipes-core/busybox/busybox_1.35.0.bb b/meta/recipes-core/busybox/busybox_1.35.0.bb
index 7ce17170462..ab11f3d89a8 100644
--- a/meta/recipes-core/busybox/busybox_1.35.0.bb
+++ b/meta/recipes-core/busybox/busybox_1.35.0.bb
@@ -1,6 +1,7 @@
 require busybox.inc
 
 SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
+           file://0001-depmod-Ignore-.debug-directories.patch \
            file://busybox-udhcpc-no_deconfig.patch \
            file://find-touchscreen.sh \
            file://busybox-cron \
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] kmod: Add an exclude directive to depmod
  2022-03-31 22:21 [PATCH v2 1/3] busybox: Exclude .debug from depmod Saul Wold
@ 2022-03-31 22:21 ` Saul Wold
  2022-03-31 22:21 ` [PATCH v2 3/3] depmodwrapper: Use nonarch_base_libdir for depmod.d Saul Wold
  1 sibling, 0 replies; 5+ messages in thread
From: Saul Wold @ 2022-03-31 22:21 UTC (permalink / raw)
  To: openembedded-core; +Cc: Saul Wold

This adds a new configuration directive to depmod that causes
depmod to exclude a give path entry like .debug.

kernel-dbg provides the modules .debug/<module>.ko files and
when installed either directly or when dbg-pkgs are selected
this can cause depmod to fail.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
---
v2: Updated patch based on upstream comments

 ...dd-support-for-excluding-a-directory.patch | 169 ++++++++++++++++++
 meta/recipes-kernel/kmod/kmod_29.bb           |   4 +
 2 files changed, 173 insertions(+)
 create mode 100644 meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch

diff --git a/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
new file mode 100644
index 00000000000..18d97935331
--- /dev/null
+++ b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
@@ -0,0 +1,169 @@
+From 01f3fe68a7a42b06eb318f3b09fa5e5ea75d46c4 Mon Sep 17 00:00:00 2001
+From: Saul Wold <saul.wold@windriver.com>
+Date: Tue, 22 Mar 2022 12:11:45 -0700
+Subject: [PATCH] depmod: Add support for excluding a directory
+
+This adds support to depmod to enable a new exclude directive in
+the depmod.d/*.conf configuration file. Currently depmod
+already excludes directories named source or build. This change
+will allow additional directories like .debug to be excluded also
+via a new exclude directive.
+
+depmod.d/exclude.conf example:
+exclude	.debug
+
+Upstream-Status: Submitted
+
+Signed-off-by: Saul Wold <saul.wold@windriver.com>
+---
+ man/depmod.d.xml | 14 +++++++++++
+ tools/depmod.c   | 65 +++++++++++++++++++++++++++++++++++++++++++++---
+ 2 files changed, 75 insertions(+), 4 deletions(-)
+
+diff --git a/man/depmod.d.xml b/man/depmod.d.xml
+index b315e93..76548e9 100644
+--- a/man/depmod.d.xml
++++ b/man/depmod.d.xml
+@@ -131,6 +131,20 @@
+           </para>
+         </listitem>
+       </varlistentry>
++      <varlistentry>
++        <term>exclude <replaceable>excludedir</replaceable>
++        </term>
++        <listitem>
++          <para>
++            This specifies the trailing directories that will be excluded
++            during the search for kernel modules.
++          </para>
++          <para>
++	    The <replaceable>excludedir</replaceable> is the trailing directory
++	    to exclude
++          </para>
++        </listitem>
++      </varlistentry>
+     </variablelist>
+   </refsect1>
+ 
+diff --git a/tools/depmod.c b/tools/depmod.c
+index eb810b8..ac365e9 100644
+--- a/tools/depmod.c
++++ b/tools/depmod.c
+@@ -458,6 +458,11 @@ struct cfg_external {
+ 	char path[];
+ };
+ 
++struct cfg_exclude {
++	struct cfg_exclude *next;
++	char exclude_dir[];
++};
++
+ struct cfg {
+ 	const char *kversion;
+ 	char dirname[PATH_MAX];
+@@ -469,6 +474,7 @@ struct cfg {
+ 	struct cfg_override *overrides;
+ 	struct cfg_search *searches;
+ 	struct cfg_external *externals;
++	struct cfg_exclude *excludes;
+ };
+ 
+ static enum search_type cfg_define_search_type(const char *path)
+@@ -580,6 +586,30 @@ static void cfg_external_free(struct cfg_external *ext)
+ 	free(ext);
+ }
+ 
++static int cfg_exclude_add(struct cfg *cfg, const char *path)
++{
++	struct cfg_exclude *exc;
++	size_t len = strlen(path);
++
++	exc = malloc(sizeof(struct cfg_exclude) + len + 1);
++	if (exc == NULL) {
++		ERR("exclude add: out of memory\n");
++		return -ENOMEM;
++	}
++	memcpy(exc->exclude_dir, path, len + 1);
++
++	DBG("exclude add: %s\n", path);
++
++	exc->next = cfg->excludes;
++	cfg->excludes = exc;
++	return 0;
++}
++
++static void cfg_exclude_free(struct cfg_exclude *exc)
++{
++	free(exc);
++}
++
+ static int cfg_kernel_matches(const struct cfg *cfg, const char *pattern)
+ {
+ 	regex_t re;
+@@ -657,6 +687,11 @@ static int cfg_file_parse(struct cfg *cfg, const char *filename)
+ 			}
+ 
+ 			cfg_external_add(cfg, dir);
++		} else if (streq(cmd, "exclude")) {
++			const char *sp;
++			while ((sp = strtok_r(NULL, "\t ", &saveptr)) != NULL) {
++				cfg_exclude_add(cfg, sp);
++			}
+ 		} else if (streq(cmd, "include")
+ 				|| streq(cmd, "make_map_files")) {
+ 			INF("%s:%u: command %s not implemented yet\n",
+@@ -857,6 +892,12 @@ static void cfg_free(struct cfg *cfg)
+ 		cfg->externals = cfg->externals->next;
+ 		cfg_external_free(tmp);
+ 	}
++
++	while (cfg->excludes) {
++		struct cfg_exclude *tmp = cfg->excludes;
++		cfg->excludes = cfg->excludes->next;
++		cfg_exclude_free(tmp);
++	}
+ }
+ 
+ 
+@@ -1229,6 +1270,24 @@ add:
+ 	return 0;
+ }
+ 
++static int should_exclude_dir(struct cfg *cfg, char *name)
++{
++	struct cfg_exclude *exc;
++
++	if (name[0] == '.' && (name[1] == '\0' ||
++			(name[1] == '.' && name[2] == '\0')))
++		return 1;
++	if (streq(name, "build") || streq(name, "source"))
++		return 1;
++
++	for (exc = cfg->excludes; exc != NULL; exc = exc->next) {
++		if (streq(name, exc->exclude_dir)) {
++			return 1;
++		}
++	}
++	return 0;
++}
++
+ static int depmod_modules_search_dir(struct depmod *depmod, DIR *d, size_t baselen, struct scratchbuf *s_path)
+ {
+ 	struct dirent *de;
+@@ -1240,11 +1299,9 @@ static int depmod_modules_search_dir(struct depmod *depmod, DIR *d, size_t basel
+ 		size_t namelen;
+ 		uint8_t is_dir;
+ 
+-		if (name[0] == '.' && (name[1] == '\0' ||
+-				       (name[1] == '.' && name[2] == '\0')))
+-			continue;
+-		if (streq(name, "build") || streq(name, "source"))
++		if (should_exclude_dir(depmod->cfg, name))
+ 			continue;
++
+ 		namelen = strlen(name);
+ 		if (scratchbuf_alloc(s_path, baselen + namelen + 2) < 0) {
+ 			err = -ENOMEM;
+-- 
+2.31.1
+
diff --git a/meta/recipes-kernel/kmod/kmod_29.bb b/meta/recipes-kernel/kmod/kmod_29.bb
index 91951edde16..9b663490666 100644
--- a/meta/recipes-kernel/kmod/kmod_29.bb
+++ b/meta/recipes-kernel/kmod/kmod_29.bb
@@ -20,6 +20,7 @@ SRCREV = "b6ecfc916a17eab8f93be5b09f4e4f845aabd3d1"
 SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \
            file://depmod-search.conf \
            file://avoid_parallel_tests.patch \
+           file://0001-depmod-Add-support-for-excluding-a-directory.patch \
            "
 
 S = "${WORKDIR}/git"
@@ -64,6 +65,9 @@ do_install:append () {
 
         # install depmod.d file for search/ dir
         install -Dm644 "${WORKDIR}/depmod-search.conf" "${D}${nonarch_base_libdir}/depmod.d/search.conf"
+
+        # Add .debug to the exclude path for depmod
+        echo "exclude .debug" > ${D}${nonarch_base_libdir}/depmod.d/exclude.conf
 }
 
 ALTERNATIVE_PRIORITY = "70"
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] depmodwrapper: Use nonarch_base_libdir for depmod.d
  2022-03-31 22:21 [PATCH v2 1/3] busybox: Exclude .debug from depmod Saul Wold
  2022-03-31 22:21 ` [PATCH v2 2/3] kmod: Add an exclude directive to depmod Saul Wold
@ 2022-03-31 22:21 ` Saul Wold
  2022-04-01 11:11   ` [OE-core] " Richard Purdie
  1 sibling, 1 reply; 5+ messages in thread
From: Saul Wold @ 2022-03-31 22:21 UTC (permalink / raw)
  To: openembedded-core; +Cc: Saul Wold

This ensure that when depmod-native runs we can find the correct
exclude.conf information, in this case adding .debug to ignore
the .debug kernell modules. The kmod utilities like depmod can use
either /etc/depmod.d or /lib/depmod.d. The kmod recipe is installing
the existing search.conf to /lib/depmod.d (nonarch_base_lib)

When the busybox modutils are used, /lib/depmod.d is not used, so
it's safe add the exclude.conf file to /lib/depmod.d.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
---
 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
index 04fc14a6d21..65068f02df8 100644
--- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
+++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
@@ -30,11 +30,16 @@ if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
     kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion")
 fi
 
+if [ ! -e "\3${nonarch_base_libdir}/depmod.d/exclude.conf" ]; then
+    mkdir -p "\$3${nonarch_base_libdir}/depmod.d"
+    echo "exclude .debug" > "\$3${nonarch_base_libdir}/depmod.d/exclude.conf"
+fi
+
 if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
     echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
-    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
+    exec env depmod -C "\$3${nonarch_base_libdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
 else
-    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
+    exec env depmod -C "\$3${nonarch_base_libdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
 fi
 EOF
 	chmod +x ${D}${bindir_crossscripts}/depmodwrapper
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH v2 3/3] depmodwrapper: Use nonarch_base_libdir for depmod.d
  2022-03-31 22:21 ` [PATCH v2 3/3] depmodwrapper: Use nonarch_base_libdir for depmod.d Saul Wold
@ 2022-04-01 11:11   ` Richard Purdie
  2022-04-01 15:28     ` Saul Wold
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2022-04-01 11:11 UTC (permalink / raw)
  To: Saul Wold, openembedded-core

On Thu, 2022-03-31 at 15:21 -0700, Saul Wold wrote:
> This ensure that when depmod-native runs we can find the correct
> exclude.conf information, in this case adding .debug to ignore
> the .debug kernell modules. The kmod utilities like depmod can use
> either /etc/depmod.d or /lib/depmod.d. The kmod recipe is installing
> the existing search.conf to /lib/depmod.d (nonarch_base_lib)
> 
> When the busybox modutils are used, /lib/depmod.d is not used, so
> it's safe add the exclude.conf file to /lib/depmod.d.
> 
> Signed-off-by: Saul Wold <saul.wold@windriver.com>
> ---
>  meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> index 04fc14a6d21..65068f02df8 100644
> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -30,11 +30,16 @@ if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>      kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion")
>  fi
>  
> +if [ ! -e "\3${nonarch_base_libdir}/depmod.d/exclude.conf" ]; then
> +    mkdir -p "\$3${nonarch_base_libdir}/depmod.d"
> +    echo "exclude .debug" > "\$3${nonarch_base_libdir}/depmod.d/exclude.conf"
> +fi

Shouldn't the above go into the kmod recipe? We need this on target as well as
in our rootfs build, right? I'm worried about the case where someone calls
depmod on target.

> +
>  if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
>      echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
> -    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
> +    exec env depmod -C "\$3${nonarch_base_libdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
>  else
> -    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
> +    exec env depmod -C "\$3${nonarch_base_libdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
>  fi
>  EOF
>  	chmod +x ${D}${bindir_crossscripts}/depmodwrapper

Does anything in the build install to $sysconfdir/depmod.d ?

Cheers,

Richard




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH v2 3/3] depmodwrapper: Use nonarch_base_libdir for depmod.d
  2022-04-01 11:11   ` [OE-core] " Richard Purdie
@ 2022-04-01 15:28     ` Saul Wold
  0 siblings, 0 replies; 5+ messages in thread
From: Saul Wold @ 2022-04-01 15:28 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core



On 4/1/22 04:11, Richard Purdie wrote:
> On Thu, 2022-03-31 at 15:21 -0700, Saul Wold wrote:
>> This ensure that when depmod-native runs we can find the correct
>> exclude.conf information, in this case adding .debug to ignore
>> the .debug kernell modules. The kmod utilities like depmod can use
>> either /etc/depmod.d or /lib/depmod.d. The kmod recipe is installing
>> the existing search.conf to /lib/depmod.d (nonarch_base_lib)
>>
>> When the busybox modutils are used, /lib/depmod.d is not used, so
>> it's safe add the exclude.conf file to /lib/depmod.d.
>>
>> Signed-off-by: Saul Wold <saul.wold@windriver.com>
>> ---
>>   meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> index 04fc14a6d21..65068f02df8 100644
>> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> @@ -30,11 +30,16 @@ if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>>       kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion")
>>   fi
>>   
>> +if [ ! -e "\3${nonarch_base_libdir}/depmod.d/exclude.conf" ]; then
>> +    mkdir -p "\$3${nonarch_base_libdir}/depmod.d"
>> +    echo "exclude .debug" > "\$3${nonarch_base_libdir}/depmod.d/exclude.conf"
>> +fi
> 
> Shouldn't the above go into the kmod recipe? We need this on target as well as
> in our rootfs build, right? I'm worried about the case where someone calls
> depmod on target.
> 
The kmod recipe does install it into nonarch_base_libdir/depmod.d, this 
is for the case of busybox which does not install anything and we are 
using kmod-native and the code below has depmod-native pointing to the 
correct depmod.d in the target rootfs image.

Files installed by kmod-native don't make it to the target rootfs, so we 
need to create the exclude.conf here.  I could remove it after 
depmod-native runs if that's your concern.

>> +
>>   if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
>>       echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
>> -    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
>> +    exec env depmod -C "\$3${nonarch_base_libdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
>>   else
>> -    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
>> +    exec env depmod -C "\$3${nonarch_base_libdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
>>   fi
>>   EOF
>>   	chmod +x ${D}${bindir_crossscripts}/depmodwrapper
> 
> Does anything in the build install to $sysconfdir/depmod.d ?

Not that I know of, it's only created by the kmod recipe.

Sau!

> 
> Cheers,
> 
> Richard
> 
> 

-- 
Sau!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-01 15:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 22:21 [PATCH v2 1/3] busybox: Exclude .debug from depmod Saul Wold
2022-03-31 22:21 ` [PATCH v2 2/3] kmod: Add an exclude directive to depmod Saul Wold
2022-03-31 22:21 ` [PATCH v2 3/3] depmodwrapper: Use nonarch_base_libdir for depmod.d Saul Wold
2022-04-01 11:11   ` [OE-core] " Richard Purdie
2022-04-01 15:28     ` Saul Wold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.