From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B55DAC5519F for ; Wed, 18 Nov 2020 15:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4415324770 for ; Wed, 18 Nov 2020 15:36:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="L8Czpm5j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbgKRPgA (ORCPT ); Wed, 18 Nov 2020 10:36:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:47320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbgKRPf7 (ORCPT ); Wed, 18 Nov 2020 10:35:59 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1701524770; Wed, 18 Nov 2020 15:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605713758; bh=Te2tFxY1BOS4uysqvA7qp8kR0pfzUS27egjsYkCWDd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8Czpm5jRlPVA1loW7sl7KBiSzmT+7jvK3/iDPPcukWU+1getGEWf8LhmwhJvEreZ +/OHLtrf6AnZVuR8iMTsZTWT7y3UBsmPy4josg61IxFh1qnkdZjMH3jbKbBkAlb1FG HLE2o9q+TfF8HusKoTEKlEGmG4y9hroTwtX94lHk= From: Masami Hiramatsu To: Steven Rostedt , Linus Torvalds Cc: Chen Yu , Chen Yu , Masami Hiramatsu , LKML , Ingo Molnar , Jonathan Corbet Subject: [PATCH v4 4/4] docs: bootconfig: Update file format on initrd image Date: Thu, 19 Nov 2020 00:35:54 +0900 Message-Id: <160571375428.277955.4215995441174873979.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <160571371674.277955.11736890010190945946.stgit@devnote2> References: <160571371674.277955.11736890010190945946.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To align the total file size, add padding null character when appending the bootconfig to initrd image. Signed-off-by: Masami Hiramatsu --- 0 files changed diff --git a/Documentation/admin-guide/bootconfig.rst b/Documentation/admin-guide/bootconfig.rst index a22024f9175e..363599683784 100644 --- a/Documentation/admin-guide/bootconfig.rst +++ b/Documentation/admin-guide/bootconfig.rst @@ -137,15 +137,22 @@ Boot Kernel With a Boot Config ============================== Since the boot configuration file is loaded with initrd, it will be added -to the end of the initrd (initramfs) image file with size, checksum and -12-byte magic word as below. +to the end of the initrd (initramfs) image file with padding, size, +checksum and 12-byte magic word as below. -[initrd][bootconfig][size(u32)][checksum(u32)][#BOOTCONFIG\n] +[initrd][bootconfig][padding][size(u32)][checksum(u32)][#BOOTCONFIG\n] + +When the boot configuration is added to the initrd image, the total +file size is aligned to 4 bytes. To fill the gap, null characters +(``\0``) will be added. Thus the ``size`` is the length of the bootconfig +file + padding bytes. The Linux kernel decodes the last part of the initrd image in memory to get the boot configuration data. Because of this "piggyback" method, there is no need to change or -update the boot loader and the kernel image itself. +update the boot loader and the kernel image itself as long as the boot +loader passes the correct initrd file size. If by any chance, the boot +loader passes a longer size, the kernel feils to find the bootconfig data. To do this operation, Linux kernel provides "bootconfig" command under tools/bootconfig, which allows admin to apply or delete the config file @@ -176,7 +183,8 @@ up to 512 key-value pairs. If keys contains 3 words in average, it can contain 256 key-value pairs. In most cases, the number of config items will be under 100 entries and smaller than 8KB, so it would be enough. If the node number exceeds 1024, parser returns an error even if the file -size is smaller than 32KB. +size is smaller than 32KB. (Note that this maximum size is not including +the padding null characters.) Anyway, since bootconfig command verifies it when appending a boot config to initrd image, user can notice it before boot.