From patchwork Tue Mar 10 05:00:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 11428461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB6E418E8 for ; Tue, 10 Mar 2020 05:01:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B672A2467D for ; Tue, 10 Mar 2020 05:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726244AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 Received: from mga07.intel.com ([134.134.136.100]:16457 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 22:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,535,1574150400"; d="scan'208";a="353525570" Received: from ldmartin1-desk.jf.intel.com ([10.165.21.151]) by fmsmga001.fm.intel.com with ESMTP; 09 Mar 2020 22:01:39 -0700 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: Yanko Kaneti , gladkov.alexey@gmail.com, auke-jan.h.kok@intel.com, Lucas De Marchi Subject: [PATCH 1/6] gitignore: ignore .cache.mk when building modules Date: Mon, 9 Mar 2020 22:00:24 -0700 Message-Id: <20200310050029.27678-2-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310050029.27678-1-lucas.demarchi@intel.com> References: <20200310050029.27678-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: --- testsuite/module-playground/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/module-playground/.gitignore b/testsuite/module-playground/.gitignore index db63fe4..fca12f3 100644 --- a/testsuite/module-playground/.gitignore +++ b/testsuite/module-playground/.gitignore @@ -2,6 +2,7 @@ *.ko !mod-simple-*.ko !cache/*.ko +.cache.mk *.mod.c .tmp_versions *.mod From patchwork Tue Mar 10 05:00:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 11428463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DAA592A for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0849B2467D for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726258AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 Received: from mga07.intel.com ([134.134.136.100]:16457 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 22:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,535,1574150400"; d="scan'208";a="353525574" Received: from ldmartin1-desk.jf.intel.com ([10.165.21.151]) by fmsmga001.fm.intel.com with ESMTP; 09 Mar 2020 22:01:39 -0700 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: Yanko Kaneti , gladkov.alexey@gmail.com, auke-jan.h.kok@intel.com, Lucas De Marchi Subject: [PATCH 2/6] depmod: do not output .bin to stdout Date: Mon, 9 Mar 2020 22:00:25 -0700 Message-Id: <20200310050029.27678-3-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310050029.27678-1-lucas.demarchi@intel.com> References: <20200310050029.27678-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: index_write() relies on fseek/ftell to manage the position to which we are write and thus needs the file stream to support it. Right now when trying to write the index to stdout we fail with: depmod: tools/depmod.c:416: index_write: Assertion `initial_offset >= 0' failed. Aborted (core dumped) We have no interest in outputting our index to stdout, so just skip it like is done with other indexes. While at it, add/remove some newlines to improve readability. Reported-by: Yanko Kaneti Fix: b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo") --- tools/depmod.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/depmod.c b/tools/depmod.c index fbbce10..875e314 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -2408,8 +2408,10 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out) struct index_node *idx; struct kmod_list *l, *builtin = NULL; - idx = index_create(); + if (out == stdout) + return 0; + idx = index_create(); if (idx == NULL) { ret = -ENOMEM; goto fail; @@ -2456,7 +2458,9 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out) if (count) index_write(idx, out); + index_destroy(idx); + fail: if (builtin) kmod_module_unref_list(builtin); From patchwork Tue Mar 10 05:00:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 11428465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43EA017D5 for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24F4A2467F for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725947AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 Received: from mga07.intel.com ([134.134.136.100]:16458 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 22:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,535,1574150400"; d="scan'208";a="353525577" Received: from ldmartin1-desk.jf.intel.com ([10.165.21.151]) by fmsmga001.fm.intel.com with ESMTP; 09 Mar 2020 22:01:39 -0700 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: Yanko Kaneti , gladkov.alexey@gmail.com, auke-jan.h.kok@intel.com, Lucas De Marchi Subject: [PATCH 3/6] libkmod: simplify lookup when builtin.modinfo.bin file is missing Date: Mon, 9 Mar 2020 22:00:26 -0700 Message-Id: <20200310050029.27678-4-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310050029.27678-1-lucas.demarchi@intel.com> References: <20200310050029.27678-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: When we try to lookup a module and builtin.modinfo.bin is missing, we would do the right thing because the caller was replacing the return code with 0 (and the list was not modified). Make it simpler by allowing the caller to check and differentiate the errors between module not found and index not found. --- libkmod/libkmod-module.c | 8 ++++---- libkmod/libkmod.c | 25 +++++++++++-------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 714ee21..76a6dc3 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -577,13 +577,13 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx, DBG(ctx, "lookup modules.builtin.modinfo %s\n", alias); err = kmod_lookup_alias_from_kernel_builtin_file(ctx, alias, list); - CHECK_ERR_AND_FINISH(err, fail, list, finish); - - if (err == 0) { + if (err == -ENOSYS) { + /* Optional index missing, try the old one */ DBG(ctx, "lookup modules.builtin %s\n", alias); err = kmod_lookup_alias_from_builtin_file(ctx, alias, list); - CHECK_ERR_AND_FINISH(err, fail, list, finish); } + CHECK_ERR_AND_FINISH(err, fail, list, finish); + finish: DBG(ctx, "lookup %s=%d, list=%p\n", alias, err, *list); diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index c9d9e2a..39f58d9 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -528,20 +528,17 @@ int kmod_lookup_alias_from_kernel_builtin_file(struct kmod_ctx *ctx, struct kmod_list **list) { struct kmod_list *l; - int ret = kmod_lookup_alias_from_alias_bin(ctx, - KMOD_INDEX_MODULES_BUILTIN_ALIAS, - name, list); - if (ret > 0) { - kmod_list_foreach(l, *list) { - struct kmod_module *mod = l->data; - kmod_module_set_builtin(mod, true); - } - } else if (ret == -ENOSYS) { - /* - * If the system does not support this yet, then - * there is no need to return an error. - */ - ret = 0; + int ret; + + assert(*list == NULL); + + ret = kmod_lookup_alias_from_alias_bin(ctx, + KMOD_INDEX_MODULES_BUILTIN_ALIAS, + name, list); + + kmod_list_foreach(l, *list) { + struct kmod_module *mod = l->data; + kmod_module_set_builtin(mod, true); } return ret; From patchwork Tue Mar 10 05:00:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 11428467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60D1A18EC for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B0562467F for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbgCJFBm (ORCPT ); Tue, 10 Mar 2020 01:01:42 -0400 Received: from mga07.intel.com ([134.134.136.100]:16457 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 22:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,535,1574150400"; d="scan'208";a="353525580" Received: from ldmartin1-desk.jf.intel.com ([10.165.21.151]) by fmsmga001.fm.intel.com with ESMTP; 09 Mar 2020 22:01:40 -0700 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: Yanko Kaneti , gladkov.alexey@gmail.com, auke-jan.h.kok@intel.com, Lucas De Marchi Subject: [PATCH 4/6] libkmod: fix return error when opening index Date: Mon, 9 Mar 2020 22:00:27 -0700 Message-Id: <20200310050029.27678-5-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310050029.27678-1-lucas.demarchi@intel.com> References: <20200310050029.27678-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: When calling kmod_load_resources() we could end up getting a bogus return value -ENOMEM due to several other reasons, like the index not existing. Change index_mm_open() to propagate the failure reason so we can take actions on it or return to the caller. --- libkmod/libkmod-index.c | 31 +++++++++++++++++++------------ libkmod/libkmod-index.h | 4 ++-- libkmod/libkmod.c | 16 ++++++++-------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index 1f3351a..6a34c8d 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -611,7 +611,7 @@ struct index_value *index_searchwild(struct index_file *in, const char *key) static const char _idx_empty_str[] = ""; struct index_mm { - struct kmod_ctx *ctx; + const struct kmod_ctx *ctx; void *mm; uint32_t root_offset; size_t size; @@ -739,10 +739,10 @@ static void index_mm_free_node(struct index_mm_node *node) free(node); } -struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename, - unsigned long long *stamp) +int index_mm_open(const struct kmod_ctx *ctx, const char *filename, + unsigned long long *stamp, struct index_mm **pidx) { - int fd; + int fd, err; struct stat st; struct index_mm *idx; struct { @@ -752,28 +752,32 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename, } hdr; void *p; + assert(pidx != NULL); + DBG(ctx, "file=%s\n", filename); idx = malloc(sizeof(*idx)); if (idx == NULL) { ERR(ctx, "malloc: %m\n"); - return NULL; + return -ENOMEM; } if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) < 0) { DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename); + err = -errno; goto fail_open; } - if (fstat(fd, &st) < 0) - goto fail_nommap; - if ((size_t) st.st_size < sizeof(hdr)) + if (fstat(fd, &st) < 0 || (size_t) st.st_size < sizeof(hdr)) { + err = -EINVAL; goto fail_nommap; + } - if ((idx->mm = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) - == MAP_FAILED) { + idx->mm = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (idx->mm == MAP_FAILED) { ERR(ctx, "mmap(NULL, %"PRIu64", PROT_READ, %d, MAP_PRIVATE, 0): %m\n", st.st_size, fd); + err = -errno; goto fail_nommap; } @@ -785,12 +789,14 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename, if (hdr.magic != INDEX_MAGIC) { ERR(ctx, "magic check fail: %x instead of %x\n", hdr.magic, INDEX_MAGIC); + err = -EINVAL; goto fail; } if (hdr.version >> 16 != INDEX_VERSION_MAJOR) { ERR(ctx, "major version check fail: %u instead of %u\n", hdr.version >> 16, INDEX_VERSION_MAJOR); + err = -EINVAL; goto fail; } @@ -800,8 +806,9 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename, close(fd); *stamp = stat_mstamp(&st); + *pidx = idx; - return idx; + return 0; fail: munmap(idx->mm, st.st_size); @@ -809,7 +816,7 @@ fail_nommap: close(fd); fail_open: free(idx); - return NULL; + return err; } void index_mm_close(struct index_mm *idx) diff --git a/libkmod/libkmod-index.h b/libkmod/libkmod-index.h index 52aebac..db671b0 100644 --- a/libkmod/libkmod-index.h +++ b/libkmod/libkmod-index.h @@ -40,8 +40,8 @@ void index_values_free(struct index_value *values); /* Implementation using mmap */ struct index_mm; -struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename, - unsigned long long *stamp); +int index_mm_open(const struct kmod_ctx *ctx, const char *filename, + unsigned long long *stamp, struct index_mm **pidx); void index_mm_close(struct index_mm *index); char *index_mm_search(struct index_mm *idx, const char *key); struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key); diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 39f58d9..ab5c1e8 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -856,6 +856,7 @@ KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx) KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx) { size_t i; + int ret; if (ctx == NULL) return -ENOENT; @@ -871,17 +872,16 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx) snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname, index_files[i].fn); - ctx->indexes[i] = index_mm_open(ctx, path, - &ctx->indexes_stamp[i]); - if (ctx->indexes[i] == NULL) - goto fail; + ret = index_mm_open(ctx, path, &ctx->indexes_stamp[i], + &ctx->indexes[i]); + if (ret) + break; } - return 0; + if (ret) + kmod_unload_resources(ctx); -fail: - kmod_unload_resources(ctx); - return -ENOMEM; + return ret; } /** From patchwork Tue Mar 10 05:00:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 11428459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70BEC924 for ; Tue, 10 Mar 2020 05:01:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A8AD2467C for ; Tue, 10 Mar 2020 05:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726224AbgCJFBl (ORCPT ); Tue, 10 Mar 2020 01:01:41 -0400 Received: from mga01.intel.com ([192.55.52.88]:53932 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgCJFBk (ORCPT ); Tue, 10 Mar 2020 01:01:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 22:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,535,1574150400"; d="scan'208";a="353525584" Received: from ldmartin1-desk.jf.intel.com ([10.165.21.151]) by fmsmga001.fm.intel.com with ESMTP; 09 Mar 2020 22:01:40 -0700 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: Yanko Kaneti , gladkov.alexey@gmail.com, auke-jan.h.kok@intel.com, Lucas De Marchi Subject: [PATCH 5/6] libkmod: allow modules.alias.builtin to be optional Date: Mon, 9 Mar 2020 22:00:28 -0700 Message-Id: <20200310050029.27678-6-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310050029.27678-1-lucas.demarchi@intel.com> References: <20200310050029.27678-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: --- libkmod/libkmod.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index ab5c1e8..43423d6 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -855,8 +855,8 @@ KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx) */ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx) { + int ret = 0; size_t i; - int ret; if (ctx == NULL) return -ENOENT; @@ -874,8 +874,17 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx) index_files[i].fn); ret = index_mm_open(ctx, path, &ctx->indexes_stamp[i], &ctx->indexes[i]); - if (ret) - break; + + /* + * modules.builtin.alias are considered optional since it's + * recently added and older installations may not have it; + * we allow failing for any reason + */ + if (ret) { + if (i != KMOD_INDEX_MODULES_BUILTIN_ALIAS) + break; + ret = 0; + } } if (ret) From patchwork Tue Mar 10 05:00:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 11428469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D71FE924 for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B871D2467C for ; Tue, 10 Mar 2020 05:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726252AbgCJFBm (ORCPT ); Tue, 10 Mar 2020 01:01:42 -0400 Received: from mga09.intel.com ([134.134.136.24]:60672 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgCJFBm (ORCPT ); Tue, 10 Mar 2020 01:01:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 22:01:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,535,1574150400"; d="scan'208";a="353525592" Received: from ldmartin1-desk.jf.intel.com ([10.165.21.151]) by fmsmga001.fm.intel.com with ESMTP; 09 Mar 2020 22:01:40 -0700 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: Yanko Kaneti , gladkov.alexey@gmail.com, auke-jan.h.kok@intel.com, Lucas De Marchi Subject: [PATCH 6/6] testsuite: add check for kmod_load_resources Date: Mon, 9 Mar 2020 22:00:29 -0700 Message-Id: <20200310050029.27678-7-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310050029.27678-1-lucas.demarchi@intel.com> References: <20200310050029.27678-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: Make sure we can call kmod_load_resources when we do have all the mandatory indexes in place. --- .../lib/modules/5.6.0/modules.alias | 1 + .../lib/modules/5.6.0/modules.alias.bin | Bin 0 -> 12 bytes .../lib/modules/5.6.0/modules.builtin | 1 + .../lib/modules/5.6.0/modules.builtin.bin | Bin 0 -> 39 bytes .../lib/modules/5.6.0/modules.dep | 0 .../lib/modules/5.6.0/modules.dep.bin | Bin 0 -> 12 bytes .../lib/modules/5.6.0/modules.devname | 1 + .../lib/modules/5.6.0/modules.softdep | 1 + .../lib/modules/5.6.0/modules.symbols | 1 + .../lib/modules/5.6.0/modules.symbols.bin | Bin 0 -> 12 bytes testsuite/test-init.c | 31 ++++++++++++++++++ 11 files changed, 36 insertions(+) create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias.bin create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin.bin create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep.bin create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.devname create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.softdep create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols create mode 100644 testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols.bin diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias new file mode 100644 index 0000000..ba76e18 --- /dev/null +++ b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias @@ -0,0 +1 @@ +# Aliases extracted from modules themselves. diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias.bin new file mode 100644 index 0000000000000000000000000000000000000000..7075435f6268c4d815aec093d61e26647666ba76 GIT binary patch literal 12 TcmdnM{w17&iGh)Ufq@4A6;A>Z literal 0 HcmV?d00001 diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin new file mode 100644 index 0000000..1cbec61 --- /dev/null +++ b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin @@ -0,0 +1 @@ +kernel/fake_builtin.ko diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin.bin new file mode 100644 index 0000000000000000000000000000000000000000..0423f039013b88f58bce7a26d4086974e5a8b96a GIT binary patch literal 39 qcmdnM{w17&iGfjpfk81bJ2gJ3G&83pGmilX7(oO>TG{~y1|9&t?g(c9 literal 0 HcmV?d00001 diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep new file mode 100644 index 0000000..e69de29 diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep.bin new file mode 100644 index 0000000000000000000000000000000000000000..7075435f6268c4d815aec093d61e26647666ba76 GIT binary patch literal 12 TcmdnM{w17&iGh)Ufq@4A6;A>Z literal 0 HcmV?d00001 diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.devname b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.devname new file mode 100644 index 0000000..58f6d6d --- /dev/null +++ b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.devname @@ -0,0 +1 @@ +# Device nodes to trigger on-demand module loading. diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.softdep b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.softdep new file mode 100644 index 0000000..5554ccc --- /dev/null +++ b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.softdep @@ -0,0 +1 @@ +# Soft dependencies extracted from modules themselves. diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols new file mode 100644 index 0000000..618c345 --- /dev/null +++ b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols @@ -0,0 +1 @@ +# Aliases for symbols, used by symbol_request(). diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols.bin new file mode 100644 index 0000000000000000000000000000000000000000..7075435f6268c4d815aec093d61e26647666ba76 GIT binary patch literal 12 TcmdnM{w17&iGh)Ufq@4A6;A>Z literal 0 HcmV?d00001 diff --git a/testsuite/test-init.c b/testsuite/test-init.c index 9651280..3a69b43 100644 --- a/testsuite/test-init.c +++ b/testsuite/test-init.c @@ -29,6 +29,37 @@ #include "testsuite.h" +static noreturn int test_load_resources(const struct test *t) +{ + struct kmod_ctx *ctx; + const char *null_config = NULL; + int err; + + ctx = kmod_new(NULL, &null_config); + if (ctx == NULL) + exit(EXIT_FAILURE); + + kmod_set_log_priority(ctx, 7); + + err = kmod_load_resources(ctx); + if (err != 0) { + ERR("could not load libkmod resources: %s\n", strerror(-err)); + exit(EXIT_FAILURE); + } + + kmod_unref(ctx); + + exit(EXIT_SUCCESS); +} +DEFINE_TEST(test_load_resources, + .description = "test if kmod_load_resources works", + .config = { + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-init-load-resources/", + [TC_UNAME_R] = "5.6.0", + }, + .need_spawn = true); + + static noreturn int test_initlib(const struct test *t) { struct kmod_ctx *ctx;