Commit Graph

642 Commits

Author SHA1 Message Date
Maurice Ma 5bd480e425 Sync up new BaseTools to EDK201911 stable release
This patch synced up the BaseTools to EDK201911.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-02-03 15:49:48 -08:00
Maurice Ma faa172e67e Add missing header files in INF
In order to sync up with EDK201911 stable release, it is required
to add missing header files in the INF file. Otherwise, the build
will throw warnings. This patch added the missing headers in INF
files.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-02-03 15:49:48 -08:00
Maurice Ma 2a3ca8bf75 Fix QEMU Flash read issue after erasing
After erasing flash on QEMU, it needs to be returned to normal
read state to allow normal read access. However, this is missing
in current SBL QEMU SpiFlashLib.  This patched added the code to
switch back to read mode. It also fixed #552.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-02-03 09:36:18 -08:00
Subash Lakkimsetti c116c33bfe
Allocate BN Buf and scratch buf with Rsa Verification (#546)
Currently BN buf is statically defined and this
would increase stack sizes. Allocate required memory.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-31 10:42:37 -08:00
Aiden Park 644cc84823
OsLoader clean-up to use common LinuxLib (#547)
This will allow OsLoader to use LinuxLib for legacy linux boot
and remove duplicated code.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-01-30 15:24:19 -08:00
Aiden Park 28cc381542
Remove duplicated code for Fsp reset request (#548)
After memory init, FSP reset request is handled by FspResetHandler.
Remove unnecessary duplicated code.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-01-30 15:24:02 -08:00
Maurice Ma 907f02694f Allow adding EMPTY component in flash layout
This patch allows the platform to add EMPTY component in the
flash layout definition in BoardConfig.py.  Without this patch,
it will cause build error because it expects EMPTY as an actual
component file.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-01-29 11:54:36 -08:00
Maurice Ma 753129ff2b Avoid hardcoded flashmap address
Current FLASH_MAP address is hard-coded at 0xFFFFFFF8. It will work
in most of the cases.  However, if region is added on top of the
Stage1A FV, it will cause FLASH_MAP address shift.  Instead, the code
can use relative address to locate FLASH_MAP.  The address can be
calculated with (Stage1AFvBase + Stage1AFvSize + 0xFFFFFFF8).

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-01-29 11:54:22 -08:00
Subash Lakkimsetti a7a5b88c97 Add logs for RSA and Hash verification params
Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-28 15:07:29 -07:00
Aiden Park c51137b7bf
Update AcpiPatchPssTable() parameter (#543)
There are many parameter passing to AcpiPatchPssTable().
A single PSS_PARAMS structure pointer will be passed to simplify.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-01-28 11:54:48 -08:00
Aiden Park 70ce0f3252 Add a common api to patch PSS table
This will allow update PSS table in a common way.
For a platform specific power calculation,
a function pointer can be provided.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-01-28 09:44:35 -07:00
Subash Lakkimsetti d111dcb12a Measured boot update for Linux OS Image
Unified interface is added in TpmLib to extend stage and
OS Image digest. For Container OS Image this interface
is added as callback functionality. IAS image utilizes same
functionality to extend TPM digest.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-28 09:35:46 -07:00
Subash Lakkimsetti d2acdab100 TPMLib and Measured boot updates (#539)
- Added GetHashToExtend to bootloader common API to
  retrive digest to extend
- Hash calculations for stage component and config date updated
  to use bootloader common API
- Added functionality to extend KeyHashManifest digest

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-22 13:53:44 -08:00
S M Narayanan c0160fcd81 Cosmetic: Update of the typo in comments (#538)
- Update of comment in Fwst.aslc for coffeelake as per review comment.
- Update of comment in Boardconfig.py for qemu.
- Removal of vtf0.bsf in BootloaderCorePkg.

Signed-off-by: SM <s.m.narayanan@intel.com>
2020-01-20 21:23:58 -08:00
Aiden Park 04cbb77999
Add GIT tool check for build (#536)
GIT is required to get FSP binary, ucode patch and so on.
This patch will check GIT availability.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-01-15 22:29:41 -08:00
Maurice Ma 9a08163be2 Enhance GenContainer tool
This patch added following enhancement to GenContainer script:
  - Fixed python3 errors in some specific condition
  - Added more error handling to notifce the user on failure
  - Removed -od option and use directory of -o option instead

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-01-14 13:54:14 -07:00
raghavag c2ec3074f7 Free memory using FreePages instead of Freepool (#534)
Allocate pages is used now to allocate memory during block update
but was freed using freepool which is throwing exception. Changed
code to use FreePages

Also removed an unused function

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-01-14 11:05:26 -08:00
Raghava Gudla 4b6e52fdd0 Added python 3 support for GenCapsuleFirmware.py
This patch updated GenCapsuleFirmware.py to Python 3
compatible.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-01-14 10:50:40 -07:00
Raghava Gudla 640dcb4bd8 Added support for container component update-from-OS
This patch added routines to support update for any
component identified by flash map. Also, if the capsule
container components inside the container, Support is added
to update these container components.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-01-13 13:39:35 -07:00
Subash Lakkimsetti f9e542a72c Update firmware component stage hash extend
LoadComponentCallback is extended to perfom TPM extend
for firmware component stages. Component callback would be
invoked after authentication.

TpmExtendStageHash would extend hash based on hash validity.
TpmExtendConfigData is added to handle the Config data blob extend.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-13 08:30:45 -08:00
Subash Lakkimsetti aefc311823 TPM and Measured boot support SHA384 and SM3
Current Slimbootloader supports only TPM for SHA256 PCR.
This patch introduces flexibility for user to select TPM
PCR bank available while build. Support of SHA384 and
SM3 to TPM measured boot are added.

Added/modified TPMLib APIs to support multiple PCR
usecases. Currently one PCR active bank usecase is supported.

For first boot SHA256/default TPM PCR would be available which
is default for most supported TPM's. Selected TPM PCR will be
available after reboot.

TPM selection would be based on PcdMeasuredBootHashMask set at
build time.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-13 08:30:45 -08:00
Raghava Gudla a71bb1d25a Added comp signature along with GUID in capsule
Currently each component inside capsule is identified with GUID
but going forward support is being added to update multiple components
inside sbl and container, so larger number of GUID's are required, also
GUID need to be passed for unknown components through command line.

Instead 4 character unique signature from flash map that is passed
through command line to indentify the component is added to the
component header. This signature is used during runtime to indentify
the component from flash map and container.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-01-13 09:02:40 -07:00
Subash Lakkimsetti 5ae79a19d8 Update Hash type to string.
Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-12 22:08:32 -07:00
Subash Lakkimsetti 94e203113d GenContainer: Converge hash param and auth type usage
In GenContainer tool auth definitions for RSA cases were
updated to include hash alg used. In current implementation
auth type is generated from hash type and private key while
container created. This patch removes hash type param
and auth type is used for hash alg generation.

Platform code to be updated as per updated auth definitions

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-10 16:23:53 -07:00
Aiden Park ccc0560670 [Stage1] Add Stage1 stack base setup offset
This patch allows to setup Stage1 stack/data in any CAR range.
By default, the stack base offset is 0 from CarBase.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-01-10 16:20:31 -07:00
Maurice Ma afc164e0b5 Fix GenContainer tool issue with python3
If running GenContainer tool with python3, 'view' sub-command will
throw out errors.  This patch fixed it.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-01-10 16:18:02 -07:00
Raghava Gudla 1ce416b20f Added routine to get comp entry from flash map
This patch added routine to get component entry from flash map
this is required in case when component entry flags are required.
GetComponentInfoByPartition function will reuse the newly added
routine GetComponentEntryByPartition.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-01-09 14:53:09 -07:00
Subash Lakkimsetti 8a4289c110 Pass Hash Alg param for verifying hash data with RsaVerify
Hash verification of Public key hash should be based on
hash alg used with Hash store. Previously hash alg in
signature info is used. There would be instances where
hashstore hash alg differs from signing alg.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-09 13:26:04 -08:00
Raghava Gudla 8fd15d62de Create Internal firmware update file
FirmwareUpdate.c is already a big file and for convenience
moved update routines to internal file. Also created a internal
header file.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-01-09 13:54:48 -07:00
Maurice Ma 05f308d8a9 Switch to use Python 3.6 or above for build
Since Python 2.7 is EOL already. SBL needs to drop the support.
This patch switched to use python version 3.6 or above for SBL
build. If lower version is used, warning message will be printed
out.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-01-09 11:26:04 -08:00
Subash Lakkimsetti 1bdaa19840 Add RSA3072 sample private key (#521)
This sample key can be used for RSA3072 signing purposes.
To test with RSA3072 private key,
- user could rename TestSigningPrivateKey_RSA3072.pem to
  TestSigningPrivateKey.pem
- This key would be included in signing tools for RSA3072
  usecase similar to RSA2048
- Same key should be used by tools for CapsuleFirmwareUpdate
  and other which gets executed outside from SBL build

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-08 11:21:00 -08:00
Aiden Park e79890742f
[PatchCheck] Add exception file types (#523)
The PatchCheck.py will skip specified file types in skip_check_file_types.
As of now, .patch and .pem files are in skip list.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-01-08 11:19:42 -08:00
Maurice Ma 5bbf0122eb Add Visual Studio Community build support
This patch enabled Visual Studio 2017 Community 2017 build support.
The following were done:
- Added new method to detect VS2017 installation path and version
- Droped VS2005, VS2008, VS2010 and VS2012 build support. Only
  VS2013 and VS2015 are supported.
- Fixed build issue in FspApiLib due to new compiler optimizations
- Synced the build support for QEMU FSP patch

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-01-08 08:23:35 -08:00
Subash Lakkimsetti e18699930d Python3 Next() compatibility fix
In Python 3 built-in function next() is used to get the next
result from an iterator. next method causes post build failure.
Fixed an issue in GenContainer for byte array comparison.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-06 22:44:36 +01:00
raghavag 98cc38ebb5 Execute version check only for SBL update (#513)
This patch will run version check only for SBL update and will
skip for all other components.

Version check for all other components will be added in future
patches.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-01-06 11:01:25 -08:00
Subash Lakkimsetti 79abb75ed6 Enable RSA3072 and SHA384 signing support
This patch introduces support for RSA3K and SHA384 signing
And verifications support to Slimbootloader. Component hash
verification is done using PcdCompSignHashAlg.

To enable RSA3072 and SHA384,
 - Signing hash algorithm SIGN_HASH_TYPE should be set to SHA2_384
 - RSA3K private keys should be configured in platform board configs.
 - Set IPP_CRYPTO_ALG_MASK to include SHA2_384
 - Enable required IPP_CRYPTO_OPTIMIZATION_MASK
 - Default siging hash type is set to SHA2_256. Use hash type option
   while using the tools as Gencontainer, CfgDataTool in standalone
   mode.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-02 11:23:49 -07:00
Raghava Gudla 76ab33cc94 Skip updating FWST table with csme driver info.
CSME driver is not a component rather it is a driver to
update CSME binary, so it is not required to update status
of the driver to FWST ACPI table.

As part of the above change, gCsmeFWUDriverImageFileGuid is
moved from PayloadPkg.dec to bootloadercommonpkg.dec

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-12-19 14:51:41 -07:00
Raghava Gudla a204c1af48 Execute CSME update only from primary partition
CSME update is working only from primary partition, added
code to check the current boot partition and if booting from
back up partition, switch to primary partition.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-12-19 14:51:16 -07:00
Maurice Ma 12f6f62630 Add MiniShell support for debug purpose
Soemtimes when JTAG based debug is not available, it might be easier
to have Shell access in earlier stage to check lots of platform
settings. Today it is impossible because full Shell has lots of other
dependencies which might not satisfy in early stage. This patch added
a PCD PcdMiniShellEnabled to build a mini Shell with very few
dependencies. This mini Shell can be used in early debug phase for SBL.

To use it, add the following to override the PCD for a specific stage
in BootloaderCorePkg.dsc.
EX:
    $(PLATFORM_PACKAGE)/Stage1B/Stage1B.inf {
      <PcdsFeatureFlag>
        gPlatformCommonLibTokenSpaceGuid.PcdMiniShellEnabled | TRUE
      ...
    }
Then include ShellLib.h in stage C code and add ShellLib in related
stage INF file. If adding it into Stage1A, it needs to be after the
Stage1A banner print out.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-12-18 21:29:07 -07:00
Maurice Ma 2ed3e9c46a Remove Shell global variable usage
This patch removed global variable usages in ShellLib.  It is
required when running Shell in early stage from flash. In this
case global variable is read-only. All memory should be allocated
from stack or heap.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-12-18 21:29:07 -07:00
Subash Lakkimsetti 4aa3ae3ad2 Remove PDR CfgData support
Configuration data blob is supported only from Bios region.
Removing CfgData in PDR as its no longer getting used.

Updated to copy signed data structure length for max supported.
Max supported is for RSA3072 size.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2019-12-18 21:28:45 -07:00
Subash Lakkimsetti 8bbef289f3 IPP License file update
Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2019-12-18 08:33:46 -08:00
Maurice Ma 53255d7c6d Clean up BootloaderCorePkg stage code
This patch did some of the following clean up:

- Rename *_HOB to *_PARAM for Stage1A/Stage1B/Stage2.
  This is to avoid confusion between real HOB and the parameter
  data block passed through stages.

- Rename BistVal to CpuBist.
  This is to make it more clear.

- Add BUF_INFO definition.
  BUF_INFO will be used as a general structure.

- Remove CarBase/Top in Stage1B HOB
  They are not used at all.

- Clean memory allocation in Stage1A
  Restructured the buffer allocations for Stage1A global
  data so that it is easier to read and maintain.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-12-17 12:59:08 -08:00
Maurice Ma 6d79b83d1c Print exact address for Shell memory dump command
If dumping address not aligned at 16 boundary, the current Shell
will print the aligned address in the dump. It makes sense for
a memory block display, but it is a little bit confusing for single
memory address display. This patch fixed this issue by printing the
exact address when the display count is 1.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-12-17 10:08:05 -08:00
Guo Dong 515ad59d9e Add SmbusLib
Add a common SmbusLib support for Intel PCH
Define PLT_MEDIUM_MISC_TYPE in device table for
devices that are not for OS boot.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-12-13 16:30:32 -07:00
Raghava Gudla 25af3e1e6c [CFL] Trigger firmware update from OS
This patch does the following

1) Enable triggering firmware update from OS
2) When firmware update mode is given control, state machine
   is set to capsule processing and firmware update platform
   specific trigger is cleared. State machine will be used
   hereafter to track firmware update
3) Created CheckStateMachine method in BoardSupportLib.c to
   check state machine to see if firmware update is in progress
   and set boot mode to firmware update.
4) Removed CMOS way of triggering firmware update and wrote code
   to use Over-Clocking WDT Scratchpad (OC_WDT_SCRATCH) bits for
   triggering firmware update
5) Update shell fwupdate command to use OC_WDT_SCRATCH bits.
6) Removed extra reset during sbl firmware update
7) Removed reset after updating configuration data update

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-12-13 15:14:06 -08:00
Subash Lakkimsetti 71c64f40bd IPP Crypto and Secure boot lib to support multiple hashes
Hash and RSA signing parameters were hardcoded in
Crypto wrappers and secure boot libraries. This patch
address support for multiple hash and key sizes.

Signed-off-by: Subash Lakkimsetti <subashx.lakkimsetti@intel.com>
2019-12-12 08:13:04 -07:00
Guo Dong f697ef33f4 Fix the build failure when firmware update is not enabled
When firmware updated is not enabled, it will not build firmware update
payload, so there is hash for FWUPDATE.hash.
Update the build tool only require it when firmware update is enabled.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-12-12 08:10:24 -07:00
Maurice Ma d2109f20db [APL] Add KEYH component in StitchIfwi script
This patch added KEYH component into the IFWI stitching process.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-12-11 14:09:05 -08:00
Aiden Park 6295c4ec8f Build stuck on unicode locale Windows
This issue happens under two conditions
  1. Unicode language environment in Windows
  2. A python calls 'BaseTools/toolsetup.bat'
     (In EDKII, edksetup.bat directly in Windows command shell)

- 'BuildLoader.py' calls 'BaseTools/toolsetup.bat' in a subprocess
- 'BaseTools/toolsetup.bat' calls 'nmake cleanall'
- 'cleanall' target runs 'python NmakeSubdirs.py' directly
- 'NmakeSubdirs.py' creates multi-threads
-  The threads create another subprocesses

But, one of multi-threads is on deadlock when python handles stdout and
stderr in a subprocess pipe only if the output includes unicode chars.
Therefore, only stderr will be handled in the pipe same as a single
thread call.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-12-11 13:35:31 -08:00