All of lore.kernel.org
 help / color / mirror / Atom feed
From: hpa@zytor.com
To: ron minnich <rminnich@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"maintainer:X86 ARCHITECTURE..." <x86@kernel.org>,
	mjg59@google.com,
	lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] x86 support for the initrd= command line option
Date: Thu, 19 Mar 2020 16:57:27 -0700	[thread overview]
Message-ID: <D31718CF-1755-4846-8043-6E62D57E4937@zytor.com> (raw)
In-Reply-To: <CAP6exY+LnUXaOVRZUXmi2wajCPZoJVMFFAwbCzN3YywWyhi8ZA@mail.gmail.com>

On March 19, 2020 4:49:05 PM PDT, ron minnich <rminnich@gmail.com> wrote:
>In LinuxBoot systems, a kernel and initramfs are loaded into FLASH
>to replace proprietary firmware/BIOS code. Space being at a premium
>on some systems, the kernel and initramfs must be place in whatever
>open corners of the FLASH exist. These corners are not always
>easily used.
>
>For example, on Intel-based UEFI systems, the Management Engine
>(ME) is given half the FLASH, though it uses very little, as little
>as 1.25MiB.  Not only is 2.75MiB of an 8MiB part unused; but
>10.75MiB of a 16MiB part is unused. This space can be recovered by
>a number of tools, e.g. utk and its tighten_me command, and if
>Linux can be told where the space is Linux can load an initrd from
>it.
>
>In an ideal case, we would take the space from the ME and add it to
>a FLASH-based filesystem.  While UEFI does have filesystem-like
>structures, this recovered space can only be added to its "file
>system" by rebuilding UEFI from source or writing a UEFI device
>driver. Both these options are impractical in most cases. The space
>can only be referenced as a physical address.
>
>There is code in the core that allows specification of the initrd
>as a physical address and size, but it is not supported on all
>architectures. This patch adds support for initrd= to the x86.
>
>For debugging and recovery purposes, if initrd= is present in the
>command line, other existing initrd sources should still have
>higher priority. The initramfs in flash might be damaged or
>broken. Hence, it must still be possible to load a kernel and
>initramfs with a conventional bootloader, or even load the
>FLASH-based kernel with a different initramfs; or boot a
>kernel and let it use the initrd in FLASH.
>
>In support of that priority ordering, this patch sets the ramdisk
>image pointer to phys_initrd_start only if it is not already set;
>and sets ramdisk_size to phys_initrd_size only if it is not already
>set.
>
>It has been tested extensively in LinuxBoot environments.
>
>Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
>---
> arch/x86/kernel/setup.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
>index a74262c71484..1b04ef8ea12d 100644
>--- a/arch/x86/kernel/setup.c
>+++ b/arch/x86/kernel/setup.c
>@@ -237,6 +237,9 @@ static u64 __init get_ramdisk_image(void)
>
>     ramdisk_image |= (u64)boot_params.ext_ramdisk_image << 32;
>
>+    if (ramdisk_image == 0) {
>+        ramdisk_image = phys_initrd_start;
>+    }
>     return ramdisk_image;
> }
> static u64 __init get_ramdisk_size(void)
>@@ -245,6 +248,9 @@ static u64 __init get_ramdisk_size(void)
>
>     ramdisk_size |= (u64)boot_params.ext_ramdisk_size << 32;
>
>+    if (ramdisk_size == 0) {
>+        ramdisk_size = phys_initrd_size;
>+    }
>     return ramdisk_size;
> }

The initrd= option is reserved namespace for the bootloader. It is also worth noting that the x86 boot protocol now allows the bootloader to point to arbitrary chunks of memory for the initrd.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

  reply	other threads:[~2020-03-19 23:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 23:49 [PATCH 1/1] x86 support for the initrd= command line option ron minnich
2020-03-19 23:57 ` hpa [this message]
2020-03-20  0:50   ` ron minnich
2020-03-20  0:59     ` hpa
2020-03-20 15:39       ` ron minnich
2020-03-20 18:19       ` Matthew Garrett
2020-03-23 18:19         ` hpa
2020-03-23 18:54           ` ron minnich
2020-03-23 19:05             ` hpa
2020-03-23 19:40               ` ron minnich
2020-03-23 21:41                 ` hpa
2020-03-23 22:29                   ` ron minnich
2020-03-23 22:38                     ` ron minnich
2020-03-24 16:05                       ` ron minnich
2020-03-24 16:12                         ` Randy Dunlap
2020-03-24 16:19                           ` ron minnich
2020-03-25 17:21                             ` hpa
2020-04-27  7:35                             ` [tip: x86/boot] x86/setup: Add an initrdmem= option to specify initrd physical address tip-bot2 for Ronald G. Minnich
2020-03-25  3:30                     ` [PATCH 1/1] x86 support for the initrd= command line option H. Peter Anvin
2020-03-25 16:19                       ` ron minnich
2020-03-25 17:20                         ` hpa

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=D31718CF-1755-4846-8043-6E62D57E4937@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mjg59@google.com \
    --cc=rminnich@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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 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.