Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp71737ybb; Thu, 19 Mar 2020 16:51:28 -0700 (PDT) X-Google-Smtp-Source: ADFU+vupw9TQbut+7LcrBJ+0fMe6kn5GmkjmpBXZrNlPS2Q45pYYbZVcUllig2FprzSe9/QJhKzn X-Received: by 2002:a9d:4d8a:: with SMTP id u10mr4521134otk.148.1584661888744; Thu, 19 Mar 2020 16:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584661888; cv=none; d=google.com; s=arc-20160816; b=xRUXjwAzfmvwXc7fiVu07c54ySodCTgNL43Ma9REsIRNj0Af8IbqQqrlwir4LpUUAT 8cuDNArw6KWBh41OEPUvZdbBMpp+iUvABe2C1t77iF2Klqv7WwgyImCRwD+5aV4FCtEj SLqql57J+uXFr+SRZQVMzC2RxCPxDfcWKNkDLn5Tqnf4unAjOiLsuyNMx0RvqSaV5fNK cIKzd4MgJ51EiHkZoC2amdevR5seGk9SYGTHZjygWYgpfXOmGhz04eOlhOsYoHq26Sch X1GEWHh5vvJGTMaYVmfabO+ucXJAwUCCqZydNdb/iZdRalddRjo1yLU7WHrgyvpQ3ISX /GeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature; bh=O6UYEuu9USYd3Lm4ZwOGt6AHTZhdq8dyDYUaZFKRfAw=; b=phIpuYjhvwAW1N101q9ZSEGYQ8o8eJLp0kMbL+LCDHm27WOgbtSc60wijT/8dB5iIC p8KuLPI8RYyrLgdqfrAKFOCTrjY/VYRQuGYTrTVbGov/VuAG30ROjgyle+4ORZ4+RVq/ 9v0ROOyDNyBsZIzH3uCZsAnn2xZdxB5Jq/pp1AvKWFzm8c2GcsaBcPmZ9rVcAxWLWL6y aFhguLMwPRcxd0segKmZyji270w/CkpxN6t6Q8jZa/mNrlpRnzOIBFis+fvz7pZNo0eO PD2QRT3lIXVCTL774+GBckti1mfOv2mqxY9D2mnFMEgsPqnkZCk3JcK80WLp0uUYHzN8 056Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R2UpNnFW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si1737660oib.32.2020.03.19.16.51.15; Thu, 19 Mar 2020 16:51:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R2UpNnFW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727228AbgCSXtR (ORCPT + 99 others); Thu, 19 Mar 2020 19:49:17 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:42622 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgCSXtR (ORCPT ); Thu, 19 Mar 2020 19:49:17 -0400 Received: by mail-oi1-f195.google.com with SMTP id 13so4687281oiy.9 for ; Thu, 19 Mar 2020 16:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=O6UYEuu9USYd3Lm4ZwOGt6AHTZhdq8dyDYUaZFKRfAw=; b=R2UpNnFWF9Dcbu0Bjkayq97kdYaixurxyQKhaCoIjtSRcIa919RhSx3VsZsz0dfqw6 EgVjfgOsTMDJuVMH0Ig8bmC5VFUyPYxrM7pjaqc4lUKZbXOpHFK6Os5JvTOkxMA40lDY oOk8gbdLw9FI0bNHGs1OOm1Dh8C8keAnChC2meNY4KMWlRfuOtQxr7vZRZ4D2nBE10iy 3ManvCKP09sfNk8jbCwmlnhwSnOMwp1caW3vqbfBPUdGR6nkbQZy+WFMLu5ljNoazr5W mMbzX46wOBJ/1l4m1TCfkbswrYRYOaeLs5cMaU9LMWYFMHoUkaSlXy14Kz7+XCaDy6YI SG2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=O6UYEuu9USYd3Lm4ZwOGt6AHTZhdq8dyDYUaZFKRfAw=; b=WUaN3Vgue9ZE7V+GV4iXZtvp89Uh6CNRLpvbTS8N7eAodL9CKyuRsI151hm+kzLJDQ u7F+8NaX//xY6ZUnBS04Tlfyi24mLhywKJStQXhHILbj9xOmSKNtF4L5EWQBaXd/50aK jVlK4/x2pWdr9L44b0FCPY6E18N/u/WpSNGLezmHo6DCFnBsvA6u/2/J4/wO9UVoSCez 0ygragx9T5YbqDwbb1oujiynjeFwSrpVCTEBaURsQQdKuNWzjFYwAtFPlt4c360cra0S AYUA7EE+bABK3KTBj3x+IIJwRPvS5OvP+ZCzxcAI8BFOEABSjf9bTZckIB+2gPeQ4Ioe zlIw== X-Gm-Message-State: ANhLgQ3HhiBoW8U/+O/Q/tT+RJduwbOh27dYHx1VR8WEy05G0qIVOvaG P/603LA8NESxC6qYbupdqesyxiEQZjgZ900j6J4= X-Received: by 2002:aca:1e1a:: with SMTP id m26mr4459581oic.39.1584661756692; Thu, 19 Mar 2020 16:49:16 -0700 (PDT) MIME-Version: 1.0 From: ron minnich Date: Thu, 19 Mar 2020 16:49:05 -0700 Message-ID: Subject: [PATCH 1/1] x86 support for the initrd= command line option To: "H. Peter Anvin" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE..." , mjg59@google.com, lkml - Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.17.1