From: Beth Kon <eak@us.ibm.com>
To: avi@redhat.com
Cc: kvm@vger.kernel.org, Beth Kon <eak@us.ibm.com>
Subject: [PATCH 2/2] Clean up RSDT Table Creation (v2)
Date: Tue, 9 Jun 2009 11:55:23 -0400 [thread overview]
Message-ID: <1244562923-4336-2-git-send-email-eak@us.ibm.com> (raw)
In-Reply-To: <1244562923-4336-1-git-send-email-eak@us.ibm.com>
This patch is also based on the patch by Vincent Minet. It corrects the size
calculation of the RSDT, and checks for overflow of MAX_RSDT_ENTRIES,
assuming that the external table entry count is contained within
MAX_RSDT_ENTRIES.
I moved the for() loop to the end of the code that adds table_offset_entry
entries so I could add the check for overflow - || (nb_rsdt_entries > MAX_RSDT_ENTRIES)
This is not ideal. An ideal fix would require a rewrite of the rsdt build code, which
I can do later and submit to qemu.
Signed-off-by: Beth Kon <eak@us.ibm.com>
diff --git a/kvm/bios/rombios32.c b/kvm/bios/rombios32.c
index cdae363..7db91d8 100755
--- a/kvm/bios/rombios32.c
+++ b/kvm/bios/rombios32.c
@@ -1602,7 +1602,7 @@ void acpi_bios_init(void)
uint32_t hpet_addr;
#endif
uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr, ssdt_addr;
- uint32_t acpi_tables_size, madt_addr, madt_size, rsdt_size, madt_end;
+ uint32_t acpi_tables_size, madt_addr, madt_size, rsdt_size, madt_end, rsdt_end;
uint32_t srat_addr,srat_size;
uint16_t i, external_tables;
int nb_numa_nodes;
@@ -1628,7 +1628,7 @@ void acpi_bios_init(void)
addr = base_addr = ram_size - ACPI_DATA_SIZE;
rsdt_addr = addr;
rsdt = (void *)(addr);
- rsdt_size = sizeof(*rsdt) + external_tables * 4;
+ rsdt_size = sizeof(*rsdt);
addr += rsdt_size;
fadt_addr = addr;
@@ -1872,16 +1872,6 @@ void acpi_bios_init(void)
"HPET", sizeof(*hpet), 1);
#endif
- acpi_additional_tables(); /* resets cfg to required entry */
- for(i = 0; i < external_tables; i++) {
- uint16_t len;
- if(acpi_load_table(i, addr, &len) < 0)
- BX_PANIC("Failed to load ACPI table from QEMU\n");
- rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(addr);
- addr += len;
- if(addr >= ram_size)
- BX_PANIC("ACPI table overflow\n");
- }
#endif
/* RSDT */
@@ -1894,9 +1884,19 @@ void acpi_bios_init(void)
// rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(hpet_addr);
if (nb_numa_nodes > 0)
rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(srat_addr);
+ acpi_additional_tables(); /* resets cfg to required entry */
+ for(i = 0; i < external_tables; i++) {
+ uint16_t len;
+ if(acpi_load_table(i, addr, &len) < 0)
+ BX_PANIC("Failed to load ACPI table from QEMU\n");
+ rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(addr);
+ addr += len;
+ if ((addr >= ram_size) || (nb_rsdt_entries > MAX_RSDT_ENTRIES))
+ BX_PANIC("ACPI table overflow\n");
+ }
#endif
- rsdt_size -= MAX_RSDT_ENTRIES * 4;
- rsdt_size += nb_rsdt_entries * 4;
+ rsdt_end = (uint32_t)(&rsdt->table_offset_entry[nb_rsdt_entries]);
+ rsdt_size = rsdt_end - rsdt_addr;
acpi_build_table_header((struct acpi_table_header *)rsdt, "RSDT",
rsdt_size, 1);
next prev parent reply other threads:[~2009-06-09 15:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-09 15:55 [PATCH 1/2] Clean up MADT Table Creation (v2) Beth Kon
2009-06-09 15:55 ` Beth Kon [this message]
2009-06-10 12:29 ` Avi Kivity
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=1244562923-4336-2-git-send-email-eak@us.ibm.com \
--to=eak@us.ibm.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.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