Skip to contentSkip to conversation

tools/libxl: mark special pages as reserved in e820 map for PVH

PATCH In review Juergen Gross 6 participants 17 messages Nov 21, 2017 – Feb 13, 2018 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tools/libxl: mark special pages as reserved in e820 map for PVH

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

---
 tools/libxl/libxl_x86.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/libxl/libxl_x86.c +11 -0
index 5f91fe4f92..d82013f6ed 100644
@@ -530,6 +530,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
         if (d_config->rdms[i].policy != LIBXL_RDM_RESERVE_POLICY_INVALID)
             e820_entries++;
 
+    /* Add mmio entry for PVH. */
+    if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH)
+        e820_entries++;
 
     /* If we should have a highmem range. */
     if (highmem_size)
@@ -564,6 +567,14 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
         nr++;
     }
 
+    /* mmio area */
+    if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH) {
+        e820[nr].addr = dom->mmio_start;
+        e820[nr].size = dom->mmio_size;
+        e820[nr].type = E820_RESERVED;
+        nr++;
+    }
+
     for (i = 0; i < MAX_ACPI_MODULES; i++) {
         if (dom->acpi_modules[i].length) {
             e820[nr].addr = dom->acpi_modules[i].guest_addr_out & ~(page_size - 1);
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 21.11.17 at 12:06, <[email protected]> wrote:

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

Afaict this differs from v1 only in no longer adding the extra entry for HVM. How does this address the concerns raised on v1 wrt spec compliance? v1 having caused problems with hvmloader should not have resulted in simply excluding HVM here. That's even more so because we mean HVM and PVH to converge in the long run - I'd expect that to mean that no clear type distinction would exist anymore on libxl.

If you want to reserve Xenstore ring buffer and console page, why don't you reserve just the two (provided of course they live outside of any [fake] PCI device BAR), which then ought to also be compatible with plain HVM?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 6 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 21.11.17 at 12:06, <[email protected]> wrote:

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

Quoted 7 lines

Afaict this differs from v1 only in no longer adding the extra entry for HVM. How does this address the concerns raised on v1 wrt spec compliance? v1 having caused problems with hvmloader should not have resulted in simply excluding HVM here. That's even more so because we mean HVM and PVH to converge in the long run - I'd expect that to mean that no clear type distinction would exist anymore on libxl.

The difference is for HVM the HVMloader is creating the additional "Reserved" entry.

Quoted 4 lines

If you want to reserve Xenstore ring buffer and console page, why don't you reserve just the two (provided of course they live outside of any [fake] PCI device BAR), which then ought to also be compatible with plain HVM?

For PVH the "mmio" area is starting with the LAPIC and extends up to 4GB. And all of this area conflicts with the HVMloader:

(d11) HVM Loader
(d11) Detected Xen v4.10-unstable
(d11) Fail to setup memory map due to conflict on dynamic reserved memory range.
(d11) *** HVMLoader bug at e820.c:52
(d11) *** HVMLoader crashed.

I guess this should be fixed, but I wanted the patch to be as small as possible to minimze the risk for 4.10.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 21.11.17 at 12:48, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 21.11.17 at 12:06, <[email protected]> wrote:

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

Quoted 7 lines

Afaict this differs from v1 only in no longer adding the extra entry for HVM. How does this address the concerns raised on v1 wrt spec compliance? v1 having caused problems with hvmloader should not have resulted in simply excluding HVM here. That's even more so because we mean HVM and PVH to converge in the long run - I'd expect that to mean that no clear type distinction would exist anymore on libxl.

The difference is for HVM the HVMloader is creating the additional "Reserved" entry.

Quoted 7 lines
Quoted 4 lines

If you want to reserve Xenstore ring buffer and console page, why don't you reserve just the two (provided of course they live outside of any [fake] PCI device BAR), which then ought to also be compatible with plain HVM?

For PVH the "mmio" area is starting with the LAPIC and extends up to 4GB.

Oh, I see - that's probably okay then (or at least as okay as libxl having knowledge of the LAPIC base address in the first place).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
In reply to Juergen Gross
Quoted 8 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

Quoted 24 lines
---
 tools/libxl/libxl_x86.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/libxl/libxl_x86.c +4 -0
index 5f91fe4f92..d82013f6ed 100644
@@ -530,6 +530,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
         if (d_config->rdms[i].policy != LIBXL_RDM_RESERVE_POLICY_INVALID)
             e820_entries++;
 
+    /* Add mmio entry for PVH. */
+    if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH)
+        e820_entries++;
 
     /* If we should have a highmem range. */
     if (highmem_size)
@@ -564,6 +567,14 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
         nr++;
     }
 
+    /* mmio area */

tools/libxl/libxl_x86.c int libxl__arch_domain_construct_memmap(libxl__gc *gc, · line 580

Quoted 10 lines
tools/libxl/libxl_x86.c +7 -0
+    if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH) {
+        e820[nr].addr = dom->mmio_start;
+        e820[nr].size = dom->mmio_size;
+        e820[nr].type = E820_RESERVED;
+        nr++;
+    }
+
     for (i = 0; i < MAX_ACPI_MODULES; i++) {
         if (dom->acpi_modules[i].length) {
             e820[nr].addr = dom->acpi_modules[i].guest_addr_out & ~(page_size - 1);

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw

Hi Juergen,

Quoted 11 lines · Juergen Gross
Quoted 8 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

I was waiting an ack from tools maintainers before looking for a release perspective.

I would recommend to tag your patch is 4.10 to help reviewers prioritize review on your patch. I have done it now.

I am looking at releasing Xen 4.10 in the next few days. Can you explain the pros/cons of this patch?

Cheers,

Quoted 42 lines
Quoted 25 lines
---
  tools/libxl/libxl_x86.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
tools/libxl/libxl_x86.c +4 -0
index 5f91fe4f92..d82013f6ed 100644
@@ -530,6 +530,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
          if (d_config->rdms[i].policy != LIBXL_RDM_RESERVE_POLICY_INVALID)
              e820_entries++;
 
+    /* Add mmio entry for PVH. */
+    if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH)
+        e820_entries++;
 
      /* If we should have a highmem range. */
      if (highmem_size)
@@ -564,6 +567,14 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
          nr++;
      }
 
+    /* mmio area */

tools/libxl/libxl_x86.c int libxl__arch_domain_construct_memmap(libxl__gc *gc, · line 580

Quoted 10 lines
tools/libxl/libxl_x86.c +7 -0
+    if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH) {
+        e820[nr].addr = dom->mmio_start;
+        e820[nr].size = dom->mmio_size;
+        e820[nr].type = E820_RESERVED;
+        nr++;
+    }
+
      for (i = 0; i < MAX_ACPI_MODULES; i++) {
          if (dom->acpi_modules[i].length) {
              e820[nr].addr = dom->acpi_modules[i].guest_addr_out & ~(page_size - 1);

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by
#7 lore raw

Julien Grall writes ("[for-4.10] Re: [Xen-devel] [PATCH v2] tools/libxl: mark special pages as reserved in e820 map for PVH"):

Quoted 2 lines

I would recommend to tag your patch is 4.10 to help reviewers prioritize review on your patch. I have done it now.

Thanks. Looking at the thread, I would have liked to see an answer to this comment by Roger:

| Albeit I would also prefer this to not be PVH specific. Ideally I
| would like both PVH and HVM to share the logic to mark the reserved
| regions in the memory map. I guess this can be fixed afterwards by
| moving away this logic from hvmloader and handling the creation of
| the memory map for both HVM and PVH in libxl.

But it seems to be a bugfix and has had review from the x86 perspective, so:

If anyone is feeling up to doing some improvement, I would like to see a rework of the algorithm to avoid this error-prone duplicated- information construction:

+ /* Add mmio entry for PVH. */
+ if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH)
+ e820_entries++;

@@ -564,6 +567,14 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,

+ /* mmio area */
+ if (dom->mmio_size && d_config->b_info.type == LIBXL_DOMAIN_TYPE_PVH) {

  +        e820[nr].addr = dom->mmio_start;
  +        e820[nr].size = dom->mmio_size;
  +        e820[nr].type = E820_RESERVED;
  +        nr++;

+ }
+

That is, there should be no separate pre-calculation of the number of entries. There would have to be an expanding array instead.

Regards,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
In reply to Julien Grall
Quoted 15 lines · Julien Grall

Hi Juergen,

Quoted 11 lines · Juergen Gross
Quoted 8 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

Quoted 8 lines

I was waiting an ack from tools maintainers before looking for a release perspective.

I would recommend to tag your patch is 4.10 to help reviewers prioritize review on your patch. I have done it now.

I am looking at releasing Xen 4.10 in the next few days. Can you explain the pros/cons of this patch?

Pros: PVH guests with 4GB of memory or more will work. :-)
Cons: There is a more general solution (as Roger pointed out), but
this would require much more work.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw

Hi Juergen,

Quoted 19 lines · Juergen Gross
Quoted 18 lines · Julien Grall

Hi Juergen,

Quoted 11 lines · Juergen Gross
Quoted 8 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

I was waiting an ack from tools maintainers before looking for a release perspective.

Quoted 7 lines
Quoted 5 lines

I would recommend to tag your patch is 4.10 to help reviewers prioritize review on your patch. I have done it now.

I am looking at releasing Xen 4.10 in the next few days. Can you explain the pros/cons of this patch?

Pros: PVH guests with 4GB of memory or more will work. :-)

They never worked before? Or is it a regression? If it is a regression when did it appear?

Quoted 2 lines

Cons: There is a more general solution (as Roger pointed out), but
this would require much more work.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#10 lore raw
Quoted 25 lines · Julien Grall

Hi Juergen,

Quoted 22 lines · Juergen Gross
Quoted 21 lines · Julien Grall

Hi Juergen,

Quoted 11 lines · Juergen Gross
Quoted 8 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

I was waiting an ack from tools maintainers before looking for a release perspective.

I would recommend to tag your patch is 4.10 to help reviewers prioritize review on your patch. I have done it now.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I am looking at releasing Xen 4.10 in the next few days. Can you explain the pros/cons of this patch?

Pros: PVH guests with 4GB of memory or more will work. :-)

They never worked before? Or is it a regression? If it is a regression when did it appear?

Hmm, seems we are lucky: Linux kernel will not try to map any memory there (I just tested it). So we don't need that patch in 4.10 for Linux running as PVH guest. Not sure about BSD, though.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#11 lore raw
Quoted 29 lines · Juergen Gross
Quoted 28 lines · Julien Grall

Hi Juergen,

Quoted 25 lines · Juergen Gross
Quoted 23 lines · Julien Grall

Hi Juergen,

Quoted 11 lines · Juergen Gross
Quoted 8 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

I was waiting an ack from tools maintainers before looking for a release perspective.

I would recommend to tag your patch is 4.10 to help reviewers prioritize review on your patch. I have done it now.

I am looking at releasing Xen 4.10 in the next few days. Can you explain the pros/cons of this patch?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Pros: PVH guests with 4GB of memory or more will work. :-)

They never worked before? Or is it a regression? If it is a regression when did it appear?

Hmm, seems we are lucky: Linux kernel will not try to map any memory there (I just tested it). So we don't need that patch in 4.10 for Linux running as PVH guest. Not sure about BSD, though.

I haven't yet committed any PVHv2 support to FreeBSD, but in any case I always avoid using memory below 4GB just in case...

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#12 lore raw

Hi,

Quoted 35 lines · Roger Pau Monné
Quoted 34 lines · Juergen Gross
Quoted 32 lines · Julien Grall

Hi Juergen,

Quoted 19 lines · Juergen Gross
Quoted 18 lines · Julien Grall

Hi Juergen,

Quoted 11 lines · Juergen Gross
Quoted 8 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

I was waiting an ack from tools maintainers before looking for a release perspective.

Quoted 7 lines
Quoted 5 lines

I would recommend to tag your patch is 4.10 to help reviewers prioritize review on your patch. I have done it now.

I am looking at releasing Xen 4.10 in the next few days. Can you explain the pros/cons of this patch?

Pros: PVH guests with 4GB of memory or more will work. :-)

They never worked before? Or is it a regression? If it is a regression when did it appear?

Quoted 6 lines
Quoted 3 lines

Hmm, seems we are lucky: Linux kernel will not try to map any memory there (I just tested it). So we don't need that patch in 4.10 for Linux running as PVH guest. Not sure about BSD, though.

I haven't yet committed any PVHv2 support to FreeBSD, but in any case I always avoid using memory below 4GB just in case...

I will defer this patch post 4.10. We can add a release note if you think it is worth it.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#13 lore raw
Quoted 47 lines · Julien Grall

Hi,

Quoted 44 lines · Roger Pau Monné
Quoted 42 lines · Juergen Gross
Quoted 29 lines · Julien Grall

Hi Juergen,

Quoted 26 lines · Juergen Gross
Quoted 25 lines · Julien Grall

Hi Juergen,

Quoted 8 lines · Juergen Gross
Quoted 7 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and
Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when
hotplugging memory into the guest.

Quoted 5 lines
Quoted 3 lines

---
This is a bugfix for PVH guests. Please consider for 4.10.

Ping?

I was waiting an ack from tools maintainers before looking for a release
perspective.

I would recommend to tag your patch is 4.10 to help reviewers prioritize
review on your patch. I have done it now.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I am looking at releasing Xen 4.10 in the next few days. Can you explain
the pros/cons of this patch?

Pros: PVH guests with 4GB of memory or more will work. :-)

They never worked before? Or is it a regression? If it is a regression when did it appear?

Hmm, seems we are lucky: Linux kernel will not try to map any memory there (I just tested it). So we don't need that patch in 4.10 for Linux running as PVH guest. Not sure about BSD, though.

Quoted 5 lines
Quoted 2 lines

I haven't yet committed any PVHv2 support to FreeBSD, but in any case I always avoid using memory below 4GB just in case...

I will defer this patch post 4.10. We can add a release note if you think it is worth it.

I don't think that is needed.

And in case someone hits this problem we can easily apply the patch to a 4.10 update release later.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v2 1/1
#14 lore raw
In reply to Juergen Gross
Quoted 6 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

Albeit I would also prefer this to not be PVH specific. Ideally I would like both PVH and HVM to share the logic to mark the reserved regions in the memory map. I guess this can be fixed afterwards by moving away this logic from hvmloader and handling the creation of the memory map for both HVM and PVH in libxl.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#15 lore raw
In reply to Juergen Gross
Quoted 6 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

Is this patch still relevant? The reasoning looks sensible to me fwiw.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#16 lore raw
Quoted 9 lines · Wei Liu
Quoted 6 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

Is this patch still relevant? The reasoning looks sensible to me fwiw.

I still think it should be applied, yes.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#17 lore raw
Quoted 7 lines · Juergen Gross
Quoted 6 lines · Wei Liu
Quoted 5 lines · Juergen Gross

The "special pages" for PVH guests include the frames for console and Xenstore ring buffers. Those have to be marked as "Reserved" in the guest's E820 map, as otherwise conflicts might arise later e.g. when hotplugging memory into the guest.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Is this patch still relevant? The reasoning looks sensible to me fwiw.

I still think it should be applied, yes.

Acked + applied.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel