All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: Re: xen: memory initialization/balloon fixes (#3)
Date: Wed, 28 Sep 2011 11:45:02 +0100	[thread overview]
Message-ID: <4E82FAAE.6020206@citrix.com> (raw)
In-Reply-To: <20110927231033.GA4712@phenom.oracle.com>

On 28/09/11 00:10, Konrad Rzeszutek Wilk wrote:
>>> (XEN) Xen-e820 RAM map:
>>> (XEN)  0000000000000000 - 000000000009d800 (usable)
>>
>> It's because it's not correctly handling the half-page of RAM at the end
>> of this region.
>>
>> I don't have access to any test boxes with a dodgy BIOS like this so can
>> you test this patch?  If it works I'll fold it in and post an updated
>> series.
> 
> It works. Albeit I think we are going to hit a problem with dmidecode
> if the DMI data is right in the reserved region
> 
> (http://lists.xensource.com/archives/html/xen-devel/2011-09/msg01299.html)
> 
> As in, if it starts in 9D800 - we consider 0->9d as RAM PFN, and 9e->100 as 1-1
> mapping.
> 
> I am thinking that perhaps the call to xen_set_phys_identity, where
> we call PFN_UP(x) should be replaced with PFN_DOWN(x). That way
> we would consider 0>9c as RAM PFN and 9D->100 as 1-1 mapping.

I almost did an equivalent change (see below) but discarded it as it
would have resulting in overlapping regions and attempting to
release/map some pages twice.

I think we will have to move the release/map until after the final e820
map has been sanitized so there are no overlapping regions.

I'll prepare another patch for this.

> That would imply a new patch to your series naturally.
>>
>> Can you remember why this page alignment was required?  I'd like to
> 
> The e820_* calls define how the memory subsystem will use it.
> It ended at some point assuming that the full page is RAM even thought
> it was only half-RAM and tried to use it and blew the machine up.
> 
> The fix was to make the calls to the e820_* with size and regions
> that were page-aligned.
> 
> Anyhow, here is what the bootup looks now:
> 
> [    0.000000] Freeing  9e-a0 pfn range: 2 pages freed
> [    0.000000] 1-1 mapping on 9e->a0
> [    0.000000] Freeing  a0-100 pfn range: 96 pages freed
> [    0.000000] 1-1 mapping on a0->100
> [    0.000000] Freeing  7fff0-80000 pfn range: 16 pages freed
> [    0.000000] 1-1 mapping on 7fff0->80000
> [    0.000000] Freeing  cfef0-cfef5 pfn range: 5 pages freed
> [    0.000000] 1-1 mapping on cfef0->cfef5
> [    0.000000] Freeing  cfef5-cff7f pfn range: 138 pages freed
> [    0.000000] 1-1 mapping on cfef5->cff7f
> [    0.000000] Freeing  cff7f-d0000 pfn range: 129 pages freed
> [    0.000000] 1-1 mapping on cff7f->d0000
> [    0.000000] Freeing  d0000-f0000 pfn range: 131072 pages freed
> [    0.000000] 1-1 mapping on d0000->f0000
> [    0.000000] Freeing  f0000-f4b58 pfn range: 19288 pages freed
> [    0.000000] 1-1 mapping on f0000->fec10
> [    0.000000] 1-1 mapping on fec10->fee01
> [    0.000000] 1-1 mapping on fee01->100000
> [    0.000000] Released 150746 pages of unused memory
> [    0.000000] Set 196994 page(s) to 1-1 mapping
> [    0.000000] BIOS-provided physical RAM map:
> [    0.000000]  Xen: 0000000000000000 - 000000000009d000 (usable)
> [    0.000000]  Xen: 000000000009d800 - 0000000000100000 (reserved)
> [    0.000000]  Xen: 0000000000100000 - 000000007fff0000 (usable)
> [    0.000000]  Xen: 000000007fff0000 - 0000000080000000 (reserved)
> 
> 
>> update the comment with the reason because the bare-metal x86 memory
>> init code doesn't appear to fixup the memory map in this way.
>>
>> diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
>> index 986661b..e473c4c 100644
>> --- a/arch/x86/xen/setup.c
>> +++ b/arch/x86/xen/setup.c
>> @@ -178,6 +178,19 @@ static unsigned long __init xen_get_max_pages(void)
>>  	return min(max_pages, MAX_DOMAIN_PAGES);
>>  }
>>
>> +static void xen_e820_add_region(u64 start, u64 size, int type)
>> +{
>> +	u64 end = start + size;
>> +
>> +	/* Align RAM regions to page boundaries. */
>> +	if (type == E820_RAM || type == E820_UNUSABLE) {
> 
> Hm, do we care about E820_UNUSABLE to be page aligned?
> If so, please comment why.

Er. We don't really but I think this if needs to be:

    /*
     * Page align regions.
     *
     * Reduce RAM regions and expand other (reserved) regions.
     */
    if (type == E820_RAM || type == E820_UNUSABLE) {
	start = PAGE_ALIGN(start);
        end  &= ~((u64)PAGE_SIZE - 1);
    } else {
        start &= ~((u64)PAGE_SIZE - 1);
        end = PAGE_ALIGN(start);
    }

So reserved regions also become page aligned (which is part of the fix
for the dmidecode bug).

>> +		start = PAGE_ALIGN(start);
> 
> Is that actually safe? Say it starts a 9ffff? We would
> end up using 9f000 which is not right.

PAGE_ALIGN() (and ALIGN()) round upwards.

David

  reply	other threads:[~2011-09-28 10:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-15 12:29 xen: memory initialization/balloon fixes (#3) David Vrabel
2011-09-15 12:29 ` [PATCH 1/7] xen: use maximum reservation to limit amount of usable RAM David Vrabel
2011-09-21 15:09   ` Konrad Rzeszutek Wilk
2011-09-15 12:29 ` [PATCH 2/7] xen: avoid adding non-existant memory if the reservation is unlimited David Vrabel
2011-09-21 15:08   ` Unknown, Konrad Rzeszutek
2011-09-15 12:29 ` [PATCH 3/7] xen/balloon: account for pages released during memory setup David Vrabel
2011-09-21 15:05   ` Konrad Rzeszutek Wilk
2011-09-15 12:29 ` [PATCH 4/7] xen/balloon: simplify test for the end of usable RAM David Vrabel
2011-09-15 12:29 ` [PATCH 5/7] xen: allow balloon driver to use more than one memory region David Vrabel
2011-09-15 12:29 ` [PATCH 6/7] xen: allow extra memory to be in multiple regions David Vrabel
2011-09-15 12:29 ` [PATCH 7/7] xen: release all pages within 1-1 p2m mappings David Vrabel
2011-09-20 16:57 ` xen: memory initialization/balloon fixes (#3) Dan Magenheimer
2011-09-21 22:29   ` Dan Magenheimer
2011-09-22 12:32   ` David Vrabel
2011-09-22 17:06     ` Dan Magenheimer
2011-09-22 22:34       ` Dan Magenheimer
2011-09-22 22:51         ` Jeremy Fitzhardinge
2011-09-22 23:46           ` Dan Magenheimer
2011-09-23 10:45             ` David Vrabel
2011-09-23 13:28               ` Konrad Rzeszutek Wilk
2011-09-23 19:04               ` Dan Magenheimer
2011-09-21 17:11 ` Konrad Rzeszutek Wilk
2011-09-22 13:08   ` David Vrabel
2011-09-24  2:08 ` Konrad Rzeszutek Wilk
2011-09-26 14:20   ` Konrad Rzeszutek Wilk
2011-09-27 14:09   ` David Vrabel
2011-09-27 23:10     ` Konrad Rzeszutek Wilk
2011-09-28 10:45       ` David Vrabel [this message]
2011-09-28 13:25         ` Konrad Rzeszutek Wilk
2011-09-28 13:47         ` Konrad Rzeszutek Wilk

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=4E82FAAE.6020206@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=konrad.wilk@oracle.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 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.