Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1101294ybm; Wed, 27 May 2020 16:29:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB5JT0mbV0g0023HwlM8aicyVurL9weVi2ecJmLIqHjtjvCrgh1RWeGxmSSvI9h4IJVUdI X-Received: by 2002:a17:906:e2d2:: with SMTP id gr18mr618490ejb.312.1590622145422; Wed, 27 May 2020 16:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590622145; cv=none; d=google.com; s=arc-20160816; b=zWFRunxdjIGNZpW4GDVS06lNqCImdIlzsgnHrW/61dhHSX68wtpPq8DMqO3osfVmsX FwjuGapXFI6g7tRAvsmS2Bg2XyHZ/Jpc95qHrHPcPqHTFd9/fao6+IcgLA9SM9qfwM8H 0a9C+kyBK0vUS6V5ESqawclWc3K3NZH/twrelaFYZ+sKTOyN0eSjYddGLKuQfC+wjTu+ j9XZjsUevhPzszkilBbPmZMm71IK5tPlfvXFO8cVTsZBEQtamUSAQ4dc2w1AeH9EutGl 4u0Uvr3gKpRDtviFkaK5IDhNWuXGUMhuHLKNLRfEAz5RqsTWRbUPdxSPJ15//uZYft9W FznA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pHGDLlJ9WIIzUBMSyQD34/Snx/SdTvbpspVS+Y0RZqY=; b=iG4aKCLMahZsqTkx2+kAX7JJiHQ+EgtlCfT5ZbRSKF9R3FhketDnnW8uRlTQfVK05x McVOiaN/zMsD5MtcL7/sZn+CHOC+n85YfZrYrcQThlMhPaDepVVqCiM7zypEaQVtwwwO DeLz70qMVTrigGVlvocRhsArrmZhPj7+qc4FQDilXXmWcn1iIW8R1e0nEdA1pX/D+sHV RGDp8BDn4y1RH1xFf4LL+u2yWZvfEAaqm4GIWi+pYkzwqGXqjPoaKIZR2/Utl37BVp2g K1bY0iCmQgM7adRkaUjJm5doOA2zTT1Vk3whmq53HQbYhhLo1SHIrjrpC7hqKKTvj64V XzVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si2700038ejx.250.2020.05.27.16.28.42; Wed, 27 May 2020 16:29:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725944AbgE0X0F (ORCPT + 99 others); Wed, 27 May 2020 19:26:05 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:39422 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgE0X0E (ORCPT ); Wed, 27 May 2020 19:26:04 -0400 Received: by mail-qt1-f196.google.com with SMTP id k22so6029925qtm.6; Wed, 27 May 2020 16:26:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pHGDLlJ9WIIzUBMSyQD34/Snx/SdTvbpspVS+Y0RZqY=; b=VvV5PZ12eNzIgDTcuoEan4zVx8CA7LaheTeBAC9EA7h2vPmcdFF1bjDEDXnR84uuOI VVdvcWAI8UDb/FeB67eMomsdYU9mczaHaSKyyO21l+tiDfLgaFBCQCnwM0D5QfgY2WMr JthuCIp/mfHtJF94c8iHV/u/h3QulLr6cXVdZngi5vHG6mk7yJreO5qBg2vkH0fiLJJM 1q/Vweasrr6/hRWSAQwvZD/jabtxGmN9Q8Li/P3Kxllcpwmtlj8ZEf9MdkwCf5MgHdNm 4/e1oVekOVsB7NAF8/Bjg1uVYn4ywUQbpJH2fsa7wvoGL0Mv4SV8HHyv39KEsqQEJ4wC yOtA== X-Gm-Message-State: AOAM5330LUsV2LUc60W2vngp9QCMBWyGWh2lGS58EECdtC1/azc9LhVW 08tJFiSZob74ku3kCjZZ+JaspSwH X-Received: by 2002:ac8:4c8b:: with SMTP id j11mr375549qtv.58.1590621963529; Wed, 27 May 2020 16:26:03 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id y66sm3774883qka.24.2020.05.27.16.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 16:26:03 -0700 (PDT) From: Arvind Sankar To: Ard Biesheuvel , Dan Williams , Ingo Molnar , Thomas Gleixner Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] efi/x86: Don't blow away existing initrd Date: Wed, 27 May 2020 19:26:02 -0400 Message-Id: <20200527232602.21596-1-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 987053a30016 ("efi/x86: Move command-line initrd loading to efi_main") moved the command-line initrd loading into efi_main, with a check to ensure that it was attempted only if the EFI stub was booted via efi_pe_entry rather than the EFI handover entry. However, in the case where it was booted via handover entry, and thus an initrd may have already been loaded by the bootloader, it then wrote 0 for the initrd address and size, removing any existing initrd. Fix this by checking if size is positive before setting the fields in the bootparams structure. Fixes: 987053a30016 ("efi/x86: Move command-line initrd loading to efi_main") Reported-by: Dan Williams Tested-by: Dan Williams Signed-off-by: Arvind Sankar --- drivers/firmware/efi/libstub/x86-stub.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 072b7cf40475..ceb8e16c8b75 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -774,10 +774,12 @@ unsigned long efi_main(efi_handle_t handle, efi_err("Failed to load initrd!\n"); goto fail; } - efi_set_u64_split(addr, &hdr->ramdisk_image, - &boot_params->ext_ramdisk_image); - efi_set_u64_split(size, &hdr->ramdisk_size, - &boot_params->ext_ramdisk_size); + if (size > 0) { + efi_set_u64_split(addr, &hdr->ramdisk_image, + &boot_params->ext_ramdisk_image); + efi_set_u64_split(size, &hdr->ramdisk_size, + &boot_params->ext_ramdisk_size); + } } /* -- 2.26.2