Skip to content

Msi stm - #955

Open
miczyg1 wants to merge 22 commits into
dasharo-25.12from
msi_stm
Open

Msi stm#955
miczyg1 wants to merge 22 commits into
dasharo-25.12from
msi_stm

Conversation

@miczyg1

@miczyg1 miczyg1 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

No description provided.

miczyg1 added 22 commits July 1, 2026 12:19
Compress the STM binary in CBFS to save space.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Override the sizes of SMM regions when STM is enabled to provide
known working defaults.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Pass STM Kconfig value to EDK2 to enable the STM option visibility
in the setup menu.

Upstream-Status: Inappropriate [Dasharo downstream]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Load STM conditionally based on the variable state.

Upstream-Status: Inappropriate [Dasharo downstream]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Add support for 64bit mode coreboot launching 32bit FSP. Certain
definitions and types have to be overridden to make coreboot compile
in 64bit mode while FSP is purely 32bit mode.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Synchronize the header copy in coreboot with its original source in
STM submodule. Certain structures have different definitions, thus
using sizeof can lead to different results. For example the
PCI_CFG_RANGE resource passed from coreboot has incorrect size
of 16 bytes, instead of expected 22 bytes. An error can be seen in STM:

(STM) Resource invalid (FromMle - 0, ForLogging - 0):
(STM) ResourceNode:
(STM) PCI_CFG_RANGE:
(STM)   RscType       : 00000005
(STM)   RscLength     : 0010
(STM)   ReturnStatus  : 0001
(STM)   IgnoreResource: 0000
(STM)   RWAttributes  : 0003
(STM)   Base          : 0000
(STM)   Length        : 1000
(STM)   OriginatingBus: 00
(STM)   LastNodeIndex : 00
(STM)   Type          : 04
(STM)   Subtype       : 00
(STM)   Length        : 0000
(STM)   PciDevice     : 00
(STM)   PciFunction   : 20
(STM) 0 LaunchBack - ValidateBiosResourceList fail!

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
The flash resides at 0xff000000 and spands 16MB, not at 0xfe000000.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Use uintptr_t instead of fixed length variabels where appropriate
to compile STM code in 64bit mode.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Create page tables for whole memory from STM. Previously, only the
first 4GB of memory were covered with pages causing page faults in STM
when the VMCS from host OS allocated it above 4G:

(STM) InitPe - PE initialization complete
(STM) 0 SmiVmcsPtr - 000000004BD4E000
(STM) 0 SmmVmcsPtr - 000000004BD4F000
(STM) 0 CurrentVmcs - 00000001185C0000 VmcsSize 1000
(STM) STM Page Fault at 0x00000001185C0000, Rip 0x000000004B14B45E
    Cr2 0x00000001185C0000

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Make the errors unique so that debugging is easier when something
goes wrong.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Allocate additional page for communication buffer so that the arguments
can be passed in the communication buffer offset equal to the block
size. In that case the SMI handler does not need to access arbitrary
memory allocated by the SMMSTORE caller. Instead the caller may place
the arguments in the same communication buffer.

When STM is enabled, it helps to restrict the memory accessed by
SMMSTORE handler. Otherwise, an EPT violation handler will prevent
access the the caller's	memory buffer with arguments.

TEST=EDK2 SMMSTORE library places the arguments in the communication
buffer and the STM no longer raises EPT violation when the SMMSTORE
SMI handler trie to access the parameters passed by the	caller.

Upstream-Status: Pending

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Describe all resources used by coreboot SMI handlers to avoid EPT
violations in STM.

TEST=Run STM on MSI PRO Z790-P with DEBUG_SMI and SMMSTORE, try to set
BootNext variable via efibootmgr under Linux with running STM module.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Do not reallocate SPI MMIO. SPI MMIO base is needed for flash access
in SMM, so STM needs to know the location of SPI registers. However,
STM is loaded before coreboot allocator runs on FSP platforms. So it is
not possible to provide correct SPI MMIO base address to STM.

To workaround that problem, report the SPI MMIO as fixed resource, so
that coreboot does not move it.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Describe resource specific to the mainboard that are used by
board's SMI handlers.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Fix check of TTYS0_BASE to allwo debug builds when serial port
base is set for STM.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signal STM to propagate SMRAM save state changes back to the
interrupted guest VMCS on RSM. Required for return values written to
EAX (e.g. SMMSTORE result) to be visible in OS context after RSM.
Without this bit set, ReadSyncSmmStateSaveArea() in the STM runtime
skips the sync entirely, so the guest sees stale pre-SMI register
values instead of the handler's return code.

TEST=Use efibootmgr to set timeout in Linux with STM launched by
stm_linux_module on MSI PRO Z790-P.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
…st GCC

Use coreboot's toolchain instead of host GCC to ensure reproducibility.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Add necessary parameters to Cmake to use coreboot's toolchain to
compile STM.

Now that STM is built with coreboot toolchain, the reproducibility
warning can be removed.

Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Update EDK2 revision to include STM option.

Upstream-Status: Inappropriate [Dasharo downstream]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Include STM in the builds by default. To allow the STM to print to
cbmem only, use 0xF0 as the serial port base. This port is unused
and prevents STM CMAKE files from selecting the default 0x3f8 base
for serial. Otherwise, one has to build a release version of STM
without debugging.

Upstream-Status: Inappropriate [custom configs]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Upstream-Status: Inappropriate [custom configs]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Upstream-Status: Inappropriate [custom configs]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant