linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Holger Eitzenberger <holger@eitzenberger.org>
To: jcm@jonmasters.org, linux-modules@vger.kernel.org
Cc: gregkh@linuxfoundation.org, sebastian.poehn@sophos.com
Subject: [RESEND] Regression using module-init-tools on Kernel v3.12.y
Date: Mon, 27 Oct 2014 13:27:42 +0100	[thread overview]
Message-ID: <20141027122742.GD9396@imap.eitzenberger.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

Hi all,

we are still using module-init-tools for module handling.  And so does
SuSE SLES11.

However, after upgrading from kernel v3.8.y to v3.12.y we noticed
that modules.pcimap was empty, which is due to the fact that the
DEFINE_PCI_DEVICE_TABLE() has been modified to encode the name of
the device table.  Which in turn has been done to avoid issues with
multiple tables in a driver (see [1]).

I understand why this patch went it, and fixing this issue in the PNP
driver is worth fixing, I agree.

However, there is quite some userbase of module-init-tools out there,
eventually upgrading as well.  And as a consequence I think it makes
sense to patch module-init-tools as well to support both format.

I know that module-init-tools are deprecated by libkmod, and therefore
they seem to be unmaintained since 2011 (at least when looking at
git.kernel.org).

Still, does the attached patch makes sense to apply to git GIT repo?
It modifies elfops to support old and new format of the table name.

I think most people will check kernel.org GIT for a patch, so I think
it makes sense to apply this patch.

Thanks.

 /Holger


[1] http://marc.info/?l=linux-input&m=139091653012772&w=2

[-- Attachment #2: support-newer-elf-section.diff --]
[-- Type: text/x-diff, Size: 4620 bytes --]

depmod: check both old and new __mod_pci_device_tab_section

New format has name of table included, e. g. for e100 driver:

  __mod_pci__e100_id_table_device_table

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>

Index: module-init-tools/elfops_core.c
===================================================================
--- module-init-tools.orig/elfops_core.c
+++ module-init-tools/elfops_core.c
@@ -348,49 +348,51 @@ static void PERBIT(fetch_tables)(struct
 	for (i = 0; i < size / sizeof(syms[0]); i++) {
 		char *name = strings + END(syms[i].st_name, conv);
 
-		if (!tables->pci_table && streq(name, "__mod_pci_device_table")) {
+		if (!tables->pci_table && mod_device_table("pci", name)) {
 			tables->pci_size = PERBIT(PCI_DEVICE_SIZE);
 			tables->pci_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 							      NULL, conv);
 		}
-		else if (!tables->usb_table && streq(name, "__mod_usb_device_table")) {
+		else if (!tables->usb_table && mod_device_table("usb", name)) {
 			tables->usb_size = PERBIT(USB_DEVICE_SIZE);
 			tables->usb_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 							      NULL, conv);
 		}
-		else if (!tables->ccw_table && streq(name, "__mod_ccw_device_table")) {
+		else if (!tables->ccw_table && mod_device_table("ccw", name)) {
 			tables->ccw_size = PERBIT(CCW_DEVICE_SIZE);
 			tables->ccw_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 							      NULL, conv);
 		}
-		else if (!tables->ieee1394_table && streq(name, "__mod_ieee1394_device_table")) {
+		else if (!tables->ieee1394_table &&
+				 mod_device_table("ieee1394", name)) {
 			tables->ieee1394_size = PERBIT(IEEE1394_DEVICE_SIZE);
 			tables->ieee1394_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 								   NULL, conv);
 		}
-		else if (!tables->pnp_table && streq(name, "__mod_pnp_device_table")) {
+		else if (!tables->pnp_table && mod_device_table("pnp", name)) {
 			tables->pnp_size = PERBIT(PNP_DEVICE_SIZE);
 			tables->pnp_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 							      NULL, conv);
 		}
-		else if (!tables->pnp_card_table && streq(name, "__mod_pnp_card_device_table")) {
+		else if (!tables->pnp_card_table &&
+				 mod_device_table("pnp_card", name)) {
 			tables->pnp_card_size = PERBIT(PNP_CARD_DEVICE_SIZE);
 			tables->pnp_card_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 								   NULL, conv);
 			tables->pnp_card_offset = PERBIT(PNP_CARD_DEVICE_OFFSET);
 		}
-		else if (!tables->input_table && streq(name, "__mod_input_device_table")) {
+		else if (!tables->input_table && mod_device_table("input", name)) {
 			tables->input_size = PERBIT(INPUT_DEVICE_SIZE);
 			tables->input_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 							        &tables->input_table_size,
 							        conv);
 		}
-		else if (!tables->serio_table && streq(name, "__mod_serio_device_table")) {
+		else if (!tables->serio_table && mod_device_table("serio", name)) {
 			tables->serio_size = PERBIT(SERIO_DEVICE_SIZE);
 			tables->serio_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 								NULL, conv);
 		}
-		else if (!tables->of_table && streq(name, "__mod_of_device_table")) {
+		else if (!tables->of_table && mod_device_table("of", name)) {
 			tables->of_size = PERBIT(OF_DEVICE_SIZE);
 			tables->of_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i],
 							     NULL, conv);
Index: module-init-tools/elfops.c
===================================================================
--- module-init-tools.orig/elfops.c
+++ module-init-tools/elfops.c
@@ -15,6 +15,8 @@
 
 #include "testing.h"
 
+#define SLEN(str)		(sizeof(str) - 1)
+
 /* Symbol types, returned by load_dep_syms */
 static const char *weak_sym = "W";
 static const char *undef_sym = "U";
@@ -28,6 +30,44 @@ static const char *skip_dot(const char *
        return str;
 }
 
+/*
+ * mod_device_table - check for name of module device table
+ * @type: section type (e. g. "pci")
+ * @name: section name
+ *
+ * Both old and new format supported.
+ *
+ * Returns non-zero value if so.
+ */
+static int
+mod_device_table(const char *type, const char *name)
+{
+	size_t len;
+
+	if (strncmp(name, "__mod_", SLEN("__mod_")) != 0)
+		return 0;
+	name += SLEN("__mod_");
+
+
+	len = strlen(type);
+	if (strncmp(name, type, len) != 0)
+		return 0;
+	name += len;
+
+	if (name[0] != '_')
+		return 0;
+
+	name++;
+	if (name[0] != '_')
+		return strcmp(name, "device_table") == 0;
+
+	/* new format */
+	len = strlen(name);
+
+	return len > SLEN("device_table") &&
+		strcmp(name + len - SLEN("device_table"), "device_table") == 0;
+}
+
 #define ELF32BIT
 #include "elfops_core.c"
 #undef ELF32BIT

             reply	other threads:[~2014-10-27 12:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27 12:27 Holger Eitzenberger [this message]
2014-10-27 14:51 ` [RESEND] Regression using module-init-tools on Kernel v3.12.y Lucas De Marchi
2014-10-28 13:53   ` Holger Eitzenberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141027122742.GD9396@imap.eitzenberger.org \
    --to=holger@eitzenberger.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jcm@jonmasters.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=sebastian.poehn@sophos.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).