Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2867269ybb; Sun, 22 Mar 2020 09:34:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu4MI/XEkbk506iQknau+PN8mBfEbIEJxyKBmMQAAbDVwhTmuSPQZCTS+L6lEih9F5NsMMy X-Received: by 2002:a05:6808:43:: with SMTP id v3mr14547448oic.59.1584894851524; Sun, 22 Mar 2020 09:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584894851; cv=none; d=google.com; s=arc-20160816; b=AJQzP1Mavj0xEFzBwQDjg66VYw5GReveku80GMeZd4+O4JKbJXL7fLifkzUU1m5x1F NHSseDdsPLS9MTd4QvZVwZHc/bPddDA0FficMfg2Ntvpf/Jo5jIjHbktb4RCOQqDiVoN fOdEAaUHIQ5p8T6csnEwi7ls64s4O/bOggLT2+2JyIZDSIojujplJTvmNAp1WKm1VVC7 P3gGjuCkzQt/+hMH8sa/xE9B1tM0Nt/YTGX6TRX0x0AXRkaAc5wDJhGQ1E2U23AT4jl+ zZJNJ9Qp746M4Vzdg7oLsNrBcSwKbkqIkvjrjXYlnOGiJ21iiv71KI1gdEUctMqVTBLj q9Zg== 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=rE1paS4p2jyWTXkjBBokLZuTQ89ze7aCdRvVGvddOTc=; b=qM78+fKk5/gwoKz/IrMNdLd8lkvg6AIwTMv8GKHvGR5BC9I9KNQWZ6C/8YPqs85fLF 9noZ+UVSg5wX7sZsgGRBMaIjS6XXFtmaEFSTopgZrkvOvU0Bke5QYDK5W9DaG6wRIBGg D7WRKFIDqyLPBEI799b+UnqGaVmgLRiPDEremwkBALcl42JDrHiqsOweCbA2UQK2NBum /jeDkw6I5IwGSke0N9+l5wU4eCs6OeXrFoe1BQ1cyPzJllD2caFqrHTo/UUyKKLPWnq3 IIHLSYRBZqIstijYfV8jT4EvbHmMJxfTk/IU0zOmGMod0LUK3KETBW6EeEUdvrbDrRo7 NlIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WvwCk952; 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 t7si1737672otd.115.2020.03.22.09.33.58; Sun, 22 Mar 2020 09:34:11 -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=WvwCk952; 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 S1726869AbgCVQb7 (ORCPT + 99 others); Sun, 22 Mar 2020 12:31:59 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:35516 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbgCVQb7 (ORCPT ); Sun, 22 Mar 2020 12:31:59 -0400 Received: by mail-ot1-f68.google.com with SMTP id k26so11012290otr.2 for ; Sun, 22 Mar 2020 09:31:59 -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=rE1paS4p2jyWTXkjBBokLZuTQ89ze7aCdRvVGvddOTc=; b=WvwCk9523yeNbywcS3SJKrelb/P70ZdC7nvbK+WMfYb+aKxG8FbQ1ksM3LqfHW8gvZ 1wn1/ZaoOMtIv8tfuW7GutVK66orW02JMz02+1N4N/sQXz9h60fkrD8o9QMdtDz+fARh aJGoO+dIAlZLPoBxv3zai+e2FY7FbGNgBf0k3gK0yMYPzQC1IU62QswVoC4SNCamVF1i Rt5jAURaGwnnx8z2O+W2QE1do45wvvPzpOpO9ppaa0wcUO1UF3ciZvUMeAR2k3rVoFaM EFUVlhy+UciFBxb3JCsjlgZUi8n7ViI28j33zyF+f9xYbYONcPRSDgvUIkihng0bhgX/ fEqQ== 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=rE1paS4p2jyWTXkjBBokLZuTQ89ze7aCdRvVGvddOTc=; b=Egit6/BrQ/XB/i10irH1AaPJsGHEZsOyKkknn1RUR/k7YuI9IURB3SBOe8E57cSrPN iAdilkx5d66hKBUFUeAKUu5i2b/X0ufCMkqA33jlfjp/VJpFZ2B+iAXa9iGwmB3pEj9s V3KOqsHbjQ/3ugf9qG/rk3XIf6Z71uilSTwVO6+WK8jCOFB1ILAp14mOhow2gua73+dO 0oSojtSuF/jdptZq/HRWT72ypeJ8rcjS1ziXhK65hNj2YBOWdc4ULi+4xVZnUUcJmCrY CMyzJZizm3ly2cG0S+eUAR4aKGAWlw4jJLD9/2CU6k+lRM5X/sEqwpERgnpl2Np73EZO sasg== X-Gm-Message-State: ANhLgQ12PN00Z27qVCo2tEx+wOZEHbbp9pwVoqJ3OARroSVbUUVRFoWr dov6qpzRAgw+HWmyV5PNr6UgiUS7YubJ+YgaXDU= X-Received: by 2002:a9d:5906:: with SMTP id t6mr5496911oth.338.1584894718538; Sun, 22 Mar 2020 09:31:58 -0700 (PDT) MIME-Version: 1.0 From: ron minnich Date: Sun, 22 Mar 2020 09:31:47 -0700 Message-ID: Subject: x86: add phys_initrd_[start,size] as an initrd source 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. In most systems, the initrd is compiled into the kernel, where space allows. 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. The initrd code provides two variables, phys_initrd_start and phys_initrd_size, which can be used to indicate the location of an initrd, which is in the physical address space but not compiled in or provided in the bootparams. For debugging and recovery purposes, other existing initrd sources should still have higher priority. The initramfs in FLASH might be damaged or broken. 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