Go to file
Lennert Buytenhek 644b8474da Fix Stage1 StackTop computation for Ia32, and align stack to 16 bytes
Adding the following bit of debug code to DetectUsedStackBottom() in
BootloaderCommonPkg/Library/BootloaderCommonLib/BootloaderCommonLib.c:

@@ -290,7 +290,10 @@ DetectUsedStackBottom (
 {
   UINT32  *StackBot;

+  DEBUG ((DEBUG_INFO, "StackTop is %x\n", StackTop));
   StackBot = (UINT32 *) ((StackTop - StackSize) & ~ (sizeof (UINTN) - 1));
+  DEBUG ((DEBUG_INFO, "StackBot is %p %x\n", StackBot, *StackBot));
   ASSERT (*StackBot == STACK_DEBUG_FILL_PATTERN);

   while ((UINT32)(UINTN)StackBot < StackTop) {

shows this for the Stage1 stack on qemu X64, as expected:

	StackTop is 2000
	StackBot is 0 5AA55AA5

but it shows this on qemu Ia32, which appears to be incorrect:

	StackTop is 2004
	StackBot is 4 5AA55AA5

This Stage1 StackTop mismatch on Ia32 seems to be caused by the setup
code in BootloaderCorePkg/Stage1A/Ia32/SecEntry.nasm pushing only a single
32-bit word onto the stack for the 'Status' field of STAGE1A_ASM_PARAM,
while that field is actually a 64-bit field, which causes this line in
BootloaderCorePkg/Stage1A/Stage1A.c to compute a stack top address that
is off by 4 bytes:

  StackTop = (UINT32)(UINTN)Params + sizeof (STAGE1A_ASM_PARAM);

This patch makes the Ia32 Stage1A setup code push an extra 32-bit
word onto the stack before calling SecStartup, which fixes the Stage1
StackTop computation.

While we are at it, let's push another dummy word onto the stack in
the Stage1A setup code to make the Stage1A stack be 16-byte aligned,
like what is already the case for X64, so that we follow Version 1.0
of the System V Intel386 ABI supplement, and satisfy any expectations
our compiler may have regarding stack alignment.

Also add a comment to both the Ia32 and X64 Stage1A setup code to
remind the reader that the structure we build on the stack before
calling SecStartup has to match the layout of STAGE1A_ASM_PARAM.

Signed-off-by: Lennert Buytenhek <buytenh@arista.com>
2021-11-19 13:41:44 -08:00
.azurepipelines Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
BaseTools PatchCheck: Skip more files that contain non-standard whitespace 2021-11-10 13:15:04 -08:00
BootloaderCommonPkg Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
BootloaderCorePkg Fix Stage1 StackTop computation for Ia32, and align stack to 16 bytes 2021-11-19 13:41:44 -08:00
IntelFsp2Pkg Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
Licenses Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
MdePkg Align the Ia32 Stage1B/Stage2 stack to 16 bytes 2021-11-19 13:41:33 -08:00
PayloadPkg Add a PCD to set RTCM RSVD SIZE 2021-11-15 19:05:05 -08:00
Platform Add common GPIO payload selection CFG 2021-11-18 13:49:44 -07:00
Silicon PatchCheck: Skip more files that contain non-standard whitespace 2021-11-10 14:28:17 -08:00
.gitattributes Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
.gitignore Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
BuildLoader.py Add a PCD to set RTCM RSVD SIZE 2021-11-15 19:05:05 -08:00
CODEOWNERS Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
Dockerfile Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
LICENSE Use LF line endings in the repository 2021-11-10 12:46:42 -08:00
README.rst Use LF line endings in the repository 2021-11-10 12:46:42 -08:00

README.rst

Slim Bootloader
================

**Welcome to the Slim Bootloader project!**

Slim Bootloader is an open-source boot firmware solution, built from the
ground up to be secure, lightweight, and highly optimized while leveraging
robust tools and libraries from the [EDK II](https://www.tianocore.org/edk2/)
framework.

What is a Bootloader?
---------------------
Just like a typical [BIOS](https://en.wikipedia.org/wiki/BIOS), Slim Bootloader
is the piece of software responsible for initializing the core hardware
components of the system when it is powered on, followed by the loading and
launching of the desired operating system.

Slim Bootloader offers the flexibility for OEMs, device manufacturers, and hobbyists
to isolate, configure, and optimize for the the specific requirements of the system
thereby achieving unparalleled boot performance and minimizing firmware footprint.

Supported Platforms
-------------------
Please visit [Supported Hardware](https://slimbootloader.github.io/supported-hardware/index.html) page for a list of platforms supported by Slim Bootloader.

Platform CI Build Status
------------------------

============================= ============= ============= ============= =============
 Toolchain                    DEBUGx86      RELEASEx86    DEBUGx64      RELEASEx64
============================= ============= ============= ============= =============
QEMU_Win_VS2019               |_unknown|    |_unknown|    |_unknown|    |_unknown|
QEMU_Lin_GCC5                 |qem_l32d|    |_unknown|    |_unknown|    |qem_l64r|
APL_Win_VS2019                |apl_w32d|    |_unknown|    |_unknown|    |apl_w64r|
APL_Lin_GCC5                  |_unknown|    |_unknown|    |apl_l64d|    |_unknown|
CFL_Win_VS2019                |_unknown|    |cfl_w32r|    |cfl_w64d|    |_unknown|
CFL_Lin_GCC5                  |_unknown|    |_unknown|    |_unknown|    |cfl_l64r|
CMLV_Win_VS2019               |_unknown|    |cmlv_w32r|   |cmlv_w64d|   |_unknown|
CMLV_Lin_GCC5                 |_unknown|    |_unknown|    |_unknown|    |cmlv_l64d|
CML_Win_VS2019                |_unknown|    |cml_w32r|    |cfl_w64d|    |_unknown|
CML_Lin_GCC5                  |cml_l32d|    |_unknown|    |_unknown|    |_unknown|
EHL_Win_VS2019                |_unknown|    |ehl_w32r|    |ehl_w64d|    |_unknown|
EHL_Lin_GCC5                  |ehl_l32d|    |_unknown|    |_unknown|    |_unknown|
TGL_Win_VS2019                |_unknown|    |tgl_w32r|    |tgl_w64d|    |_unknown|
TGL_Lin_GCC5                  |tgl_l32d|    |_unknown|    |_unknown|    |_unknown|
============================= ============= ============= ============= =============

Getting Started
---------------
Documentation for compiling, using, and extending Slim Bootloader can be found
[here](https://slimbootloader.github.io/).

Mailing List
--------------
You can subscribe to our mailing list for questions or share your learnings:
https://groups.io/g/slimbootloader

Topic Archive: https://groups.io/g/slimbootloader/topics

License
-------
Slim Bootloader is released under the terms of the BSD-2-Clause Plus Patent License.
Please see the `LICENSE` file for the full terms of the license.

Slim Bootloader may include other Open Source Software licensed pursuant to license agreement(s)
identified in the applicable source code file(s) and/or file header(s).

.. |_unknown| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20UNKNOWN
.. |qem_l32d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=QEMU
.. |qem_l64r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Linux&configuration=Linux%20QEMU_X64_RELEASE
.. |apl_w32d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20APL_X86_DEBUG
.. |apl_w64r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20APL_X64_RELEASE
.. |apl_l64d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Linux&configuration=Linux%20APL_X64_DEBUG
.. |cfl_w32r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20CFL_X86_RELEASE
.. |cfl_w64d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20CFL_X64_DEBUG
.. |cfl_l64r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Linux&configuration=Linux%20CFL_X64_RELEASE
.. |cmlv_w32r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20CMLV_X86_RELEASE
.. |cmlv_w64d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20CMLV_X64_DEBUG
.. |cmlv_l64d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Linux&configuration=Linux%20CMLV_X64_DEBUG
.. |cml_w32r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20CML_X86_RELEASE
.. |cml_w64d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20CML_X64_DEBUG
.. |cml_l32d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Linux&configuration=Linux%20CML_X86_DEBUG
.. |tgl_w32r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20TGL_X86_RELEASE
.. |tgl_w64d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20TGL_X64_DEBUG
.. |tgl_l32d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Linux&configuration=Linux%20TGL_X86_DEBUG
.. |ehl_w32r| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20EHL_X86_RELEASE
.. |ehl_w64d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Windows&configuration=Windows%20EHL_X64_DEBUG
.. |ehl_l32d| image:: https://dev.azure.com/slimbootloader/slimbootloader/_apis/build/status/slimbootloader.slimbootloader?branchName=master&jobName=Linux&configuration=Linux%20EHL_X86_DEBUG