Commit Graph

335 Commits

Author SHA1 Message Date
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
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 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
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 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
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
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
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
Raghava Gudla 0e6cda520d Add support for getting csme boot time perf data
This patch added support to get csme boot time performance
data and display it in perf command and also before booting
to linux.

Introduced a board config option BOOT_PERFORMANCE_MASK to control
PcdBootPerformanceMask, BIT 2 now enables printing CSME boot
performance data.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2022-05-11 09:02:52 -07:00
Stanley Chang e9ee58d8ce Add USB command timeout control
A USB disk behind a hub may take longer time to respond command.
Prior to the patch, a magic 2000 ms is set. This patch introduces
a python control (USB_CMD_TIMEOUT) for customizing the timeout if
need. The patch also extends the default timeout to 4196 ms.

This patch does not impact booting time when a platform boots with
a good-conditioning usb disk, because the timeout only takes effect
when a disk does not respond to a USB inquiry for a long time.

Verified: Ehl RVP

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2022-04-12 08:42:07 -07:00
Maurice Ma fd6c9dedf3 Add FS load Shell command
This patch adds "fs load" command to SBL shell so that it can be
used to load a file from boot media into memory. It also supports
loading file at specified memory address.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-03-03 08:23:00 -08:00
Maurice Ma b0269b62d0 Enhance SerialPortLib to handle debug output during PCI enumeration
If there is DEBUG output during PCI enumeration, it could cause SBL
hang due to invalid PCI bar resource. In this case, SBL will force
to return 0 for any serial port register read. And it might cause
dead loop because of LSR_TXRDY bit polling in SerialPortWrite().
To avoid this potential dead loop, it is required to set LSR_TXRDY
bit for LSR_OFFSET register read if the PCI resource is invalid.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-02-28 10:57:26 -08:00
Maurice Ma 76afeb000d Fix incorrect lspci behavior for multi-function PCI device
According to PCI spec, it is required to check the multi-function
support in PCI configuration header type before scanning next PCI
function. Current SBL does not follow this, and it caused duplicated
PCI devices listed in Shell command "lspci".  This patch fixed
this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-02-28 10:55:16 -08:00
Maurice Ma 527e787477 Add LZ4 compress support
This patch extended the LZ4 library to support both compression and
decompression. It is useful for SBL to support runtime compression
in order to reduce data size. It is in sync with the LZ4 1.7.4 used
in the BaseTools.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-02-08 06:38:59 -08:00
Ong Kok Tong 2474323aa0 [Common] Fix CSME update build issue
There is unresolved external symbol build issue with
BUILD_CSME_UPDATE_DRIVER enabled in BoardConfig.
By adding the BootloaderCommonLib in BootloaderDebugLib
inf file will address this issue.

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2022-01-05 12:01:43 -08:00
Maurice Ma e3cc5cacac Update LZMA to match EDK2 LZMA SDK 19
This patch updated LZMA to LZMA SDK 19.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-12-13 14:08:25 -08:00
Maurice Ma 5b5edd2168 Fix EDK2 rebasing caused AzurePipeline build issue
This patch fixed several build issue reported by Azure Pipeline.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-12-13 14:08:25 -08:00
Mike Crowe 990e3e81e6 Use LF line endings in the repository
Convert the line endings stored for all text files in the repository to
LF. The majority previously used DOS-style CRLF line endings. Add a
.gitattributes file to enforce this and treat certain extensions as
never being text files.

Update PatchCheck.py to insist on LF line endings rather than CRLF.
However, its other checks fail on this commit due to lots of
pre-existing complaints that it only notices because the line endings
have changed.

Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch
needs to be treated as binary since it contains a mixture of line
endings.

This change has implications depending on the client platform you are
using the repository from:

* Windows

The usual configuration for Git on Windows means that text files will
be checked out to the work tree with DOS-style CRLF line endings. If
that's not the case then you can configure Git to do so for the entire
machine with:

 git config --global core.autocrlf true

or for just the repository with:

 git config core.autocrlf true

Line endings will be normalised to LF when they are committed to the
repository. If you commit a text file with only LF line endings then it
will be converted to CRLF line endings in your work tree.

* Linux, MacOS and other Unices

The usual configuration for Git on such platforms is to check files out
of the repository with LF line endings. This is probably the right thing
for you. In the unlikely even that you are using Git on Unix but editing
or compiling on Windows for some reason then you may need to tweak your
configuration to force the use of CRLF line endings as described above.

* General

For more information see
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings .

Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400
Signed-off-by: Mike Crowe <mac@mcrowe.com>
2021-11-10 12:46:42 -08:00
Maurice Ma acfe51f382 Sync up MTRR for MP before boot
SBL might change MTRR to enable framebuffer cache. Current code
only handles BSP MTRR programming, and it is necessary to sync
up the MTRR programming for all APs as well. This patch added
a function to sync up MTRRs for all APs.

Please note, this MTRR sync up is a simplified version for SBL
case since SBL will only add new MTRRs for GFX framebuffer.
To do a full generic MTRRs sync up, it is required to flush cache,
reload TLB, etc. And it will come with some performance impacts.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-11-05 11:09:16 -07:00
Maurice Ma f4a184ef35 Enhance Ext2 filesystem library
For EXT2 filesystem revision 0, there are some fixed fields in the
super block structure according to the documentation. The code should
always use those fixed values for safe regardless of the value inside
the image.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-11-05 07:27:13 -07:00
Maurice Ma de621184e8 Adjust debug message in USB libraries
This patch adjusted the following debug message for USB libraries:
  - For SBL, since mutli-TT is not utilized, it should not be
    classified as error message. It is changed to be DEBUG_INFO now.
  - Added DeInit debug print for USB so that it tells the USB
    resources are de-allocated.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-26 14:19:14 -07:00
Maurice Ma dfed4f59bc Add print for bootable USB device name
When multiple USB mass storage devices are connected to the
target, it is not clear to the end user which one is selected
for boot. This patch added code to print the USB mass storage
device manufacturer and product name string. In this way, it
is easier for the end user to identify specific USB device.

It can also be used to determine the HwPart field for USB boot
option. HwPart for USB boot option is mapped to the USB mass
storage device index detected on the platform. BTW, to allow
boot from multiple USB mass storage devices, the optoin
ENABLE_MULTI_USB_BOOT_DEV needs to be enabled. So this patch
enabled ENABLE_MULTI_USB_BOOT_DEV by default.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-26 12:11:51 -07:00
Maurice Ma b490824397 Append ACPI rsdp parameter only for old Linux boot protocol
Current SBL will always append "acpi_rsdp=" as part of the command
line for Linux boot. However, since acpi_rsdp_addr was added in
boot parameter for Linux boot protocol 2.14 and later, it is only
required to do this for old boot protocol. This patch implemented
this.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-21 10:14:30 -07:00