From patchwork Sat May 16 03:16:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beth Kon X-Patchwork-Id: 24228 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4G3FguF007295 for ; Sat, 16 May 2009 03:15:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755653AbZEPDPj (ORCPT ); Fri, 15 May 2009 23:15:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755435AbZEPDPj (ORCPT ); Fri, 15 May 2009 23:15:39 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:43947 "EHLO e8.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755594AbZEPDPi (ORCPT ); Fri, 15 May 2009 23:15:38 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e8.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n4G35hwE024834 for ; Fri, 15 May 2009 23:05:43 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4G3FdGl251870 for ; Fri, 15 May 2009 23:15:39 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4G3FcsN010391 for ; Fri, 15 May 2009 23:15:39 -0400 Received: from localhost.localdomain (sig-9-65-58-50.mts.ibm.com [9.65.58.50]) by d01av04.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n4G3FbcN010359; Fri, 15 May 2009 23:15:37 -0400 From: Beth Kon To: avi@redhat.com Cc: kvm@vger.kernel.org, mtosatti@redhat.com, vincent@vincent-minet.net, gleb@redhat.com, anthony@codemonkey.ws, Beth Kon Subject: [PATCH 1/2] Clean up MADT Table Creation Date: Fri, 15 May 2009 23:16:39 -0400 Message-Id: <1242443800-22686-1-git-send-email-eak@us.ibm.com> X-Mailer: git-send-email 1.5.4.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch is based on the recent patch from Vincent Minet. I split Vincent's changes into 2 patches (to separate MADT and RSDT table cleanup, as suggested by Marcelo) and added a bit to them. And to give credit where it is due, this cleanup is also related to the patch Marcelo provided when the HPET addition tripped over the same problem. (Thanks again Marcelo :-) This patch moves all the table layout calculations to the same area of acpi_bios_init. This prevents corruption problems when, in the middle of filling in the tables, the MADT table size grows. The idea is to do all the layout in one section, then fill things in afterwards. It also corrects a problem where the madt table was memset to 0 before the final size of the table had been determined. Signed-off-by: Beth Kon --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kvm/bios/rombios32.c b/kvm/bios/rombios32.c index cbd5f15..7f62e4f 100755 --- a/kvm/bios/rombios32.c +++ b/kvm/bios/rombios32.c @@ -1665,6 +1665,7 @@ void acpi_bios_init(void) addr = (addr + 7) & ~7; madt_addr = addr; + madt = (void *)(addr); madt_size = sizeof(*madt) + sizeof(struct madt_processor_apic) * MAX_CPUS + #ifdef BX_QEMU @@ -1672,7 +1673,11 @@ void acpi_bios_init(void) #else sizeof(struct madt_io_apic); #endif - madt = (void *)(addr); + for ( i = 0; i < 16; i++ ) { + if ( PCI_ISA_IRQ_MASK & (1U << i) ) { + madt_size += sizeof(struct madt_int_override); + } + } addr += madt_size; #ifdef BX_QEMU @@ -1786,7 +1791,6 @@ void acpi_bios_init(void) continue; } int_override++; - madt_size += sizeof(struct madt_int_override); } acpi_build_table_header((struct acpi_table_header *)madt, "APIC", madt_size, 1);