Commit Graph

166 Commits

Author SHA1 Message Date
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
Sai T 6eaea8fafa Add a PCD to set RTCM RSVD SIZE
If the number of cores are more and the RTCM is
required to support HyperThreading, then it needs
more reserved size, preferably 511 pages instead of
current 255 pages.

So, add a FixedPcd and let each platform override
the default 255 pages value to whatever is required.

Signed-off-by: Sai T <sai.kiran.talamudupula@intel.com>
2021-11-15 19:05:05 -08:00
Maurice Ma d424a15994 Add boot from multiple USB devices
When multiple USB devices are attached, current SBL will try to
boot the device with index specified by HwPart in the boot option.
However, it is hard to determine the USB device index order since
it depends on which port the device is connected to. Instead, for
USB devices, SBL can try to boot from each of them until the boot
image is loaded successfully or all USB devices have been tried out.
This patch added this support.

To enable this feature, it is required to set the USB boot option
HwPart to 0xFF.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-11-10 14:28:31 -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
Guo Dong 992d637f27 Add capsule image location info
It is useful to have capsule image location info since
capsule image could be configured to different places.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-11-01 20:55:26 -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
Ong Kok Tong 22ba6209a6 Enhance firmware update to handle different BIOS region size
Current SBL FWU code assumes the SBL ROM image size is the same as
the BIOS region size defined in the SPI descriptor. It is used to
calculate the offset for flash write and erase. However, the SBL
ROM image size could be smaller than BIOS region size, in this case
the offsets are all wrong. This patch addressed this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-21 10:14:38 -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
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 9c206b58bd Fix misleading error message in OsLoader
This patch fixed the misleading partitioin detection error message.
It should be file system detection error message instead.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:16:04 -07:00
Maurice Ma 52b0edb409 Enhance FWU flow to prevent infinite loop
This patch enhanced the FWU code flow:

- Moved the capsule signature save to later flow because current
  code saved it too early and later on the state block will be
  erased.

- Enhanced error handling. If there is error during FWU, both the
  state machine and the trigger need to be cleared. Otherwise, it
  will be in infinite loop.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 06:58:24 -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 079b7bf095 Fix HelloWorld payload build issue
This patch fixed SBL HelloWorld payload build failure.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-06 16:52:26 -07:00
Sai T 9ceb26745a Enhance FWU logic for CSME update
CSMD (CSME update driver) is a part of FwuImage.bin capsule,
and it updates the CSME binary on SPI Flash. ApplyFwImage call
cant be invoked for CSMD component.

Signed-off-by: Sai T <stalamudupula@gmail.com>
2021-10-06 05:45:01 -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
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
stanley 04f90a7708
Fix error logs for capsule file too small (#1222)
If the capsule file is too small, it should not only
show "the guid is not expected" that may mislead users
using a release-build image. This patch prints out
specific error if opening a small-than-expected capsule.

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2021-07-12 11:21:36 -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 7886a8ec66
Remove unused code ever used for PreOsChecker (#1182)
PreOsChecker is supported in the generic boot flow,
no special code is needed to support PreOsChecker.
So remove these unused code.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-06-09 15:59:42 -07:00
Guo Dong 29073e4782
Get RTCM from OS boot media instead IFWI (#1179)
RTCM will sit in OS boot media instead of IFWI image
So update SBL logic to load RTCM from OS boot media.

If the RTCM could not be found, SBL should continue
boot normal OS.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-06-09 08:05:56 -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 6d1734a6ec [FWU] Fix a pointer misusing in capsule name
This will fix an invalid pointer operation while copying capsule filename
from capsule info config data to a unicode buffer.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-05-25 11:14:06 -07:00
Maurice Ma 7deab616aa Add ELF image support for OsLoader
This patch enhanced OsLoader to support ELF image boot on top of
PE, FV, Multiboot and Kernel. As a result, a new image flag
LOADED_IMAGE_ELF is added to indicate ELF image type.

Verified SBL can boot uboot ELF image (non-Multiboot) on QEMU.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-27 09:12:17 -07:00
Maurice Ma ded75d8859 Enable SBL call into extra module in boot option
SBL allows extra module to be called before tranfering into the main
boot option. For example, RTCM module can be called for boot option
with TCC feature support. This patch enabled this support.  Since the
extra module might have different ARCH mode from current SBL mode,
thunk will be provided if mismatching is detected.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-13 14:05:48 -07:00
Adithya Baglody fec4f039f6
csmeupdatedriver: Fix incorrect typecasting. (#1100)
This patch fixes the default 32bit typecasting of a pointer.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2021-04-06 10:47:55 -07:00
Guo Dong d4f1efd8d6 Fix the boot option
When PreOS is configured from OS boot option data, the common function
FillBootOptionListFromCfgData () need update it to correct boot option
image LoadImageTypePreOs. Similarly when extra image is specified, need
update to extra image.
Update ImageType value and fix an image load issue for RTCM.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-04-01 17:02:25 -07:00
Guo Dong 74d5b5243e Add TCC RTCM support in SBL boot option
Before normal OS boot, some images need run firstly.
These images will return to SBL after complete.
This patch uses OS boot option extra images to
support TCC RTCM use case.

TCC RTCM should be in flash memory map in container format
with container "IPFW" and component "TCCR".

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-03-29 15:19:13 -07:00
Maurice Ma d7ab7a595b Set current boot option in OsLoader
The boot logic has been adjusted in OsLoader. As a result, the
mCurrentBoot does not point to the current boot option any more.
It is always 0. This patch adjusted the value for it to indicate
the current boot option.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-03-28 21:24:47 -07:00
Maurice Ma e4661845bc Fix firmware update version check
As part of the commit e21c74f42e,
it used the HOB to get the firmware version info. However, the
HOB firmware version structure is not exactly the same as SBL
firmware version structure. It needs to be adjusted accordingly.
This patch addressed this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-03-28 09:34:15 -07:00
Maurice Ma e21c74f42e [APL] Firmware update flow fix
This patch enforces to use the SBL version for current boot
to check against the new version in capsule. Only when the
new SVN version in capsule is greater than or equal to current
SBL SVN version, the update is allowed.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-03-26 15:36:29 -07:00
Raghava Gudla 7c5464f880
Remove next line char during csme fw update (#1046)
This patch removed next line character printed during
progress update of csme firmware update, this would remove
lot of prints in the next line and show progress much more
user friendly.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2021-03-11 17:10:17 -08:00
Subash Lakkimsetti aa36ae70d1
Oem Key revocation feature support (#1043)
EHL, TGL supports multiple OEM keys and their revocation
by CSE. This patch supports,
- CMDI interface to perform key revocation using
  OEMKEYREVOCATION string in cmd file.
- EHL HECI APIs for OemkeyRevoke and to get key status
- FW componets are sorted as per required order.
  CSME and BIOS should be signed with new keys and
  both components would go together with capsule update.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2021-03-08 11:04:44 -08:00
Raghava Gudla de6bc238d4 Fix bug while updating binary not aligned to 4k
This patch fixed an error that occur during updating a
binary that is not aligned to 4k. Current code will always
update next 4K block. This patch adjusted the block length
to remaining size other than 4K.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2021-02-27 16:44:25 -08:00
Subash Lakkimsetti 84c8a3ffe2 Update CsmePciReadBuffer callback prototype params
CsmePciReadBuffer function prototype is alligned as
per the CSME fwupdate lib. It fixes issue with
CSME capsule fw update.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2021-02-24 21:15:03 -08:00
Aiden Park 2aade4dddb
Fix new Klocwork scanning issues (#1012)
This patch addresses new reported klocwork scanning issues.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-02-10 08:55:00 -08:00
Raghava Gudla ca738786cc
Fix firmware update failure during sbl svn check (#999)
This patch fixed a failure in firmware update that
occur during SBL version check. Current code assume
that the SBL layout does not change between the existing
firmware and the capsule, when the layout change, stage1A
address change and this is causing error while obtaining
the firmware version.

Code is modified to use the last 4 bytes of the SBL region
which contain Stage1A FV address and this is used to obtain
the version information.

Signed-off-by: Raghava <raghava.gudla@intel.com>
2021-02-05 09:01:26 -08:00
Raghava Gudla c9be70efd2
Fix failure during csme firmware update (#982)
This patch fixed a failure occured during CSME firmware
update. CSME firmware update library expects PCI read buffer
with a specific format, there is mismatch with input and output
parameter with the current code. Added a wrapper function
with the expected format to fix the failure.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2021-01-25 15:46:54 -08:00
Aiden Park 2e9d97de20 Fix a bug in PAE 2MB paging
This will fix invalid PDP/PDE generation with PAE 2MB Pages,
and high bit calculation at PayloadEntry additionally.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-01-23 07:42:19 -08:00
Maurice Ma 5d573cf55e Fix paging issue when PCI PMEM64 resource exists
In 32 bit SBL, when PCI PMEM64 exists, the OsLoader will hang
during boot in CreateIdentityMappingPageTables().  The function
is inteneded to be used in X64 mode only, and cannot handle
32bit well. So OsLoader should not call it for 32 bit build.

This patch also zeroed the allcated memory to ensure the unused
entries are all 0.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-01-21 14:08:53 -08:00
Raghava Gudla 46e4a98cd1 Get SVN ver from capsule during firmware update
During firmware update svn check for SBL region, Current code
assumes that Stage1A base does not change, because of this when
Stage1A base changed in capsule image, getting svn version from
the capsule fails and firmware update is failing.

This patch addressed above issue by reading stage1A base from
capsule image, this way even if stage1A base changes, code will
be able to read it and get svn version from capsule.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2021-01-16 09:41:04 -07:00
Guo Dong 78cce60ce8 Enhance PreOS support
SBL support to load PreOS and normal OS in a single boot option.
This patch tries to standardize the PreOS support.
The PreOS could be TrustyOS, PreOsChecker or others.
As long as PreOS flag is set in boot option, SBL will load and
boot PreOS before normal OS. If the preOS has specific requirement,
it could be addressed using PreOS image type.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-01-15 21:29:43 -07:00
Guo Dong 89c7b82b84 Fix the HelloWord build failure
Add required library for HelloWorld build.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-01-11 08:20:30 -07:00
Maurice Ma e51ab53016 Enhance grub.cfg to support CentOS
CentOS live CD iso image has different path for grub.cfg file. It
also used "linuxefi" and "initrdefi" for keywords. This patch added
support for it. With this patch, verified it can boot to CentOS
live-cd on APL platform.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-12-01 16:19:21 -08:00
Maurice Ma 5f1923604d Fix InitRd image alignment issue
Current SBL used AllocatePool to allocae space for Linux files
including Kernel and InitRd. However, since InitRd is required to
be aligned at page boundary, it needs to use AllocatePages instead.
This patch addressed this issue. It fixed #908.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-12-01 13:09:34 -08:00
James Gutbub ae99635490
Resolve raw partition boot loading (#899)
The calculation on where to start reading the
remainder of the boot image from is not being
calculated properly, the aligned header size
is given in bytes instead of in terms of block
size. This patch updates the calculation
accordingly.

Also, if SwPart is set as 255 then the LBA given
will be used as an absolute LBA instead of used
relative to the SwPart's starting LBA.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2020-11-10 22:26:26 -08:00
Maurice Ma 1002d880a2 Enable mixed payload mode calling
Since SBL could be built into either x86 or x64 mode, and the payload
can also be x86 or x64 mode. When mixed modes are used, it is required
to switch to proper mode first before calling into payload entrypoint.
This patch added this check to switch to required mode before calling
into payload entry point.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-10-12 13:01:07 -07:00
Maurice Ma 9a4407018d [QEMU] Fix NOOPT build failure
This patch fixed NOOPT build failure for QEMU.
It fixed #871.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-10-12 13:00:44 -07:00
Praveen Hp 7314822a5b Fix klockwork scanning issue
This patch add code to check OsBootOptionList for NULL to avoid
NULL pointer dereference.

Signed-off-by: Praveen Hp <praveen.hodagatta.pranesh@intel.com>
2020-09-09 21:42:29 -07:00
Maurice Ma 98b55affa1 Add payload module support in OsLoader
This patch added support to launch payload module on top of OsLoader.
Comparing with payload binary, payload module will utilize the API
services provided by OsLoader, so it will have smaller size. Other
than this, the concept is exactly same as normal payload. For payload
module, additional parameter is required to pass into the payload
module entry point.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-09-02 15:42:36 -07:00
Maurice Ma 7779f127af Added restricted boot in boot option
This patch added restricted boot flag support. When restricted boot
flag is set, the OsLoader will only try the current boot option
selected without falling through all other boot options. Also it will
not allow to get into Shell.  This is for the usage to run some
critical applications such as bootloader Setup.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-09-02 15:42:36 -07:00