xen/arm: head: early printk on 1:1 mapping
cover xen/arm: head: early printk on 1:1 mapping
This series is a follow up to 1ec3fe1f664f ("xen/arm32: head: Improve logging in head.S").
Michal Orzel (2):
xen/arm32: head: Move earlyprintk 'hex' to .rodata.idmap xen/arm64: head: Allow to use early printk while on 1:1 mapping
xen/arch/arm/arm32/head.S | 2 +- xen/arch/arm/arm64/head.S | 13 ++----------- xen/arch/arm/arm64/mmu/head.S | 8 ++++++++ xen/arch/arm/include/asm/arm64/macros.h | 25 ++++++++++++++++++------- xen/arch/arm/include/asm/asm_defns.h | 2 -- 5 files changed, 29 insertions(+), 21 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 xen/arm32: head: Move earlyprintk 'hex' to .rodata.idmap
Thanks to 1ec3fe1f664f ("xen/arm32: head: Improve logging in head.S"), we can now use PRINT_ID() macro to print messages when running on identity mapping. For that, all the strings need to be part of the first page that is mapped. This is not the case for a 'hex' string (used by asm_putn when printing register values), which currently resides in .rodata.str. Move it to .rodata.idmap to allow making use of print_reg macro from anywhere (mostly to aid debugging).
--- xen/arch/arm/arm32/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm32/head.S +1 -1
@@ -320,7 +320,7 @@ ENTRY(asm_putn) mov pc, lr ENDPROC(asm_putn) -RODATA_STR(hex, "0123456789abcdef") +RODATA_SECT(.rodata.idmap, hex, "0123456789abcdef") #endif /* CONFIG_EARLY_PRINTK */
Signature · 1 line
2.25.1
Re: [PATCH 1/2] xen/arm32: head: Move earlyprintk 'hex' to .rodata.idmap
Hi Michal,
Quoted 9 lines · Michal Orzel
Thanks to
1ec3fe1f664f("xen/arm32: head: Improve logging inhead.S"), we can now usePRINT_ID()macro to print messages when running on identity mapping. For that, all the strings need to be part of the first page that is mapped. This is not the case for a 'hex' string (used byasm_putnwhen printing register values), which currently resides in .rodata.str. Move it to .rodata.idmap to allow making use ofprint_regmacro from anywhere (mostly to aid debugging).Signed-off-by Michal Orzel <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
PATCH 2/2 xen/arm64: head: Allow to use early printk while on 1:1 mapping
In reply to Michal OrzelTake an example from commit 1ec3fe1f664f ("xen/arm32: head: Improve logging in head.S") to add support for printing early boot messages while running on identity mapping:
- define PRINT_SECT() macro to be able to specify a section for storing a string. PRINT() will use .rodata.str and PRINT_ID() - .rodata.idmap. This is necessary, because when running on identity mapping, the strings need to be part of the first page that is mapped,
- move loading a runtime virtual UART address right after enabling MMU (the corresponding steps repeated in {primary,secondary}_switched are now consolidated in a single place),
- move early printk 'hex' string into .rodata.idmap and replace 'adr' instruction in asm_putn with 'adr_l' to extend the addressable range,
- remove RODATA_STR() macro given no use.
--- xen/arch/arm/arm64/head.S | 13 ++----------- xen/arch/arm/arm64/mmu/head.S | 8 ++++++++ xen/arch/arm/include/asm/arm64/macros.h | 25 ++++++++++++++++++------- xen/arch/arm/include/asm/asm_defns.h | 2 -- 4 files changed, 28 insertions(+), 20 deletions(-)
xen/arch/arm/arm64/head.S +2 -11
@@ -256,10 +256,6 @@ real_start_efi: b enable_boot_cpu_mm primary_switched: -#ifdef CONFIG_EARLY_PRINTK - /* Use a virtual address to access the UART. */ - ldr x23, =EARLY_UART_VIRTUAL_ADDRESS -#endif bl zero_bss PRINT("- Ready -\r\n") /* Setup the arguments for start_xen and jump to C world */
@@ -304,10 +300,6 @@ GLOBAL(init_secondary) b enable_secondary_cpu_mm secondary_switched: -#ifdef CONFIG_EARLY_PRINTK - /* Use a virtual address to access the UART. */ - ldr x23, =EARLY_UART_VIRTUAL_ADDRESS -#endif PRINT("- Ready -\r\n") /* Jump to C world */ ldr x2, =start_secondary
@@ -480,7 +472,7 @@ ENDPROC(asm_puts) * Clobbers x0-x3 */ ENTRY(asm_putn) - adr x1, hex + adr_l x1, hex mov x3, #16 1: early_uart_ready x23, 2
@@ -494,8 +486,7 @@ ENTRY(asm_putn) ret ENDPROC(asm_putn) -hex: .ascii "0123456789abcdef" - .align 2 +RODATA_SECT(.rodata.idmap, hex, "0123456789abcdef") #endif /* CONFIG_EARLY_PRINTK */
xen/arch/arm/arm64/mmu/head.S +8 -0
@@ -295,6 +295,14 @@ enable_mmu: dsb sy /* Flush PTE writes and finish reads */ msr SCTLR_EL2, x0 /* now paging is enabled */ isb /* Now, flush the icache */ + +#ifdef CONFIG_EARLY_PRINTK + /* Use a virtual address to access the UART. */ + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS +#endif + + PRINT_ID("- Paging turned on -\r\n") + ret ENDPROC(enable_mmu)
xen/arch/arm/include/asm/arm64/macros.h +18 -7
@@ -34,16 +34,26 @@#ifdef CONFIG_EARLY_PRINTK /* -* Macro to print a string to the UART, if there is one. +* Macros to print a string to the UART, if there is one. +* +* There are multiple flavors: +* - PRINT_SECT(section, string): The @string will be located in @section +* - PRINT(): The string will be located in .rodata.str. +* - PRINT_ID(): When Xen is running on the Identity Mapping, it is +* only possible to have a limited amount of Xen. This will create +* the string in .rodata.idmap which will always be mapped. * * Clobbers x0 - x3 */ -#define #define PRINT_SECT (section, string) \ + mov x3, lr ;\ + adr_l x0, 98f ;\ + bl asm_puts ;\ + mov lr, x3 ;\ + RODATA_SECT(section, 98, string) + +#define #define PRINT_ID (string) PRINT_SECT(.rodata.idmap, string)/* * Macro to print the value of register \xb
@@ -59,6 +69,7 @@#else /* CONFIG_EARLY_PRINTK */ #define #define PRINT_ID (s) .macro print_reg xb .endm
xen/arch/arm/include/asm/asm_defns.h +0 -2
@@ -27,8 +27,6 @@ label: .asciz msg; \ .popsection -#define RODATA_STR (label, msg) RODATA_SECT(.rodata.str, label, msg) -#define ASM_INT (label, val) \ .p2align 2; \ label: .long (val); \
Signature · 1 line
2.25.1
Re: [PATCH 2/2] xen/arm64: head: Allow to use early printk while on 1:1 mapping
Hi Michal,
Quoted 14 lines · Michal Orzel
Take an example from commit
1ec3fe1f664f("xen/arm32: head: Improve logging inhead.S") to add support for printing early boot messages while running on identity mapping:
- definePRINT_SECT()macro to be able to specify a section for storing a string.PRINT()will use .rodata.str andPRINT_ID()- .rodata.idmap. This is necessary, because when running on identity mapping, the strings need to be part of the first page that is mapped,
- move loading a runtime virtual UART address right after enabling MMU (the corresponding steps repeated in {primary,secondary}_switched are now consolidated in a single place),
- move early printk 'hex' string into .rodata.idmap and replace 'adr' instruction inasm_putnwith 'adr_l' to extend the addressable range,
- removeRODATA_STR()macro given no use.
Quoted 1 line
Signed-off-by Michal Orzel <[email protected]>
I have tested with my upcoming series to get all pre-MMU code in a single page.
Cheers,
Signature · 1 line
Julien Grall
Hi Michal,
Quoted 6 lines · Michal Orzel
This series is a follow up to
1ec3fe1f664f("xen/arm32: head: Improve logging inhead.S").Michal Orzel (2):
xen/arm32: head: Move earlyprintk 'hex' to .rodata.idmap xen/arm64: head: Allow to use early printk while on 1:1 mapping
This is now committed.
Cheers,
Quoted 8 lines
xen/arch/arm/arm32/head.S | 2 +- xen/arch/arm/arm64/head.S | 13 ++----------- xen/arch/arm/arm64/mmu/head.S | 8 ++++++++ xen/arch/arm/include/asm/arm64/macros.h | 25 ++++++++++++++++++------- xen/arch/arm/include/asm/asm_defns.h | 2 -- 5 files changed, 29 insertions(+), 21 deletions(-)
Signature · 1 line
Julien Grall