Skip to contentSkip to conversation

xen/arm32: setup: Give a xenheap page to the boot allocator

PATCH In review Julien Grall 2 participants 2 messages Sep 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/arm32: setup: Give a xenheap page to the boot allocator

After commit 6e3e771203 "xen/arm: setup: Relocate the Device-Tree later on in the boot", the boot allocator will not receive any xenheap page (i.e. mapped page) on Arm32.

However, the boot allocator implicitely rely on having the first page already mapped and therefore result to break boot on Arm32.

The easiest way for now is to give a xenheap page to the boot allocator. We may want to rethink the interface in the future.

Fixes 6e3e771203 ('xen/arm: setup: Relocate the Device-Tree later on in the boot')

---
Changes in v2:
- Add Jan's reviewed-by
- Use boot_mfn_start rather than boot_mfn_end when giving xenheap pages.

---
 xen/arch/arm/setup.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xen/arch/arm/setup.c +7 -1
index 581b262655..fca7e68cba 100644
@@ -593,6 +593,7 @@ static void __init setup_mm(void)
     unsigned long heap_pages, xenheap_pages, domheap_pages;
     int i;
     const uint32_t ctr = READ_CP32(CTR);
+    mfn_t boot_mfn_start, boot_mfn_end;
 
     if ( !bootinfo.mem.nr_banks )
         panic("No memory bank\n");
@@ -665,6 +666,11 @@ static void __init setup_mm(void)
 
     setup_xenheap_mappings((e >> PAGE_SHIFT) - xenheap_pages, xenheap_pages);
 
+    /* We need a single mapped page for populating bootmem_region_list. */
+    boot_mfn_start = mfn_add(xenheap_mfn_end, -1);
+    boot_mfn_end = xenheap_mfn_end;
+    init_boot_pages(mfn_to_maddr(boot_mfn_start), mfn_to_maddr(boot_mfn_end));
+
     /* Add non-xenheap memory */
     for ( i = 0; i < bootinfo.mem.nr_banks; i++ )
     {
@@ -710,7 +716,7 @@ static void __init setup_mm(void)
 
     /* Add xenheap memory that was not already added to the boot allocator. */
     init_xenheap_pages(mfn_to_maddr(xenheap_mfn_start),
-                       mfn_to_maddr(xenheap_mfn_end));
+                       mfn_to_maddr(boot_mfn_start));
 }
 #else /* CONFIG_ARM_64 */
 static void __init setup_mm(void)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Julien Grall

After commit 6e3e771203 "xen/arm: setup: Relocate the Device-Tree later on in the boot", the boot allocator will not receive any xenheap page (i.e. mapped page) on Arm32.

However, the boot allocator implicitely rely on having the first page

"implicitly relies"

I fixed the commit message and committed.

Quoted 53 lines

already mapped and therefore result to break boot on Arm32.

The easiest way for now is to give a xenheap page to the boot allocator. We may want to rethink the interface in the future.

Fixes 6e3e771203 ('xen/arm: setup: Relocate the Device-Tree later on in the boot')

---
Changes in v2:
- Add Jan's reviewed-by
- Use boot_mfn_start rather than boot_mfn_end when giving xenheap pages.

---
 xen/arch/arm/setup.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xen/arch/arm/setup.c +7 -1
index 581b262655..fca7e68cba 100644
@@ -593,6 +593,7 @@ static void __init setup_mm(void)
     unsigned long heap_pages, xenheap_pages, domheap_pages;
     int i;
     const uint32_t ctr = READ_CP32(CTR);
+    mfn_t boot_mfn_start, boot_mfn_end;
 
     if ( !bootinfo.mem.nr_banks )
         panic("No memory bank\n");
@@ -665,6 +666,11 @@ static void __init setup_mm(void)
 
     setup_xenheap_mappings((e >> PAGE_SHIFT) - xenheap_pages, xenheap_pages);
 
+    /* We need a single mapped page for populating bootmem_region_list. */
+    boot_mfn_start = mfn_add(xenheap_mfn_end, -1);
+    boot_mfn_end = xenheap_mfn_end;
+    init_boot_pages(mfn_to_maddr(boot_mfn_start), mfn_to_maddr(boot_mfn_end));
+
     /* Add non-xenheap memory */
     for ( i = 0; i < bootinfo.mem.nr_banks; i++ )
     {
@@ -710,7 +716,7 @@ static void __init setup_mm(void)
 
     /* Add xenheap memory that was not already added to the boot allocator. */
     init_xenheap_pages(mfn_to_maddr(xenheap_mfn_start),
-                       mfn_to_maddr(xenheap_mfn_end));
+                       mfn_to_maddr(boot_mfn_start));
 }
 #else /* CONFIG_ARM_64 */
 static void __init setup_mm(void)
Signature · 1 line
2.11.0

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