Re: [Xen-devel] [PATCH for-4.10] tools/libxl: mark hvm mmio area as reserved in e820 map

2017-11-17 Thread Juergen Gross
On 17/11/17 12:47, Juergen Gross wrote:
> Make sure the HVM mmio area (especially console and Xenstore pages) is
> marked as "reserved" in the guest's E820 map, as otherwise conflicts
> might arise later, e.g. when hotplugging memory into the guest.
> 
> Signed-off-by: Juergen Gross 
> ---
> This is a bugfix for PVH and HVM guests. Please consider for 4.10.

Please ignore this patch, it upsets HVMloader.


Juergen

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] tools/libxl: mark hvm mmio area as reserved in e820 map

2017-11-17 Thread Juergen Gross
On 17/11/17 13:26, Jan Beulich wrote:
 On 17.11.17 at 12:47,  wrote:
>> Make sure the HVM mmio area (especially console and Xenstore pages) is
>> 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 very certainly wrong. Have you looked at a couple of physical
> machines? Have you found an E820_RESERVED area on any of them for
> the MMIO hole? Two examples I can present right away:
> 
> <6>BIOS-e820: [mem 0xc93f-0xc9f8cfff] reserved
> <6>BIOS-e820: [mem 0xc9f8d000-0xc9fdefff] ACPI data
> <6>BIOS-e820: [mem 0xc9fdf000-0xcac82fff] ACPI NVS
> <6>BIOS-e820: [mem 0xcac83000-0xcb172fff] reserved
> <6>BIOS-e820: [mem 0xcb173000-0xcb173fff] usable
> <6>BIOS-e820: [mem 0xcb174000-0xcb181fff] reserved
> <6>BIOS-e820: [mem 0xcb182000-0xccff] usable
> <6>BIOS-e820: [mem 0xcd00-0xcdff] reserved
> <6>BIOS-e820: [mem 0xd000-0xdfff] reserved
> <6>BIOS-e820: [mem 0xfed1c000-0xfed1] reserved
> <6>BIOS-e820: [mem 0xff00-0x] reserved
> 
> and
> 
> (XEN)  cf4bd000 - cf4bf000 (reserved)
> (XEN)  cf4bf000 - cf636000 (usable)
> (XEN)  cf636000 - cf7bf000 (ACPI NVS)
> (XEN)  cf7bf000 - cf7df000 (usable)
> (XEN)  cf7df000 - cf7ff000 (ACPI data)
> (XEN)  cf7ff000 - cf80 (usable)
> (XEN)  cf80 - d000 (reserved)
> (XEN)  f800 - fd00 (reserved)
> (XEN)  ffe0 - 0001 (reserved)
> 
> Things covered by E820_RESERVED include the MCFG area, yes, but
> not most other parts. The OS has to either be careful or consult
> ACPI for further resource usage details. In particular, the ACPI spec
> says
> 
> "The platform boot firmware does not return a range description for
>  the memory mapping of PCI devices, ISA Option ROMs, and ISA Plug
>  and Play cards because the OS has mechanisms available to detect
>  them."
> 
> See the section "E820 Assumptions and Limitations" for further details.

So is it _wrong_ to return the mmio area as reserved? We at least want
the shared console and Xenstore page to be marked as reserved, and those
are part of the mmio area.

We could, of course, just report the HVM special pages as reserved, but
this would IMO be more hacky than reporting just the mmio area.

Oh yes, and the LAPIC, of course. Again part of mmio area.


Juergen

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] tools/libxl: mark hvm mmio area as reserved in e820 map

2017-11-17 Thread Jan Beulich
>>> On 17.11.17 at 12:47,  wrote:
> Make sure the HVM mmio area (especially console and Xenstore pages) is
> 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 very certainly wrong. Have you looked at a couple of physical
machines? Have you found an E820_RESERVED area on any of them for
the MMIO hole? Two examples I can present right away:

<6>BIOS-e820: [mem 0xc93f-0xc9f8cfff] reserved
<6>BIOS-e820: [mem 0xc9f8d000-0xc9fdefff] ACPI data
<6>BIOS-e820: [mem 0xc9fdf000-0xcac82fff] ACPI NVS
<6>BIOS-e820: [mem 0xcac83000-0xcb172fff] reserved
<6>BIOS-e820: [mem 0xcb173000-0xcb173fff] usable
<6>BIOS-e820: [mem 0xcb174000-0xcb181fff] reserved
<6>BIOS-e820: [mem 0xcb182000-0xccff] usable
<6>BIOS-e820: [mem 0xcd00-0xcdff] reserved
<6>BIOS-e820: [mem 0xd000-0xdfff] reserved
<6>BIOS-e820: [mem 0xfed1c000-0xfed1] reserved
<6>BIOS-e820: [mem 0xff00-0x] reserved

and

(XEN)  cf4bd000 - cf4bf000 (reserved)
(XEN)  cf4bf000 - cf636000 (usable)
(XEN)  cf636000 - cf7bf000 (ACPI NVS)
(XEN)  cf7bf000 - cf7df000 (usable)
(XEN)  cf7df000 - cf7ff000 (ACPI data)
(XEN)  cf7ff000 - cf80 (usable)
(XEN)  cf80 - d000 (reserved)
(XEN)  f800 - fd00 (reserved)
(XEN)  ffe0 - 0001 (reserved)

Things covered by E820_RESERVED include the MCFG area, yes, but
not most other parts. The OS has to either be careful or consult
ACPI for further resource usage details. In particular, the ACPI spec
says

"The platform boot firmware does not return a range description for
 the memory mapping of PCI devices, ISA Option ROMs, and ISA Plug
 and Play cards because the OS has mechanisms available to detect
 them."

See the section "E820 Assumptions and Limitations" for further details.

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH for-4.10] tools/libxl: mark hvm mmio area as reserved in e820 map

2017-11-17 Thread Wei Liu
On Fri, Nov 17, 2017 at 12:47:33PM +0100, Juergen Gross wrote:
> Make sure the HVM mmio area (especially console and Xenstore pages) is
> marked as "reserved" in the guest's E820 map, as otherwise conflicts
> might arise later, e.g. when hotplugging memory into the guest.
> 
> Signed-off-by: Juergen Gross 

Acked-by: Wei Liu 

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

I agree this is 4.10 material.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH for-4.10] tools/libxl: mark hvm mmio area as reserved in e820 map

2017-11-17 Thread Juergen Gross
Make sure the HVM mmio area (especially console and Xenstore pages) is
marked as "reserved" in the guest's E820 map, as otherwise conflicts
might arise later, e.g. when hotplugging memory into the guest.

Signed-off-by: Juergen Gross 
---
This is a bugfix for PVH and HVM guests. Please consider for 4.10.
---
 tools/libxl/libxl_x86.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 5f91fe4f92..664bf8bd64 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -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. */
+if (dom->mmio_size)
+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) {
+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);
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel