From patchwork Wed May 7 16:16:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 346721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6FA0B14015E for ; Thu, 8 May 2014 02:20:32 +1000 (EST) Received: from localhost ([::1]:42534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi4a6-00018R-8V for incoming@patchwork.ozlabs.org; Wed, 07 May 2014 12:20:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi4Xu-0005P3-QC for qemu-devel@nongnu.org; Wed, 07 May 2014 12:18:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wi4Xp-0001rP-No for qemu-devel@nongnu.org; Wed, 07 May 2014 12:18:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi4Xp-0001rI-F4; Wed, 07 May 2014 12:18:09 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s47GI5Ao011162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 May 2014 12:18:06 -0400 Received: from redhat.com (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id s47GI3MU015413; Wed, 7 May 2014 12:18:03 -0400 Date: Wed, 7 May 2014 19:16:57 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1399479367-31336-4-git-send-email-mst@redhat.com> References: <1399479367-31336-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1399479367-31336-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , qemu-stable@nongnu.org, Anthony Liguori , TeLeMan Subject: [Qemu-devel] [PULL v2 03/11] acpi: fix tables for no-hpet configuration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org acpi build tried to add offset of hpet table to rsdt even when hpet was disabled. If no tables follow hpet, this could lead to a malformed rsdt. Fix it up. To avoid such errors in the future, rearrange code slightly to make it clear that acpi_add_table stores the offset of the following table - not of the previous one. Reported-by: TeLeMan Signed-off-by: Michael S. Tsirkin Cc: qemu-stable@nongnu.org --- hw/i386/acpi-build.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1ef8ca9..9fac589 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1416,15 +1416,16 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) /* ACPI tables pointed to by RSDT */ acpi_add_table(table_offsets, tables->table_data); build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt); - acpi_add_table(table_offsets, tables->table_data); + acpi_add_table(table_offsets, tables->table_data); build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci, guest_info); - acpi_add_table(table_offsets, tables->table_data); - build_madt(tables->table_data, tables->linker, &cpu, guest_info); acpi_add_table(table_offsets, tables->table_data); + build_madt(tables->table_data, tables->linker, &cpu, guest_info); + if (misc.has_hpet) { + acpi_add_table(table_offsets, tables->table_data); build_hpet(tables->table_data, tables->linker); } if (guest_info->numa_nodes) {