xen/arm: Stop relocating Xen
PATCH 1/1 xen/arm: Stop relocating Xen
At the moment, Xen is relocated towards the end of the memory. While this has the advantage to free space in low memory, the code is not compliant with the break-before-make because it requires to switch between two sets of page-table. This is not entirely trivial to fix as it would require us to go through an identity mapping and disabling MMU.
Furtheremore, it looks like that some platform (such as the Hikey960) may not be able to bring-up secondary CPUs if the entry is too high.
I don't believe the low memory is an issue because Xen is quite tiny (< 2MB). So the best solution is to stop relocating Xen. This has the advantage to simplify the code.
Note that the break-before-make issue is not fixed by this patch.
--- xen/arch/arm/arm32/head.S | 54 +++------------------------------------ xen/arch/arm/arm64/head.S | 50 +++++------------------------------- xen/arch/arm/mm.c | 22 +++++----------- xen/arch/arm/setup.c | 65 +++-------------------------------------------- xen/include/asm-arm/mm.h | 2 +- 5 files changed, 19 insertions(+), 174 deletions(-)
xen/arch/arm/arm32/head.S +3 -51
@@ -469,58 +469,12 @@ fail: PRINT("- Boot failed -\r\n") GLOBAL(_end_boot) /* - * Copy Xen to new location and switch TTBR + * Switch TTBR * r1:r0 ttbr - * r2 source address - * r3 destination address - * [sp]=>r4 length * - * Source and destination must be word aligned, length is rounded up - * to a 16 byte boundary. - * - * MUST BE VERY CAREFUL when saving things to RAM over the copy + * TODO: This code does not comply with break-before-make. */ -ENTRY(relocate_xen) - push {r4,r5,r6,r7,r8,r9,r10,r11} - - ldr r4, [sp, #8*4] /* Get 4th argument from stack */ - - /* Copy 16 bytes at a time using: - * r5: counter - * r6: data - * r7: data - * r8: data - * r9: data - * r10: source - * r11: destination - */ - mov r5, r4 - mov r10, r2 - mov r11, r3 -1: ldmia r10!, {r6, r7, r8, r9} - stmia r11!, {r6, r7, r8, r9} - - subs r5, r5, #16 - bgt 1b - - /* Flush destination from dcache using: - * r5: counter - * r6: step - * r7: vaddr - */ - dsb /* So the CPU issues all writes to the range */ - - mov r5, r4 - ldr r6, =dcache_line_bytes /* r6 := step */ - ldr r6, [r6] - mov r7, r3 - -1: mcr CP32(r7, DCCMVAC) - - add r7, r7, r6 - subs r5, r5, r6 - bgt 1b - +ENTRY(switch_ttbr) dsb /* Ensure the flushes happen before * continuing */ isb /* Ensure synchronization with previous
@@ -543,8 +497,6 @@ ENTRY(relocate_xen) dsb /* Ensure completion of TLB+BP flush */ isb - pop {r4, r5,r6,r7,r8,r9,r10,r11} - mov pc, lr #ifdef CONFIG_EARLY_PRINTK
xen/arch/arm/arm64/head.S +6 -44
58 lines not on this page · raw message
xen/arch/arm/mm.c +6 -16
@@ -601,7 +601,7 @@ void __init remove_early_mappings(void)flush_xen_data_tlb_range_va (BOOT_FDT_VIRT_START ,BOOT_FDT_SLOT_SIZE ); } -extern void relocate_xen (uint64_t ttbr,void *src,void *dst,size_t len); +extern void switch_ttbr (uint64_t ttbr);/* Clear a translation table and clean & invalidate the cache */ static void clear_table (void *table)
@@ -612,15 +612,13 @@ static void clear_table(void *table)/* Boot-time pagetable setup. * Changes here may need matching changes in head.S */ -void __init setup_pagetables (unsigned long boot_phys_offset,paddr_t xen_paddr) +void __init setup_pagetables (unsigned long boot_phys_offset) {uint64_t ttbr; -unsigned long dest_va;lpae_t pte, *p;int i; -/* Calculate virt-to-phys offset for the new location */ - phys_offset = xen_paddr - (unsigned long ) _start; + phys_offset = boot_phys_offset;#ifdef CONFIG_ARM_64 p = (void *) xen_pgtable;
@@ -652,7 +650,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Initialise xen second level entries ... */ /* ... Xen's text etc */ - pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_NORMAL ); + pte =pte_of_xenaddr ((vaddr_t )_start); pte.pt.xn =0 ;/* Contains our text mapping! */ xen_second[second_table_offset (XEN_VIRT_START )] = pte;
@@ -667,21 +665,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) pte = boot_second[second_table_offset (BOOT_FDT_VIRT_START +SZ_2M )]; xen_second[second_table_offset (BOOT_FDT_VIRT_START +SZ_2M )] = pte; -/* ... Boot Misc area for xen relocation */ - dest_va =BOOT_RELOC_VIRT_START ; - pte =mfn_to_xen_entry (maddr_to_mfn (xen_paddr),MT_NORMAL ); -/* Map the destination in xen_second. */ - xen_second[second_table_offset (dest_va)] = pte; -/* Map the destination in boot_second. */ -write_pte (boot_second +second_table_offset (dest_va), pte); -flush_xen_data_tlb_range_va_local (dest_va,SECOND_SIZE );#ifdef CONFIG_ARM_64 ttbr = (uintptr_t ) xen_pgtable + phys_offset;#else ttbr = (uintptr_t ) cpu0_pgtable + phys_offset;#endif -relocate_xen (ttbr, _start, (void *)dest_va, _end - _start); +switch_ttbr (ttbr);/* Clear the copy of the boot pagetables. Each secondary CPU * rebuilds these itself (see head.S) */
@@ -696,7 +686,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)/* Break up the Xen mapping into 4k pages and protect them separately. */ for ( i =0 ; i <LPAE_ENTRIES ; i++ ) { -mfn_t mfn =mfn_add (maddr_to_mfn (xen_paddr), i); +mfn_t mfn =mfn_add (maddr_to_mfn ((vaddr_t )_start + phys_offset), i);unsigned long va =XEN_VIRT_START + (i <<PAGE_SHIFT );if ( !is_kernel (va) )break ;
xen/arch/arm/setup.c +3 -62
95 lines not on this page · raw message
xen/include/asm-arm/mm.h +1 -1
@@ -169,7 +169,7 @@ extern unsigned long total_pages;#define PDX_GROUP_SHIFT SECOND_SHIFT/* Boot-time pagetable setup */ -extern void setup_pagetables (unsigned long boot_phys_offset,paddr_t xen_paddr); +extern void setup_pagetables (unsigned long boot_phys_offset);/* Map FDT in boot pagetable */ extern void *early_fdt_map (paddr_t fdt_paddr);/* Remove early mappings */
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel