From: Don Slutz <dslutz@verizon.com>
To: xen-devel@lists.xensource.com, qemu-devel@nongnu.org,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: "Marcel Apfelbaum" <marcel.a@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Don Slutz" <dslutz@verizon.com>,
"Anthony Liguori" <aliguori@amazon.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH 2.1 v7 3/3] xen-hvm: Handle machine opt max-ram-below-4g
Date: Thu, 19 Jun 2014 21:40:26 -0400 [thread overview]
Message-ID: <1403228426-7609-4-git-send-email-dslutz@verizon.com> (raw)
In-Reply-To: <1403228426-7609-1-git-send-email-dslutz@verizon.com>
This is the xen part of "pc & q35: Add new machine opt max-ram-below-4g"
Note: this machine option cannot be used to increase the amount
of ram below 4G.
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
v7:
Rename from "xen-hvm: Pass is_default to xen_hvm_init"
Drop is_default.
Use object_property_get_int() to get max-ram-below-4g.
Do min(xen limit, user limit).
v6:
Changed to work with the changes in #2:
Added max_ram_below_4g_changed in order to know if it is a default value
or a user specified one.
Added "assert(pc_machine->max_ram_below_4g_changed > 0)" so that
"make check" will abort on default not set for any of the pc or
q35 machine types.
Dropped "Acked-by: Stefano Stabellin" do to bigger change.
xen-hvm.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/xen-hvm.c b/xen-hvm.c
index a0b6b5d..2745a7a 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -161,25 +161,36 @@ static void xen_ram_init(ram_addr_t *below_4g_mem_size,
{
MemoryRegion *sysmem = get_system_memory();
ram_addr_t block_len;
+ uint64_t user_lowmem = object_property_get_int(qdev_get_machine(),
+ PC_MACHINE_MAX_RAM_BELOW_4G,
+ &error_abort);
- block_len = ram_size;
- if (ram_size >= HVM_BELOW_4G_RAM_END) {
- /* Xen does not allocate the memory continuously, and keep a hole at
- * HVM_BELOW_4G_MMIO_START of HVM_BELOW_4G_MMIO_LENGTH
- */
- block_len += HVM_BELOW_4G_MMIO_LENGTH;
+ /* Handle the machine opt max-ram-below-4g. It is basicly doing
+ * min(xen limit, user limit).
+ */
+ if (HVM_BELOW_4G_RAM_END <= user_lowmem) {
+ user_lowmem = HVM_BELOW_4G_RAM_END;
}
- memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len);
- *ram_memory_p = &ram_memory;
- vmstate_register_ram_global(&ram_memory);
- if (ram_size >= HVM_BELOW_4G_RAM_END) {
- *above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
- *below_4g_mem_size = HVM_BELOW_4G_RAM_END;
+ if (ram_size >= user_lowmem) {
+ *above_4g_mem_size = ram_size - user_lowmem;
+ *below_4g_mem_size = user_lowmem;
} else {
*above_4g_mem_size = 0;
*below_4g_mem_size = ram_size;
}
+ if (!*above_4g_mem_size) {
+ block_len = ram_size;
+ } else {
+ /*
+ * Xen does not allocate the memory continuously, it keeps a
+ * hole of the size computed above or passed in.
+ */
+ block_len = (1ULL << 32) + *above_4g_mem_size;
+ }
+ memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len);
+ *ram_memory_p = &ram_memory;
+ vmstate_register_ram_global(&ram_memory);
memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
&ram_memory, 0, 0xa0000);
--
1.8.4
next prev parent reply other threads:[~2014-06-20 1:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 1:40 [Qemu-devel] [PATCH 2.1 v7 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
2014-06-20 1:40 ` [Qemu-devel] [PATCH 2.1 v7 1/3] xen-hvm: Fix xen_hvm_init() to adjust pc memory layout Don Slutz
2014-06-20 1:40 ` [Qemu-devel] [PATCH 2.1 v7 2/3] pc & q35: Add new machine opt max-ram-below-4g Don Slutz
2014-06-23 14:59 ` Michael S. Tsirkin
2014-06-23 17:49 ` Don Slutz
2014-06-20 1:40 ` Don Slutz [this message]
2014-06-20 12:21 ` [Qemu-devel] [PATCH 2.1 v7 3/3] xen-hvm: Handle " Stefano Stabellini
2014-06-23 14:41 ` [Qemu-devel] [PATCH 2.1 v7 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Michael S. Tsirkin
2014-06-23 14:53 ` Stefano Stabellini
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=1403228426-7609-4-git-send-email-dslutz@verizon.com \
--to=dslutz@verizon.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=imammedo@redhat.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).