All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] bootconfig: Show more error information
@ 2020-02-05 13:49 Masami Hiramatsu
  2020-02-05 13:49 ` [PATCH 1/4] bootconfig: Use bootconfig instead of boot config Masami Hiramatsu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2020-02-05 13:49 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Andrew Morton, Masami Hiramatsu, Tom Zanussi,
	Peter Zijlstra

Hello,

Here are some patches to show more error information and
the number of nodes on boot message and bootconfig tool.

Since the max number of the nodes are limited and it is hard
to count the number of nodes while writing the config file,
it is better that the bootconfig command informs user the
current number of the node.

Thank you,

---

Masami Hiramatsu (4):
      bootconfig: Use bootconfig instead of boot config
      bootconfig: Add more parse error messages
      tools/bootconfig: Show the number of bootconfig nodes
      bootconfig: Show the number of nodes on boot message


 init/main.c             |   10 ++++++----
 lib/bootconfig.c        |   21 ++++++++++++++++-----
 tools/bootconfig/main.c |    1 +
 3 files changed, 23 insertions(+), 9 deletions(-)

--
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>

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

* [PATCH 1/4] bootconfig: Use bootconfig instead of boot config
  2020-02-05 13:49 [PATCH 0/4] bootconfig: Show more error information Masami Hiramatsu
@ 2020-02-05 13:49 ` Masami Hiramatsu
  2020-02-05 13:50 ` [PATCH 2/4] bootconfig: Add more parse error messages Masami Hiramatsu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2020-02-05 13:49 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Andrew Morton, Masami Hiramatsu, Tom Zanussi,
	Peter Zijlstra

Use "bootconfig" (1 word) instead of "boot config" (2 words)
in the boot message.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 init/main.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/init/main.c b/init/main.c
index f174a59d3903..2de2f9f7aab9 100644
--- a/init/main.c
+++ b/init/main.c
@@ -372,7 +372,7 @@ static void __init setup_boot_config(const char *cmdline)
 
 	copy = memblock_alloc(size + 1, SMP_CACHE_BYTES);
 	if (!copy) {
-		pr_err("Failed to allocate memory for boot config\n");
+		pr_err("Failed to allocate memory for bootconfig\n");
 		return;
 	}
 
@@ -380,9 +380,9 @@ static void __init setup_boot_config(const char *cmdline)
 	copy[size] = '\0';
 
 	if (xbc_init(copy) < 0)
-		pr_err("Failed to parse boot config\n");
+		pr_err("Failed to parse bootconfig\n");
 	else {
-		pr_info("Load boot config: %d bytes\n", size);
+		pr_info("Load bootconfig: %d bytes\n", size);
 		/* keys starting with "kernel." are passed via cmdline */
 		extra_command_line = xbc_make_cmdline("kernel");
 		/* Also, "init." keys are init arguments */


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

* [PATCH 2/4] bootconfig: Add more parse error messages
  2020-02-05 13:49 [PATCH 0/4] bootconfig: Show more error information Masami Hiramatsu
  2020-02-05 13:49 ` [PATCH 1/4] bootconfig: Use bootconfig instead of boot config Masami Hiramatsu
@ 2020-02-05 13:50 ` Masami Hiramatsu
  2020-02-05 13:50 ` [PATCH 3/4] tools/bootconfig: Show the number of bootconfig nodes Masami Hiramatsu
  2020-02-05 13:50 ` [PATCH 4/4] bootconfig: Show the number of nodes on boot message Masami Hiramatsu
  3 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2020-02-05 13:50 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Andrew Morton, Masami Hiramatsu, Tom Zanussi,
	Peter Zijlstra

Add more error messages for following cases.
 - Exceeding max number of nodes
 - Config tree data is empty (e.g. comment only)
 - Config data is empty or exceeding max size
 - bootconfig is already initialized

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 lib/bootconfig.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 055014e233a5..a98ae136529c 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -373,7 +373,8 @@ static struct xbc_node * __init xbc_add_sibling(char *data, u32 flag)
 				sib->next = xbc_node_index(node);
 			}
 		}
-	}
+	} else
+		xbc_parse_error("Too many nodes", data);
 
 	return node;
 }
@@ -657,8 +658,10 @@ static int __init xbc_verify_tree(void)
 	struct xbc_node *n, *m;
 
 	/* Empty tree */
-	if (xbc_node_num == 0)
+	if (xbc_node_num == 0) {
+		xbc_parse_error("Empty config", xbc_data);
 		return -ENOENT;
+	}
 
 	for (i = 0; i < xbc_node_num; i++) {
 		if (xbc_nodes[i].next > xbc_node_num) {
@@ -732,12 +735,17 @@ int __init xbc_init(char *buf)
 	char *p, *q;
 	int ret, c;
 
-	if (xbc_data)
+	if (xbc_data) {
+		pr_err("Error: bootconfig is already initialized.\n");
 		return -EBUSY;
+	}
 
 	ret = strlen(buf);
-	if (ret > XBC_DATA_MAX - 1 || ret == 0)
+	if (ret > XBC_DATA_MAX - 1 || ret == 0) {
+		pr_err("Error: Config data is %s.\n",
+			ret ? "too big" : "empty");
 		return -ERANGE;
+	}
 
 	xbc_data = buf;
 	xbc_data_size = ret + 1;


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

* [PATCH 3/4] tools/bootconfig: Show the number of bootconfig nodes
  2020-02-05 13:49 [PATCH 0/4] bootconfig: Show more error information Masami Hiramatsu
  2020-02-05 13:49 ` [PATCH 1/4] bootconfig: Use bootconfig instead of boot config Masami Hiramatsu
  2020-02-05 13:50 ` [PATCH 2/4] bootconfig: Add more parse error messages Masami Hiramatsu
@ 2020-02-05 13:50 ` Masami Hiramatsu
  2020-02-05 13:50 ` [PATCH 4/4] bootconfig: Show the number of nodes on boot message Masami Hiramatsu
  3 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2020-02-05 13:50 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Andrew Morton, Masami Hiramatsu, Tom Zanussi,
	Peter Zijlstra

Show the number of bootconfig nodes when applying new bootconfig to
initrd.

Since there are limitations of bootconfig not only in its filesize,
but also the number of nodes, the number should be shown when applying
so that user can get the feeling of scale of current bootconfig.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 lib/bootconfig.c        |    5 ++++-
 tools/bootconfig/main.c |    1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index a98ae136529c..afb2e767e6fe 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -728,7 +728,8 @@ void __init xbc_destroy_all(void)
  *
  * This parses the boot config text in @buf. @buf must be a
  * null terminated string and smaller than XBC_DATA_MAX.
- * Return 0 if succeeded, or -errno if there is any error.
+ * Return the number of stored nodes (>0) if succeeded, or -errno
+ * if there is any error.
  */
 int __init xbc_init(char *buf)
 {
@@ -788,6 +789,8 @@ int __init xbc_init(char *buf)
 
 	if (ret < 0)
 		xbc_destroy_all();
+	else
+		ret = xbc_node_num;
 
 	return ret;
 }
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index 91c9a5c0c499..47f488458328 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -268,6 +268,7 @@ int apply_xbc(const char *path, const char *xbc_path)
 		return ret;
 	}
 	printf("Apply %s to %s\n", xbc_path, path);
+	printf("\tNumber of nodes: %d\n", ret);
 	printf("\tSize: %u bytes\n", (unsigned int)size);
 	printf("\tChecksum: %d\n", (unsigned int)csum);
 


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

* [PATCH 4/4] bootconfig: Show the number of nodes on boot message
  2020-02-05 13:49 [PATCH 0/4] bootconfig: Show more error information Masami Hiramatsu
                   ` (2 preceding siblings ...)
  2020-02-05 13:50 ` [PATCH 3/4] tools/bootconfig: Show the number of bootconfig nodes Masami Hiramatsu
@ 2020-02-05 13:50 ` Masami Hiramatsu
  3 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2020-02-05 13:50 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Andrew Morton, Masami Hiramatsu, Tom Zanussi,
	Peter Zijlstra

Show the number of bootconfig nodes on boot message.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 init/main.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index 2de2f9f7aab9..491f1cdb3105 100644
--- a/init/main.c
+++ b/init/main.c
@@ -342,6 +342,7 @@ static void __init setup_boot_config(const char *cmdline)
 	char *data, *copy;
 	const char *p;
 	u32 *hdr;
+	int ret;
 
 	p = strstr(cmdline, "bootconfig");
 	if (!p || (p != cmdline && !isspace(*(p-1))) ||
@@ -379,10 +380,11 @@ static void __init setup_boot_config(const char *cmdline)
 	memcpy(copy, data, size);
 	copy[size] = '\0';
 
-	if (xbc_init(copy) < 0)
+	ret = xbc_init(copy);
+	if (ret < 0)
 		pr_err("Failed to parse bootconfig\n");
 	else {
-		pr_info("Load bootconfig: %d bytes\n", size);
+		pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret);
 		/* keys starting with "kernel." are passed via cmdline */
 		extra_command_line = xbc_make_cmdline("kernel");
 		/* Also, "init." keys are init arguments */


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

end of thread, other threads:[~2020-02-05 13:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 13:49 [PATCH 0/4] bootconfig: Show more error information Masami Hiramatsu
2020-02-05 13:49 ` [PATCH 1/4] bootconfig: Use bootconfig instead of boot config Masami Hiramatsu
2020-02-05 13:50 ` [PATCH 2/4] bootconfig: Add more parse error messages Masami Hiramatsu
2020-02-05 13:50 ` [PATCH 3/4] tools/bootconfig: Show the number of bootconfig nodes Masami Hiramatsu
2020-02-05 13:50 ` [PATCH 4/4] bootconfig: Show the number of nodes on boot message Masami Hiramatsu

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.