From: Don Slutz <dslutz@verizon.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Don Slutz <dslutz@verizon.com>
Cc: xen-devel@lists.xensource.com, qemu-devel@nongnu.org,
Anthony Liguori <aliguori@amazon.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init.
Date: Mon, 17 Mar 2014 10:52:50 -0400 [thread overview]
Message-ID: <53270C42.60804@terremark.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1403161605530.30819@kaball.uk.xensource.com>
On 03/16/14 12:10, Stefano Stabellini wrote:
> On Tue, 11 Mar 2014, Don Slutz wrote:
>> This is the xen part of "pc & q35: Add new object pc-memory-layout."
>>
>> Signed-off-by: Don Slutz<dslutz@verizon.com>
>> ---
>> hw/i386/pc_piix.c | 4 ++--
>> hw/i386/pc_q35.c | 4 ++--
>> include/hw/xen/xen.h | 4 ++--
>> xen-all.c | 41 ++++++++++++++++++++++-------------------
>> xen-stub.c | 4 ++--
>> 5 files changed, 30 insertions(+), 27 deletions(-)
>>
>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>> index 964ea33..691fc5d 100644
>> --- a/hw/i386/pc_piix.c
>> +++ b/hw/i386/pc_piix.c
>> @@ -131,8 +131,8 @@ static void pc_init1(QEMUMachineInitArgs *args,
>> below_4g_mem_size = args->ram_size;
>> }
>>
>> - if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
>> - &ram_memory) != 0) {
>> + if (xen_enabled() && xen_hvm_init(max_ram_below_4g, &below_4g_mem_size,
>> + &above_4g_mem_size, &ram_memory) != 0) {
>> fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
>> exit(1);
>> }
>> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
>> index c95e6e2..8e1c417 100644
>> --- a/hw/i386/pc_q35.c
>> +++ b/hw/i386/pc_q35.c
>> @@ -120,8 +120,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
>> below_4g_mem_size = args->ram_size;
>> }
>>
>> - if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
>> - &ram_memory) != 0) {
>> + if (xen_enabled() && xen_hvm_init(max_ram_below_4g, &below_4g_mem_size,
>> + &above_4g_mem_size, &ram_memory) != 0) {
>> fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
>> exit(1);
>> }
>> diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
>> index 0769db2..fda559a 100644
>> --- a/include/hw/xen/xen.h
>> +++ b/include/hw/xen/xen.h
>> @@ -41,8 +41,8 @@ int xen_init(QEMUMachine *machine);
>> void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
>>
>> #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
>> -int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
>> - MemoryRegion **ram_memory);
>> +int xen_hvm_init(ram_addr_t max_ram_below_4g, ram_addr_t *below_4g_mem_size,
>> + ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory);
>> void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
>> struct MemoryRegion *mr);
>> void xen_modified_memory(ram_addr_t start, ram_addr_t length);
>> diff --git a/xen-all.c b/xen-all.c
>> index c64300c..48ba335 100644
>> --- a/xen-all.c
>> +++ b/xen-all.c
>> @@ -155,32 +155,34 @@ qemu_irq *xen_interrupt_controller_init(void)
>>
>> /* Memory Ops */
>>
>> -static void xen_ram_init(ram_addr_t *below_4g_mem_size,
>> +static void xen_ram_init(ram_addr_t ram_size, ram_addr_t max_ram_below_4g,
>> + ram_addr_t *below_4g_mem_size,
>> ram_addr_t *above_4g_mem_size,
>> - ram_addr_t ram_size, MemoryRegion **ram_memory_p)
>> + MemoryRegion **ram_memory_p)
>> {
>> MemoryRegion *sysmem = get_system_memory();
>> ram_addr_t block_len;
>>
>> - 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;
>> + if (!max_ram_below_4g) {
>> + 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;
>> + } else {
>> + *above_4g_mem_size = 0;
>> + *below_4g_mem_size = ram_size;
>> + }
>> + }
> Instead of treating max_ram_below_4g as a special case, couldn't
> initialize it to HVM_BELOW_4G_RAM_END?
Since max_ram_below_4g is used and initialize in normal QEMU code
where HVM_BELOW_4G_RAM_END is not defined, I do not see how to
do this outside of this routine without adding a new routine for this.
> We could consider HVM_BELOW_4G_RAM_END as the upper bound of
> max_ram_below_4g.
Yes. Currently the only limit on max_ram_below_4g is 4G. I am on
the fence on this. I think there are valid values > HVM_BELOW_4G_RAM_END,
but not clear they need to be supported.
> I would just change the code to:
>
> if (ram_size >= max_ram_below_4g) {
> above_4g_mem_size = ram_size - max_ram_below_4g;
> below_4g_mem_size = max_ram_below_4g;
> } else {
> below_4g_mem_size = ram_size;
> }
>
This is the code that is in patch #3 in the normal QEMU path but using
the variable lowmem so that xen can know if max_ram_below_4g was
set to non-zero. The issue that I am looking at handling here is the case
of an older xen (does not know about max_ram_below_4g) and the
newer QEMU, where xen expects QEMUs memory layout to change to
HVM_BELOW_4G_RAM_END.
Because of this (QEMU is doing the right thing if max_ram_below_4g is
non-zero) is why I coded it as only when max_ram_below_4g is zero, the
xen default is not the same as QEMU.
-Don Slutz
>> + if (!*above_4g_mem_size) {
>> + block_len = ram_size;
>> + } else {
>> + /* Xen does not allocate the memory continuously, and keep a hole of
>> + * 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);
>>
>> - 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;
>> - } else {
>> - *above_4g_mem_size = 0;
>> - *below_4g_mem_size = ram_size;
>> - }
>> -
>> memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
>> &ram_memory, 0, 0xa0000);
>> memory_region_add_subregion(sysmem, 0, &ram_640k);
>> @@ -1069,8 +1071,8 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
>> xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0);
>> }
>>
>> -int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
>> - MemoryRegion **ram_memory)
>> +int xen_hvm_init(ram_addr_t max_ram_below_4g, ram_addr_t *below_4g_mem_size,
>> + ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory)
>> {
>> int i, rc;
>> unsigned long ioreq_pfn;
>> @@ -1148,7 +1150,8 @@ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
>>
>> /* Init RAM management */
>> xen_map_cache_init(xen_phys_offset_to_gaddr, state);
>> - xen_ram_init(below_4g_mem_size, above_4g_mem_size, ram_size, ram_memory);
>> + xen_ram_init(ram_size, max_ram_below_4g, below_4g_mem_size,
>> + above_4g_mem_size, ram_memory);
>>
>> qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
>>
>> diff --git a/xen-stub.c b/xen-stub.c
>> index 0302dff..dd317a5 100644
>> --- a/xen-stub.c
>> +++ b/xen-stub.c
>> @@ -64,8 +64,8 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length)
>> {
>> }
>>
>> -int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
>> - MemoryRegion **ram_memory)
>> +int xen_hvm_init(ram_addr_t max_ram_below_4g, ram_addr_t *below_4g_mem_size,
>> + ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory)
>> {
>> return 0;
>> }
>> --
>> 1.8.4
>>
next prev parent reply other threads:[~2014-03-17 14:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-11 15:59 [PATCH v2 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
2014-03-11 15:59 ` [PATCH v2 1/4] xen-all: Fix xen_hvm_init() to adjust pc memory layout Don Slutz
2014-03-16 16:02 ` Stefano Stabellini
2014-03-11 15:59 ` [PATCH v2 2/4] GlobalProperty: Display warning about unused -global Don Slutz
2014-03-11 15:59 ` [PATCH v2 3/4] pc & q35: Add new object pc-memory-layout Don Slutz
2014-03-11 15:59 ` [PATCH v2 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init Don Slutz
2014-03-16 16:10 ` Stefano Stabellini
2014-03-17 14:52 ` Don Slutz [this message]
2014-03-17 17:55 ` Stefano Stabellini
2014-03-17 18:22 ` Don Slutz
2014-03-17 18:24 ` Don Slutz
2014-03-17 18:41 ` 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=53270C42.60804@terremark.com \
--to=dslutz@verizon.com \
--cc=aliguori@amazon.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).