This is series 5 of the whole capsule solution. Version 4. According to feedback, we split the big patch series to smaller one. Series 5: Vlv2 update The code is also in https://github.com/jyao1/edk2 V4 is at Capsule_V4 branch. V3, V2, V1 are also pushed to coresponding branch. Below is detail description for each version. ==Below is V4 description== 1) SecurityPkg - Refine AuthenticateFmpImage() API to let caller input PublicKeyData and PublicKeyDataLength, instead of PCD. The benefit is that then this API can be used for a platform which stores PublicKeyData in anywhere other than PCD. 2) SecurityPkg - Use OFFSET_OF(WIN_CERTIFICATE_UEFI_GUID, CertData) for better understanding the code. 3) MdeModulePkg - Update CapsuleApp to let it consume ShellParameters protocol to get Argc and Argv. 4) UefiCpuPkg - Update MicrocodeCapsuleApp to let it consume ShellParameters protocol to get Argc and Argv. 5) QuarkPlatformPkg - Merge QuarkCapsule.fdf to Quark.fdf. ==Below is V3 description== 1) We move all EDKII related capsule definition to SignedCapsulePkg. MdeModulePkg only contains FmAuthenticationLib and CapsuleApp, because they are generic and follow UEFI specification on FMP/ESRT and Microsoft platform firmware update document. Any capsule implementation can use them. Here is full library classes: MdeModulePkg: FmpAuthenticationLib.h: new lib - follow UEFI spec. (*) Verify FMP signature of FMP Capsule CapsuleLib.h: new API ¨C ProcessCapsules() It processes all the capsules. Remove duplicated code in platform BDS. UefiCpuPkg: MicrocodeFlashAccessLib.h: Update Microcode region. SignedCapsulePkg: EdkiiSystemCapsuleLib.h ¨C Library for EDKII system FMP. IniParsingLib.h ¨C Library for INI file parsing. PlatformFlashAccessLib.h ¨C Library for write flash. 2) We will submit 5 series. Series 1: Generic Update (MdeModulePkg/SecurityPkg) DxeCapsuleLib FmAuthenticationLib (*) CapsuleApp (*) Series 2: EDKII Capsule (SignedCapsulePkg) IniParsingLib EdkiiSystemCapsuleLib PlatformFlashAccessLib SystemFirmwareUpdate driver RecoveryModuleLoadPei driver Series 3: Microcode Update (UefiCpuPkg) MicrocodeFlashAccessLib MicrocodeUpdate driver. Series 4: Quark update Series 5: Vlv2 update 3) DxeCapsuleLib: Move code that performs authentication and parsing of the capsule format into the implementation of the FMP Protocol. We move the dispatch FV code from CapsuleLib to SystemFirmwareReport.efi. SystemFirmwareReport.efi supports SetImage() to verify and dispatch the SystemFirmwareUpdate.efi, then pass thru SetImage() request to SystemFirmwareUpdate.efi. Now the DxeCapsuleLib is very clean and it does not have any EDKII capsule format knowledge. 4) DxeCapsuleLib: Fix issue where a reset may be too soon. Defer reset to 2nd pass. 5) DxeCapsuleLib: Boot mode check is removed. Capsule should be populated to system table even boot mode is not BIOS_UPDATE. 5) FmAuthenticationLib: Add zero ImageSize check. 6) FmAuthenticationLib: Remove Authentication Library Registration. Each FMP Producer needs to carry its own auth algoritms(s). Now we have FmpAuthenticationLibPkcs7 and FmpAuthenticationLibRsa2048Sha256. No registration is needed. 7) FmAuthenticationLib: Move MonotonicCount handling after Payload We confirmed with USWG to process MonotonicCount after PayLoad. ==Below is V2 description== The V2 series patch incorporated the feedback for V1. There are 3 major updates. 1) BDS is update to display a warning message if TEST key is used to sign recovery image or capsule image. So a production BIOS should always use its own production singing key for the capsule image generation. A production BIOS should never use test key. 2) IniParsingLib is enhanced to do more sanity check for invalid input. The detail data format is added in IniParsingLib.h header file. If there is any vialation, the OpenInitFile() API will return failure. 3) The *Bios* keyword is renamed to *SystemFirmware* in any header file or c file data structure definition. The rest is minor update, such as add help info, clean up debug message, coding style. ==Below is V1 description== This series patch provides sample on how to do signed capsule update and recovery in EDKII. This series patch is also checked into git@github.com:jyao1/edk2.git. The feature includes: 1) Define EDKII signed system BIOS capsule format. 2) Provide EDKII signed system BIOS update sample. 3) Provide EDKII signed recovery sample. 4) Provide Microcode update sample for X86 system. 5) Update Quark to use new capsule/recovery solution. 6) Update Vlv2(MinnowMax) to use new capsule/recovery solution. The signed capsule/recovery solution is in MdeModulePkg. The capsule in IntelFrameworkModulePkg is deprecated. The Microcode update solution is in UefiCpuPkg. Cc: Feng Tian Cc: Star Zeng Cc: Michael D Kinney Cc: Liming Gao Cc: Chao Zhang Cc: Jeff Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Jiewen Yao (10): Vlv2TbltDevicePkg/dec: Add test key file guid. Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add instance for capsule update. Vlv2TbltDevicePkg/SystemFirmwareDescriptor: Add Descriptor for capsule update. Vlv2TbltDevicePkg/SystemFirmwareUpdateConfig: Add capsule config file. Vlv2TbltDevicePkg/FlashDeviceLib: Add DXE flash device lib. Vlv2TbltDevicePkg/PlatformBootManager: Add capsule/recovery handling. Vlv2TbltDevicePkg/dsc/fdf: Add capsule/recovery support. Vlv2TbltDevicePkg/dsc/fdf: add capsule generation DSC/FDF. Vlv2TbltDevicePkg/bat: add capsule generation in bat. Vlv2TbltDevicePkg/Build: Add capsule/recovery in help info. Vlv2TbltDevicePkg/Build_IFWI.bat | 5 + Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c | 190 ++++++++++++++++++++ Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf | 48 +++++ Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc | 89 +++++++++ Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf | 46 +++++ Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c | 66 +++++++ Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini | 72 ++++++++ Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfigGcc.ini | 72 ++++++++ Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLib.c | 156 +--------------- Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLib.inf | 8 +- Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLibDxe.c | 62 +++++++ Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLibDxe.inf | 49 +++++ Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLibDxeRuntimeSmm.c | 188 +++++++++++++++++++ Vlv2TbltDevicePkg/Library/FlashDeviceLib/SpiChipDefinitions.h | 5 +- Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c | 181 +++++++++++++------ Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf | 8 + Vlv2TbltDevicePkg/PlatformCapsule.dsc | 44 +++++ Vlv2TbltDevicePkg/PlatformCapsule.fdf | 81 +++++++++ Vlv2TbltDevicePkg/PlatformCapsuleGcc.fdf | 81 +++++++++ Vlv2TbltDevicePkg/PlatformPkg.dec | 3 + Vlv2TbltDevicePkg/PlatformPkg.fdf | 146 ++++++++------- Vlv2TbltDevicePkg/PlatformPkgConfig.dsc | 3 +- Vlv2TbltDevicePkg/PlatformPkgGcc.fdf | 146 ++++++++------- Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 82 ++++++++- Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 82 ++++++++- Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 82 ++++++++- Vlv2TbltDevicePkg/bld_vlv.bat | 9 +- 27 files changed, 1656 insertions(+), 348 deletions(-) create mode 100644 Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c create mode 100644 Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf create mode 100644 Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc create mode 100644 Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf create mode 100644 Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c create mode 100644 Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini create mode 100644 Vlv2TbltDevicePkg/Feature/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfigGcc.ini create mode 100644 Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLibDxe.c create mode 100644 Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLibDxe.inf create mode 100644 Vlv2TbltDevicePkg/Library/FlashDeviceLib/FlashDeviceLibDxeRuntimeSmm.c create mode 100644 Vlv2TbltDevicePkg/PlatformCapsule.dsc create mode 100644 Vlv2TbltDevicePkg/PlatformCapsule.fdf create mode 100644 Vlv2TbltDevicePkg/PlatformCapsuleGcc.fdf -- 2.7.4.windows.1