public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] OvmfPkg: FMP Capsule Update Modifications.
@ 2020-11-09 11:03 Sandeep Dhanvada
  2020-11-09 11:03 ` [PATCH 1/2] MdeModulePkg: Capsule upgrade fixes Sandeep Dhanvada
  2020-11-09 11:03 ` [PATCH 2/2] OvmfPkg: Add EsrtFmpDxe in OVMF X64 Builds Sandeep Dhanvada
  0 siblings, 2 replies; 4+ messages in thread
From: Sandeep Dhanvada @ 2020-11-09 11:03 UTC (permalink / raw)
  To: devel; +Cc: sandeep.dhanvada

This patch enables FMP Capsule upgrade of firmware on PCI add on
cards with PCI Passthrough enabled in OVMF environment by enabling
DxeCapsuleLibFmp and EsrtFMP modules.

DxeCapsuleLibFmp/DxeCapsuleLib.c has modifications to connect to
all controllers after capsule update is executed. This enables FMP
SetImage() to be executed through UpdateCapsule(). without this
change, connect command has to be issued manually from UEFI Shell
for the FMP SetImage() to execute.

FMP capsule update is validated using CapsuleApp.efi, with -E option
dumping the ESRT Table fetched from FMP producer on PCI UEFI driver.
capsule update is validated using capsulefile generated using
BaseTools/Source/Python/Capsule/GenerateCapsule.py.

Sandeep Dhanvada (2):
  MdeModulePkg: Capsule upgrade fixes.
  OvmfPkg: Add EsrtFmpDxe in OVMF X64 Builds.

 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c       | 43 ++++++++++++++++++++++
 OvmfPkg/OvmfPkgX64.dsc                             |  4 +-
 OvmfPkg/OvmfPkgX64.fdf                             |  1 +
 3 files changed, 47 insertions(+), 1 deletion(-)

--
2.1.1

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] MdeModulePkg: Capsule upgrade fixes.
  2020-11-09 11:03 [PATCH 0/2] OvmfPkg: FMP Capsule Update Modifications Sandeep Dhanvada
@ 2020-11-09 11:03 ` Sandeep Dhanvada
  2020-11-09 11:03 ` [PATCH 2/2] OvmfPkg: Add EsrtFmpDxe in OVMF X64 Builds Sandeep Dhanvada
  1 sibling, 0 replies; 4+ messages in thread
From: Sandeep Dhanvada @ 2020-11-09 11:03 UTC (permalink / raw)
  To: devel; +Cc: sandeep.dhanvada

ConnectAllControlers() function is taken from
ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c:ConnectAllEfi()

without this function call, connect command should be explicitly
exeucted on shell for the FMP SetImage to be executed after capsule
update.

Signed-off-by: Sandeep Dhanvada <sandeep.dhanvada@xilinx.com>
---
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c       | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 9094213..818a91b 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -1001,6 +1001,48 @@ SetFmpImageData (
 }

 /**
+  This function will connect all current system handles recursively. The
+  connection will finish until every handle's child handle created if it have.
+
+  This function is taken from ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
+
+  @retval EFI_SUCCESS           All handles and it's child handle have been
+                                connected
+  @retval EFI_STATUS            Return the status of gBS->LocateHandleBuffer().
+
+**/
+
+EFI_STATUS
+ConnectAllControllers (VOID)
+{
+  EFI_STATUS  Status;
+  UINTN       HandleCount;
+  EFI_HANDLE  *HandleBuffer;
+  UINTN       Index;
+
+  Status = gBS->LocateHandleBuffer (
+                  AllHandles,
+                  NULL,
+                  NULL,
+                  &HandleCount,
+                  &HandleBuffer
+                 );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  for (Index = 0; Index < HandleCount; Index++) {
+    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
+  }
+
+  if (HandleBuffer != NULL) {
+    FreePool (HandleBuffer);
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
   Start a UEFI image in the FMP payload.

   @param[in]  ImageBuffer   A pointer to the memory location containing a copy of the image to be loaded..
@@ -1067,6 +1109,7 @@ StartFmpImage (
     DEBUG ((DEBUG_ERROR, "Driver Return Status = %r\n", Status));
   }

+  ConnectAllControllers();
   FreePool(DriverDevicePath);
   return Status;
 }
--
2.1.1

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] OvmfPkg: Add EsrtFmpDxe in OVMF X64 Builds.
  2020-11-09 11:03 [PATCH 0/2] OvmfPkg: FMP Capsule Update Modifications Sandeep Dhanvada
  2020-11-09 11:03 ` [PATCH 1/2] MdeModulePkg: Capsule upgrade fixes Sandeep Dhanvada
@ 2020-11-09 11:03 ` Sandeep Dhanvada
  2020-11-10 21:17   ` [edk2-devel] " Laszlo Ersek
  1 sibling, 1 reply; 4+ messages in thread
From: Sandeep Dhanvada @ 2020-11-09 11:03 UTC (permalink / raw)
  To: devel; +Cc: sandeep.dhanvada

This will allow testing of FMP Capsule update on a PCI device with OVMF.

DxeRuntimeCapsuleLib from DxeCapsuleLibFmp enables capsule update
support in OVMF.

Inclusion of EsrtFmpDxe in OVMF X64 builds will enable dynamic creation
of ESRT using FMP produced by UEFI device driver.

Testing these changes with CapsuleApp.efi and with FMP support added in
UEFI device driver shows that, dump ESRT using -E option displays ESRT
table and using this efi with a capsule file as argument, is initiating
the firmware update process using UpdateCapsule API.

Signed-off-by: Sandeep Dhanvada <sandeep.dhanvada@xilinx.com>
---
 OvmfPkg/OvmfPkgX64.dsc | 4 +++-
 OvmfPkg/OvmfPkgX64.fdf | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 7a8bdb8..07cc167 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -138,7 +138,7 @@
   UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
   BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
   FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
   DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
   PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
@@ -796,6 +796,8 @@
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
+  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
   MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf {
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 17ba9e1..97405e8 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -281,6 +281,7 @@ INF  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 INF  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
 INF  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
 INF  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
+NF  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf

 INF  OvmfPkg/SioBusDxe/SioBusDxe.inf
 !if $(SOURCE_DEBUG_ENABLE) == FALSE
--
2.1.1

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] OvmfPkg: Add EsrtFmpDxe in OVMF X64 Builds.
  2020-11-09 11:03 ` [PATCH 2/2] OvmfPkg: Add EsrtFmpDxe in OVMF X64 Builds Sandeep Dhanvada
@ 2020-11-10 21:17   ` Laszlo Ersek
  0 siblings, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2020-11-10 21:17 UTC (permalink / raw)
  To: devel; +Cc: sandeep.dhanvada, Tomas Pilar (tpilar)

On 11/09/20 12:03, Sandeep Dhanvada wrote:
> This will allow testing of FMP Capsule update on a PCI device with OVMF.
>
> DxeRuntimeCapsuleLib from DxeCapsuleLibFmp enables capsule update
> support in OVMF.
>
> Inclusion of EsrtFmpDxe in OVMF X64 builds will enable dynamic creation
> of ESRT using FMP produced by UEFI device driver.
>
> Testing these changes with CapsuleApp.efi and with FMP support added in
> UEFI device driver shows that, dump ESRT using -E option displays ESRT
> table and using this efi with a capsule file as argument, is initiating
> the firmware update process using UpdateCapsule API.
>
> Signed-off-by: Sandeep Dhanvada <sandeep.dhanvada@xilinx.com>
> ---
>  OvmfPkg/OvmfPkgX64.dsc | 4 +++-
>  OvmfPkg/OvmfPkgX64.fdf | 1 +
>  2 files changed, 4 insertions(+), 1 deletion(-)


Please see the previous discussion here:

* [edk2-devel] [PATCH v2]
  OvmfPkg: Use DxeRuntimeCapsuleLib from DxeCapsuleLibFmp in X64 builds

  https://edk2.groups.io/g/devel/message/42752
  http://mid.mail-archive.com/6ef09714-fd1f-2f7b-5a1d-fdf5e1a609fb@solarflare.com

(1) Please address the requests that I made in that thread. In
particular:

(1a) Unless this is specific to X64, the same modifications should be
replicated to the IA32 and IA32X64 DSC/FDF files.

(1b) Please make these changes dependent on a new build flag (default
value: FALSE), in the DSC file(s). I suggest:

> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 2637dfaf2de3..232e9ce2726a 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -33,6 +33,7 @@ [Defines]
>    DEFINE SOURCE_DEBUG_ENABLE     = FALSE
>    DEFINE TPM_ENABLE              = FALSE
>    DEFINE TPM_CONFIG_ENABLE       = FALSE
> +  DEFINE PCI_DEV_CAPSULE_ENABLE  = FALSE
>
>    #
>    # Network definition

(1c) Please spell out the role of "CapsuleRuntimeDxe" in the commit
message.

Some new comments:

>
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 7a8bdb8..07cc167 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -138,7 +138,7 @@

(2) Please run "BaseTools/Scripts/SetupGit.py" in your edk2 clone, or
else manually implement the settings at
<https://github.com/tianocore/tianocore.github.io/wiki/Laszlo%27s-unkempt-git-guide-for-edk2-contributors-and-maintainers#contrib-05>.

I'm asking specifically because the "@@" hunk header above should show
which section of the DSC file is being modified.

>    UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
>    BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
>    FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
> -  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
> +  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
>    DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
>    DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
>    PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
> @@ -796,6 +796,8 @@
>    MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>    MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
>    MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> +  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
> +  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf

(3) Listing a library instance in the [Components] section of a DSC file
makes no sense in the OVMF DSC files. (It may make sense for in other
packages' DSC files, but not for OVMF.)

>    MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
>    MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
>    MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf {
> diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
> index 17ba9e1..97405e8 100644
> --- a/OvmfPkg/OvmfPkgX64.fdf
> +++ b/OvmfPkg/OvmfPkgX64.fdf
> @@ -281,6 +281,7 @@ INF  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
>  INF  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
>  INF  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
>  INF  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
> +NF  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf

(4) This change seems corrupt.

(5) Please try to list modules in the DSC and FDF files in the same
order. If you insert EsrtFmpDxe just after CapsuleRuntimeDxe in the DSC
file, then please attempt to follow suit in the FDF file.

Thanks
Laszlo

>
>  INF  OvmfPkg/SioBusDxe/SioBusDxe.inf
>  !if $(SOURCE_DEBUG_ENABLE) == FALSE
> --
> 2.1.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-10 21:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-09 11:03 [PATCH 0/2] OvmfPkg: FMP Capsule Update Modifications Sandeep Dhanvada
2020-11-09 11:03 ` [PATCH 1/2] MdeModulePkg: Capsule upgrade fixes Sandeep Dhanvada
2020-11-09 11:03 ` [PATCH 2/2] OvmfPkg: Add EsrtFmpDxe in OVMF X64 Builds Sandeep Dhanvada
2020-11-10 21:17   ` [edk2-devel] " Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox