Commit Graph

502 Commits

Author SHA1 Message Date
James Gutbub 2ea731017c Skip submodules during PatchCheck.py
If a submodule is being updated in a
commit there is inadvertently some line
ending issues that will cause PatchCheck.py
to report an error; since we cannot change
the line ending in the submodule files
we should skip over a line in a patch that
matches the format of a submodule being
updated.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2020-02-06 16:05:11 -07:00
Maurice Ma 6d41183c52 Fix BaseTools FFS map file dependency issue
With the lastest EDK2 201911 BaseTools, the generated Makefile has
missing dependcy file for the map file target. It results in staled
map file when source code is modified.  This patch added the missing
dependencies.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-02-06 12:27:14 -08:00
Subash Lakkimsetti cca25f64ef IAS Library KlocWork fixes
Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-02-05 22:44:10 -08:00
Aiden Park c90ca31d02 [CFL] Fix incomplete ACPI table generation
With EDK201911 BaseTools update, a ACPI binary is not included into ACPI
table section properly and it mis-leads some other ACPI tables as well.
This will add 'RAW BIN' type in ACPITABLE override rule and use it for
ACPI binary integration into ACPI table section.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-02-05 22:43:37 -08:00
Guo Dong 6476272fb5 Fix FPDT size issue
FPDT size should be FIRMWARE_PERFORMANCE_TABLE. And updated
this logic to correct the size and adjust next ACPI table
starting address.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2020-02-05 13:55:44 -07:00
Subash Lakkimsetti 776aef4078 KlocWork issue fixes in security libraries
Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-02-04 14:40:17 -07:00
Aiden Park 9193a72864
Support booting to 64-bit kernel entry point (#550)
This will allow OsLoader payload to boot to 64-bit kernel entry point.
If CPU supports 64-bit mode and a kernel image has 64-bit entry point,
OsLoader will switch to 64-bit long mode and jump to the 64-bit entry
point. Otherwise, continue to boot to 32-bit entry point.
- Ported necessary code from EDK2 VitualMemory.c in MdeModulePkg
- Moved PagingLib from BootloaderCorePkg to BootloaderCommonPkg
- Removed unused FlushCacheLine
- TBD: 64-bit IDT

Next step is to support 64-bit Payload.
- 32-bit compatible mode
- 64-bit CryptoLib
- etc.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-02-04 10:44:45 -08:00
Raghava Gudla 1b40195126 Fix several minor issues in the code
1) GetComponentInfoByPartition does not check FlashMapPtr, added code
   to return error if FlashMapPtr is NULL

2) In GetComponentHash function, there is no check for if HashEntryPtr is
   greater than or equal to HashEndPtr. In this case HashEntryData will be
   corrupted.

3) In InitFirmwareUpdate function, if we could not find corresponding
   image in capsule, there is an error message but after that we continue
   to update reserved region based on ImageHdr which is not valid.
   Added code to continue if image is not found in capsule.

4) In UpdateSblComponent function, Status is uninitialized.
   Initialized Status to not found.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2020-02-04 10:38:08 -07:00
Maurice Ma 5e822e0608 Fix GenCfgData script issue with Python 3
This patch fixed the GenCfgData failure with Python 3.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-02-04 07:03:22 -08:00
Maurice Ma 5e1620b619 [QEMU] Add test container data print
This patch printed out the loaded data from the test containere.
It is helpful for tool to parse the boot log and verify if the
component inside the container has been loaded properly.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-02-04 07:02:54 -08:00
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