Skip to content

Commit a2577fa

Browse files
Sean-StarLabscrawfxrd
authored andcommitted
soc/intel/common/block/smm: drain sync smi around smmstore
Drain pending SPI sync SMIs before dropping write protect for SMMSTORE and once more after the command runs. This keeps a stale sync status from leaking into the next request. Change-Id: I7ba21719a6dafa926b0d5986a253da9cff52575a Signed-off-by: Sean Rhodes <sean@starlabs.systems> Reviewed-on: https://review.coreboot.org/c/coreboot/+/91726 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
1 parent 256bb69 commit a2577fa

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/soc/intel/common/block/smm/smihandler.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ __weak void mainboard_smi_espi_handler(void)
6666
/* no-op */
6767
}
6868

69+
#define SMMSTORE_SYNC_SMI_SETTLE_USEC 50
70+
#define SMMSTORE_SYNC_SMI_CLEAR_TRIES 8
71+
72+
static void smmstore_drain_sync_smi(void)
73+
{
74+
int i;
75+
76+
for (i = 0; i < SMMSTORE_SYNC_SMI_CLEAR_TRIES; i++) {
77+
if (!fast_spi_clear_sync_smi_status())
78+
return;
79+
udelay(SMMSTORE_SYNC_SMI_SETTLE_USEC);
80+
}
81+
}
82+
6983
/* Inherited from cpu/x86/smm.h resulting in a different signature */
7084
void southbridge_smi_set_eos(void)
7185
{
@@ -279,12 +293,13 @@ static void southbridge_smi_store(
279293
* bit is a must prior setting SPI_BIOS_CONTROL_WPD" bit
280294
* to avoid 3-strike error.
281295
*/
282-
fast_spi_clear_sync_smi_status();
296+
smmstore_drain_sync_smi();
283297
fast_spi_disable_wp();
284298
}
285299

286300
/* drivers/smmstore/smi.c */
287301
ret = smmstore_exec(sub_command, (void *)(uintptr_t)reg_ebx);
302+
smmstore_drain_sync_smi();
288303
save_state_ops->set_reg(RAX, node, &ret, sizeof(ret));
289304

290305
if (wp_enabled) {

0 commit comments

Comments
 (0)