Skip to contentSkip to conversation

linux-xen: Extend xen kexec hypercall to return additional regions

PATCH In review Simon Horman 3 participants 8 messages Feb 27, 2008 – Feb 29, 2008 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

cover linux-xen: Extend xen kexec hypercall to return additional regions

this series makes use of the extra regions that can be retrieved using the kexec hypercall, as per patches posted in a separate series.

This allows all regions that kexec needs to avoid to be retrieved from the hypervisor. The patch set also places all of these regions into /proc/iomem_machine - previously some where in /proc/iomem_machine and some where in /proc/iomem.

There are generic and ia64 specific patches in this series. I wanted to post them together as they don't make much sense without each other.

As well as the related xen patches, there are also related kexec-tools patches which I have posted to the kexec mailing list and intend to merge.
http://lists.infradead.org/pipermail/kexec/2008-February/001348.html

The end-game here is to make sure that all the reserved regions show up in /proc/iomem_machine on ia64. This currently does not happen. And manifests as kexec only being able to be performed once as the boot parameter ends up being overwritten in relocate_kernel before purgatory is reached.

Xen--kexec-->Xen--kexec [hang in purgatory!]

The EFI-RID patches for ia64 xen kexec are also needed for kexec to function on ia64. However they touch different code paths and can be merged separately.

Signature · 1 line
Horms
#1 lore raw

PATCH 1/4 kexec: add parent to per-cpu regions at setup time.

This is slightly more efficient as xen_machine_kexec_setup_resorces() is called once (before xen_machine_kexec_register_resources()). While xen_machine_kexec_register_resources() is called once for each EFI memory region seen by a domain.

More cosmetic than anything else, but it seems more logical to me.

---

 drivers/xen/core/machine_kexec.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/xen/core/machine_kexec.c +4 -6
Index: linux-2.6.18-xen.hg/drivers/xen/core/machine_kexec.c
===================================================================
@@ -79,6 +79,10 @@ void __init xen_machine_kexec_setup_reso
 	xen_hypervisor_res.end = range.start + range.size - 1;
 	xen_hypervisor_res.flags = IORESOURCE_BUSY | IORESOURCE_MEM;
 
+	/* The per-cpu crash note resources belong to the hypervisor resource */
+	for (k = 0; k < xen_max_nr_phys_cpus; k++)
+		request_resource(&xen_hypervisor_res, xen_phys_cpus + k);
+
 	/* fill in crashk_res if range is reserved by hypervisor */
 
 	memset(&range, 0, sizeof(range));
@@ -106,13 +110,7 @@ void __init xen_machine_kexec_setup_reso
 
 void __init xen_machine_kexec_register_resources(struct resource *res)
 {
-	int k;
-
 	request_resource(res, &xen_hypervisor_res);
-
-	for (k = 0; k < xen_max_nr_phys_cpus; k++)
-		request_resource(&xen_hypervisor_res, xen_phys_cpus + k);
-
 }
 
 static void setup_load_arg(xen_kexec_image_t *xki, struct kimage *image)
Signature · 2 lines
-- 
Horms
#2 lore raw

PATCH 2/4 kexec: add xen_machine_kexec_register_resources() and machine_kexec_register_resources()

In reply to Simon Horman

Add xen_machine_kexec_register_resources() and machine_kexec_register_resources() to allow architecture specific handling of iomem resources.

At this time xen_machine_kexec_register_resources() does the same parenting of per-cpu resources on all architectures. And machine_kexec_register_resources does nothing on all architectures. A subsequent patch will alter the behaviour on ia64.

---

 arch/i386/kernel/machine_kexec.c   |   15 +++++++++++++++
 arch/ia64/kernel/machine_kexec.c   |   15 +++++++++++++++
 arch/x86_64/kernel/machine_kexec.c |   15 +++++++++++++++
 drivers/xen/core/machine_kexec.c   |   13 +++++++++----
 4 files changed, 54 insertions(+), 4 deletions(-)
arch/i386/kernel/machine_kexec.c +15 -0
Index: linux-2.6.18-xen.hg/arch/i386/kernel/machine_kexec.c
===================================================================
@@ -64,6 +64,21 @@ void machine_kexec_setup_load_arg(xen_ke
 
 }
 
+int __init machine_kexec_setup_resources(struct resource *hypervisor,
+					 struct resource *phys_cpus,
+					 int nr_phys_cpus)
+{
+	int k;
+
+	/* The per-cpu crash note resources belong to the hypervisor resource */
+	for (k = 0; k < nr_phys_cpus; k++)
+		request_resource(hypervisor, phys_cpus + k);
+
+	return 0;
+}
+
+void machine_kexec_register_resources(struct resource *res) { ; }
+
 #endif /* CONFIG_XEN */
 
 /*
arch/ia64/kernel/machine_kexec.c +15 -0
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/machine_kexec.c
===================================================================
@@ -142,4 +142,19 @@ void machine_kexec_setup_load_arg(xen_ke
 	xki->reboot_code_buffer =
 		kexec_page_to_pfn(image->control_code_page) << PAGE_SHIFT;
 }
+
+int __init machine_kexec_setup_resources(struct resource *hypervisor,
+					 struct resource *phys_cpus,
+					 int nr_phys_cpus)
+{
+	int k;
+
+	/* The per-cpu crash note resources belong to the hypervisor resource */
+	for (k = 0; k < nr_phys_cpus; k++)
+		request_resource(hypervisor, phys_cpus + k);
+
+	return 0;
+}
+
+void machine_kexec_register_resources(struct resource *res) { ; }
 #endif /* CONFIG_XEN */
