From nobody Tue Feb 10 06:26:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55335+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55335+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583244095; cv=none; d=zohomail.com; s=zohoarc; b=QR9grt+S9sc+QCYHUqOHoXf+NALTRMcO3lt1prPlQRjZ5Xi4IkbhG86/guiBEkMabV0rCZcyIsxHtgsOK8ejX3YYB0537i5/k2HHutgGfo2JYIxO3mTakzAbt90Al0coKhBt0NnmizCQreO6NebuELaXcnlK1180aRqWJBvdKzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583244095; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=Lu18rOvVeDVdyyTH4QHtWqLXPDfO4DvMcCmh6qtNh7o=; b=CL3bm2NNfaEMJ64RIfZDMiuUwY/o7lLCHuoBg+9SylQauNxHA5wJChO+unGri3B/Bnn1i2uvHIl6HpWe4Qw+oDfxfzYRcXHHLfrXxe947K0VbqJkDsNF7omZGHq7okLsdqFoUaRY4wxN6NiN4/7dBmQNQ8/girOumXDe/BuoaU8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55335+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1583244095162134.12899561140784; Tue, 3 Mar 2020 06:01:35 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tqDFYY1788612xf3t5J7exMU; Tue, 03 Mar 2020 06:01:34 -0800 X-Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web10.4147.1583244093373974117 for ; Tue, 03 Mar 2020 06:01:33 -0800 X-Received: by mail-wm1-f66.google.com with SMTP id j1so1507965wmi.4 for ; Tue, 03 Mar 2020 06:01:33 -0800 (PST) X-Gm-Message-State: XBlD9N0boysVXJU5GeORtzPex1787277AA= X-Google-Smtp-Source: ADFU+vtKO2ubeP/1gg5Zf99P2RQi+AU6SIXROoiUuw3ZiA/8tFCJFgF2k7MVFR9Hh6ONHY67DuSA7A== X-Received: by 2002:a1c:4c03:: with SMTP id z3mr4639511wmf.133.1583244091678; Tue, 03 Mar 2020 06:01:31 -0800 (PST) X-Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id i10sm27575122wrn.53.2020.03.03.06.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 06:01:30 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , lersek@redhat.com, leif@nuviainc.com, Liming Gao Subject: [edk2-devel] [PATCH v4 7/7] OvmfPkg/LinuxInitrdDynamicShellCommand: bail if initrd already exists Date: Tue, 3 Mar 2020 15:01:17 +0100 Message-Id: <20200303140117.7288-8-ard.biesheuvel@linaro.org> In-Reply-To: <20200303140117.7288-1-ard.biesheuvel@linaro.org> References: <20200303140117.7288-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583244094; bh=Zugqo4PEbtwRhZ0rT3XBMScJmkPy5NvLwK0XQckwtPU=; h=Cc:Date:From:Reply-To:Subject:To; b=LLqmTVBUarBucvRMsouYafk5D4nTIGs1NcL5TPvtXOIurk5KEn6uoP8mP6BgpSm7qEf /04DTmfDPnSQ70JrKdoxprUWaJNR9mrf/v6apCPm3qUNTlAI89Fi0qV233g6YEQpisKMk BN8VSeN6nKkDymbFb9IlXN9uJpmwV42aaNQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Before taking any actions, check if an instance of the LoadFile2 exists already on the Linux initrd media GUID device path, and whether it was provided by this command. If so, abort, since no duplicate instances of the device path should exist. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2564 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c = | 31 ++++++++++++++++++++ OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.uni = | 3 ++ 2 files changed, 34 insertions(+) diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShell= Command.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellC= ommand.c index 47ed26b50d3a..ed8fbaa77069 100644 --- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand= .c +++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand= .c @@ -53,6 +53,33 @@ STATIC CONST SINGLE_NODE_VENDOR_MEDIA_DEVPATH mInitrdDev= icePath =3D { } }; =20 +STATIC +BOOLEAN +IsOtherInitrdDevicePathAlreadyInstalled ( + VOID + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_HANDLE Handle; + + DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *)&mInitrdDevicePath; + Status =3D gBS->LocateDevicePath (&gEfiLoadFile2ProtocolGuid, &DevicePat= h, + &Handle); + if (EFI_ERROR (Status)) { + return FALSE; + } + + // + // Check whether the existing instance is one that we installed during + // a previous invocation. + // + if (Handle =3D=3D mInitrdLoadFile2Handle) { + return FALSE; + } + return TRUE; +} + STATIC EFI_STATUS EFIAPI @@ -217,6 +244,10 @@ RunInitrd ( } else { ASSERT(FALSE); } + } else if (IsOtherInitrdDevicePathAlreadyInstalled ()) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ALREADY_INSTALLED= ), + mLinuxInitrdShellCommandHiiHandle, L"initrd"); + ShellStatus =3D SHELL_UNSUPPORTED; } else { if (ShellCommandLineGetCount (Package) > 2) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShell= Command.uni b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShel= lCommand.uni index a88fa6e3641b..4b6b1285fffd 100644 --- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand= .uni +++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand= .uni @@ -18,6 +18,7 @@ #langdef en-US "english" =20 #string STR_GEN_PROBLEM #language en-US "%H%s%N: Unknown flag - = '%H%s%N'\r\n" +#string STR_GEN_ALREADY_INSTALLED #language en-US "%H%s%N: Linux initrd al= ready provided by platform\r\n" #string STR_GEN_TOO_MANY #language en-US "%H%s%N: Too many argume= nts.\r\n" #string STR_GEN_TOO_FEW #language en-US "%H%s%N: Too few argumen= ts.\r\n" #string STR_GEN_FIND_FAIL #language en-US "%H%s%N: File not found = - '%H%s%N'\r\n" @@ -47,3 +48,5 @@ " Consumers of the LoadFile2 protocol on the LINUX_EFI_INITRD_MEDIA_GU= ID\r\n" " device path that are started via means other than the shell will be = able\r\n" " to locate the protocol and invoke it.\r\n" +" 3. Exposing an initrd using this command is only supported if no initrd= is\r\n" +" already being exposed by another driver on the platform.\r\n" --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55335): https://edk2.groups.io/g/devel/message/55335 Mute This Topic: https://groups.io/mt/71700589/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-