From nobody Sat Feb 7 15:10:19 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61E657404E; Thu, 5 Feb 2026 00:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770252390; cv=none; b=tjPp1LFcOkZWZqyk/wLlsLwJ5eTwGPmErqDBCeQiIkmCW25240Dm644LsILIM2THUzfFONUyRdjXYxP5JuMfETa9Rnvc9lAYSkHQgWEvnozSE9sKiuNDF7uBrFfvtV+XMrHfbNeqKJyQfkw1n4cmyEStj4OFk+wtZCcbpFi8Tk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770252390; c=relaxed/simple; bh=CYucySd/QdhRnX3CitqaqmBkfOkdjmueqVIkTVvH2sE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gZ017uO8CKb6GsSw+YqE7tUPornjc9qvQlP+yLH9AhMuuFsZfosmFQNvHREORyAltBYGaPUWeZjDMJsyGbx21CE6CdmPmARZQx6ZvZsEDHllfPd2fYXFhNiWCuDljD9K3WbZ0XoQrM7hsmtIbngITKWc/fdgBJXLFnFi0vVvaRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OH586ABp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OH586ABp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E40EFC4CEF7; Thu, 5 Feb 2026 00:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770252389; bh=CYucySd/QdhRnX3CitqaqmBkfOkdjmueqVIkTVvH2sE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OH586ABpXkyAaM89y1wpMUkbMNpinDX69QW+Q6m0CNAKeHOK6DicUatkzQmB7jtzO vcSFxrvFASKPrhlumRP0GE0ZkhXYhX7leGSw9r1isNstDmPl4STT4jCBX8ll57QXyh ufpF4XKfwrV29qk8AP8ROA4wy88BBtSJ1BYtuXyH3apVw4koUbl1o/fG/cIpQ4kqHz E0bnPa66vSbynh+v6cDAl8aemiANy5kGa9eb1bJbUJoTDlvKALrViMNfCsyjjYIkTM ZQqos08OEJjTmxX8+6/I3NHwagEHmUjOdyTDgS8FrH+wfHpOsP+69ipK/5h8RgX1H3 PH49Q+J5I7KFA== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: Julius Werner , Masami Hiramatsu , LKML Subject: [PATCH v3 1/2] bootconfig: Terminate value search if it hits a newline Date: Thu, 5 Feb 2026 09:46:25 +0900 Message-ID: <177025238503.14982.17059549076175612447.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <177025237564.14982.14899224362754775890.stgit@devnote2> References: <177025237564.14982.14899224362754775890.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Masami Hiramatsu (Google) Terminate the value search for a key if it hits a newline and make the value empty. When we pass a bootconfig with an empty value terminated by the newline, like below:: foo =3D bar =3D value Current bootconfig interprets it as a single entry:: foo =3D "bar =3D value"; The Documentation/admin-guide/bootconfig.rst defines the value itself is terminated by newline: The value has to be terminated by semi-colon (``;``) or newline (``\n``). but it does not define when the value search is terminated. This changes the behavior to be more line-oriented, so that it is clearer in how it works. - The value search of key-value pair will be terminated by a comment or newline. - The value search of an array will continue beyond comments and newlines. Thus, with this update, the above example is interpreted as:: foo =3D ""; bar =3D "value"; And the below example will cause a syntax error because "bar" is expected as a key but it has ','. foo =3D bar, buz According to this change, one wrong example config is updated. Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Julius Werner --- Changes in v3: - Fix typos. - Add bad examples (which was good previously). Changes in v2: - Fix to handle multi-line array case correctly. - Make this as a spec update, not fix. --- .../samples/bad-array-after-comment.bconf | 4 ++++ .../samples/bad-array-in-next-line.bconf | 4 ++++ .../samples/good-array-space-comment.bconf | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tools/bootconfig/samples/bad-array-after-comment.bconf create mode 100644 tools/bootconfig/samples/bad-array-in-next-line.bconf diff --git a/Documentation/admin-guide/bootconfig.rst b/Documentation/admin= -guide/bootconfig.rst index 7a86042c9b6d..f712758472d5 100644 --- a/Documentation/admin-guide/bootconfig.rst +++ b/Documentation/admin-guide/bootconfig.rst @@ -20,18 +20,26 @@ Config File Syntax =20 The boot config syntax is a simple structured key-value. Each key consists of dot-connected-words, and key and value are connected by ``=3D``. The va= lue -has to be terminated by semi-colon (``;``) or newline (``\n``). -For array value, array entries are separated by comma (``,``). :: - - KEY[.WORD[...]] =3D VALUE[, VALUE2[...]][;] - -Unlike the kernel command line syntax, spaces are OK around the comma and = ``=3D``. +string has to be terminated by the following delimiters described below. =20 Each key word must contain only alphabets, numbers, dash (``-``) or unders= core (``_``). And each value only contains printable characters or spaces except for delimiters such as semi-colon (``;``), new-line (``\n``), comma (``,``= ), hash (``#``) and closing brace (``}``). =20 +If the ``=3D`` is followed by whitespace up to one of these delimiters, the +key is assigned an empty value. + +For arrays, the array values are comma (``,``) separated, and comments and +line breaks with newline (``\n``) are allowed between array values for +readability. Thus the first entry of the array must be on the same line as +the key.:: + + KEY[.WORD[...]] =3D VALUE[, VALUE2[...]][;] + +Unlike the kernel command line syntax, white spaces (including tabs) are +ignored around the comma and ``=3D``. + If you want to use those delimiters in a value, you can use either double- quotes (``"VALUE"``) or single-quotes (``'VALUE'``) to quote it. Note that you can not escape these quotes. @@ -138,8 +146,8 @@ This is parsed as below:: foo =3D value bar =3D 1, 2, 3 =20 -Note that you can not put a comment between value and delimiter(``,`` or -``;``). This means following config has a syntax error :: +Note that you can NOT put a comment or a newline between value and delimit= er +(``,`` or ``;``). This means following config has a syntax error :: =20 key =3D 1 # comment ,2 diff --git a/lib/bootconfig.c b/lib/bootconfig.c index 81f29c29f47b..449369a60846 100644 --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -557,17 +557,13 @@ static int __init __xbc_close_brace(char *p) /* * Return delimiter or error, no node added. As same as lib/cmdline.c, * you can use " around spaces, but can't escape " for value. + * *@__v must point real value string. (not including spaces before value.) */ static int __init __xbc_parse_value(char **__v, char **__n) { char *p, *v =3D *__v; int c, quotes =3D 0; =20 - v =3D skip_spaces(v); - while (*v =3D=3D '#') { - v =3D skip_comment(v); - v =3D skip_spaces(v); - } if (*v =3D=3D '"' || *v =3D=3D '\'') { quotes =3D *v; v++; @@ -617,6 +613,13 @@ static int __init xbc_parse_array(char **__v) last_parent =3D xbc_node_get_child(last_parent); =20 do { + /* Search the next array value beyond comments and empty lines */ + next =3D skip_spaces(*__v); + while (*next =3D=3D '#') { + next =3D skip_comment(next); + next =3D skip_spaces(next); + } + *__v =3D next; c =3D __xbc_parse_value(__v, &next); if (c < 0) return c; @@ -701,9 +704,17 @@ static int __init xbc_parse_kv(char **k, char *v, int = op) if (ret) return ret; =20 - c =3D __xbc_parse_value(&v, &next); - if (c < 0) - return c; + v =3D skip_spaces_until_newline(v); + /* If there is a comment, this has an empty value. */ + if (*v =3D=3D '#') { + next =3D skip_comment(v); + *v =3D '\0'; + c =3D '\n'; + } else { + c =3D __xbc_parse_value(&v, &next); + if (c < 0) + return c; + } =20 child =3D xbc_node_get_child(last_parent); if (child && xbc_node_is_value(child)) { diff --git a/tools/bootconfig/samples/bad-array-after-comment.bconf b/tools= /bootconfig/samples/bad-array-after-comment.bconf new file mode 100644 index 000000000000..fdb6d4e04447 --- /dev/null +++ b/tools/bootconfig/samples/bad-array-after-comment.bconf @@ -0,0 +1,4 @@ +# the first array value must be on the same line as the key +key =3D # comment + value1, + value2 diff --git a/tools/bootconfig/samples/bad-array-in-next-line.bconf b/tools/= bootconfig/samples/bad-array-in-next-line.bconf new file mode 100644 index 000000000000..95a99a3bde8c --- /dev/null +++ b/tools/bootconfig/samples/bad-array-in-next-line.bconf @@ -0,0 +1,4 @@ +# the first array value must be on the same line as the key +key =3D + value1, + value2 diff --git a/tools/bootconfig/samples/good-array-space-comment.bconf b/tool= s/bootconfig/samples/good-array-space-comment.bconf index 45b938dc0695..416fa2ed4109 100644 --- a/tools/bootconfig/samples/good-array-space-comment.bconf +++ b/tools/bootconfig/samples/good-array-space-comment.bconf @@ -1,4 +1,3 @@ -key =3D # comment - "value1", # comment1 +key =3D "value1", # comment1 "value2" , # comment2 "value3" From nobody Sat Feb 7 15:10:19 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76AA77404E; Thu, 5 Feb 2026 00:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770252399; cv=none; b=AuTDQhcx7dk/4o7d4R/7+pdoMjGdLlY3AxYvs5jLCWKk53mwbsjDgHgZsrfCAJU5f/AHCBmd1XtKZdrjZBUJWI8DEsKCnbjWBBJ450AO7m3SE2oXzQBo70gHqPXbw8Nc6NmirbI/en8EeKxXGv3x1qZEnBG46TGRu+6K1D2sy8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770252399; c=relaxed/simple; bh=KD/PrNKxu0z69syPL6ucmtIuDepM7ZtLxk7vRvNSJng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uXfW3LdaIWWZZIobr6sMMfogfBAz915Ez/kjcW8sclAkCgRtrxewHHtFN5VMmt8Lh+WRRQzIFddx5wDBItry4voXT8pE8alPZ4ds5oxijvz0oLC46COxIvy+jUuf6sJejwHJbkLXkMyKlTfmfmgDBPUG0B+5YGnUdxDnXmR/jds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gUflrtpU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gUflrtpU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1CE2C4CEF7; Thu, 5 Feb 2026 00:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770252399; bh=KD/PrNKxu0z69syPL6ucmtIuDepM7ZtLxk7vRvNSJng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gUflrtpU4DkcCvCIoYYBRC5JFAW56oewCMzlYUXevv3LFvXzapSrHNz/j1JX4pCDi IfLNKD7qV68eSqgc5VgSlS7E0zH0ue2ZkwHjdQnVhE8qg9tT+umcZPpsqsW7SAQ0x2 urBkMC5Bx0A633UVsgXrzYkCLnlZDCkQaizbwWa229dnzHtcvdk/mTs3k/c4IkE+O1 5djiAwOpx8Xw8XdFF+bmtC7Y/erAip+nTKN48h1/3ijnwtQJD8SER/DpwYDa6E6Jpf lji4KizKEfbf+CMhmLUeUjfgmna3yA0H4mQMzdVJK/ig+zmJnZwLsPf2mNbM3B9mZ5 CyxWiT58+mElA== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: Julius Werner , Masami Hiramatsu , LKML Subject: [PATCH v3 2/2] bootconfig: Check the parsed output of the good examples Date: Thu, 5 Feb 2026 09:46:35 +0900 Message-ID: <177025239529.14982.12913754615993262263.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <177025237564.14982.14899224362754775890.stgit@devnote2> References: <177025237564.14982.14899224362754775890.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Masami Hiramatsu (Google) Check whether the parsed output of the good example configs are the same as expected. Signed-off-by: Masami Hiramatsu (Google) Tested-by: Steven Rostedt (Google) --- .../samples/exp-good-array-space-comment.bconf | 1 + .../samples/exp-good-comment-after-value.bconf | 1 + .../bootconfig/samples/exp-good-mixed-append.bconf | 2 ++ tools/bootconfig/samples/exp-good-mixed-kv1.bconf | 2 ++ tools/bootconfig/samples/exp-good-mixed-kv2.bconf | 2 ++ tools/bootconfig/samples/exp-good-mixed-kv3.bconf | 5 +++++ .../samples/exp-good-mixed-override.bconf | 2 ++ tools/bootconfig/samples/exp-good-override.bconf | 4 ++++ tools/bootconfig/samples/exp-good-printables.bconf | 2 ++ tools/bootconfig/samples/exp-good-simple.bconf | 8 ++++++++ tools/bootconfig/samples/exp-good-single.bconf | 3 +++ .../samples/exp-good-space-after-value.bconf | 1 + tools/bootconfig/samples/exp-good-tree.bconf | 8 ++++++++ tools/bootconfig/test-bootconfig.sh | 3 +++ 14 files changed, 44 insertions(+) create mode 100644 tools/bootconfig/samples/exp-good-array-space-comment.b= conf create mode 100644 tools/bootconfig/samples/exp-good-comment-after-value.b= conf create mode 100644 tools/bootconfig/samples/exp-good-mixed-append.bconf create mode 100644 tools/bootconfig/samples/exp-good-mixed-kv1.bconf create mode 100644 tools/bootconfig/samples/exp-good-mixed-kv2.bconf create mode 100644 tools/bootconfig/samples/exp-good-mixed-kv3.bconf create mode 100644 tools/bootconfig/samples/exp-good-mixed-override.bconf create mode 100644 tools/bootconfig/samples/exp-good-override.bconf create mode 100644 tools/bootconfig/samples/exp-good-printables.bconf create mode 100644 tools/bootconfig/samples/exp-good-simple.bconf create mode 100644 tools/bootconfig/samples/exp-good-single.bconf create mode 100644 tools/bootconfig/samples/exp-good-space-after-value.bco= nf create mode 100644 tools/bootconfig/samples/exp-good-tree.bconf diff --git a/tools/bootconfig/samples/exp-good-array-space-comment.bconf b/= tools/bootconfig/samples/exp-good-array-space-comment.bconf new file mode 100644 index 000000000000..8d3278fa6af5 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-array-space-comment.bconf @@ -0,0 +1 @@ +key =3D "value1", "value2", "value3"; diff --git a/tools/bootconfig/samples/exp-good-comment-after-value.bconf b/= tools/bootconfig/samples/exp-good-comment-after-value.bconf new file mode 100644 index 000000000000..a8e8450db3c0 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-comment-after-value.bconf @@ -0,0 +1 @@ +key =3D "value"; diff --git a/tools/bootconfig/samples/exp-good-mixed-append.bconf b/tools/b= ootconfig/samples/exp-good-mixed-append.bconf new file mode 100644 index 000000000000..c2b407901ddd --- /dev/null +++ b/tools/bootconfig/samples/exp-good-mixed-append.bconf @@ -0,0 +1,2 @@ +key =3D "foo", "bar"; +keyx.subkey =3D "value"; diff --git a/tools/bootconfig/samples/exp-good-mixed-kv1.bconf b/tools/boot= config/samples/exp-good-mixed-kv1.bconf new file mode 100644 index 000000000000..8346287d9251 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-mixed-kv1.bconf @@ -0,0 +1,2 @@ +key =3D "value"; +key.subkey =3D "another-value"; diff --git a/tools/bootconfig/samples/exp-good-mixed-kv2.bconf b/tools/boot= config/samples/exp-good-mixed-kv2.bconf new file mode 100644 index 000000000000..40c6232c7cdd --- /dev/null +++ b/tools/bootconfig/samples/exp-good-mixed-kv2.bconf @@ -0,0 +1,2 @@ +key =3D "another-value"; +key.subkey =3D "value"; diff --git a/tools/bootconfig/samples/exp-good-mixed-kv3.bconf b/tools/boot= config/samples/exp-good-mixed-kv3.bconf new file mode 100644 index 000000000000..8368a7bef60a --- /dev/null +++ b/tools/bootconfig/samples/exp-good-mixed-kv3.bconf @@ -0,0 +1,5 @@ +key =3D "value"; +key { + subkey1; + subkey2 =3D "foo"; +} diff --git a/tools/bootconfig/samples/exp-good-mixed-override.bconf b/tools= /bootconfig/samples/exp-good-mixed-override.bconf new file mode 100644 index 000000000000..58757712ca45 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-mixed-override.bconf @@ -0,0 +1,2 @@ +key =3D "value2"; +key.foo =3D "bar"; diff --git a/tools/bootconfig/samples/exp-good-override.bconf b/tools/bootc= onfig/samples/exp-good-override.bconf new file mode 100644 index 000000000000..00bbd30e99ae --- /dev/null +++ b/tools/bootconfig/samples/exp-good-override.bconf @@ -0,0 +1,4 @@ +key { + word =3D "2", "3"; + new.word =3D "new"; +} diff --git a/tools/bootconfig/samples/exp-good-printables.bconf b/tools/boo= tconfig/samples/exp-good-printables.bconf new file mode 100644 index 000000000000..5981d304eacb --- /dev/null +++ b/tools/bootconfig/samples/exp-good-printables.bconf @@ -0,0 +1,2 @@ +key =3D "=09 +=0B=0C !#$%&'()*+,-./0123456789:;<=3D>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab= cdefghijklmnopqrstuvwxyz{|}~"; diff --git a/tools/bootconfig/samples/exp-good-simple.bconf b/tools/bootcon= fig/samples/exp-good-simple.bconf new file mode 100644 index 000000000000..d17f39421c86 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-simple.bconf @@ -0,0 +1,8 @@ +key { + word1 =3D "1"; + word2 =3D "2"; + word3 =3D "3"; + word4 =3D "4"; + word5 =3D "5"; + word6 =3D "6"; +} diff --git a/tools/bootconfig/samples/exp-good-single.bconf b/tools/bootcon= fig/samples/exp-good-single.bconf new file mode 100644 index 000000000000..01196910d7f4 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-single.bconf @@ -0,0 +1,3 @@ +key =3D "1"; +key2 =3D "2"; +key3 =3D "alpha", "beta"; diff --git a/tools/bootconfig/samples/exp-good-space-after-value.bconf b/to= ols/bootconfig/samples/exp-good-space-after-value.bconf new file mode 100644 index 000000000000..a8e8450db3c0 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-space-after-value.bconf @@ -0,0 +1 @@ +key =3D "value"; diff --git a/tools/bootconfig/samples/exp-good-tree.bconf b/tools/bootconfi= g/samples/exp-good-tree.bconf new file mode 100644 index 000000000000..b711d38d86fd --- /dev/null +++ b/tools/bootconfig/samples/exp-good-tree.bconf @@ -0,0 +1,8 @@ +key { + word.tree.value =3D "0"; + word2.tree.value =3D "1", "2"; +} +other.tree { + value =3D "2"; + value2 =3D "3"; +} diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bo= otconfig.sh index 7594659af1e1..be9bd18b1d56 100755 --- a/tools/bootconfig/test-bootconfig.sh +++ b/tools/bootconfig/test-bootconfig.sh @@ -179,6 +179,9 @@ done echo "=3D=3D=3D expected success cases =3D=3D=3D" for i in samples/good-* ; do xpass $BOOTCONF -a $i $INITRD + x=3D"samples/exp-"`basename $i` + $BOOTCONF $i > $TEMPCONF + xpass diff $x $TEMPCONF done