arch/x86_64/kernel/machine_kexec.c +15 -0
Index: linux-2.6.18-xen.hg/arch/x86_64/kernel/machine_kexec.c
===================================================================
@@ -104,6 +104,21 @@ void machine_kexec_setup_load_arg(xen_ke
 	xki->page_list[PA_PTE_1] = __ma(kexec_pte1);
 }
 
+int __init machine_kexec_setup_resources(struct resource *hypervisor,
+					 struct resource *phys_cpus,
+					 int nr_phys_cpus)
+{
+	int k;
+
+	/* The per-cpu crash note resources belong to the hypervisor resource */
+	for (k = 0; k < nr_phys_cpus; k++)
+		request_resource(hypervisor, phys_cpus + k);
+
+	return 0;
+}
+
+void machine_kexec_register_resources(struct resource *res) { ; }
+
 #else /* CONFIG_XEN */
 
 #define x__pmd(x) __pmd(x)
drivers/xen/core/machine_kexec.c +9 -4
Index: linux-2.6.18-xen.hg/drivers/xen/core/machine_kexec.c
===================================================================
@@ -10,6 +10,10 @@
 
 extern void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, 
 					 struct kimage *image);
+extern int machine_kexec_setup_resources(struct resource *hypervisor,
+					 struct resource *phys_cpus,
+					 int nr_phys_cpus);
+extern void machine_kexec_register_resources(struct resource *res);
 
 static int __initdata xen_max_nr_phys_cpus;
 static struct resource xen_hypervisor_res;
@@ -79,10 +83,6 @@ void __init xen_machine_kexec_setup_reso
 	xen_hypervisor_res.end = range.start + range.size - 1;
 	xen_hypervisor_res.flags = IORESOURCE_BUSY | IORESOURCE_MEM;
 
-	/* The per-cpu crash note resources belong to the hypervisor resource */
-	for (k = 0; k < xen_max_nr_phys_cpus; k++)
-		request_resource(&xen_hypervisor_res, xen_phys_cpus + k);
-
 	/* fill in crashk_res if range is reserved by hypervisor */
 
 	memset(&range, 0, sizeof(range));
@@ -96,6 +96,10 @@ void __init xen_machine_kexec_setup_reso
 		crashk_res.end = range.start + range.size - 1;
 	}
 
+	if (machine_kexec_setup_resources(&xen_hypervisor_res, xen_phys_cpus,
+					  xen_max_nr_phys_cpus))
+		goto err;
+
 	return;
 
  err:
@@ -111,6 +115,7 @@ void __init xen_machine_kexec_setup_reso
 void __init xen_machine_kexec_register_resources(struct resource *res)
 {
 	request_resource(res, &xen_hypervisor_res);
+	machine_kexec_register_resources(res);
 }
 
 static void setup_load_arg(xen_kexec_image_t *xki, struct kimage *image)
Signature · 2 lines
-- 
Horms
#3 lore raw

PATCH 3/4 kexec: read more iomem regions from hypevisor

In reply to Simon Horman

This sets the location of the efi memmap and boot parameter regions using information provided by the hypervisor, overriding values derived by dom0 from the virtualised efi memory regions.

It also creates a xen heap region and uses this as the parent of per-cpu regions - they belong in hypervisor memory not dom0 kernel memory.

The xen heap region is inserted into /proc/iomem_machine

* There is also a hypervisor portion of this patch.
* In order for the regions to show up after kexec patches to kexec-tools are required. I have posted them to the kexec mailing list and intend to merge them.

http://lists.infradead.org/pipermail/kexec/2008-February/001348.html

---

 arch/ia64/kernel/machine_kexec.c |   50 +++++++++++++++++++++++++++++++++++---
 include/xen/interface/kexec.h    |   15 +++++++++--
 2 files changed, 59 insertions(+), 6 deletions(-)
include/xen/interface/kexec.h +12 -3
Index: linux-2.6.18-xen.hg/include/xen/interface/kexec.h
===================================================================
@@ -108,9 +108,18 @@ typedef struct xen_kexec_load {
     xen_kexec_image_t image;
 } xen_kexec_load_t;
 
