mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Graf <graf@amazon.com>
To: Bagas Sanjaya <bagasdotme@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: "Linux Documentation" <linux-doc@vger.kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jan H. Schönherr" <jschoenh@amazon.de>,
	"James Gowans" <jgowans@amazon.com>
Subject: Re: [PATCH v3] initramfs: Expose retained initrd as sysfs file
Date: Sat, 9 Dec 2023 10:23:03 +0100	[thread overview]
Message-ID: <b32fe3b6-9123-4c20-864b-5282c8dea567@amazon.com> (raw)
In-Reply-To: <ZXPkL1jyXwGH11gJ@archie.me>


On 09.12.23 04:51, Bagas Sanjaya wrote:
> On Thu, Dec 07, 2023 at 11:56:54PM +0000, Alexander Graf wrote:
>> When the kernel command line option "retain_initrd" is set, we do not
>> free the initrd memory. However, we also don't expose it to anyone for
>> consumption. That leaves us in a weird situation where the only user of
>> this feature is ppc64 and arm64 specific kexec tooling.
>>
>> To make it more generally useful, this patch adds a kobject to the
>> firmware object that contains the initrd context when "retain_initrd"
>> is set. That way, we can access the initrd any time after boot from
>> user space and for example hand it into kexec as --initrd parameter
>> if we want to reboot the same initrd. Or inspect it directly locally.
>>
>> With this patch applied, there is a new /sys/firmware/initrd file when
>> the kernel was booted with an initrd and "retain_initrd" command line
>> option is set.
>>
>> Signed-off-by: Alexander Graf <graf@amazon.com>
>> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
>>
>> ---
>>
>> v1 -> v2:
>>
>>    - Reword commit message to explain the new file path
>>    - Add a Documentation/ABI/testing/sysfs-firmware-initrd file
>>
>> v2 -> v3:
>>
>>    - Only expose file when initrd is present (James Gowans)
>> ---
>>   .../ABI/testing/sysfs-firmware-initrd          |  8 ++++++++
>>   .../admin-guide/kernel-parameters.txt          |  5 +++--
>>   init/initramfs.c                               | 18 +++++++++++++++++-
>>   3 files changed, 28 insertions(+), 3 deletions(-)
>>   create mode 100644 Documentation/ABI/testing/sysfs-firmware-initrd
>>
>> diff --git a/Documentation/ABI/testing/sysfs-firmware-initrd b/Documentation/ABI/testing/sysfs-firmware-initrd
>> new file mode 100644
>> index 000000000000..20bf7cf77a19
>> --- /dev/null
>> +++ b/Documentation/ABI/testing/sysfs-firmware-initrd
>> @@ -0,0 +1,8 @@
>> +What:		/sys/firmware/initrd
>> +Date:		December 2023
>> +Contact:	Alexander Graf <graf@amazon.com>
>> +Description:
>> +		When the kernel was booted with an initrd and the
>> +		"retain_initrd" option is set on the kernel command
>> +		line, /sys/firmware/initrd contains the contents of the
>> +		initrd that the kernel was booted with.
>> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
>> index 65731b060e3f..51575cd31741 100644
>> --- a/Documentation/admin-guide/kernel-parameters.txt
>> +++ b/Documentation/admin-guide/kernel-parameters.txt
>> @@ -2438,7 +2438,7 @@
>>   			between unregistering the boot console and initializing
>>   			the real console.
>>   
>> -	keepinitrd	[HW,ARM]
>> +	keepinitrd	[HW,ARM] See retain_initrd.
>>   
>>   	kernelcore=	[KNL,X86,IA-64,PPC]
>>   			Format: nn[KMGTPE] | nn% | "mirror"
>> @@ -5580,7 +5580,8 @@
>>   			Useful for devices that are detected asynchronously
>>   			(e.g. USB and MMC devices).
>>   
>> -	retain_initrd	[RAM] Keep initrd memory after extraction
>> +	retain_initrd	[RAM] Keep initrd memory after extraction. After boot, it will
>> +			be accessible via /sys/firmware/initrd.
>>   
>>   	retbleed=	[X86] Control mitigation of RETBleed (Arbitrary
>>   			Speculative Code Execution with Return Instructions)
> You may want to adjust documentation to address my testing [1]. In summary,
> only the first initrd blob that was passed to the kernel will be exposed
> in /sys/firmware/initrd.


 From the kernel's point of view, there is only a single initrd binary 
:). Whether your boot loader concatenates multiple archives to create 
that single one out of multiple individual files is a boot loader 
implementation detail.

Alex





Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879



      reply	other threads:[~2023-12-09  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 23:56 Alexander Graf
2023-12-09  3:51 ` Bagas Sanjaya
2023-12-09  9:23   ` Alexander Graf [this message]

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=b32fe3b6-9123-4c20-864b-5282c8dea567@amazon.com \
    --to=graf@amazon.com \
    --cc=akpm@linux-foundation.org \
    --cc=bagasdotme@gmail.com \
    --cc=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jgowans@amazon.com \
    --cc=jschoenh@amazon.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®