All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: wei.liu2@citrix.com, xen-devel@lists.xen.org
Subject: Re: Xen not working with stock Debian Wheezy 3.2 kernel on a Core 2 Duo box
Date: Mon, 8 Jul 2013 13:06:18 +0100	[thread overview]
Message-ID: <51DAAB3A.7060802@citrix.com> (raw)
In-Reply-To: <51DABE9E02000078000E33A6@nat28.tlf.novell.com>

On 08/07/13 12:29, Jan Beulich wrote:
>>>> On 08.07.13 at 12:31, Wei Liu <wei.liu2@citrix.com> wrote:
> 
> $subject is probably the wrong way round, since ...
> 
>> (XEN)  0000000000000000 - 000000000008f000 (usable)
>> (XEN)  000000000008f000 - 00000000000a0000 (reserved)
>> (XEN)  00000000000e0000 - 0000000000100000 (reserved)
>> (XEN)  0000000000100000 - 00000000ce69a000 (usable)
>> (XEN)  00000000ce69a000 - 00000000ce6f1000 (ACPI NVS)
>> (XEN)  00000000ce6f1000 - 00000000cf5fb000 (usable)
>> (XEN)  00000000cf5fb000 - 00000000cf608000 (reserved)
>> (XEN)  00000000cf608000 - 00000000cf6a5000 (usable)
>> (XEN)  00000000cf6a5000 - 00000000cf6aa000 (ACPI data)
>> (XEN)  00000000cf6aa000 - 00000000cf6ab000 (usable)
>> (XEN)  00000000cf6ab000 - 00000000cf6f2000 (ACPI NVS)
>> (XEN)  00000000cf6f2000 - 00000000cf6ff000 (ACPI data)
>> (XEN)  00000000cf6ff000 - 00000000cf700000 (usable)
>> (XEN)  00000000cf700000 - 00000000d0000000 (reserved)
>> (XEN)  00000000fff00000 - 0000000100000000 (reserved)
>> (XEN)  0000000100000000 - 0000000228000000 (usable)
>> (XEN)  0000000228000000 - 000000022c000000 (unusable)
> 
> .. this and ...
> 
>> [    0.000000]  Xen: 0000000000000000 - 000000000008f000 (usable)
>> [    0.000000]  Xen: 000000000008f000 - 0000000000100000 (reserved)
>> [    0.000000]  Xen: 0000000000100000 - 00000000ce69a000 (usable)
>> [    0.000000]  Xen: 00000000ce69a000 - 00000000ce6f1000 (ACPI NVS)
>> [    0.000000]  Xen: 00000000ce6f1000 - 00000000cf5fb000 (usable)
>> [    0.000000]  Xen: 00000000cf5fb000 - 00000000cf608000 (reserved)
>> [    0.000000]  Xen: 00000000cf608000 - 00000000cf6a5000 (usable)
>> [    0.000000]  Xen: 00000000cf6a5000 - 00000000cf6aa000 (ACPI data)
>> [    0.000000]  Xen: 00000000cf6aa000 - 00000000cf6ab000 (usable)
>> [    0.000000]  Xen: 00000000cf6ab000 - 00000000cf6f2000 (ACPI NVS)
>> [    0.000000]  Xen: 00000000cf6f2000 - 00000000cf6ff000 (ACPI data)
>> [    0.000000]  Xen: 00000000cf6ff000 - 00000000cf700000 (usable)
>> [    0.000000]  Xen: 00000000cf700000 - 00000000d0000000 (reserved)
>> [    0.000000]  Xen: 00000000fee00000 - 00000000fee01000 (reserved)
>> [    0.000000]  Xen: 00000000fff00000 - 0000000100000000 (reserved)
>> [    0.000000]  Xen: 0000000100000000 - 0000000228000000 (usable)
>> [    0.000000]  Xen: 0000000228000000 - 000000022c000000 (unusable)
> 
> ... this show that the kernel should be well aware that it shouldn't
> map (or use in any other way) this region.

This came up before when tboot (?) was incorrectly marking a region as
UNUSABLE instead of RESERVED.

Does the following (untested) patch help?

8<---------------------------------------
x86/xen: do not identity map UNUSABLE regions in the machine E820

If there are UNUSABLE regions in the machine memory map, dom0 will
attempt to map them 1:1 which is not permitted by Xen and the kernel
will crash.

There isn't anything interesting in the UNUSABLE region that the dom0
kernel needs access to so we can avoid making the 1:1 mapping and
treat it as RAM.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 arch/x86/xen/setup.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 94eac5c..73f621c 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -313,6 +313,17 @@ static void xen_align_and_add_e820_region(u64
start, u64 size, int type)
 	e820_add_region(start, end - start, type);
 }

+void xen_ignore_unusable(struct e820entry *list, size_t map_size)
+{
+	struct e820entry *entry;
+	unsigned int i;
+
+	for (i = 0, entry = list; i < map_size; i++, entry++) {
+		if (entry->type == E820_UNUSABLE)
+			entry->type = E820_RAM;
+	}
+}
+
 /**
  * machine_specific_memory_setup - Hook for machine specific memory setup.
  **/
@@ -353,6 +364,19 @@ char * __init xen_memory_setup(void)
 	}
 	BUG_ON(rc);

+	/*
+	 * Xen won't allow a 1:1 mapping to be created to UNUSABLE
+	 * regions, so if we're using the machine memory map convert
+	 * UNUSABLE to RAM.
+	 *
+	 * This might look odd but what we're really doing here is
+	 * taking the psuedo-physical memory map and punching 1:1
+	 * holes through to interesting bits found in the machine
+	 * memory map.
+	 */
+	if (xen_initial_domain())
+		xen_ignore_unusable(map, memmap.nr_entries);
+
 	/* Make sure the Xen-supplied memory map is well-ordered. */
 	sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);

  reply	other threads:[~2013-07-08 12:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-08 10:31 Xen not working with stock Debian Wheezy 3.2 kernel on a Core 2 Duo box Wei Liu
2013-07-08 11:29 ` Jan Beulich
2013-07-08 12:06   ` David Vrabel [this message]
2013-07-08 12:52     ` Wei Liu
2013-07-08 13:02     ` Wei Liu
2013-07-08 12:50   ` Wei Liu
2013-07-08 13:16     ` Jan Beulich
2013-07-08 13:42       ` Wei Liu
2013-07-08 14:03         ` Jan Beulich
2013-07-08 14:11           ` Wei Liu
2013-07-08 19:47       ` Is: MTRR issue + Xen + memory clipping? Was:Re: " Konrad Rzeszutek Wilk
2013-07-09  9:46         ` Stefan Bader
2013-07-09 13:37           ` Wei Liu

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=51DAAB3A.7060802@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=wei.liu2@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 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.