From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKp3Z-0004zU-U0 for qemu-devel@nongnu.org; Mon, 09 Feb 2015 09:11:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKp3W-0000DW-JL for qemu-devel@nongnu.org; Mon, 09 Feb 2015 09:11:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKp3W-0000D3-Ck for qemu-devel@nongnu.org; Mon, 09 Feb 2015 09:11:18 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t19EBHwD006789 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 9 Feb 2015 09:11:17 -0500 Message-ID: <54D8C002.4090808@redhat.com> Date: Mon, 09 Feb 2015 16:11:14 +0200 From: Marcel Apfelbaum MIME-Version: 1.0 References: <1423490395-22054-1-git-send-email-imammedo@redhat.com> <1423490395-22054-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1423490395-22054-2-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 1/3] acpi: update RSDP on guest access List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: mst@redhat.com, marcel.a@redhat.com On 02/09/2015 03:59 PM, Igor Mammedov wrote: > From: "Michael S. Tsirkin" > > RSDT offset can change across reboots and that makes > immutable RSDP, which is build at startup, point to > incorrect place in ACPI table blob. That results in > BIOS corrupting tables and guest OS failing to find > ACPI tables. > We really should have put it in a ROM region, but > we can't change that for old machine types, > let's just set the callback and update it explicitly. > > Signed-off-by: Michael S. Tsirkin > Signed-off-by: Igor Mammedov > --- > v2: > * do not forget to pass build_state to callback > otherwise it's NOP. > --- > hw/i386/acpi-build.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 4944249..5b2b017 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -1526,6 +1526,7 @@ struct AcpiBuildState { > /* Is table patched? */ > uint8_t patched; > PcGuestInfo *guest_info; > + void *rsdp; > } AcpiBuildState; > > static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) > @@ -1660,8 +1661,6 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) > > /* We'll expose it all to Guest so we want to reduce > * chance of size changes. > - * RSDP is small so it's easy to keep it immutable, no need to > - * bother with alignment. > * > * We used to align the tables to 4k, but of course this would > * too simple to be enough. 4k turned out to be too small an > @@ -1733,6 +1732,7 @@ static void acpi_build_update(void *build_opaque, uint32_t offset) > > memcpy(qemu_get_ram_ptr(build_state->table_ram), tables.table_data->data, > build_state->table_size); > + memcpy(build_state->rsdp, tables.rsdp->data, acpi_data_len(tables.rsdp)); > > cpu_physical_memory_set_dirty_range_nocode(build_state->table_ram, > build_state->table_size); > @@ -1805,11 +1805,14 @@ void acpi_setup(PcGuestInfo *guest_info) > tables.tcpalog->data, acpi_data_len(tables.tcpalog)); > > /* > - * RSDP is small so it's easy to keep it immutable, no need to > - * bother with ROM blobs. > + * Though RSDP is small, its contents isn't immutable, so > + * update it along with the rest of tables on guest access. > */ > - fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE, > - tables.rsdp->data, acpi_data_len(tables.rsdp)); > + fw_cfg_add_file_callback(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE, > + acpi_build_update, build_state, > + tables.rsdp->data, acpi_data_len(tables.rsdp)); > + > + build_state->rsdp = tables.rsdp->data; > > qemu_register_reset(acpi_build_reset, build_state); > acpi_build_reset(build_state); > Reviewed-by: Marcel Apfelbaum