Commit Graph

419 Commits

Author SHA1 Message Date
Sean McGinn f9d614c09f Move MB/ACPI macros to BootloaderCommonLib
Move macros to BootloaderCommonLib as they
are now consumed by both SBL stages and payload

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-05-04 13:25:07 -07:00
sean-m-mcginn 598f12347f
[ADL] Additional TPM-related cleanup (#1881)
Update copyright years
Initialize pointers to NULL
Check pointers for NULL before de-reference
Standardize debug logs

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-04-26 11:39:22 -07:00
sean-m-mcginn ba9da25442
[ADL] Update TPM event logging to match BIOS (#1859)
* [ADL] Update TPM event logging to match BIOS

If measured boot disabled via BtG profile but enabled via SBL
config flag, skip logging startup locality TPM event

If measured boot enabled via BtG profile or SBL config flag, log
CRTM version TPM event

Set startup locality based off startup locality on ACM policy status

Log detail and authority PCR events based off SCTRM status on ACM
policy status

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>

* Initialize startup locality and remove measured boot check

Initialize startup locality variable used in setting up event
log

Remove measured boot check as it is not seen in BIOS and it
occurs at higher level

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>

---------

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-04-20 16:37:18 -07:00
Aakash Panwar 834a01351f feat: Added support to set ref_clock frequency for UFS device
This Patch add the support to set UFS clock frequency.
- Added the function to read or write specified attribute of a UFS device
- Shifted function which switch the link power mode and gear after ref_clock setting
  because if an unsuported clock frequency being set, it won't be able to overwrite
  the corrupted UFS attributes.

Signed-off-by: Aakash Panwar <aakash.panwar@intel.com>
2023-04-13 20:35:20 -07:00
Ionut Nechita a7b6f8adb4
fix: variable is not named correctly (#1865)
Description:
 - GetVaraibelStoreBase to GetVariableStoreBase

Change-Id: I79ddb319d733ebb53131f0df6143bd18bb9aaee7

Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
2023-04-11 09:29:10 -07:00
Sean McGinn 04e872d77b Remove unnecessary continue statement in TPM library
Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-03-28 15:55:01 -07:00
Sean McGinn b8830af723 Enhance TPM2 Logs
Show error message whenever an unsupported PCR bank is used

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-03-28 15:55:01 -07:00
Sean McGinn e207c062d9 Change SecureBootPolicy TPM Event Type
Whenever EV_EFI_VARIABLE_DRIVER_CONFIG is specified as TPM event type,
the data that accompanies it is expected to be an UEFI variable in the
appropriate format

This change fixes an erroneously typed TPM event so that the tpm2_eventlog
command works in Linux

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-03-28 15:55:01 -07:00
Atharva Lele 1c807e51fa
Fix OsLoader handling of non-container images and remove PcdContainerBootEnabled (#1843)
* OsLoader: set default status to EFI_UNSUPPORTED when parsing a boot image

This was set to EFI_SUCCESS which resulted in ParseBootImages() returning
EFI_SUCCESS even if the boot image was not a container or a component.

Thus, the boot would continue and fail at a later stage due to the
LoadedImage structure not being populated correctly.

Setting it to EFI_UNSUPPORTED will result in ParseBootImages() returning
EFI_UNSUPPORTED if a non-supported boot image is provided and OsLoader
will attempt to boot the next entry in the boot options list.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* Remove PcdContainerBootEnabled PCD

SBL requires boot images to be packaged as a container or a component

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

---------

Signed-off-by: Atharva Lele <atharva.lele@intel.com>
2023-03-10 14:14:13 -08:00
Bejean Mosher 2c81ff2e71 fix: [RPL-P] Build error when ENABLE_SOURCE_DEBUG=1.
On platforms where only serial console input is enabled, enabling
source debug will lead to an infinite loop in ConsoleRead(). Newer
compilers detect this and generate a build error.

Signed-off-by: Bejean Mosher <bejean.mosher@intel.com>
2023-03-07 14:16:13 -07:00
Sean McGinn f3d515cd32 Cast FW blob pointers to UINTN then UINT64
Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-03-06 10:48:47 -07:00
Sean McGinn 0c4dca2a82 Log the correct TPM2 event type for stage hashing
In BIOS, all stage measurements are of type
EV_EFI_PLATFORM_FIRMWARE_BLOB. This change aligns SBL
with BIOS.

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-03-06 10:48:47 -07:00
Bruno Achauer 3f0beb9fa3
Ensure that ELF images are loaded at their preferred address (#1833)
Currently, loading an ELF image will relocate the image (to its
preferred load address) only if there is at least one ELF segment
that is not completely contained in the file loaded (i.e. the memory
segment size is larger than the size inside the file. This behavior
is generally triggered by the segment that contains the .bss section).

Consequently, images that contain initialized data only (e.g. QNX IFS
files) don't get relocated, and will usually crash when jumping to the
image entry point.

This change checks whether the ELF image is already loaded at the
preferred address, and forces image relocation if not.

Signed-off-by: Bruno Achauer <bruno.achauer@intel.com>
2023-02-21 08:40:13 -08:00
Arghya Biswas 224e75fbf6
fix: enumerate all USB instances to search devices (#1818)
instance 0 was hardcoded, so not able to read the devices from other
instances. Now read the instances number from the device table and
enumerate all USB instances one by one.

Signed-off-by: Biswas Arghya <arghya.biswas@intel.com>
2023-02-03 10:54:33 -08:00
Atharva Lele 82769186dc
OsLoader - Container Type Cleanup (#1816)
* Add Name field to IMAGE_DATA structure

Add a name field to the structure to be used by container parsing
functions. It will be useful to determine the name of the container
component when dealing with special files like ACPI blobs.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* OsLoader: save the name of the component when creating array of components

Saving the name will help us deal with special files like ACPI blobs
more easily

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* OsLoader: streamline container types

Update container functionality to streamline container types:
- Normal: PE32, FV, ELF images. Supports ACPI table update.
- Classic (Linux): Used for a traditional Linux boot setup.
  (cmdline, bzImage, initrd). Additionally supports ACPI table update.
- Multiboot: Used for Multiboot/Multiboot-2 compliant ELF images.
  Supports ACPI table update.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* Rename CLASSIC container to CLASSIC_LINUX

This type of container is to be used for a traditional Linux
boot setup consisting of a cmdline, bzImage, initrd(optional),
and other binary blobs or ACPI blobs.

Rename it to CLASSIC_LINUX to make the purpose of the container
clearer.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* OsLoader: copy Linux ExtraBlobs to reserved mem and add to cmdline

Until now, SBL loaded the Extra blobs with the Linux kernel
into memory. However, there was no way for the OS to know where
these blobs resided in memory. The blobs were also loaded in
memory that was not marked as reserved.

This patch copies the blobs to reserved memory and adds the
blob addresses into an expected placeholder in the Linux cmdline.
If the placeholder is not present, nothing related to that blob
will be added to the cmdline.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

---------

Signed-off-by: Atharva Lele <atharva.lele@intel.com>
2023-02-02 09:19:31 -08:00
Atharva Lele 622ad48cff
ShellLib/CmdMmap: fix MemTypeToStr() strings (#1820)
0x03 is ACPI Reclaim Memory
0x04 is ACPI NVS Memory

As defined in BootloaderCommonPkg/Include/Guid/MemoryMapInfoGuid.h
and ACPI Specification Chapter 15.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>
2023-02-01 18:31:41 -08:00
Guo Dong aee7833455
Add description for performance data (#1783)
When running "perf" command from OsLoader shell, it would
print the performance data but it is difficult to know what
they are mean. The patch adds the description to performance
data.

Signed-off-by: Guo Dong <guo.dong@intel.com>

Signed-off-by: Guo Dong <guo.dong@intel.com>
2022-12-14 07:27:53 -05:00
Atharva Lele bc7505ca9d
OsLoader Cleanup (IAS) (#1778)
* OsLoader: remove references to IAS images

Change IAS references to 'Boot Image' since IAS support is deprecated.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* ContainerLib: add container type defines

Add comments to indicate the use cases of each container type

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* OsLoader: Use container defines instead of IAS defines

This commit also changes some comments referencing IAS instead of a container.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* OsLoader: remove ParseIasImage() since it is deprecated

Remove deprecated functionality and header include.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>
Signed-off-by: Chirag Vijay Kolhe <chirag.vijay.kolhe@intel.com>

* OsLoader: add check for normal container type and fix comment

NORMAL type of container is usually used with FV, regular ELF images, etc.
This commit adds the check for it and removes the "non valid use case" comment.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* GenContainer: add comments explaining container types

Add comments explaining use cases of each container type

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* OsLoader: add a check for number of files in classic container

Classic Container needs to have the boot file in it. According
to the fixed order, this is the second file in the container.
Add a check to make sure there are atleast 2 files before attempting
boot.

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

* QEMU: replace IAS references in boot options with container

Clean up IAS reference from boot options list

Signed-off-by: Atharva Lele <atharva.lele@intel.com>

Signed-off-by: Atharva Lele <atharva.lele@intel.com>
Signed-off-by: Chirag Vijay Kolhe <chirag.vijay.kolhe@intel.com>
2022-12-13 11:06:45 -08:00
Guo Dong e5fb055c0c Update universal payload ID
Update the universal payload ID to align with
the universal payload specification.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2022-12-08 14:42:56 -07:00
Stanley Chang a6264ae2c4 [ExtLib] fix the list of symbolic links
This patch fixes 2 issues related to symbolic links:

1. when "fs ls" a directory, symbolic links are not shown.

  It is because Ext2fsLs() only shows regular files and directories.

2. when "fs ls <symbolic_link>" the output is incorrect.

  It is because File->FileNamePtr points to a local variable,
  "NameBuf" in Ext2fsOpen(), if the file is a symbolic link

This patch replaces File->FileNamePtr with FileNameBuf.
It slightly increases Ext2fsLs/Ext2fsOpen/SearchDirectory time,
because of the use of strcpy and strcat.

Test method:

1. create a regular file, "a", in directory "x"
2. create a symbolic link file, "b", pointing to "a".
3. under the shell of OSLoader,
   "fs ls x"
     - expected result: a, b (symbolic link)
   "fs ls x/a"
     - expected result: a and its file size is shown
   "fs ls x/b"
     - expected result: b -> a, and the file size of a is shown

Verify: TGL-UP3 RVP

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2022-12-05 11:35:37 -07:00
Stanley Chang aca5762eec [ExtLib] fix the failure of loading files in Ext4 partition
This patch fixes an issue that SBL fails to load a file in Ext4 partition,
when
  1. the ext4 partition uses Extent
  2. the inode's first extent block is an internal node
  3. the node has only one entry (i.e., eh_entries = 1)
Under the above conditions, the data block may point to the child of
first ei_block when accessing the data within the range of child node.

Test method:
  1. Install Ubuntu 20.04.5 LTS/(min install) in an eMMC disk

     Note: this issue is only reproducible when loading a file
     satisfying all conditions mentioned above (i.e., eh_entries = 1).

     So far, the /boot/initrd.img after installing Ubuntu in an eMMC
     (where part table: 500MB(FAT), 20GB (EXT4), 4GB (Swap)) satisfies
     the conditions. However, for some reasons, when using USB SATA disk,
     it will not generate a /boot/initr.rd meeting the conditions.

  2. Boot to OSLoader
  3. "fs init 2:0 0 1" the eMMC disk (assume the HW:SW-part is 0 1)
  4. "fs load boot/initrd.img"

Expected result:
  1. With this patch: successfully load the file.
  2. Without this patch: ASSERT [OsLoader] ..

Verified: EHL CRB

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2022-11-29 14:55:30 -07:00
Bruno Achauer bf8b2b3618 OsLoader: Add Multiboot-2 support
- Add (partial) multiboot-2 support as specified in
  https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html
- header file imported (and adjusted to SBL OsLoader) from
  https://github.com/NetBSD/src/blob/trunk/sys/arch/i386/include/multiboot2.h

Also bump APL PAYLOAD_SIZE, ADL OS_LOADER_FD_SIZE to account for increased payload size

Signed-off-by: Bruno Achauer <bruno.achauer@intel.com>
2022-11-29 14:51:45 -07:00
Guo Dong 80e3bc8293
Remove unnecessary check in partition library (#1754)
In the Ubuntu ISO image, it has 0xF8 partition entries.
The partition library could not work as expected since
it expects the partition entries are no more than 128.

Potentially it could have more partition entries, so just
remove the check.

Signed-off-by: Guo Dong <guo.dong@intel.com>

Signed-off-by: Guo Dong <guo.dong@intel.com>
2022-11-15 15:57:59 -05:00
Stanley Chang b6f150c0ea [ExtLib] fix invalid memory access to support large EXT fs (#1739)
This patch fixes an invalid memory access issue caused by
the fs->Ext2FsGDSize is smaller than the size of EXT2GD.

The EXT2GD is a 64-byte structure, but fs->Ext2FsGDSize is not always 32.

Before this patch, Ext2fsOpen() allocates a smaller memory than expected:
  i.e., Ext2FsGrpDes = AllocatePool (Ext2FsGDSize * Ext2FsNumCylinder);
When ReadGDBlock() loads data (E2FS_CGLOAD) into fs->Ext2FsGrpDes,
it possibly accesses mem out of the allocated Ext2FsGrpDes space.

This patch loads each element into fs->Ext2FsGrpDes.

This patch also
1. prints informative messages when OS Loader fails to load Linux files.
2. increase EHL's PLD_HEAP_SIZE (since the size of initrd in Ubuntu LiveCD
   is over 130MB)

Test method:
1. create a huge EXT FS (says, at least 36GB)
2. In the fs, place the following file/dir:
    a: non-empty file
    b: dir
    b/c: non-empty file
3. boot with SBL OS Loader and enter Shell.
4. execute "fs init <...skip...>" to init the fs
5. execute "fs ls"
6. execute "fs ls b/c"
7. execute "fs load a"
8. execute "fs load b/c"

Verify:
1. 10MB/10GB/100GB/200GB EXT2/EXT3/EXT4 FS
2. EHL CRB

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2022-11-14 08:33:16 -07:00
Kalp Parikh c68f61707f [ADL/RPL] Update default boot options
Change boot flag to 0 to enable booting
yocto/ubuntu

TEST:Boot to yocto on ADL

Signed-off-by: Kalp Parikh <kalp.parikh@intel.com>
2022-11-09 13:54:13 -07:00
Gavin Xue 9a39dd8d5c [EHL] Fix SD card enumeration failure issue
Similar fix in EHL BIOS reference code. Verified
on EHL CRB/RVP1/RVP4 and OEM customer board.

Signed-off-by: Gavin Xue <gavin.xue@intel.com>
2022-11-04 15:02:41 -07:00
Guo Dong 505209d9c3 Enhance multiboot support
Currently SBL would return when preferred graphics mode is set
in the multiboot image. This patch would continue boot and print
the preferred graphics mode information.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2022-10-24 10:52:03 -07:00
Sean McGinn 0a19cd4842 Allow multiple redundant SBL components to be updated in the same session
Currently, only a single redundant SBL component, the configuration data
component, is allowed per update session. However, with support added for
ACM and uCode component updates, the user might desire to update multiple
redundant SBL components in the same session. This change allows this to
happen.

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-10-24 10:51:36 -07:00
Sean McGinn ceea7d1d03 Rename PCD for SBL component corruption command
Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-10-17 11:59:04 -07:00
Sean McGinn 44b332d609 Add more examples for corruptcomp tool
Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-10-17 11:59:04 -07:00
Sean McGinn b82dcd344f Add PCD for enablement of corruptcomp tool
Adds build-time PCD that hides corruptcomp
tool by default
Renames corruptcomponent to corruptcomp
Enhances error checking/logs

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-10-17 11:59:04 -07:00
Sean McGinn f7c6cc599e Create OS loader shell tool for SBL component corruption
Create a tool that corrupts SBL components so that
the SBL resiliency feature can more easily be tested
and demonstrated

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-10-17 11:59:04 -07:00
Leon Theunissen 192e8a568a Interrupt packet length is maximum 8, not exclusively 8
Accomodate USB interrupt transfers that require less than 8 bytes per packet.

Signed-off-by: Leon Theunissen <leon.theunissen@etion.co.za>
2022-10-17 11:55:10 -07:00
Leon Theunissen 861f587b63 USB fix descriptor parsing
While iterating over a USB descriptor in GetExpectedDescriptor(),
the "Len" variable always uses the 1st byte in the buffer,
This is only true for the 1st iteration, thereafter the variable should
advance as the descriptor advances.

Signed-off-by: Leon Theunissen <leon.theunissen@etion.co.za>
2022-10-17 11:55:10 -07:00
bejeanmo 15f365d774
fix: [ADL] TCC was never getting enabled via the board config option. (#1715)
PcdTccEnabled was declared as a FeaturePcd which evaluates to a code symbol
and can't be used in a #if. From the preprocessor perspective it is always
undefined. Changed this pcd to a FixedPcd instead.

Signed-off-by: Bejean Mosher <bejean.mosher@intel.com>

Signed-off-by: Bejean Mosher <bejean.mosher@intel.com>
2022-10-10 16:42:22 -04:00
Subash Lakkimsetti 0eceb0cfe7
Update Universal payload hob for secure boot. (#1695)
Universal paayload hobs are updated for secure boot
and measured boot. Event logs Hobs are created to consume
by TCG2Dxe in uefi payload.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2022-10-06 08:48:06 -07:00
ckolhe 0ad56ef2dd
Update mm shell command description (#1700)
Updated the help section of mm shell command.

Signed-off-by: Chirag Vijay Kolhe <chirag.vijay.kolhe@intel.com>
Signed-off-by: Sachin Kamat <sachin.kamat@intel.com>

Signed-off-by: Chirag Vijay Kolhe <chirag.vijay.kolhe@intel.com>
Signed-off-by: Sachin Kamat <sachin.kamat@intel.com>
2022-10-03 09:43:09 -04:00
Karuppa-samy 90406ffbac
[LiteVariable] Added Data NULL conditional check in InternalGetVariable() (#1699)
Argument DataLen of function InternalGetVariable() inside Reclaim()
function is not initialized. This uninitialized value is assigned
to another variable and compared, resulting in EFI_BUFFER_TOO_SMALL
error when Data is NULL. Hence added Data NULL conditional check with
DataLen to overcome EFI_BUFFER_TOO_SMALL error when Data is NULL.

Signed-off-by: M Karuppasamy <karuppasamy.m@intel.com>
Signed-off-by: Sachin Kamat <sachin.kamat@intel.com>

Signed-off-by: M Karuppasamy <karuppasamy.m@intel.com>
Signed-off-by: Sachin Kamat <sachin.kamat@intel.com>
2022-09-30 09:06:47 -04:00
Sean McGinn 3a6aa45abb Create FirmwareUpdateStatus header and FirmwareResiliencyLib
library

Migrates FW resiliency APIs of Stage1B.c to
FirmwareResiliencyLib
Migrates FW update status types from FirmwareUpdateLib.h and
BootloaderCommonLib.h to FirmwareUpdateStatus.h

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-09-06 09:38:52 -07:00
Sean McGinn b7e7b7b93b Cover IBB corruption in SBL resiliency implementation
If TS bit flipped and it does not match FWU state,
assume ACM detected corruption in SG1A or SG1B and
recover broken BP

Add WDT trigger for recovery

Add ADL-specific WDT trigger for TS

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-09-06 09:38:52 -07:00
Sean McGinn 1e677e5a4d Update full FW update status structure on recovery
This change makes sure that, during each recovery,
the FW update status structure is cleared and
repopulated

Without this change, in the event that there is
a full recovery and then an interrupted recovery,
the interrupted recovery is unable to resume

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-08-17 11:40:43 -07:00
Sean McGinn eeb05a8a5e Add SBL resiliency common code
This change adds SBL resiliency-related code
to common SG1A, SG1B, SG02, and FWU code

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-08-17 11:40:43 -07:00
Sean McGinn 1da1768bc1 Create TopSwapLib for SBL resiliency
Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2022-08-07 17:21:33 -07:00
Biswas Arghya 414e39f4e5 Add shell command to list USB devices
New shell command 'usbdev' added to enumerate USB bus and list down
all the USB devices that are found on the bus.

Signed-off-by: Biswas Arghya <arghya.biswas@intel.com>
Signed-off-by: Sachin Kamat <sachin.kamat@intel.com>
2022-07-31 20:13:23 -07:00
Aakash Panwar 3eba958a4c Enable UFS support for common Intel Platforms.
This Patch adds the support for UFS(Universal Flash Storage)
as a boot media.
- Added support to Enable all Lun's for UFS
- Added support to change power modes in UFS
- Enable Bus master for proper PCI addressing

Signed-off-by: Aakash Panwar <aakash.panwar@intel.com>
Signed-off-by: Sachin Kamat <sachin.kamat@intel.com>
Signed-off-by: Chirag Vijay Kolhe <chirag.vijay.kolhe@intel.com>
Signed-off-by: Aakash Panwar <aakash.panwar@intel.com>
2022-07-29 11:13:30 -07:00
Vincent Chen 5536008324 FWU: refine the reboot timing for different payload combinations
- If BIOS update is followed by any payload,
  reboot to ensure the update is completed.
- Before processing CMDI payload, ensure CSME update has
  taken effect to prevent {OEMKEYREVOCATION} command failure.

Signed-off-by: Vincent Chen <vincent.chen@intel.com>
2022-07-29 09:01:57 -07:00
Stanley Chang f61bb6c116 FWU: support OEM key revocation together with BIOS/CSME update
The steps of OEM key revocation are:
  1. Replace OEM KM (signed with key2) by updating CSME
  2. Replace BIOS region (signed with key2)
  3. Reboot with new BIOS region (to make key1 inactive)
  4. Revoke key1

Before this patch, it requires 2 firmware updates and 2 capsules for
step 1~2 and step 4 respectively. The patch combines them into a single
update/capsule.

To implement the feature, the patch:
  1. Double max # of payloads to allow CSME/CSMD/BIOS/CMDI update
     in one capsule image.
  2. Prevent from failing update of a critical component.
     e.g., if step 1(CSME) fails, step 2(BIOS) should be skipped

Verified cases:

 Case 1: Capsule having CSMD/CSMD/BIOS/CMDI.
         Expectation: successful

    $ python BootloaderCorePkg/Tools/GenCapsuleFirmware.py \
      -p CSME FWUpdate.bin \
      -p CSMD CsmeUpdateDriver.efi \
      -p BIOS new_BiosRegion.bin \
      -p CMDI cmdi.txt \
      ...(skip)

 Case 2: Capsule having CSME/BIOS/CMDI but no CSMD.
         Expectation: no update

 Case 3: Inject fault flow (no partition switch after first flash),
         Capsule having CSME/CSMD/BIOS/CMDI.
         Expectation: no CMDI update

Verification: EHL CRB

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2022-07-19 15:31:23 -07:00
Stanley Chang 03325fabfe FWU: fix infinite fwu caused by a/b update failure
In A/B update, after FWU updates partition B, it switches to and boots
with partition B. If boot fails because of anything wrong with the update,
CSME will switch back to booting with partition A.

Before this patch, unfortunately, the EnforceFwUpdatePolicy will
immediately try to boot again with partition B, which results in
an infinite FWU loop:

   try B -> failed -> boot A -> try B -> failed ...
   (Same for initial with "try A -> failed" scheme.)

This patch adds a retry count field in FW_UPDATE_STATUS.
Using retry count field to determine if retry also reaches a
max times. If so, stop the loop.

To simplify the implementation for SPI, the retry count field is
implemented as continuous 1 (ONE) of a bit array.

Test scenarios:
  Case 1. update bios region. Expectation: PASS
  Case 2. update non-bios region. Expectation: PASS
  Case 3. Inject fault flow (no partition switch after first flash),
          and update bios region. Expectation: Stop retry after few times.

Verify: EHL RVP

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2022-07-15 14:50:47 -07:00
Gavin Xue d811bebb3c Fix build error caused by non-ASCII characters
If customer uses a non-English version (e.g. Chinese)
Windows OS, the build error will happen.

Signed-off-by: Gavin Xue <gavin.xue@intel.com>
2022-07-13 16:43:19 -07:00
Kalp Parikh 213cad7205
KW fix for unitialized buffer (#1594)
Signed-off-by: Kalp Parikh <kalp.parikh@intel.com>
2022-06-01 13:50:08 -07:00