From: Marcel Apfelbaum <marcel@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcel@redhat.com, mst@redhat.com, imammedo@redhat.com,
lersek@redhat.com, ehabkost@redhat.com
Subject: [Qemu-devel] [PATCH V2 1/4] hw/pc: extract reserved memory end computation to a standalone function
Date: Sun, 15 May 2016 22:23:31 +0300 [thread overview]
Message-ID: <1463340214-8721-2-git-send-email-marcel@redhat.com> (raw)
In-Reply-To: <1463340214-8721-1-git-send-email-marcel@redhat.com>
This code will be reused when calculating 64-bit MMIO hotplug ranges.
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
hw/i386/pc.c | 29 +++++++++++++++++++++--------
include/hw/i386/pc.h | 1 +
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 99437e0..a7791e3 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1280,6 +1280,7 @@ void pc_memory_init(PCMachineState *pcms,
FWCfgState *fw_cfg;
MachineState *machine = MACHINE(pcms);
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
+ uint64_t res_mem_end;
assert(machine->ram_size == pcms->below_4g_mem_size +
pcms->above_4g_mem_size);
@@ -1375,15 +1376,10 @@ void pc_memory_init(PCMachineState *pcms,
rom_set_fw(fw_cfg);
- if (pcmc->has_reserved_memory && pcms->hotplug_memory.base) {
+ res_mem_end = pc_machine_get_reserved_memory_end(pcms);
+ if (res_mem_end) {
uint64_t *val = g_malloc(sizeof(*val));
- 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));
+ *val = cpu_to_le64(res_mem_end);
fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
}
@@ -1853,6 +1849,23 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms)
return false;
}
+uint64_t pc_machine_get_reserved_memory_end(PCMachineState *pcms)
+{
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
+ uint64_t res_mem_end = 0;
+
+ if (pcmc->has_reserved_memory && pcms->hotplug_memory.base) {
+ res_mem_end = pcms->hotplug_memory.base;
+
+ if (!pcmc->broken_reserved_end) {
+ res_mem_end += memory_region_size(&pcms->hotplug_memory.mr);
+ }
+ res_mem_end = ROUND_UP(res_mem_end, 0x1ULL << 30);
+ }
+
+ return res_mem_end;
+}
+
static void pc_machine_get_smm(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 96f0b66..7c25814 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -223,6 +223,7 @@ void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);
extern int fd_bootchk;
bool pc_machine_is_smm_enabled(PCMachineState *pcms);
+uint64_t pc_machine_get_reserved_memory_end(PCMachineState *pcms);
void pc_register_ferr_irq(qemu_irq irq);
void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
--
2.4.3
next prev parent reply other threads:[~2016-05-15 19:23 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-15 19:23 [Qemu-devel] [PATCH V2 0/4] pci: better support for 64-bit MMIO allocation Marcel Apfelbaum
2016-05-15 19:23 ` Marcel Apfelbaum [this message]
2016-05-16 8:13 ` [Qemu-devel] [PATCH V2 1/4] hw/pc: extract reserved memory end computation to a standalone function Igor Mammedov
2016-05-15 19:23 ` [Qemu-devel] [PATCH V2 2/4] pci: reserve 64 bit MMIO range for PCI hotplug Marcel Apfelbaum
2016-05-16 8:24 ` Igor Mammedov
2016-05-16 10:14 ` Marcel Apfelbaum
2016-05-16 14:19 ` Igor Mammedov
2016-05-18 14:07 ` Marcel Apfelbaum
2016-05-18 14:26 ` Igor Mammedov
2016-05-18 14:33 ` Marcel Apfelbaum
2016-05-18 13:59 ` Igor Mammedov
2016-05-18 14:10 ` Laszlo Ersek
2016-05-18 14:11 ` Marcel Apfelbaum
2016-05-18 14:11 ` Michael S. Tsirkin
2016-05-18 14:12 ` Marcel Apfelbaum
2016-05-18 14:31 ` Igor Mammedov
2016-05-18 14:33 ` Marcel Apfelbaum
2016-05-18 14:42 ` Michael S. Tsirkin
2016-05-18 14:52 ` Marcel Apfelbaum
2016-05-18 15:06 ` Michael S. Tsirkin
2016-05-18 14:14 ` Michael S. Tsirkin
2016-05-18 14:43 ` Marcel Apfelbaum
2016-05-18 14:57 ` Michael S. Tsirkin
2016-05-18 15:01 ` Marcel Apfelbaum
2016-05-18 15:30 ` Michael S. Tsirkin
2016-05-15 19:23 ` [Qemu-devel] [PATCH V2 3/4] acpi: refactor pxb crs computation Marcel Apfelbaum
2016-05-15 19:23 ` [Qemu-devel] [PATCH V2 4/4] hw/apci: handle 64-bit MMIO regions correctly Marcel Apfelbaum
2016-05-16 11:19 ` Igor Mammedov
2016-05-16 11:30 ` Marcel Apfelbaum
2016-05-18 14:16 ` Michael S. Tsirkin
2016-05-18 14:30 ` Marcel Apfelbaum
2016-05-18 13:53 ` [Qemu-devel] [PATCH V2 0/4] pci: better support for 64-bit MMIO allocation Igor Mammedov
2016-05-18 14:09 ` Michael S. Tsirkin
2016-05-18 14:38 ` Igor Mammedov
2016-05-18 14:44 ` Michael S. Tsirkin
2016-05-19 7:40 ` Igor Mammedov
2016-05-18 14:22 ` Marcel Apfelbaum
2016-05-19 9:04 ` Igor Mammedov
2016-05-19 20:23 ` Marcel Apfelbaum
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=1463340214-8721-2-git-send-email-marcel@redhat.com \
--to=marcel@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=lersek@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.