-#define KEXEC_RANGE_MA_CRASH 0   /* machine address and size of crash area */
-#define KEXEC_RANGE_MA_XEN   1   /* machine address and size of Xen itself */
-#define KEXEC_RANGE_MA_CPU   2   /* machine address and size of a CPU note */
+#define KEXEC_RANGE_MA_CRASH      0 /* machine address and size of crash area */
+#define KEXEC_RANGE_MA_XEN        1 /* machine address and size of Xen itself */
+#define KEXEC_RANGE_MA_CPU        2 /* machine address and size of a CPU note */
+#define KEXEC_RANGE_MA_XENHEAP    3 /* machine address and size of xenheap
+				     * Note that although this is adjacent
+				     * to Xen it exists in a separate EFI
+				     * region on ia64, and thus needs to be
+				     * inserted into iomem_machine separately */
+#define KEXEC_RANGE_MA_BOOT_PARAM 4 /* machine address and size of
+                                     * the ia64_boot_param */
+#define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of
+                                     * of the EFI Memory Map */
 
 /*
  * Find the address and size of certain memory areas
arch/ia64/kernel/machine_kexec.c +47 -3

65 lines not on this page · raw message

Signature · 2 lines
-- 
Horms
#4 lore raw

PATCH 4/4 kexec: dont initialise regions in reserve_memory()

In reply to Simon Horman

There is no need to initialise efi_memmap_res and boot_param_res in reserve_memory() for the initial xen domain as it is done in machine_kexec_setup_resources() using values from the kexec hypercall.

---

 arch/ia64/kernel/setup.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
arch/ia64/kernel/setup.c +3 -3
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/setup.c
===================================================================
@@ -336,15 +336,15 @@ reserve_memory (void)
 				}
 			}
 		}
-#ifdef CONFIG_XEN
-		}
-#endif
 		efi_memmap_res.start = ia64_boot_param->efi_memmap;
                 efi_memmap_res.end = efi_memmap_res.start +
                         ia64_boot_param->efi_memmap_size;
                 boot_param_res.start = kexec_virt_to_phys(ia64_boot_param);
                 boot_param_res.end = boot_param_res.start +
                         sizeof(*ia64_boot_param);
+#ifdef CONFIG_XEN
+		}
+#endif
 	}
 #endif
 	/* end of memory marker */
Signature · 2 lines
-- 
Horms
#5 lore raw
In reply to Simon Horman

Hi Simon,

These look ok to me. Ack. Thanks,

Alex

Quoted 31 lines · Simon Horman

this series makes use of the extra regions that can be retrieved using the kexec hypercall, as per patches posted in a separate series.

This allows all regions that kexec needs to avoid to be retrieved from the hypervisor. The patch set also places all of these regions into /proc/iomem_machine - previously some where in /proc/iomem_machine and some where in /proc/iomem.

There are generic and ia64 specific patches in this series. I wanted to post them together as they don't make much sense without each other.

As well as the related xen patches, there are also related kexec-tools patches which I have posted to the kexec mailing list and intend to merge.
http://lists.infradead.org/pipermail/kexec/2008-February/001348.html

The end-game here is to make sure that all the reserved regions show up in /proc/iomem_machine on ia64. This currently does not happen. And manifests as kexec only being able to be performed once as the boot parameter ends up being overwritten in relocate_kernel before purgatory is reached.

Xen--kexec-->Xen--kexec [hang in purgatory!]

The EFI-RID patches for ia64 xen kexec are also needed for kexec to function on ia64. However they touch different code paths and can be merged separately.

Signature · 1 line
Alex Williamson                             HP Open Source & Linux Org.
#6 lore raw

Thanks,

I will apply all parts of these kexec patches into xen-unstable directly, including the ia64 portions.

-- Keir

Quoted 38 lines · Alex Williamson

Hi Simon,

These look ok to me. Ack. Thanks,

Alex

Quoted 31 lines · Simon Horman

this series makes use of the extra regions that can be retrieved using the kexec hypercall, as per patches posted in a separate series.

This allows all regions that kexec needs to avoid to be retrieved from the hypervisor. The patch set also places all of these regions into /proc/iomem_machine - previously some where in /proc/iomem_machine and some where in /proc/iomem.

There are generic and ia64 specific patches in this series. I wanted to post them together as they don't make much sense without each other.

As well as the related xen patches, there are also related kexec-tools patches which I have posted to the kexec mailing list and intend to merge.
http://lists.infradead.org/pipermail/kexec/2008-February/001348.html

The end-game here is to make sure that all the reserved regions show up in /proc/iomem_machine on ia64. This currently does not happen. And manifests as kexec only being able to be performed once as the boot parameter ends up being overwritten in relocate_kernel before purgatory is reached.

Xen--kexec-->Xen--kexec [hang in purgatory!]

The EFI-RID patches for ia64 xen kexec are also needed for kexec to function on ia64. However they touch different code paths and can be merged separately.

#7 lore raw
Quoted 4 lines · Keir Fraser

Thanks,

I will apply all parts of these kexec patches into xen-unstable directly, including the ia64 portions.

Thanks Keir.

Signature · 1 line
Horms