arch/x86/tables: Move max ACPI table size to Kconfig

The maximum ACPI table size is currently hardcoded to 144 KiB.
When using QEMU with TPM enabled there is ~200 KiB of ACPI tables
returned by the fw_cfg interface, so in order to allow this to be
overridden by a mainboard move it to Kconfig.

This is seen when using a TPM with qemu as it will hang when
processing the fw_cfg tables.

qemu-system-x86_64 \
  -machine q35 -enable-kvm -vga virtio -serial stdio \
  -drive 'id=hd,file=disk.bin' -bios coreboot.rom \
  -chardev 'socket,id=swtpm,path=/tmp/swtpm/swtpm-sock' \
  -tpmdev 'emulator,id=tpm0,chardev=swtpm' \
  -device 'tpm-tis,tpmdev=tpm0'

Change-Id: Ib5baa8fe12cb9027a340875f1ccf5fef6f9460bd
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/39832
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Duncan Laurie 2020-03-17 18:32:54 -07:00 committed by Patrick Georgi
parent 516c0a5338
commit f02bf35e00
2 changed files with 9 additions and 4 deletions

View File

@ -322,4 +322,10 @@ config MAX_PIRQ_LINKS
table specifies links greater than 4, pirq_route_irqs will not table specifies links greater than 4, pirq_route_irqs will not
function properly, unless this variable is correctly set. function properly, unless this variable is correctly set.
config MAX_ACPI_TABLE_SIZE_KB
int
default 144
help
Set the maximum size of all ACPI tables in KiB.
endif endif

View File

@ -78,8 +78,7 @@ static unsigned long write_mptable(unsigned long rom_table_end)
static unsigned long write_acpi_table(unsigned long rom_table_end) static unsigned long write_acpi_table(unsigned long rom_table_end)
{ {
unsigned long high_table_pointer; unsigned long high_table_pointer;
const size_t max_acpi_size = CONFIG_MAX_ACPI_TABLE_SIZE_KB * KiB;
#define MAX_ACPI_SIZE (144 * 1024)
post_code(0x9c); post_code(0x9c);
@ -96,7 +95,7 @@ static unsigned long write_acpi_table(unsigned long rom_table_end)
* how far we get. * how far we get.
*/ */
high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_ACPI, high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_ACPI,
MAX_ACPI_SIZE); max_acpi_size);
if (high_table_pointer) { if (high_table_pointer) {
unsigned long acpi_start = high_table_pointer; unsigned long acpi_start = high_table_pointer;
unsigned long new_high_table_pointer; unsigned long new_high_table_pointer;
@ -104,7 +103,7 @@ static unsigned long write_acpi_table(unsigned long rom_table_end)
rom_table_end = ALIGN_UP(rom_table_end, 16); rom_table_end = ALIGN_UP(rom_table_end, 16);
new_high_table_pointer = write_acpi_tables(high_table_pointer); new_high_table_pointer = write_acpi_tables(high_table_pointer);
if (new_high_table_pointer > (high_table_pointer if (new_high_table_pointer > (high_table_pointer
+ MAX_ACPI_SIZE)) + max_acpi_size))
printk(BIOS_ERR, "ERROR: Increase ACPI size\n"); printk(BIOS_ERR, "ERROR: Increase ACPI size\n");
printk(BIOS_DEBUG, "ACPI tables: %ld bytes.\n", printk(BIOS_DEBUG, "ACPI tables: %ld bytes.\n",
new_high_table_pointer - high_table_pointer); new_high_table_pointer - high_table_pointer);