Commit Graph

36 Commits

Author SHA1 Message Date
Maurice Ma 7b2ca97b97 Rename UsbIoLib to UsbInitLib
This patch renamed UsbIoLib to UsbInitLib to better match its
actual functionality.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-05 19:55:25 -07:00
Sai Talamudupula a88c44e792 Enhance GenContainer.py
Container type can be input from command line
from a list of [NORMAL, CLASSIC, MULTIBOOT] while
generating a container using GenContainer.py.
Setting default as NORMAL.

Revert varnames of out dir and key dir for commands
other than create container, as this is breaking stitch.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-10-02 20:28:17 -07:00
Sai Talamudupula 709d7c1470 Support boot image from container
Add support to load the boot image from container.
Container must be signed using the same private key
as the key used to sign IAS (i.e. IAS_PRIVATE_KEY).

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-10-02 12:18:45 -07:00
Maurice Ma 8a019c7758 Fix config file buffer overflow issue
Current code will try to append a NULL char at the end of the
config file buffer to ensure the string is terminated properly.
However, it did that without considering the buffer size. The
current config buffer could have been fully used and no more
space is available to append an extra NULL char. If this happens,
during the pool de-allocation, the assertion will be seen due to
buffer overflow. This patch increased the config buffer size by 1
to ensure it will have space to append string terminator.

It fixed #319.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-09-11 09:46:21 -07:00
James Gutbub 327fbac532 Resolve Klocwork issues in Payload & Platform
Klocwork scanning reported several issues in the
PayloadPkg and Platform code folders, this commit
aims to resolve all of the issues currently being
reported in these folders.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-08-29 10:39:22 -07:00
James Gutbub f9335e19a9 Switch to use container for pre-OS checker/payload
Since we may want to perform FW update on
pre-OS checker/payload binaries separately
from the OS Loader payload we will search
for pre-OS checker/payload in the container
entries instead of adding it into the OS
Loader FD.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-08-15 11:08:46 -07:00
Maurice Ma 19a0890a54 Break Load Linux BzImage into more functions
This patch splitted LoadBzImage() into two functions.  One is just
for kernel loading.  The other one UpdateLinuxBootParams() is for
Linux boot parameter updates. It is required to do so because when
kernel loading in Stage2 is enabled the loading occurs before all
HOBs are finalized. The Linux boot parameters depend on HOBs to fill
correct information, such as frame buffer. With this patch, the boot
parameters can be updated at the very end.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-12 10:40:11 -07:00
Maurice Ma 4a5af4f8b0 Add Linux Kernel Boot Support in Stage2
OsLoader has the capability to boot a Linux kernel. However, to support
LinuxBoot type of payload, it is required to load kernel in Stage2. This
patch abstracts the standard Linux loading logic into common LinuxLib
class so that it can be linked in Stage2 or Payload such as OsLoader.
A new PcdLinuxPayloadEnabled is introduced to control if this feature
should be enabled or not.

To boot a Linux kernel from Stage2, it is required to put the command
line file and kernel image into the EPAYLOAD container during the build.
And the PayloadId CFGDATA needs to be set to 'LINX'.
For example:
  python BuildLoader.py build qemu
         -p OsLoader.efi::Lz4;vmlinuz:LINX:Dummy;cmdline.txt:CMDL:Dummy
vmlinuz and cmdkube.txt need to be copied to PayloadPkg/PayloadBins
folder. If kernel size cannot fit into EPAYLOAD, EPAYLOAD_SIZE in
BoardConfig.py needs to be adjusted accordingly.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-09 16:48:12 -07:00
Maurice Ma 944e5b8d2d Break down boot option CFGDATA
The current implementation used a huge array to represent boot options in
a single CFGDATA tag. With this approach, when a different board needs
to modify a single field, the whole array needs to be duplicated in the
CFGDATA. It is not efficient. A better approach is to break the options
into individual boot option CFGDATA tag. It will reduce the overall CFGDATA
in general. This patch implemented this mechanism. A library interface
FillBootOptionListFromCfgData() is provided to convert the CFGDATA into
the required OS_BOOT_OPTION_LIST.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-07 14:06:45 -07:00
Maurice Ma 21ba997ff2 Allow initrd to be optional for Linux boot
OsLoader shall allow Linux kernel to boot without initrd. But
current code returns an error if initrd is not provided. This
patch added extra logic to return success if initrd cannot be
found.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-05 17:11:54 -07:00
James Gutbub d6a21287d4 Add initial support for Mender boot
Mender is an A/B partitioning scheme
for Linux OSes. Adding initial support
for specifying the root partition label
that should be used. Later on the root
partition label should be acquired based
on the value of the env files stored in
the EFI/FAT32 partition of the boot media.

Also fix misspellings.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-08-01 14:07:36 -07:00
James Gutbub 40d81c6d23 Append optional IAS image cmd line params
There may be additional cmd line params specified
by a platform that needs to be added without
updating the IAS image cmd line data. These
optional additional cmd line params can be included
via CFG data, Shell command, etc., and applied
by setting the mAppendCmdLineParams pointer.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-07-25 09:57:49 -07:00
James Gutbub bdfac7dae1 Modify kernel size loading check
When loading a Linux kernel we should not
limit the size of the kernel being loaded
to 15MB but we should verify that the kernel
will not overwrite the payload which can
some times be located in low memory where
the kernel is being loaded.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-07-22 13:20:19 -07:00
Aiden Park 0066eccdb3
Re-implement ElfLib for ELF32 format image (#193)
The previous implementation has a little confusion in license header.
To avoid further annoying, simply re-implement ElfLib.
- 32bits, little-endian, executable elf only supported
- elf32.h/elf_common.h from BaseTools/Source/C/GenFw
- LoadElfImage() interface changed

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-06-17 16:58:08 -07:00
Guo Dong 5e10bd1e07 Update BSD license to BSD+Patent license
To align with EDK2, update file license
to use BSD+Patent license

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-06-13 10:46:49 -07:00
Maurice Ma 179130751f Fix FAT file path matching issue
In current FAT lib, the file path matching code will just compare
the 1st N chars and ignored the remaining. The end of the string
should be checked to ensure exact matching. As part of this fix,
the GRUB config parsing library needs to be updated since the file
name length field is one less than expected.

It fixed #183.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-06-12 10:59:31 -07:00
Aiden Park 497e66eadb [FileSystemLib] Added generic filesystem/file access APIs
FileSystemLib provides generic interfaces to access file system and
its files as a abstraction of FatLib/ExtLib.

- Added CloseFileSystem
  If there are opened files in a specific filesystem, those files
  will be de-allocated in CloseFileSystem.
- Added OpenFile/GetFileSize/ReadFile/CloseFile
  The ReadFile() does not allocate any memory for the file content.
  The caller of OpenFile() MUST allocate necessary memory before
  calling ReadFile().

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-05-23 15:53:03 -07:00
Aiden Park 51b69d447b
[PartitionLib] Added ClosePartitions to clean-up partition data (#167)
The FindPartitions() allocates memory for PART_BLOCK_DEVICE instance.
This allocated memory needs to be de-allocated if no more necessary
to avoid memory leak.

TBD: Current partition info needs to be cleared before going to next
boot option.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-05-22 09:03:41 -07:00
James Gutbub c67e5e2955 Add HobListPtr to pre-OS payload param struct
It might be useful for the pre-OS payload/checker
to have a handle to the HOB list data for additional
support or data checking that the HOB list contains.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-05-14 12:00:39 -07:00
Maurice Ma 9742830d0e Enhance GRUB config file parser
Current GRUB config parser can only handle UNIX EOL style. For DOS
EOL style config file, an extra '\r' will be left at the line end
which might cause failure for initrd file loading due to incorrect
file name string. This patch enhanced the GRUB config file parser
to handle both UNIX and DOS EOL style.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-05-09 17:47:35 -07:00
James Gutbub e19dbfbf84 Update the pre-OS payload/checker parameter
For the pre-OS payload/checker pass in a parameter
that contains additional information for heap space,
heap address, and additional CPU registers that may
need to be set before the pre-OS payload/checker
passes control to the OS.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-04-30 15:54:39 -07:00
Maurice Ma 3c8f71a16c Enhance error message print for OsLoader
This patch added some additional error message print during the
boot media initializtion and file loading. It makes it easier to
identify issues in case of failure.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-19 10:43:44 -07:00
James Gutbub 0721b7c3d4 Add pre-OS checker support
Some OSes may require a pre-OS checker executable
to run before actually jumping to the OS. Add
support for this pre-OS checker loading & execution
as part of the OS Loader payload when it is compiled
as an FV and when ENABLE_PRE_OS_CHECKER option is
enabled in BoardConfig.py (per the following command):

SblBuild.py build <plat> -p OsLoader.Fv:LLDR:Lz4

The pre-OS checker entry point takes in a single
parameter which provides the CPU boot state that
should be loaded once jumping into the OS for the
pre-OS checker to launch after it finishes execution
(e.g. pre-OS checker does not return to Slim Bootloader).

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-04-15 14:16:03 -07:00
Guo Dong 5c041c0fe1 Clean up graphics HOBs
Removing the HOB defined by SBL to use generic HOBs from EDK2.
Update GraphicsLib for above HOB change.
Update osloader and multibootLib for hob change.
update APL and Qemu platform for hob change.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-04-10 10:23:58 -07:00
Maurice Ma f6c1b690c2 Disable deprecated EDKII API interfaces
This patch enabled DISABLE_NEW_DEPRECATED_INTERFACES build option by
default so that the deprecated APIs cannot be used in SBL source tree.
It is to enhance the coding for security.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-14 11:26:03 -07:00
Maurice Ma cc21783e0d Allow more flexible config.cfg format
Since grub.cfg is already supported in SBL. It makes sense to support
the similar syntax in config.cfg. This patch enabled config.cfg to
follow grub.cfg format to provide multiple boot options. The old
config.cfg format will still be supported. This patch also added
support for single/double quote around boot menu entry name.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-05 07:44:50 -07:00
Maurice Ma d397299797 Add GRUB config file support to boot Ubuntu
This patch added a simple parser for grub.cfg to make it easy to boot
Ubuntu ISO image using OsLoader payload. Without it, it is required to
copy vmlinuz/initrd to root directory and create a config.cfg to list
the kernel boot command line in order to boot the ISO image. This patch
makes it possible to boot the original Ubuntu ISO (16.04 or 18.04)
directly. It provides better user experience for people who wants to
try out SBL.

Please note, same as before, when verified boot is enabled, only debug
build will support this feature. Release build will disable this feature
due to security concern, please use IAS image boot mechnism instead.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-02-28 12:42:44 -08:00
Subash Lakkimsetti 5e1174fc67 Security Flags updates to LOADER_PLATFORM_INFO
LOADER_GLOBAL_DATA.LdrFeatures is updated in early stages and
subsequent stages could use these flags.

LOADER_PLATFORM_INFO.LdrFeatures is used to for feature updates
and this need to be checked by loader and payloads.

LOADER_PLATFORM_INFO.HwState for Hw supported features as
Boot guard profiles.

Signed-off-by: Subash Lakkimsetti <subashx.lakkimsetti@intel.com>
2019-02-25 10:45:39 -07:00
Maurice Ma 5f5c14b10a Enable UEFI payload boot from IAS image
This is a feature implementation to enabled chained payloads loading
for UEFI. Current SBL boot flow requires UEFI payload to be built in
flash in order to boot UEFI payload. However, for convenience, if
somebody just wants to try UEFI payload, it is better to allow them to
chain-loading the UEFI payload from media devices such as USB, SATA, etc,
and then boot to UEFI payload directly. This patch enabled this feature.
The new supported boot flow is:  SBL->OsLoader->UefiPayload->OS. The
same applies to other ELF/PE32 based other payloads.

To do this the UEFI payload needs to be packed into IAS image using
iasimage script. The command line is as below:
  python iasimage.py create -d TestSigningIasPrivateKey.pem UefiPld.fd
         -o iasimage.bin -i 0x30000
Please use the latest iasimage script from
  http://github.com/intel/iasimage

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-01-31 16:01:48 -08:00
Guo Dong edc112328c Enhance USB keyboard support
Make USB keyboard not depend on OS boot option.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-01-03 14:23:14 -08:00
Aiden Park aabfe786a6
Fix gcc compile errors (#43)
There are 'uninitialized' errors and size exceed error in PAYLOAD
with old gcc versions. This change has been verified with gcc-4.8,
gcc-5, gcc-7 and gcc-8 on Ubuntu 18.04 LTS.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2018-11-15 09:39:16 -08:00
Guo Dong cd9edfdd8b Add Device table
Update core code to support device table.
Updated boot option to consume device table.
Update firmware update to consume device table.
Update shell command on boot option changes.
Add device table for APL and Qemu.
Remove unnecessary code.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2018-11-12 09:38:59 -07:00
Aiden Park 76db3e9714 Support ELF format payload
In order to support ELF format payload in Stage2, ElfLib is separated
from MultibootLib.

Additionally,
- Load ONLY Executable/Loadable segments
- Keep LoadElfSymtab function for future use
- Mark ELF syms flag as 'not supported' in MultibootInfo

Change-Id: Iec1ca6770ffeff9222b71327216cc6176ea1e925
Signed-off-by: Aiden Park <aiden.park@intel.com>
2018-10-30 17:41:41 -07:00
Borgerson, Matthew A 2255bc10b0 Enable basic framebuffer text console output
This patch simplifies the GraphicsLib code and adds an abstraction layer
for printing to a virtual "console," through the familier
ConsoleWrite(buffer, len) style function call.

ConsoleWrite can be configured to output to either the serial port, or
the display framebuffer, or both. This primarily enables the command
shell to be used with a display and keyboard.

Signed-off-by: Borgerson, Matthew A <matthew.a.borgerson@intel.com>
2018-10-25 19:25:44 -07:00
Maurice Ma 09f8270825 Add USB input console support
This patch implemented USB keyboard library and added it as an
input console device. It can be enabled by setting BIT1 in
self.CONSOLE_IN_DEVICE_MASK in BoardConfig.py. By default, it
will be disabled for performance and size consideration.

Test has been done on APL Leafhill board. USB keyboard can work
in Shell.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2018-10-09 12:56:58 -07:00
Maurice Ma c6999f497a Initial check-in for Slim Bootloader source 2018-09-13 16:11:07 -07:00