From: George Dunlap <george.dunlap@eu.citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@citrix.com>,
Hanweidong <hanweidong@huawei.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH v2 5/5] libxl, hvmloader: Don't relocate memory for MMIO hole
Date: Thu, 20 Jun 2013 10:22:40 +0100 [thread overview]
Message-ID: <51C2C9E0.6060006@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1306191754390.4548@kaball.uk.xensource.com>
On 19/06/13 18:18, Stefano Stabellini wrote:
> On Tue, 18 Jun 2013, George Dunlap wrote:
>> + const char *s;
>> + bool allow_memory_relocate = 1;
> Arguably the default should be 0, given that the default device model is
> qemu-xen that cannot cope with memory relocation.
OK, so time to think a bit harder about this. This will only matter if
someone is using this hvmloader with a non-libxl toolstack which
includes xend, or a home-grown one.
* If we default to 1, then:
- VMs running qemu-traditional will be have exactly as before
- VMs running qemu-xen will have the risk of crashing mysteriously.
- If qemu-xen is the default, then there is a work-around: run
qemu-traditional
* If we default to 0, then:
- VMs running qemu-xen will be fine
- VMs running qemu-traditional may have strange problems; we haven't
tested relocating things into 64-bit with qemu-tradiational.
- There is no work-around available; if the device either can't be
relocated, or the OS / qemu can't handle the relocation, then the user
is just hosed.
Furthermore, I think xm defaults to qemu-traditional, right? Does xm
even know how to drive qemu-xen? If it does default to
qemu-traditional, defaulting to 0 will pretty much guarantee a whole
slew of currently-working configurations will be affected (perhaps
break, perhaps not).
Overall I think defaulting to 1 is probably the lowest-risk option.
>
>
>> + s = xenstore_read(HVM_XS_ALLOW_MEMORY_RELOCATE, NULL);
>> + if ( s )
>> + allow_memory_relocate = (bool)strtoll(s, NULL, 0);
>> + printf("Relocating guest memory for lowmem MMIO space %s\n",
>> + allow_memory_relocate?"enabled":"disabled");
> It doesn't take a strtoll to parse a boolean.
As discussed in v1, strtoll is the only "XtoY" function available in
hvmloader. :-) The only other option would be to explicitly compare for
"1" or "0" (or do some half-baked *s-'0' thing).
This does make me think though -- what is the semantics of casting to a
bool? Is it !!, or will it essentially clip off the high bits? (e.g.,
would "2" become "1", or "0"?)
>> /* Program PCI-ISA bridge with appropriate link routes. */
>> isa_irq = 0;
>> for ( link = 0; link < 4; link++ )
>> @@ -209,14 +220,38 @@ void pci_setup(void)
>> pci_writew(devfn, PCI_COMMAND, cmd);
>> }
>>
>> - while ( (mmio_total > (pci_mem_end - pci_mem_start)) &&
>> - ((pci_mem_start << 1) != 0) )
>> + /*
>> + * At the moment qemu-xen can't deal with relocated memory regions.
>> + * It's too close to the release to make a proper fix; for now,
>> + * only allow the MMIO hole to grow large enough to move guest memory
>> + * if we're running qemu-traditional. Items that don't fit will be
>> + * relocated into the 64-bit address space.
> I would avoid mentioning release issues in a comment within the code.
I guess it depends on whether we intend to keep this change or to get
rid of it once the 4.4. window opens. If we intend to get rid of it,
then I think the comment should stay; if for some reason someone comes
along later and and wants to know, "Can I change this?" Knowing that it
was only meant to be a temporary measure is important information.
Really, I'm of the opinion that if KVM is using SeaBIOS's pci routines,
we should just move do the same. No sense in duplicating the effort for
something like this.
>> + * This loop now does the following:
>> + * - If allow_memory_relocate, increase the MMIO hole until it's
>> + * big enough, or until it's 2GiB
>> + * - If !allow_memory_relocate, increase the MMIO hole until it's
>> + * big enough, or until it's 2GiB, or until it overlaps guest
>> + * memory
>> + */
>> + while ( (mmio_total > (pci_mem_end - pci_mem_start))
>> + && ((pci_mem_start << 1) != 0)
>> + && (allow_memory_relocate
>> + || (((pci_mem_start << 1) >> PAGE_SHIFT)
>> + < hvm_info->low_mem_pgend)) )
> Isn't this last condition inverted? It should be '>=' ?
Yep -- replied to myself Tuesday saying as much. :-)
Good catch though -- thanks for the close review.
-George
next prev parent reply other threads:[~2013-06-20 9:22 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 16:46 [PATCH v2 1/5] hvmloader: Correct bug in low mmio region accounting George Dunlap
2013-06-18 16:46 ` [PATCH v2 2/5] hvmloader: Load large devices into high MMIO space as needed George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-20 9:23 ` George Dunlap
2013-06-20 9:47 ` Jan Beulich
2013-06-18 16:46 ` [PATCH v2 3/5] hvmloader: Remove minimum size for BARs to relocate to 64-bit space George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-19 21:14 ` Wei Liu
2013-06-20 9:01 ` George Dunlap
2013-06-20 9:48 ` Jan Beulich
2013-06-18 16:46 ` [PATCH v2 4/5] hvmloader: Fix check for needing a 64-bit bar George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-20 10:01 ` Jan Beulich
2013-06-20 10:21 ` George Dunlap
2013-06-18 16:46 ` [PATCH v2 5/5] libxl, hvmloader: Don't relocate memory for MMIO hole George Dunlap
2013-06-18 17:16 ` George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-20 9:22 ` George Dunlap [this message]
2013-06-20 10:12 ` Jan Beulich
2013-06-20 10:20 ` George Dunlap
2013-06-20 10:29 ` Stefano Stabellini
2013-06-20 10:56 ` Jan Beulich
2013-06-20 10:59 ` George Dunlap
2013-06-20 11:01 ` George Dunlap
2013-06-20 13:35 ` Ian Jackson
2013-06-20 14:06 ` George Dunlap
2013-06-20 10:37 ` Ian Jackson
2013-06-20 10:44 ` George Dunlap
2013-06-20 10:52 ` Jan Beulich
2013-06-20 10:49 ` Stefano Stabellini
2013-06-25 9:56 ` Ian Campbell
2013-06-25 10:15 ` George Dunlap
2013-06-18 16:53 ` [PATCH v2 1/5] hvmloader: Correct bug in low mmio region accounting George Dunlap
2013-06-19 17:18 ` Stefano Stabellini
2013-06-20 8:56 ` George Dunlap
2013-06-20 10:40 ` Stefano Stabellini
2013-06-20 10:43 ` George Dunlap
2013-06-20 9:36 ` Jan Beulich
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=51C2C9E0.6060006@eu.citrix.com \
--to=george.dunlap@eu.citrix.com \
--cc=hanweidong@huawei.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@citrix.com \
--cc=stefano.stabellini@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.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).