From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH RFC 2/3] acpi: add tables as ROM so they are migrated
Date: Thu, 13 Jun 2013 17:29:52 +0300 [thread overview]
Message-ID: <1371133655-10186-3-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1371133655-10186-1-git-send-email-mst@redhat.com>
As we are going to very likely change ACPI tables across QEMU versions,
cross-verion migration will be a pain.
Register the tables as a ROM: this way they are migrated, same as BIOS
code.
Since size is going to likely change, too, round it up to a multiple of
1MByte to avoid too much churn there.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/acpi-build.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 43e4988..911c913 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -35,6 +35,7 @@
#include "hw/nvram/fw_cfg.h"
#include "hw/i386/bios-linker-loader.h"
#include "hw/pci/pci_bus.h"
+#include "hw/loader.h"
#define ACPI_BUILD_APPNAME "Bochs"
#define ACPI_BUILD_APPNAME6 "BOCHS "
@@ -933,6 +934,28 @@ build_rsdp(GArray *linker, unsigned rsdt)
return rsdp_table;
}
+static void acpi_add_rom_blob(PcGuestInfo *guest_info, GArray *blob,
+ const char *name, unsigned align)
+{
+ MemoryRegion *mr = g_malloc(sizeof(*mr));
+
+ /* Align size to multiple of given size. This reduces the chance
+ * we need to change size in the future (breaking cross version migration).
+ */
+ g_array_set_size(blob, (ROUND_UP(acpi_data_len(blob), align) +
+ g_array_get_element_size(blob) - 1) /
+ g_array_get_element_size(blob));
+ memory_region_init_ram_ptr(mr, "etc/blob-script",
+ acpi_data_len(blob), blob->data);
+ memory_region_set_readonly(mr, true);
+ vmstate_register_ram_global(mr);
+ rom_add_blob(ACPI_BUILD_TABLE_FILE, blob->data, acpi_data_len(blob),
+ -1, mr);
+
+ fw_cfg_add_file(guest_info->fw_cfg, name,
+ blob->data, acpi_data_len(blob));
+}
+
#define ACPI_MAX_ACPI_TABLES 20
void acpi_setup(PcGuestInfo *guest_info)
{
@@ -993,12 +1016,18 @@ void acpi_setup(PcGuestInfo *guest_info)
rsdp = build_rsdp(linker, rsdt);
/* Now expose it all to Guest */
- fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TABLE_FILE,
- table_data->data, table_data->len);
+ acpi_add_rom_blob(guest_info, table_data,
+ ACPI_BUILD_TABLE_FILE, 1 << 20);
+
+ acpi_add_rom_blob(guest_info, linker,
+ "etc/linker-script", TARGET_PAGE_SIZE);
+
+ /*
+ * RSDP is small so it's easy to keep it immutable, no need to
+ * bother with ROM blobs.
+ */
fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
rsdp->data, acpi_data_len(rsdp));
- fw_cfg_add_file(guest_info->fw_cfg, "etc/linker-script",
- linker->data, acpi_data_len(linker));
/* Cleanup GArray wrappers and memory if no longer used. */
bios_linker_cleanup(linker);
--
MST
next prev parent reply other threads:[~2013-06-13 14:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-13 14:29 [Qemu-devel] [PATCH RFC 0/3] qemu/acpi-build: cross migration fixes Michael S. Tsirkin
2013-06-13 14:29 ` [Qemu-devel] [PATCH RFC 1/3] loader: support for unmapped ROM blobs Michael S. Tsirkin
2013-06-13 14:29 ` Michael S. Tsirkin [this message]
2013-06-13 14:29 ` [Qemu-devel] [PATCH RFC 3/3] acpi-build: disable acpi generation for compat Michael S. Tsirkin
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=1371133655-10186-3-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).