From: Juergen Gross <jgross@suse.com>
To: Ed Swierk <eswierk@skyportsystems.com>, xen-devel@lists.xensource.com
Subject: Re: Linux 4.4 boot crash on xen 4.5.3 with dom0_mem == max
Date: Wed, 18 May 2016 10:30:30 +0200 [thread overview]
Message-ID: <573C2826.9010309@suse.com> (raw)
In-Reply-To: <1463518233-128452-1-git-send-email-eswierk@skyportsystems.com>
On 17/05/16 22:50, Ed Swierk wrote:
> I added some more instrumentation and discovered that the result of
> xen_count_remap_pages() (0x85dea) is one less than the actual number
> of pages remapped by xen_set_identity_and_remap() (0x85deb).
>
> The two functions differ in their handling of a xen_e820_map entry
> whose size is not a multiple of the page size. The entry starting at
> 0x68000 has size 0x33400. xen_count_remap_pages() rounds up when
> computing the end_pfn (to 0x9c), while xen_set_identity_and_remap()
> rounds down (to 0x9b). Thus xen_count_remap_pages() counts the
> remapped space following the entry as one page smaller than the other
> function does.
>
> (Confusingly, the "BIOS-provided physical RAM map" shows both the
> start and end addresses rounded down to page boundaries, rather than
> the addresses actually provided by the BIOS.)
>
> [ 0.000000] xen_count_remap_pages i=0 addr=0x0 size=0x60000 start_pfn=0x0 end_pfn=0x0
> [ 0.000000] xen_count_remap_pages i=0 plus end_pfn=0x60 type=0x1
> [ 0.000000] xen_count_remap_pages i=1 addr=0x60000 size=0x8000 start_pfn=0x60 end_pfn=0x60
> [ 0.000000] xen_count_remap_pages i=1 plus end_pfn=0x68 type=0x2
> [ 0.000000] xen_count_remap_pages i=2 addr=0x68000 size=0x33400 start_pfn=0x68 end_pfn=0x68
> [ 0.000000] xen_count_remap_pages i=2 plus end_pfn=0x9c type=0x1
> [ 0.000000] xen_count_remap_pages i=3 addr=0x100000 size=0x759fe000 start_pfn=0x100 end_pfn=0x9c
> [ 0.000000] xen_count_remap_pages i=3 plus end_pfn=0x75afe type=0x1
> [ 0.000000] xen_count_remap_pages i=4 addr=0x75bab000 size=0x464b000 start_pfn=0x75bab end_pfn=0x75afe
> [ 0.000000] xen_count_remap_pages i=4 plus end_pfn=0x7a1f6 type=0x1
> [ 0.000000] xen_count_remap_pages i=5 addr=0x7b7d7000 size=0x29000 start_pfn=0x7b7d7 end_pfn=0x7a1f6
> [ 0.000000] xen_count_remap_pages i=5 plus end_pfn=0x7b800 type=0x1
> [ 0.000000] xen_count_remap_pages i=6 addr=0x7bf00000 size=0x100000 start_pfn=0x7bf00 end_pfn=0x7b800
> [ 0.000000] xen_count_remap_pages i=6 plus end_pfn=0x7c000 type=0x1
> [ 0.000000] xen_count_remap_pages i=7 addr=0xc7ffc000 size=0x1000 start_pfn=0xc7ffc end_pfn=0x7c000
> [ 0.000000] xen_count_remap_pages i=7 plus end_pfn=0xc7ffd type=0x2
> [ 0.000000] xen_count_remap_pages i=8 addr=0xfbffc000 size=0x1000 start_pfn=0xfbffc end_pfn=0xc7ffd
> [ 0.000000] xen_count_remap_pages i=8 plus end_pfn=0xfbffd type=0x2
> [ 0.000000] xen_count_remap_pages i=9 addr=0xfec00000 size=0x2000 start_pfn=0xfec00 end_pfn=0xfbffd
> [ 0.000000] xen_count_remap_pages i=9 plus end_pfn=0xfec02 type=0x2
> [ 0.000000] xen_count_remap_pages i=10 addr=0xfec40000 size=0x1000 start_pfn=0xfec40 end_pfn=0xfec02
> [ 0.000000] xen_count_remap_pages i=10 plus end_pfn=0xfec41 type=0x2
> [ 0.000000] xen_count_remap_pages i=11 addr=0xfed20000 size=0x10000 start_pfn=0xfed20 end_pfn=0xfec41
> [ 0.000000] xen_count_remap_pages i=11 plus end_pfn=0xfed30 type=0x1
> [ 0.000000] xen_count_remap_pages i=12 addr=0xfee00000 size=0x100000 start_pfn=0xfee00 end_pfn=0xfed30
> [ 0.000000] xen_count_remap_pages i=12 plus end_pfn=0xfef00 type=0x2
> [ 0.000000] xen_count_remap_pages i=13 addr=0x100000000 size=0x1f80000000 start_pfn=0x100000 end_pfn=0xfef00
> [ 0.000000] xen_count_remap_pages i=13 plus end_pfn=0x480000 type=0x1
> [ 0.000000] xen_count_remap_pages(max_pfn=0x480000) == 0x85dea
> [ 0.000000] max_pages 0x505dea
> [ 0.000000] xen_add_extra_mem(480000, 85dea)
> [ 0.000000] memblock_reserve(0x480000000, 0x85dea000)
> [ 0.000000] xen_set_identity_and_remap i=0 addr=0x0 size=0x60000 type=0x1
> [ 0.000000] xen_set_identity_and_remap i=1 addr=0x60000 size=0x8000 type=0x2
> [ 0.000000] xen_set_identity_and_remap i=2 addr=0x68000 size=0x33400 type=0x1
> [ 0.000000] xen_set_identity_and_remap_chunk start_pfn=0x60 end_pfn=0x68 nr_pages=0x480000 remap_pfn=0x480000
> [ 0.000000] xen_set_identity_and_remap_chunk i=0x0 cur_pfn=0x60 left=0x8 size=0x8 remap_range_size=0x1c00000
> [ 0.000000] xen_set_identity_and_remap i=3 addr=0x100000 size=0x759fe000 type=0x1
> [ 0.000000] xen_set_identity_and_remap_chunk start_pfn=0x9b end_pfn=0x100 nr_pages=0x480000 remap_pfn=0x480008
> [ 0.000000] xen_set_identity_and_remap_chunk i=0x0 cur_pfn=0x9b left=0x65 size=0x65 remap_range_size=0x1bffff8
> [ 0.000000] xen_set_identity_and_remap i=4 addr=0x75bab000 size=0x464b000 type=0x1
> [ 0.000000] xen_set_identity_and_remap_chunk start_pfn=0x75afe end_pfn=0x75bab nr_pages=0x480000 remap_pfn=0x48006d
> [ 0.000000] xen_set_identity_and_remap_chunk i=0x0 cur_pfn=0x75afe left=0xad size=0xad remap_range_size=0x1bfff93
> [ 0.000000] xen_set_identity_and_remap i=5 addr=0x7b7d7000 size=0x29000 type=0x1
> [ 0.000000] xen_set_identity_and_remap_chunk start_pfn=0x7a1f6 end_pfn=0x7b7d7 nr_pages=0x480000 remap_pfn=0x48011a
> [ 0.000000] xen_set_identity_and_remap_chunk i=0x0 cur_pfn=0x7a1f6 left=0x15e1 size=0x15e1 remap_range_size=0x1bffee6
> [ 0.000000] xen_set_identity_and_remap i=6 addr=0x7bf00000 size=0x100000 type=0x1
> [ 0.000000] xen_set_identity_and_remap_chunk start_pfn=0x7b800 end_pfn=0x7bf00 nr_pages=0x480000 remap_pfn=0x4816fb
> [ 0.000000] xen_set_identity_and_remap_chunk i=0x0 cur_pfn=0x7b800 left=0x700 size=0x700 remap_range_size=0x1bfe905
> [ 0.000000] xen_set_identity_and_remap i=7 addr=0xc7ffc000 size=0x1000 type=0x2
> [ 0.000000] xen_set_identity_and_remap i=8 addr=0xfbffc000 size=0x1000 type=0x2
> [ 0.000000] xen_set_identity_and_remap i=9 addr=0xfec00000 size=0x2000 type=0x2
> [ 0.000000] xen_set_identity_and_remap i=10 addr=0xfec40000 size=0x1000 type=0x2
> [ 0.000000] xen_set_identity_and_remap i=11 addr=0xfed20000 size=0x10000 type=0x1
> [ 0.000000] xen_set_identity_and_remap_chunk start_pfn=0x7c000 end_pfn=0xfed20 nr_pages=0x480000 remap_pfn=0x481dfb
> [ 0.000000] xen_set_identity_and_remap_chunk i=0x0 cur_pfn=0x7c000 left=0x82d20 size=0x82d20 remap_range_size=0x1bfe205
> [ 0.000000] xen_set_identity_and_remap i=12 addr=0xfee00000 size=0x100000 type=0x2
> [ 0.000000] xen_set_identity_and_remap i=13 addr=0x100000000 size=0x1f80000000 type=0x1
> [ 0.000000] xen_set_identity_and_remap_chunk start_pfn=0xfed30 end_pfn=0x100000 nr_pages=0x480000 remap_pfn=0x504b1b
> [ 0.000000] xen_set_identity_and_remap_chunk i=0x0 cur_pfn=0xfed30 left=0x12d0 size=0x12d0 remap_range_size=0x1b7b4e5
> [ 0.000000] Released 0 page(s)
> [ 0.000000] e820: BIOS-provided physical RAM map:
> [ 0.000000] Xen: [mem 0x0000000000000000-0x000000000005ffff] usable
> [ 0.000000] Xen: [mem 0x0000000000060000-0x0000000000067fff] reserved
> [ 0.000000] Xen: [mem 0x0000000000068000-0x000000000009afff] usable
> [ 0.000000] Xen: [mem 0x00000000000a0000-0x00000000000fffff] reserved
> [ 0.000000] Xen: [mem 0x0000000000100000-0x0000000075afdfff] usable
> [ 0.000000] Xen: [mem 0x0000000075bab000-0x000000007a1f5fff] usable
> [ 0.000000] Xen: [mem 0x000000007b7d7000-0x000000007b7fffff] usable
> [ 0.000000] Xen: [mem 0x000000007bf00000-0x000000007bffffff] usable
> [ 0.000000] Xen: [mem 0x00000000c7ffc000-0x00000000c7ffcfff] reserved
> [ 0.000000] Xen: [mem 0x00000000fbffc000-0x00000000fbffcfff] reserved
> [ 0.000000] Xen: [mem 0x00000000fec00000-0x00000000fec01fff] reserved
> [ 0.000000] Xen: [mem 0x00000000fec40000-0x00000000fec40fff] reserved
> [ 0.000000] Xen: [mem 0x00000000fed20000-0x00000000fed2ffff] usable
> [ 0.000000] Xen: [mem 0x00000000fee00000-0x00000000feefffff] reserved
> [ 0.000000] Xen: [mem 0x0000000100000000-0x0000000505de9fff] usable
> [ 0.000000] bootconsole [xenboot0] enabled
> [ 0.000000] debug: ignoring loglevel setting.
> [ 0.000000] NX (Execute Disable) protection: active
> [ 0.000000] e820: user-defined physical RAM map:
> [ 0.000000] user: [mem 0x0000000000000000-0x000000000005ffff] usable
> [ 0.000000] user: [mem 0x0000000000060000-0x0000000000067fff] reserved
> [ 0.000000] user: [mem 0x0000000000068000-0x000000000009afff] usable
> [ 0.000000] user: [mem 0x00000000000a0000-0x00000000000fffff] reserved
> [ 0.000000] user: [mem 0x0000000000100000-0x0000000075afdfff] usable
> [ 0.000000] user: [mem 0x0000000075bab000-0x000000007a1f5fff] usable
> [ 0.000000] user: [mem 0x000000007b7d7000-0x000000007b7fffff] usable
> [ 0.000000] user: [mem 0x000000007bf00000-0x000000007bffffff] usable
> [ 0.000000] user: [mem 0x0000000080000000-0x000000008fffffff] reserved
> [ 0.000000] user: [mem 0x00000000c7ffc000-0x00000000c7ffcfff] reserved
> [ 0.000000] user: [mem 0x00000000fbffc000-0x00000000fbffcfff] reserved
> [ 0.000000] user: [mem 0x00000000fec00000-0x00000000fec01fff] reserved
> [ 0.000000] user: [mem 0x00000000fec40000-0x00000000fec40fff] reserved
> [ 0.000000] user: [mem 0x00000000fed20000-0x00000000fed2ffff] usable
> [ 0.000000] user: [mem 0x00000000fee00000-0x00000000feefffff] reserved
> [ 0.000000] user: [mem 0x0000000100000000-0x0000000505de9fff] usable
>
> It seems to me we'd be better off with just one function counting
> remapped pages rather than two, so as an experiment I tried combining
> them. The patch below adds a do_remap argument to
> xen_set_identity_and_remap() that tells it whether to do the actual
> remapping or just return the number pages that would be remapped.
> This change fixes the crash on my system.
But it is wrong.
> diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
> index 7ab2951..2746b7b 100644
> --- a/arch/x86/xen/setup.c
> +++ b/arch/x86/xen/setup.c
> @@ -438,11 +438,13 @@ static unsigned long __init xen_set_identity_and_remap_chunk(
> return remap_pfn;
> }
>
> -static void __init xen_set_identity_and_remap(unsigned long nr_pages)
> +static unsigned long __init xen_set_identity_and_remap(unsigned long nr_pages,
> + int do_remap)
> {
> phys_addr_t start = 0;
> unsigned long last_pfn = nr_pages;
> const struct e820entry *entry = xen_e820_map;
> + unsigned long remap_pages = 0;
> int i;
>
> /*
> @@ -465,15 +467,21 @@ static void __init xen_set_identity_and_remap(unsigned long nr_pages)
> if (entry->type == E820_RAM)
> end_pfn = PFN_UP(entry->addr);
>
> - if (start_pfn < end_pfn)
> - last_pfn = xen_set_identity_and_remap_chunk(
> - start_pfn, end_pfn, nr_pages,
> - last_pfn);
> + if (start_pfn < end_pfn) {
> + if (do_remap)
> + last_pfn = xen_set_identity_and_remap_chunk(
> + start_pfn, end_pfn, nr_pages,
> + last_pfn);
> + remap_pages += end_pfn - start_pfn;
> + }
> start = end;
You fail to skip counting remap_pages above nr_pages.
> }
> }
>
> - pr_info("Released %ld page(s)\n", xen_released_pages);
> + if (do_remap)
> + pr_info("Released %ld page(s)\n", xen_released_pages);
> +
> + return remap_pages;
> }
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-05-18 8:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-17 4:28 Linux 4.4 boot crash on xen 4.5.3 with dom0_mem == max Ed Swierk
2016-05-17 7:43 ` Juergen Gross
2016-05-17 13:37 ` Ed Swierk
2016-05-17 20:50 ` Ed Swierk
2016-05-18 8:30 ` Juergen Gross [this message]
2016-05-18 11:44 ` Juergen Gross
2016-05-18 14:39 ` Ed Swierk
2016-05-18 14:45 ` Juergen Gross
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=573C2826.9010309@suse.com \
--to=jgross@suse.com \
--cc=eswierk@skyportsystems.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.