From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web10.1503.1582680346860772917 for ; Tue, 25 Feb 2020 17:25:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Izx64Fyd; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582680346; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9XUl6ZiGVA8JoTyo4lJDPLn4Q2to6gdfKAzPIOmRB2I=; b=Izx64FydeB+hp3Xv6OcoYK8EKWzWAVZ6pmUfvY3tkMlBJx5AjG9Zz95QuX7nkHCwoqIcIQ 0lZpF97xc3AWiWRGSLi5HjTPOo/dBjWUNRZBmnr5HzGzw/RWIqDgonHXhWJijOwq3Xve6r FJ/hmWUciHjmuHXoBJ/HOgNPxY8d7sA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-_61iIwPcOVmzgHH5YrYPGw-1; Tue, 25 Feb 2020 20:25:44 -0500 X-MC-Unique: _61iIwPcOVmzgHH5YrYPGw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F341DBA3; Wed, 26 Feb 2020 01:25:42 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5FFC100164D; Wed, 26 Feb 2020 01:25:39 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 2/6] OvmfPkg: add 'initrd' shell command to expose Linux initrd via device path From: "Laszlo Ersek" To: devel@edk2.groups.io, ard.biesheuvel@linaro.org Cc: leif@nuviainc.com, pjones@redhat.com, mjg59@google.com, agraf@csgraf.de, daniel.kiper@oracle.com, michael.d.kinney@intel.com, jian.j.wang@intel.com, hao.a.wu@intel.com, ray.ni@intel.com, zhichao.gao@intel.com References: <20200225093908.6707-1-ard.biesheuvel@linaro.org> <20200225093908.6707-3-ard.biesheuvel@linaro.org> <2192beca-d8af-beae-cf72-ba63ad0883f7@redhat.com> Message-ID: <8e0f8f74-46f3-eb56-819b-2894aa99e9a5@redhat.com> Date: Wed, 26 Feb 2020 02:25:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <2192beca-d8af-beae-cf72-ba63ad0883f7@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 02/26/20 00:43, Laszlo Ersek wrote: > On 02/25/20 10:39, Ard Biesheuvel wrote: >> +" 2. The initrd is not unloaded when the shell exits, and will remain active\r\n" >> +" until it is unloaded again by a different invocation of the shell.\r\n" >> +" Consumers of the LoadFile2 protocol on the LINUX_EFI_INITRD_MEDIA_GUID\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" >> > > (16) So, I don't see how paragraph#2 works here. When the shell exits, > all our global variables disappear. (LoadFile2 disappears too.) The next > time the shell is launched (in the same "UEFI session", so to say), we > won't know that we had loaded an initrd before. Is that right? Sorry, I guess I missed the core idea behind dynamic shell commands :( The dynamic shell command seems like a separate DXE driver, after all. The shell can call into it (via EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL), but its lifecycle is independent of the shell's. The shell can also unload it (like the shell can unload any other driver). So please ignore my point (16). (But then, I do think we leak the initrd, if one has been loaded, in LinuxInitrdDynamicShellCommandUnload()). I.e., pls see my point (15).) Thanks Laszlo