diff --git a/Documentation/drivers/smmstorev2.md b/Documentation/drivers/smmstorev2.md index cf714835a5..b29ffa886f 100644 --- a/Documentation/drivers/smmstorev2.md +++ b/Documentation/drivers/smmstorev2.md @@ -74,19 +74,30 @@ has to read the coreboot table with tag `0x0039`, containing: struct lb_smmstorev2 { uint32_t tag; uint32_t size; - uint32_t num_blocks; /* Number of writeable blocks in SMM */ - uint32_t block_size; /* Size of a block in byte. Default: 64 KiB */ - uint32_t mmap_addr; /* MMIO address of the store for read only access */ - uint32_t com_buffer; /* Physical address of the communication buffer */ - uint32_t com_buffer_size; /* Size of the communication buffer in byte */ - uint8_t apm_cmd; /* The command byte to write to the APM I/O port */ - uint8_t unused[3]; /* Set to zero */ + uint32_t num_blocks; /* Number of writable blocks in SMM */ + uint32_t block_size; /* Size of a block in byte. Default: 64 KiB */ + uint32_t mmap_addr_deprecated; /* 32-bit MMIO address of the store for read only access. + Prefer 'mmap_addr' for new software. + Zero when the address won't fit into 32-bits. */ + uint32_t com_buffer; /* Physical address of the communication buffer */ + uint32_t com_buffer_size; /* Size of the communication buffer in bytes */ + uint8_t apm_cmd; /* The command byte to write to the APM I/O port */ + uint8_t unused[3]; /* Set to zero */ + uint64_t mmap_addr; /* 64-bit MMIO address of the store for read only access. + Introduced after the initial implementation. Users of + this table must check the 'size' field to detect if its + written out by coreboot. */ }; ``` The absence of this coreboot table entry indicates that there's no SMMSTOREv2 support. +`mmap_addr` is an optional field added after the initial implementation. +Users of this table must check the size field to know if it's written by coreboot. +In case it's not present 'mmap_addr_deprecated' is to be used as the SPI ROM MMIO +address and it must be below 4 GiB. + ### Blocks The SMMSTOREv2 splits the SMMSTORE FMAP partition into smaller chunks diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index 78dbe8ef4c..7860a413ce 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -539,11 +539,17 @@ struct lb_smmstorev2 { uint32_t size; uint32_t num_blocks; /* Number of writable blocks in SMM */ uint32_t block_size; /* Size of a block in byte. Default: 64 KiB */ - uint32_t mmap_addr; /* MMIO address of the store for read only access */ + uint32_t mmap_addr_deprecated; /* 32-bit MMIO address of the store for read only access. + Prefer 'mmap_addr' for new software. + Zero when the address won't fit into 32-bits. */ uint32_t com_buffer; /* Physical address of the communication buffer */ uint32_t com_buffer_size; /* Size of the communication buffer in bytes */ uint8_t apm_cmd; /* The command byte to write to the APM I/O port */ uint8_t unused[3]; /* Set to zero */ + uint64_t mmap_addr; /* 64-bit MMIO address of the store for read only access. + Introduced after the initial implementation. Users of + this table must check the 'size' field to detect if its + written out by coreboot. */ }; enum lb_tpm_ppi_tpm_version { diff --git a/src/drivers/smmstore/ramstage.c b/src/drivers/smmstore/ramstage.c index 1cbf9fb28a..507678754c 100644 --- a/src/drivers/smmstore/ramstage.c +++ b/src/drivers/smmstore/ramstage.c @@ -28,6 +28,10 @@ void lb_smmstorev2(struct lb_header *header) store->size = sizeof(*store); store->com_buffer = (uintptr_t)cbmem_entry_start(e); store->com_buffer_size = cbmem_entry_size(e); + if (info.mmap_addr < 4ULL * GiB) + store->mmap_addr_deprecated = info.mmap_addr; + else + store->mmap_addr_deprecated = 0; store->mmap_addr = info.mmap_addr; store->num_blocks = info.num_blocks; store->block_size = info.block_size; diff --git a/src/include/smmstore.h b/src/include/smmstore.h index 595fe8b29b..4ee4c55c75 100644 --- a/src/include/smmstore.h +++ b/src/include/smmstore.h @@ -69,7 +69,7 @@ struct smmstore_params_init { struct smmstore_params_info { uint32_t num_blocks; uint32_t block_size; - uint32_t mmap_addr; + uint64_t mmap_addr; } __packed; /*