9ae3a8
From 7212bc6c8e9b4a3118e1cc90157c2f123198139e Mon Sep 17 00:00:00 2001
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Date: Thu, 16 Jan 2014 10:25:57 +0100
9ae3a8
Subject: [PATCH 02/14] pc_piix: document gigabyte_align
9ae3a8
9ae3a8
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Message-id: <1389867959-12463-3-git-send-email-kraxel@redhat.com>
9ae3a8
Patchwork-id: 56745
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH 2/4] pc_piix: document gigabyte_align
9ae3a8
Bugzilla: 1026548
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
From: "Michael S. Tsirkin" <mst@redhat.com>
9ae3a8
9ae3a8
Document the logic behind the below/above 4G split.
9ae3a8
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
(cherry picked from commit ecdbfceb0f20a3ef784bf522ed7264660aa3d150)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	hw/i386/pc_piix.c
9ae3a8
---
9ae3a8
 hw/i386/pc_piix.c | 11 +++++++++++
9ae3a8
 1 file changed, 11 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/i386/pc_piix.c |   11 +++++++++++
9ae3a8
 1 files changed, 11 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
9ae3a8
index 9f1d0b5..12351f9 100644
9ae3a8
--- a/hw/i386/pc_piix.c
9ae3a8
+++ b/hw/i386/pc_piix.c
9ae3a8
@@ -61,6 +61,10 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
9ae3a8
 static bool smbios_type1_defaults = true;
9ae3a8
 static bool has_pci_info;
9ae3a8
 static bool has_acpi_build = true;
9ae3a8
+/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
9ae3a8
+ * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
9ae3a8
+ * pages in the host.
9ae3a8
+ */
9ae3a8
 static bool gigabyte_align = true;
9ae3a8
 
9ae3a8
 /* PC hardware initialisation */
9ae3a8
@@ -102,6 +106,13 @@ static void pc_init1(QEMUMachineInitArgs *args,
9ae3a8
         kvmclock_create();
9ae3a8
     }
9ae3a8
 
9ae3a8
+    /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
9ae3a8
+     * If it doesn't, we need to split it in chunks below and above 4G.
9ae3a8
+     * In any case, try to make sure that guest addresses aligned at
9ae3a8
+     * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
9ae3a8
+     * For old machine types, use whatever split we used historically to avoid
9ae3a8
+     * breaking migration.
9ae3a8
+     */
9ae3a8
     if (args->ram_size >= 0xe0000000) {
9ae3a8
         ram_addr_t lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
9ae3a8
         above_4g_mem_size = args->ram_size - lowmem;
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8