qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: jsnow@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 3/6] pc: redo sizing of reserved high memory area for -kernel/-initrd
Date: Thu, 18 Sep 2014 18:17:51 +0200	[thread overview]
Message-ID: <1411057074-11157-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1411057074-11157-1-git-send-email-pbonzini@redhat.com>

The initrd is loaded close to the top of memory, with some extra padding
on top to account for memory that the BIOS could reserve in the memory
map (for ACPI tables and the like).

This reserved high memory area can get quite big.  We currently force
a 128k size for 2.1+ machine types, but even that might not be enough:
if the BIOS allocates more memory from the high area than just the ACPI
tables, loading the initrd can stumble on that memory and break.

So, we want to do two things.  First, increase the size of the padding
to account for BIOS data structures.  32k will do, since in practice
the problems were fixed with just 4k.

Second, to avoid wasting memory, size the padding based on the actual
size of the ACPI tables.  The table builder can pass the right size,
padded as above and with a minimum of 64k.  For older machine types,
the padding has basically no consequence; simply, the acpi_data_size
will be set at machine_ready time instead of machine init, which
is made possible by calling load_linux after the ACPI tables are built.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/acpi-build.c | 1 +
 hw/i386/pc.c         | 6 +++---
 hw/i386/pc_piix.c    | 1 -
 hw/i386/pc_q35.c     | 1 -
 include/hw/i386/pc.h | 2 +-
 5 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a313321..694ee91 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1691,6 +1691,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
         acpi_align_size(tables->table_data, ACPI_BUILD_TABLE_SIZE);
     }
 
+    pc_set_acpi_data_size(tables->table_data->len);
     acpi_align_size(tables->linker, ACPI_BUILD_ALIGN_SIZE);
 
     /* Cleanup memory that's no longer used. */
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 863a40e..b4158f2 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -73,10 +73,10 @@
 #endif
 
 /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables.  */
-unsigned acpi_data_size = 0x28000;
-void pc_set_legacy_acpi_data_size(void)
+unsigned acpi_data_size = 0x10000;
+void pc_set_acpi_data_size(unsigned size)
 {
-    acpi_data_size = 0x10000;
+    acpi_data_size = MAX(size + 0x8000, 0x10000);
 }
 
 #define BIOS_CFG_IOPORT 0x510
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 2aa2b6d..ca9f07c 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -316,7 +316,6 @@ static void pc_compat_2_0(MachineState *machine)
     legacy_acpi_table_size = 6652;
     smbios_legacy_mode = true;
     has_reserved_memory = false;
-    pc_set_legacy_acpi_data_size();
 }
 
 static void pc_compat_1_7(MachineState *machine)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d4a907c..4b5a274 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -280,7 +280,6 @@ static void pc_compat_2_0(MachineState *machine)
 {
     smbios_legacy_mode = true;
     has_reserved_memory = false;
-    pc_set_legacy_acpi_data_size();
 }
 
 static void pc_compat_1_7(MachineState *machine)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 77316d5..853829b 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -176,7 +176,7 @@ void pc_acpi_init(const char *default_dsdt);
 PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
                                 ram_addr_t above_4g_mem_size);
 
-void pc_set_legacy_acpi_data_size(void);
+void pc_set_acpi_data_size(unsigned);
 
 #define PCI_HOST_PROP_PCI_HOLE_START   "pci-hole-start"
 #define PCI_HOST_PROP_PCI_HOLE_END     "pci-hole-end"
-- 
2.1.0

  parent reply	other threads:[~2014-09-18 16:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18 16:17 [Qemu-devel] [PATCH 0/6] pc: bring ACPI table size below to 2.0 levels, try fixing -initrd for good Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 1/6] pc: initialize fw_cfg earlier Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 2/6] pc: load the kernel after ACPI tables are built Paolo Bonzini
2014-09-18 16:17 ` Paolo Bonzini [this message]
2014-09-18 16:17 ` [Qemu-devel] [PATCH 4/6] pc: introduce new ACPI table sizing algorithm Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 5/6] pc: go back to smaller ACPI tables Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 6/6] pc: clean up pre-2.1 compatibility code Paolo Bonzini
2014-09-19  7:36 ` [Qemu-devel] [PATCH 0/6] pc: bring ACPI table size below to 2.0 levels, try fixing -initrd for good Gerd Hoffmann
2014-09-19  8:06   ` Paolo Bonzini
2014-09-19 13:09   ` Paolo Bonzini
2014-10-02 12:11 ` Michael S. Tsirkin
2014-10-02 12:44   ` Paolo Bonzini
2014-10-02 13:30   ` Paolo Bonzini
2014-10-02 13:41     ` Michael S. Tsirkin
2014-10-02 13:43       ` Paolo Bonzini
2014-10-02 13:49         ` Michael S. Tsirkin
2014-10-06 13:42           ` Paolo Bonzini
2014-10-06 13:52             ` Michael S. Tsirkin
2014-10-06 13:55               ` Paolo Bonzini
2014-10-06 14:12                 ` 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=1411057074-11157-4-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mst@redhat.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).