Commit Graph

358 Commits

Author SHA1 Message Date
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
Subash Lakkimsetti 7a3bab7fa3
[TGL][EHL] Fix regression for Flash descriptor lock (#1425)
Add BootMediaWriteByType and use for flash descriptor
update.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2021-12-01 22:25:11 -07: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
Guo Dong 5d0195f962 Build SMM HOBs for universal payload
UEFI payload built from open sourced EDK2 supports SMM variable now.
So build the required HOBs to work with EDK2.
This patch just changed the common SBL code, so there is no platform
change required.
This patch also added a PCD PcdBuildSmmHobs for old SMM HOBs and new
SMM HOBs. Late old SMM HOBs might be dropped.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-11-04 11:50:00 -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
Maurice Ma 21917377c8 Change GetSerialPortBase() API to return 64bit address
When UART bar is alloaced to 64 bit address, the current SBL API
GetSerialPortBase() only returns the lower 32 bit address, which will
cause problem for UART access. This patch fixed this issue.

Please note the patch did not change the payload HOB interface for
UART info. That needs to be updated to 64bit base address too. But this
patch does not cover that.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-21 10:09:20 -07:00
Ong Kok Tong f70b13bf62 [Common] Filename prompt issue fix in OSL shell
When user disabled PRE_OS in bootflag with boot->idx
command in OSL shell but shell still prompt user to
enter PREOS image file path, This is due to the system
check the existing boot option list instead of the
boot option that user currently updating.

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2021-10-20 06:01:50 -07:00
James Gutbub 46dc0363ab Resolve VS2015x86 compile issue
When trying to build tgl target with
VS2015x86 there is some error reported:

TimeStampLib.lib: error LNK2001: unresolved external symbol __allmul
FirmwareUpdate.dll : fatal error LNK1120: 1 unresolved externals

This patch resolves the issue by removing
the UINT8 casting.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-10-18 08:18:11 -07:00
Maurice Ma 7392f16005 Move paging table build from OsLoader to Stage2
Current SBL will build full address paging table supported by CPU
only at the beginning of the OsLoader. It is better to move it to
Stage2 so that all payloads can have the full range address support
in x64 mode. It also allows Stage2 platform code to access 64bit
PCI resource.  This patch addressed this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:17:30 -07:00
Maurice Ma 18ccc4115a Enhance GPT partition detection
Current SBL only looks into the primary GPT during partition detection.
If it is not valid, then MRB partition will be checked next. In some
case of the Ubuntu USB disk created, only the 2nd GPT is valid. SBL
should check both primary and secondary GPT table before moving to MBR
check. This patch added this fix.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:16:37 -07:00
Maurice Ma f453d57835 Clean up NVMe debug message
This patch cleaned up the NVMe library DEBUG message. Lots of the
DEBUG_INFO level were changed to DEBUG_VERBOSE to reduce normal
output.

It also removed the hardcoded device index 0 for NvmeReadBlocks,
NvmeWriteBlocks and NvmeGetMediaInfo APIs.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:15:30 -07:00
Maurice Ma 638679f87e Fix NVMe library media info
Current NVMe library reports hardcoded block size 512 and block num
512. It is incorrect. This patch fixed it.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:15:30 -07:00
Maurice Ma 2954034a06 Improve XHCI library timeout polling mechanism
Current XHCI library does a big loop to poll the status of a
USB command execution. In each loop it will delay 1us until
it completes or reachs the timeout. When the loop is very big,
the accumulated 1us delay together will be shifted far beyond
the original timeout requested. This is because of the inaccuracy
of the 1us delay provided by ACPI timer library. This patch
addressed this issue by checking the actual executed time rather
than looping with delay.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-14 11:05:29 -07:00
Maurice Ma 50e5c23594 Revert "Add cache flush on warm reset for SBL shell"
This reverts commit 24f5aa59b5.

There are cases that warm reset is requested before memory is
initialized. Doing WBINVD in this case can cause system hang.
A better approach is to let the caller to decide when to do
cache flush for a warm reset.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-13 14:58:35 -07:00
Maurice Ma 1f3de3399e Enable BIOS region update in single shot
Sometimes it is helpful if SBL can support firmware update from
SBL FW to UEFI FW, or update from incompatible SBL flash layout.
This will need SBL to write full BIOS region without using
redundant partition. To support this, a special capsule image
flag is added to indicate this special update. Please note, this
update might be very risky. This is only for development purpose.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-11 15:29:37 -07:00
Maurice Ma 24f5aa59b5 Add cache flush on warm reset for SBL shell
In some cases, the memory needs to keep consistent across a warm
reset. When warm reset is triggered, it might still have modified
cacheline that has not been flushed to memory yet. The patch added
WBINVD to flush cache before the warm reset.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-11 15:24:07 -07:00
James Gutbub 95482aa01a Resolve KW possible NULL refs in ElfLib
KW scan reported a couple errors regarding
Sec*Shdr value, need to check if they are
NULL before using these values.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-10-05 13:32:41 -07:00
Maurice Ma 8c85533285 Add accurate TSC frequency calculation support
Current SBL code uses MSR(0xce) to calculate the CPU TSC frequency.
However, it is not very accurate. A better way is to use CPUID to
calculate the TSC frequency. This patch added new API to get accurate
TSC frequency.  It also added APIs to allow conversion between time
and TSC ticks.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-04 13:16:51 -07:00
Maurice Ma 8d0b3467b5 [QEMU] Fix AUTO boot option index
On SBL, it can support boot option selection through QEMU command line
"-boot order" parameter. However, it does not work anymore. It was
because of the MAX_BOOT_OPTION_CFGDATA_ENTRY adjustment in other commit.
This patch decoupled internal boot option index with the CFGDATA boot
option index so that it does not have impacts on each other. With this
change, QEMU boot option can be altered through command line again.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-04 12:00:05 -07:00
Maurice Ma 9f31593b58 Add Universal Payload library support
Universal Payload uses ELF format. As a result, the ELF loading
library has been enhanced to handle more complicated cases. The
Universal Payload library added an abstract layer on top of
ELF lib to make it easer to use by SBL. OsLoader and Stage2 were
modified to work with the new library interfaces.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-04 11:59:55 -07:00
Maurice Ma 5c98b11ecd Add UniversalPayload header files
This patch added universal payload header files.  Thess files
were copied from EDK2 MdeModulePkg.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-30 18:19:13 -07:00
Maurice Ma 5507df44e5 Enhance 64bit to 32bit thunk code
In some cases the paging will be enabled after returning from the
thunked function. To ensure the paging table can be reloaded before
switching back to x64 mode, the paging needs to be in disabled
state. This patch ensures the CR0 bit31 paging bit is cleared.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-30 14:50:27 -07:00
Maurice Ma 2d3261bdc3 Add platform device type enum definitions
SBL defined SetDeviceAddr/GetDeviceAddr to abstract platform
device info. However, currently only boot media devices are
defined. It has cases that other platform device info is needed,
such as GFX device. This patch extended the concept to define
some other platform devices as an extenstion to
OS_BOOT_MEDIUM_TYPE. The enum values should not overlap with
the ones defined in OS_BOOT_MEDIUM_TYPE.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-30 10:59:20 -07:00
Ong Kok Tong 9aa615c01f [Common] Sync boot option print function
Synced the PrintBootOptions fucntions to print
Pre-OS and extra images.
Fixed bug -> if pre-os or extra images are not enabled
in boot flag and it still output in PrintBootOptions
function

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2021-09-28 09:21:23 -07:00
James Gutbub a6a0c317dd Resolve fs cmd KW issue
Currently the PLT_DEVICE_TABLE is limited
to only using OS_BOOT_MEDIUM_TYPE devices
but ideally should be capable of mapping
any system device into the table. For the
time being we will remove the OsBootDeviceGraphics
since it created some KW issue in the fs command.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-09-27 17:08:32 -07:00
Maurice Ma 4d83ea1126 Add BOCHS graphics init support
On Simics or QEMU, BOCHS graphics is used. This patch provides
library to initialize BOCHS graphics. It is useful when GFX
initiailzation is not provided by FSP. In this case, the native
code can be used to initialize graphics.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-23 09:15:13 -07:00
Maurice Ma 14166f2b37 Enforce FFS alignment in FvLib
When FV extended header exists, the first FFS pointer returned by
GetFirstFfsFileInFv() might not be 8-byte aligned. This patch
adjusted the pointer accordingly to ensure it is aligned per UEFI
spec.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-17 13:50:53 -07:00
James Gutbub 2bfdb8faac
Resolve KW issue in boot command (#1280)
Boot command may attempt to use an index which
exceeds the max image type. Check if the value
is larger than the max allowed value and return
if there is an error.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-08-31 14:12:08 -07:00
Ong Kok Tong f2b6d0e602 [COMMON] Fix Pre-OS and extra image bug in OSL shell
There is a bug when user use boot->idx command in OSL
shell to modify boot option which contained Pre-OS and extra images
(eg. POSC or RTCM etc.)

Current CmdBoot didnt cover for extra images in idx command.
This patch cover for extra images.

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2021-08-30 11:01:49 -07:00
Sai T 06acbc85a2 Fix UefiVarialbeLib KW issues
This patch addresses KW issues reported from UefiVarialbeLib.

Signed-off-by: Sai T <sai.kiran.talamudupula@intel.com>
2021-08-06 12:35:05 -07:00
stalamudupula d627d92c94
Fix UefiVarialbeLib KW issues (#1230)
This patch addresses KW issues reported from UefiVarialbeLib.

Signed-off-by: Sai T <stalamudupula@gmail.com>
2021-07-23 11:34:06 -07:00
stalamudupula ec20bf39e7
Fix security violation for IA32 build in VS2019 toolchain (#1225)
IA32 build from VS2019 toolchain has security violation
because Digest value from SHA512_384 is not matching the
value calculated and stored in hashstore during build.

Aligning the stack to 32-byte boundary during SHA_Update
fixes this error.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-07-15 09:21:10 -07:00
Vincent Chen de2761170e
add missing UsbBlockIoLib in UsbInitLib.inf (#1216)
Resolve link error when using UsbInitLib
UsbInitLib invokes UsbDeInitBot() which is defined in UsbBlockIoLib

Signed-off-by: Vincent Chen <vincent.chen@intel.com>
2021-07-06 09:18:58 -07:00
Maurice Ma d8c0177fe9 Added mailbox debug port support
This patch allows to use a mailbox register (DWORD) to support debug
port. If CCA debug is connected, it is possible to access certain
SOC register through BSSB. Then this register can be used for debug
console input/output.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-07-01 11:22:16 -07:00
Maurice Ma 163458e32d Add GPIO bit bang debug port library
This patch adds DebugPortLib as a platform extention lib to add new
debug port support. It also adds a generic GpioDebugPortLib to allow
GPIO bit bang to emulate UART TX pin.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-07-01 11:22:16 -07:00
CSHur c7b8d5a848 Fix Linux build issue when adding UefiVariableLib
When adding UefiVariableLib, there is a build issue in Linux.
Fix the build issue.

Signed-off-by: CSHur <cs.hur@intel.com>
2021-06-29 18:23:14 -07:00
CSHur 1db0acf9ba Fix UefiVariableLib code
When adding UefiVariableLib code, there is build issue.
Fix the build issue.

Signed-off-by: CSHur <cs.hur@intel.com>
2021-06-25 06:38:23 -07:00
Jan Schlosser 8f2af41f52 [IAS] Consider signature for size only if enabled
As per specification of the IAS-Image format
https://github.com/intel/iasimage/blob/master/docs/02_mcd.md
the signature and public key are optional.

As per specification of the header format
https://github.com/intel/iasimage/blob/master/docs/02_mcd.md#image-type

The 8th bit indicate if the signature is included, while the 9th bit
indicates whether the public key is included.

While the previous solution checked if public key is enabled, it did
not check if the signature is included, but rather assumed that it
is always included.

This will lead to a miss-calculation of the `IAS_IMAGE_END` and
`IAS_IMAGE_SIZE` which on the other hand will cause `IsIasImageValid()`
to fail, which will fail the loading of unsigned IAS-Images.

Signed-off-by: Jan Schlosser <jan.schlosser@outlook.com>
2021-06-25 06:37:29 -07:00
Ong Kok Tong b78cbcf128 [EHL] s0ix fix for Fusa sku
Enable s0ix only for Non-Fusa sku
Removed PcdPreOsCheckerEnabled PCD flag

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2021-06-22 06:26:34 -07:00
Guo Dong be9f726139 [EHL] Remove unused feature flag for PreOS checker
FEATURE_PRE_OS_CHECKER_BOOT is not used by any core or platform code.
So just remove it.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-06-10 13:31:16 -07:00
Vincent Chen 6275eb6eb7
Fix PCI address check in CsmeFwUpdate (#1165)
The PCI address consumed by CSME FW update library is in
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS format.
- when register offset is  < 0x100, it is :    bbddffrr
- when register offset is >= 0x100, it is : rrrbbddff00
Consider the two different cases in CsmePciReadBuffer()

Signed-off-by: Vincent Chen <vincent.chen@intel.com>
2021-05-25 13:40:57 -07:00
Aiden Park 236a800284 Support ELF32/64 format payloads regardless of operation mode
This allows to load and execute ELF32 or ELF64 format payloads
regardless of Ia32 or X64 SBL operation modes.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-05-24 09:04:14 -07:00
Stanley Chang 3a02cd0f45 Add EXT FS check in initialization
This patch runs basic check during EXT FS initialization
by opening root directory to ensure superblock been
validated.

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2021-05-21 20:11:53 -07:00
Stanley Chang 19123314d5 Fix return code of SearchDirectory
This patch changes the return code of SearchDirectory
to EFI_NOT_FOUND when a file to search cannot be found

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2021-05-19 07:12:16 -07:00
Maurice Ma 4e770bfb22 Fix eMMC controller driver issue
When the bus master decoding was disabled by default in PCI bus, the
device driver should try to enable it on its own. However, eMMC
driver does not have the enabling code. It caused the eMMC access
failure.

It fixed #1153.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-05-15 09:13:50 -07:00