xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Gordan Bobic <gordan@bobich.net>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: HVM support for e820_host (Was: Bug: Limitation of <=2GB RAM in domU persists with 4.3.0)
Date: Fri, 06 Sep 2013 20:54:24 +0100	[thread overview]
Message-ID: <522A32F0.6080304@bobich.net> (raw)
In-Reply-To: <d1c8c70b6f730671c91d6289f15e5a5c@mail.shatteredsilicon.net>

Here is a test patch I applied to:
/tools/firmware/hvmloader/e820.c

===
--- e820.c.orig	2013-09-06 11:15:20.023337321 +0100
+++ e820.c	2013-09-06 19:53:00.141876019 +0100
@@ -79,6 +79,7 @@
      unsigned int nr = 0;
      struct xen_memory_map op;
      struct e820entry map[E820MAX];
+    int e820_host = 0;
      int rc;

      if ( !lowmem_reserved_base )
@@ -88,6 +89,7 @@

      rc = hypercall_memory_op ( XENMEM_memory_map, &op);
      if ( rc != -ENOSYS) { /* It works!? */
+        e820_host = 1;
          printf("%s:%d got %d op.nr_entries \n", __func__, __LINE__, 
op.nr_entries);
          dump_e820_table(&map[0], op.nr_entries);
      }
@@ -133,7 +135,12 @@
      /* Low RAM goes here. Reserve space for special pages. */
      BUG_ON((hvm_info->low_mem_pgend << PAGE_SHIFT) < (2u << 20));
      e820[nr].addr = 0x100000;
-    e820[nr].size = (hvm_info->low_mem_pgend << PAGE_SHIFT) - 
e820[nr].addr;
+
+    if (e820_host)
+        e820[nr].size = 0x3f7e0000 - e820[nr].addr;
+    else
+        e820[nr].size = (hvm_info->low_mem_pgend << PAGE_SHIFT) - 
e820[nr].addr;
+
      e820[nr].type = E820_RAM;
      nr++;

===

I'm sure this doesn't need explicitly pointing out, but for the record, 
it is a gross hack just to prove the concept.

The map dump with this patch applied and memory set to 8192 is:

===
(XEN) HVM5: BIOS map:
(XEN) HVM5:  f0000-fffff: Main BIOS
(XEN) HVM5: build_e820_table:93 got 8 op.nr_entries
(XEN) HVM5: E820 table:
(XEN) HVM5:  [00]: 00000000:00000000 - 00000000:3f790000: RAM
(XEN) HVM5:  [01]: 00000000:3f790000 - 00000000:3f79e000: ACPI
(XEN) HVM5:  [02]: 00000000:3f79e000 - 00000000:3f7d0000: NVS
(XEN) HVM5:  [03]: 00000000:3f7d0000 - 00000000:3f7e0000: RESERVED
(XEN) HVM5:  HOLE: 00000000:3f7e0000 - 00000000:3f7e7000
(XEN) HVM5:  [04]: 00000000:3f7e7000 - 00000000:40000000: RESERVED
(XEN) HVM5:  HOLE: 00000000:40000000 - 00000000:fee00000
(XEN) HVM5:  [05]: 00000000:fee00000 - 00000000:fee01000: RESERVED
(XEN) HVM5:  HOLE: 00000000:fee01000 - 00000000:ffc00000
(XEN) HVM5:  [06]: 00000000:ffc00000 - 00000001:00000000: RESERVED
(XEN) HVM5:  [07]: 00000001:00000000 - 00000002:c0870000: RAM
(XEN) HVM5: E820 table:
(XEN) HVM5:  [00]: 00000000:00000000 - 00000000:0009e000: RAM
(XEN) HVM5:  [01]: 00000000:0009e000 - 00000000:000a0000: RESERVED
(XEN) HVM5:  HOLE: 00000000:000a0000 - 00000000:000e0000
(XEN) HVM5:  [02]: 00000000:000e0000 - 00000000:00100000: RESERVED
(XEN) HVM5:  [03]: 00000000:00100000 - 00000000:3f7e0000: RAM
(XEN) HVM5:  HOLE: 00000000:3f7e0000 - 00000000:fc000000
(XEN) HVM5:  [04]: 00000000:fc000000 - 00000001:00000000: RESERVED
(XEN) HVM5:  [05]: 00000001:00000000 - 00000002:1f800000: RAM
(XEN) HVM5: Invoking ROMBIOS ...
===

Good observations:
It works! No crashes, no screen corruption! As an added bonus, it fixes 
the problem of rebooting domUs causing them to lose GPU access and 
eventually crash the host even with memory allocation below the first 
PCI MMIO block. I am suspecting that something in the 
0x3f7e0000-0x3f7e7000 hole that isn't showing up on lspci might be 
responsible.

I think that proves beyond any doubt what the problem was before.

Interesting observations:
1) GPU PCI MMIO is still mapped at E0000000, rather than at the bottom 
of the memory hole. That implies that SeaBIOS (or whatever does the 
mapping) makes assumptions about where the memory hole begins. This will 
need to somehow be fixed / made dynamic. What decides where to map PCI 
memory for each device?

2) The memory hole size difference counts toward the total guest memory. 
I set
memory=8192
maxmem=8192
but Windows in domU only sees 5.48GB. What is particularly odd is that 
that the missing memory isn't 3GB, but 2.5GB - which implies that, 
again, there are other things making assumptions about the size and 
shape of the memory hole and moving the memory from the hole elsewhere 
to make it usable. What does this?

My todo list, in order of priority (unless somebody here has a better 
idea) is:
1) Tidy up the hole enlargement to make it dynamically based on the host 
hole locations. In cases where the host hole overlaps something other 
than guest RAM/HOLE (i.e. RESERVED), guest spec wins.

2) Fix whatever is causing the hole memory increase to reduce the guest 
memory. The memory hole is a hole, not a shadow. I need some pointers on 
where to look for whatever is responsible for this.

3) Fix what makes decisions on where to map devices' memory apertures. 
Ideally, the fix should be to detect host's pBAR make vBAR=pBAR. Again, 
I need some pointers on where to look for whatever is responsible for 
doing this mapping.

Gordan

  reply	other threads:[~2013-09-06 19:54 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 22:34 Bug: Limitation of <=2GB RAM in domU persists with 4.3.0 Gordan Bobic
2013-07-24 14:08 ` Konrad Rzeszutek Wilk
2013-07-24 14:17   ` Gordan Bobic
2013-07-24 16:06     ` Konrad Rzeszutek Wilk
2013-07-24 16:14       ` Gordan Bobic
2013-07-24 16:31         ` Konrad Rzeszutek Wilk
2013-07-24 17:26           ` Gordan Bobic
2013-07-24 22:15           ` Gordan Bobic
2013-07-25 19:18             ` George Dunlap
2013-07-25 21:48               ` Gordan Bobic
2013-07-25 22:23                 ` Gordan Bobic
2013-07-26  0:21                   ` Ian Campbell
2013-07-26  1:15                     ` Andrew Bobulsky
2013-07-26  9:28                       ` Gordan Bobic
2013-07-26 13:11                         ` Gordan Bobic
2013-07-31 17:53                           ` George Dunlap
2013-07-31 17:56                             ` Andrew Cooper
2013-07-31 19:36                               ` Gordan Bobic
2013-07-31 19:35                             ` Gordan Bobic
2013-08-01  9:15                               ` George Dunlap
2013-08-01 13:10                                 ` Fabio Fantoni
2013-08-02 14:43                                   ` George Dunlap
2013-07-28 10:26                       ` Konrad Rzeszutek Wilk
2013-07-28 21:24                         ` Gordan Bobic
2013-07-28 23:17                           ` Konrad Rzeszutek Wilk
2013-07-28 23:30                             ` Gordan Bobic
2013-07-29  9:53                             ` Ian Campbell
2013-07-26  9:23                     ` Gordan Bobic
2013-07-29 11:14                       ` Ian Campbell
2013-07-29 18:04                       ` Konrad Rzeszutek Wilk
2013-09-03 13:53                         ` Gordan Bobic
2013-09-03 14:59                           ` Konrad Rzeszutek Wilk
2013-09-03 19:47                             ` HVM support for e820_host (Was: Bug: Limitation of <=2GB RAM in domU persists with 4.3.0) Gordan Bobic
2013-09-03 20:35                               ` Gordan Bobic
2013-09-03 20:49                                 ` Gordan Bobic
2013-09-03 21:10                                   ` Konrad Rzeszutek Wilk
2013-09-03 21:24                                     ` Gordan Bobic
2013-09-03 21:30                                       ` Konrad Rzeszutek Wilk
2013-09-04  0:18                                         ` Gordan Bobic
2013-09-04 14:08                                           ` Konrad Rzeszutek Wilk
2013-09-04 14:23                                             ` Gordan Bobic
2013-09-04 18:00                                               ` Konrad Rzeszutek Wilk
2013-09-03 21:08                                 ` Konrad Rzeszutek Wilk
2013-09-04  9:21                                   ` Gordan Bobic
2013-09-04 11:01                                   ` Gordan Bobic
2013-09-04 13:11                                     ` Gordan Bobic
2013-09-04 20:18                                       ` Gordan Bobic
2013-09-05  2:04                                       ` Konrad Rzeszutek Wilk
2013-09-05  9:41                                         ` Gordan Bobic
2013-09-05 10:00                                           ` Gordan Bobic
2013-09-05 12:36                                             ` Konrad Rzeszutek Wilk
2013-09-05 10:26                                         ` Gordan Bobic
2013-09-05 12:38                                           ` Konrad Rzeszutek Wilk
2013-09-05 21:13                                         ` Gordan Bobic
2013-09-05 21:29                                           ` Gordan Bobic
2013-09-05 21:46                                             ` Gordan Bobic
2013-09-05 22:23                                           ` Konrad Rzeszutek Wilk
2013-09-05 22:42                                             ` Gordan Bobic
2013-09-06 13:09                                               ` Konrad Rzeszutek Wilk
2013-09-06 14:09                                                 ` Gordan Bobic
2013-09-05 22:45                                             ` Gordan Bobic
2013-09-05 23:01                                               ` Konrad Rzeszutek Wilk
2013-09-06 12:23                                                 ` Gordan Bobic
2013-09-06 13:20                                                   ` Konrad Rzeszutek Wilk
2013-09-06 14:45                                                     ` Gordan Bobic
2013-09-05 22:33                                           ` Gordan Bobic
2013-09-06 13:04                                             ` Konrad Rzeszutek Wilk
2013-09-06 13:34                                               ` Gordan Bobic
2013-09-06 14:32                                                 ` Konrad Rzeszutek Wilk
2013-09-06 16:30                                                   ` Gordan Bobic
2013-09-06 19:54                                                     ` Gordan Bobic [this message]
2013-09-10 13:35                                                       ` Konrad Rzeszutek Wilk
2013-09-10 15:04                                                         ` Gordan Bobic
2013-07-25 21:26           ` Bug: Limitation of <=2GB RAM in domU persists with 4.3.0 Gordan Bobic

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=522A32F0.6080304@bobich.net \
    --to=gordan@bobich.net \
    --cc=konrad.wilk@oracle.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).