U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Holmes-Mitra <dholmesm@google.com>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	 Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: [PATCH 3/4] qfw/acpi: Skip absent ACPI bloblist and size from table-loader
Date: Thu, 03 Dec 2026 02:21:11 GMT	[thread overview]
Message-ID: <20261203022028.04-03-dholmesm@google.com> (raw)
In-Reply-To: <20261203022028.04-00-dholmesm@google.com>

When QEMU is launched with ACPI disabled (for example -M virt,acpi=off),
etc/table-loader is not exposed over fw_cfg, yet evt_write_acpi_tables()
still created an empty BLOBLISTT_ACPI_TABLES entry.

In addition, when CONFIG_BLOBLIST_TABLES is enabled, all ALLOCATE files
(such as 128 KiB etc/acpi/tables plus optional TPM log and RSDP) are
placed into the bloblist, exceeding the fixed 64 KiB reservation, while
a fixed 256 KiB reservation overflows smaller CONFIG_BLOBLIST_SIZE_RELOC
budgets (such as 0x20000 or 0x40000).

Check for etc/table-loader before creating BLOBLISTT_ACPI_TABLES, keep
the 64 KiB reservation when CONFIG_BLOBLIST_TABLES is disabled, and sum
the aligned ALLOCATE entry sizes from etc/table-loader when enabled.

Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
 drivers/misc/qfw_acpi.c | 53 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/qfw_acpi.c b/drivers/misc/qfw_acpi.c
index 580bef4adb..9553d89e06 100644
--- a/drivers/misc/qfw_acpi.c
+++ b/drivers/misc/qfw_acpi.c
@@ -326,13 +326,62 @@ void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt,
 }
 
 #ifndef CONFIG_X86
+static u32 qfw_acpi_blob_size(struct udevice *dev, struct fw_file *loader)
+{
+	struct bios_linker_entry *entries;
+	u32 size, total = 0;
+	int i;
+
+	if (!IS_ENABLED(CONFIG_BLOBLIST_TABLES))
+		return SZ_64K;
+
+	size = be32_to_cpu(loader->cfg.size);
+	entries = malloc(size);
+	if (!entries)
+		return SZ_64K;
+
+	qfw_read_entry(dev, be16_to_cpu(loader->cfg.select), size, entries);
+	for (i = 0; i < size / sizeof(*entries); i++) {
+		struct bios_linker_entry *entry = entries + i;
+		struct fw_file *file;
+		u32 align;
+
+		if (le32_to_cpu(entry->command) !=
+		    BIOS_LINKER_LOADER_COMMAND_ALLOCATE)
+			continue;
+		file = qfw_find_file(dev, entry->alloc.file);
+		if (!file)
+			continue;
+		align = le32_to_cpu(entry->alloc.align);
+		if (align && !(align & (align - 1))) {
+			if (align > SZ_4K)
+				total += align - SZ_4K;
+			total = ALIGN(total, align);
+		}
+		total += be32_to_cpu(file->cfg.size);
+	}
+	free(entries);
+
+	return max_t(u32, ALIGN(total, SZ_4K), SZ_64K);
+}
+
 static int evt_write_acpi_tables(void)
 {
+	struct udevice *dev;
+	struct fw_file *loader;
 	ulong addr, end;
 	void *ptr;
 
-	/* Reserve 64K for ACPI tables, aligned to a 4K boundary */
-	ptr = bloblist_add(BLOBLISTT_ACPI_TABLES, SZ_64K, 12);
+	if (qfw_get_dev(&dev) || qfw_read_firmware_list(dev))
+		return 0;
+
+	loader = qfw_find_file(dev, "etc/table-loader");
+	if (!loader)
+		return 0;
+
+	/* Reserve space for ACPI tables, aligned to a 4K boundary */
+	ptr = bloblist_add(BLOBLISTT_ACPI_TABLES,
+			   qfw_acpi_blob_size(dev, loader), 12);
 	if (!ptr)
 		return -ENOBUFS;
 	addr = map_to_sysmem(ptr);
-- 
2.56.1.911.g883d8bcb20-goog


  parent reply	other threads:[~2026-12-03  5:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:21 [PATCH 0/4] qfw/acpi & efi_loader: Fix linker cleanup, RSDP bounds, and absent/offset ACPI handling Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 1/4] qfw/acpi: Do not free non-heap addresses on linker error Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 2/4] qfw/acpi: Guard ACPI 1.0 RSDP bounds and NULL lookup Dan Holmes-Mitra
2026-12-03  2:21 ` Dan Holmes-Mitra [this message]
2026-12-03  2:21 ` [PATCH 4/4] efi_loader: Handle offset or absent runtime ACPI tables Dan Holmes-Mitra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203022028.04-03-dholmesm@google.com \
    --to=dholmesm@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox