coreboot/src
Angel Pons 967753f0d8 soc/intel/common: Prevent SMI storm when setting SPI WPD bit
From Skylake/Sunrise Point onwards, there are two BIOS_CNTL registers:
one on the LPC/eSPI PCI device, and another on the SPI PCI device. When
the WPD bit changes from 0 to 1 and the LE bit is set, the PCH raises a
TCO SMI with the BIOSWR_STS bit set. However, the BIOSWR_STS bit is not
set when the TCO SMI comes from the SPI or eSPI controller instead, but
a status bit in the BIOS_CNTL register gets set. If the SMI cause is not
handled, another SMI will happen immediately after returning from the
SMI handler, which results in a deadlock.

Prevent deadlocks by clearing the SPI synchronous SMI status bit in the
SMI handler. When SPI raises a synchronous SMI, the TCO_STS bit in the
SMI_STS register is continously set until the SPI synchronous SMI status
bit is cleared. To not risk missing any other TCO SMIs, do not clear the
TCO_STS bit again in the same SMI handler invocation. If the TCO_STS bit
remains set when returning from SMM, another SMI immediately happens and
clears the TCO_STS bit, handling any pending events.

SPI can also generate asynchronous SMIs when the WPD bit is cleared and
one attempts to write to flash using SPI hardware sequencing. This patch
does not account for SPI asynchronous SMIs, because they are disabled by
default and cannot be enabled once the BIOS Interface Lock-Down bit in
the BIOS_CNTL register has been set, which coreboot already does. These
asynchronous SMIs set the SPI_STS bit of the SMI_STS register. Clearing
the SPI asynchronous SMI source should be done inside the SPI_STS SMI
handler, which is currently not implemented. All of this goes out of the
scope of this patch, and is currently not necessary anyway.

This patch does not handle eSPI because I cannot test it, and knowing if
a board uses LPC or eSPI from common code is currently not possible, and
this is beyond the scope of what this commit tries to achieve (fix SPI).

Tested on HP 280 G2, no longer deadlocks when SMM BIOS write protection
is on. Write protection will be enforced in a follow-up.

Change-Id: Iec498674ae70f6590c33a6bf4967876268f2b0c8
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50754
Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-04-06 18:57:30 +00:00
..
acpi ACPI: Add SATC structure for DMAR table 2021-03-28 16:03:21 +00:00
arch arch/x86: Provide readXp/writeXp helpers in arch/mmio.h 2021-04-06 07:10:40 +00:00
commonlib mem_pool: Track the last two allocations (not just one) 2021-04-06 07:50:05 +00:00
console console/vtxprintf.c: Add missing <types.h> 2021-02-16 08:15:26 +00:00
cpu cpu/x86/smm: Fix SMM start address passing 2021-03-24 15:36:36 +00:00
device device/i2c_bus.c: Correct code style 2021-04-06 07:02:47 +00:00
drivers drivers/i2c/nau8825: Support nau8825 for ACPI GPIO descriptors 2021-04-06 07:09:02 +00:00
ec ec/system76/ec: Add OLED screen toggle 2021-02-27 09:38:19 +00:00
include soc/intel/alderlake: Add LPC and IGD device Ids for Alderlake M 2021-04-06 07:51:05 +00:00
lib decompressor: Add CBFS_VERIFICATION support 2021-04-06 07:49:15 +00:00
mainboard Revert "mb/google/guybrush: Disable GFX" 2021-04-06 16:08:39 +00:00
northbridge nb/intel/i440bx: Enable bootblock console 2021-04-06 07:11:39 +00:00
security verstage: Add debug print when returning from verstage 2021-04-06 07:49:43 +00:00
soc soc/intel/common: Prevent SMI storm when setting SPI WPD bit 2021-04-06 18:57:30 +00:00
southbridge arch/x86: Provide readXp/writeXp helpers in arch/mmio.h 2021-04-06 07:10:40 +00:00
superio acpi/acpigen.h: Add more intuitive AML package closing functions 2021-03-22 11:21:55 +00:00
vendorcode vendorcode/intel/FSP2_0/CPX-SP: Declare struct RC_VERSION non-packed 2021-04-06 07:02:18 +00:00
Kconfig southbridge: Ensure common Kconfig gets included last 2021-02-18 10:11:39 +00:00