qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: bharata@linux.vnet.ibm.com, ehabkost@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] pc: memhotplug: keep reserved-memory-end broken on 2.4 and earlier machines
Date: Mon,  7 Sep 2015 13:55:32 +0200	[thread overview]
Message-ID: <1441626932-76366-3-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1441626932-76366-1-git-send-email-imammedo@redhat.com>

it will prevent guests on old machines from seeing
inconsistent memory mapping in firmware/ACPI views.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
PS: this patch probably clashes with Eduardo's
    pc_compat refactoring, so I've split it from
    main fix, if applied via Eduardo's it could
    be squashed in main fix after merging on top
    of his patches or as is if goes in first.
---
 hw/i386/pc.c         | 8 ++++++--
 hw/i386/pc_piix.c    | 2 ++
 hw/i386/pc_q35.c     | 2 ++
 include/hw/i386/pc.h | 1 +
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 354e1b3..b5107f7 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1412,8 +1412,12 @@ FWCfgState *pc_memory_init(PCMachineState *pcms,
 
     if (guest_info->has_reserved_memory && pcms->hotplug_memory.base) {
         uint64_t *val = g_malloc(sizeof(*val));
-        uint64_t res_mem_end = pcms->hotplug_memory.base +
-                               memory_region_size(&pcms->hotplug_memory.mr);
+        PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
+        uint64_t res_mem_end = pcms->hotplug_memory.base;
+
+        if (!pcmc->broken_reserved_end) {
+            res_mem_end += memory_region_size(&pcms->hotplug_memory.mr);
+        }
         *val = cpu_to_le64(ROUND_UP(res_mem_end, 0x1ULL << 30));
         fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
     }
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index b82921d..589f530 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -451,7 +451,9 @@ static void pc_i440fx_machine_options(MachineClass *m)
 
 static void pc_i440fx_2_4_machine_options(MachineClass *m)
 {
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_machine_options(m);
+    pcmc->broken_reserved_end = true;
     m->default_machine_opts = "firmware=bios-256k.bin";
     m->default_display = "std";
     m->alias = "pc";
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 7217cbf..839d3b9 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -370,7 +370,9 @@ static void pc_q35_machine_options(MachineClass *m)
 
 static void pc_q35_2_4_machine_options(MachineClass *m)
 {
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_machine_options(m);
+    pcmc->broken_reserved_end = true;
     m->default_machine_opts = "firmware=bios-256k.bin";
     m->default_display = "std";
     m->no_floppy = 1;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index d0cad87..ff0b48b 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -59,6 +59,7 @@ struct PCMachineClass {
     MachineClass parent_class;
 
     /*< public >*/
+    bool broken_reserved_end;
     HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
                                            DeviceState *dev);
 };
-- 
1.8.3.1

  parent reply	other threads:[~2015-09-07 11:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07 11:55 [Qemu-devel] [PATCH 0/2] pc: fix 64-bit PCI window clashing with memory hotplug region Igor Mammedov
2015-09-07 11:55 ` [Qemu-devel] [PATCH 1/2] pc: memhotplug: fix incorrectly set reserved-memory-end Igor Mammedov
2015-09-09 20:03   ` Eduardo Habkost
2015-09-10  9:59     ` Igor Mammedov
2015-09-10 10:42       ` Michael S. Tsirkin
2015-09-07 11:55 ` Igor Mammedov [this message]
2015-09-09 20:14   ` [Qemu-devel] [PATCH 2/2] pc: memhotplug: keep reserved-memory-end broken on 2.4 and earlier machines Eduardo Habkost

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=1441626932-76366-3-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=ehabkost@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).