xen/arm: UART addresses are not always aligned to a page.
PATCH v2 1/1 xen/arm: UART addresses are not always aligned to a page.
When calculating the virtual address of the UART, add the page offset of the UART to the mapped address.
Create define EARLY_UART_VIRTUAL_ADDRESS and use instead of FIXMAP_ADDR(FIXMAP_CONSOLE)
--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- xen/arch/arm/arm64/debug.S | 5 +++-- xen/arch/arm/arm64/head.S | 3 ++- xen/include/asm-arm/early_printk.h | 10 ++++++++++ 5 files changed, 20 insertions(+), 6 deletions(-)
xen/arch/arm/arm32/debug.S +3 -2
@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC
@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * r0: character to print */ GLOBAL(early_putch) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 early_uart_transmit r1, r0 mov pc, lr /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 mov pc, lr
xen/arch/arm/arm32/head.S +2 -1
@@ -22,6 +22,7 @@ #include <asm/processor-ca15.h> #include <asm/processor-ca7.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define ZIMAGE_MAGIC_NUMBER 0x016f2818
@@ -356,7 +357,7 @@ paging: strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr r11, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr r11, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */ teq r12, #0 /* Only on boot CPU */
xen/arch/arm/arm64/debug.S +3 -2
@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC
@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * x0: character to print */ GLOBAL(early_putch) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS early_uart_ready x15, 1 early_uart_transmit x15, w0 ret /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* x15 := VA UART base address */ + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS /* x15 := VA UART base address */ early_uart_ready x15, 1 ret
xen/arch/arm/arm64/head.S +2 -1
@@ -23,6 +23,7 @@ #include <asm/config.h> #include <asm/page.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ #define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */
@@ -368,7 +369,7 @@ paging: str x2, [x4, x1] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr x23, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */
xen/include/asm-arm/early_printk.h +10 -0
@@ -12,6 +12,14 @@#include <xen/config.h> +#ifdef __ASSEMBLY__ + +/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK)) + +#else +#ifdef EARLY_PRINTK void early_printk (const char *fmt, ...)
@@ -31,4 +39,6 @@ __attribute__((format (printf, 1, 2))) early_panic(const char *fmt, ...)#endif +#endif /* __ASSEMBLY__ */ +#endif
Signature · 1 line
1.7.11.3
Quoted 120 lines · Jon Fraser
When calculating the virtual address of the UART, add the page offset of the UART to the mapped address.
Create define
EARLY_UART_VIRTUAL_ADDRESSand use instead ofFIXMAP_ADDR(FIXMAP_CONSOLE)Signed-off-by Jon Fraser <[email protected]>--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- xen/arch/arm/arm64/debug.S | 5 +++-- xen/arch/arm/arm64/head.S | 3 ++- xen/include/asm-arm/early_printk.h | 10 ++++++++++ 5 files changed, 20 insertions(+), 6 deletions(-)xen/arch/arm/arm32/debug.S +3
-2@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * r0: character to print */ GLOBAL(early_putch) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 early_uart_transmit r1, r0 mov pc, lr /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 mov pc, lrxen/arch/arm/arm32/head.S +2
-1@@ -22,6 +22,7 @@ #include <asm/processor-ca15.h> #include <asm/processor-ca7.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define ZIMAGE_MAGIC_NUMBER 0x016f2818@@ -356,7 +357,7 @@ paging: strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr r11, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr r11, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */ teq r12, #0 /* Only on boot CPU */xen/arch/arm/arm64/debug.S +3
-2@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * x0: character to print */ GLOBAL(early_putch) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS early_uart_ready x15, 1 early_uart_transmit x15, w0 ret /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* x15 := VA UART base address */ + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS /* x15 := VA UART base address */ early_uart_ready x15, 1 retxen/arch/arm/arm64/head.S +2
-1@@ -23,6 +23,7 @@ #include <asm/config.h> #include <asm/page.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ #define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */@@ -368,7 +369,7 @@ paging: str x2, [x4, x1] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr x23, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */xen/include/asm-arm/early_printk.h +0
-0
xen/include/asm-arm/early_printk.h line 19
Quoted 8 lines
xen/include/asm-arm/early_printk.h +5
-0@@ -12,6 +12,14 @@#include <xen/config.h> +#ifdef __ASSEMBLY__ + +/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
Why should this be limited to assembly code? It would seem valid for early C code to see and use as well.
With that change, you can drop all the #ifdef'ary
~Andrew
Quoted 13 lines
xen/include/asm-arm/early_printk.h +5
-0+ +#else +#ifdef EARLY_PRINTK void early_printk (const char *fmt, ...)@@ -31,4 +39,6 @@ __attribute__((format (printf, 1, 2))) early_panic(const char *fmt, ...)#endif +#endif /* __ASSEMBLY__ */ +#endif
Quoted 133 lines · Andrew Cooper
Quoted 120 lines · Jon Fraser
When calculating the virtual address of the UART, add the page offset of the UART to the mapped address.
Create define
EARLY_UART_VIRTUAL_ADDRESSand use instead ofFIXMAP_ADDR(FIXMAP_CONSOLE)Signed-off-by Jon Fraser <[email protected]>--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- xen/arch/arm/arm64/debug.S | 5 +++-- xen/arch/arm/arm64/head.S | 3 ++- xen/include/asm-arm/early_printk.h | 10 ++++++++++ 5 files changed, 20 insertions(+), 6 deletions(-)xen/arch/arm/arm32/debug.S +3
-2@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * r0: character to print */ GLOBAL(early_putch) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 early_uart_transmit r1, r0 mov pc, lr /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 mov pc, lrxen/arch/arm/arm32/head.S +2
-1@@ -22,6 +22,7 @@ #include <asm/processor-ca15.h> #include <asm/processor-ca7.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define ZIMAGE_MAGIC_NUMBER 0x016f2818@@ -356,7 +357,7 @@ paging: strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr r11, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr r11, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */ teq r12, #0 /* Only on boot CPU */xen/arch/arm/arm64/debug.S +3
-2@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * x0: character to print */ GLOBAL(early_putch) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS early_uart_ready x15, 1 early_uart_transmit x15, w0 ret /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* x15 := VA UART base address */ + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS /* x15 := VA UART base address */ early_uart_ready x15, 1 retxen/arch/arm/arm64/head.S +2
-1@@ -23,6 +23,7 @@ #include <asm/config.h> #include <asm/page.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ #define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */@@ -368,7 +369,7 @@ paging: str x2, [x4, x1] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr x23, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */xen/include/asm-arm/early_printk.h +0
-0xen/include/asm-arm/early_printk.h line 19
Quoted 8 lines
xen/include/asm-arm/early_printk.h +5
-0@@ -12,6 +12,14 @@#include <xen/config.h> +#ifdef __ASSEMBLY__ + +/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))Why should this be limited to assembly code? It would seem valid for early C code to see and use as well.
Quoted 4 lines
With that change, you can drop all the #ifdef'ary
~Andrew
The problem is that the C code in the include can't be included in the assembler files. I suppose that EARLY_UART_VIRTUAL_ADDRESS could be used in C code. I'd still have to ifdef out the C code in the include file for the assembler files.
Jon
Quoted 15 lines
Quoted 13 lines
xen/include/asm-arm/early_printk.h +5
-0+ +#else +#ifdef EARLY_PRINTK void early_printk (const char *fmt, ...)@@ -31,4 +39,6 @@ __attribute__((format (printf, 1, 2))) early_panic(const char *fmt, ...)#endif +#endif /* __ASSEMBLY__ */ +#endif
Quoted 134 lines · Jon Fraser
Quoted 133 lines · Andrew Cooper
Quoted 120 lines · Jon Fraser
When calculating the virtual address of the UART, add the page offset of the UART to the mapped address.
Create define
EARLY_UART_VIRTUAL_ADDRESSand use instead ofFIXMAP_ADDR(FIXMAP_CONSOLE)Signed-off-by Jon Fraser <[email protected]>--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- xen/arch/arm/arm64/debug.S | 5 +++-- xen/arch/arm/arm64/head.S | 3 ++- xen/include/asm-arm/early_printk.h | 10 ++++++++++ 5 files changed, 20 insertions(+), 6 deletions(-)xen/arch/arm/arm32/debug.S +3
-2@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * r0: character to print */ GLOBAL(early_putch) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 early_uart_transmit r1, r0 mov pc, lr /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 mov pc, lrxen/arch/arm/arm32/head.S +2
-1@@ -22,6 +22,7 @@ #include <asm/processor-ca15.h> #include <asm/processor-ca7.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define ZIMAGE_MAGIC_NUMBER 0x016f2818@@ -356,7 +357,7 @@ paging: strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr r11, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr r11, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */ teq r12, #0 /* Only on boot CPU */xen/arch/arm/arm64/debug.S +3
-2@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * x0: character to print */ GLOBAL(early_putch) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS early_uart_ready x15, 1 early_uart_transmit x15, w0 ret /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* x15 := VA UART base address */ + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS /* x15 := VA UART base address */ early_uart_ready x15, 1 retxen/arch/arm/arm64/head.S +2
-1@@ -23,6 +23,7 @@ #include <asm/config.h> #include <asm/page.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ #define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */@@ -368,7 +369,7 @@ paging: str x2, [x4, x1] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr x23, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */xen/include/asm-arm/early_printk.h +0
-0xen/include/asm-arm/early_printk.h line 19
Quoted 8 lines
xen/include/asm-arm/early_printk.h +5
-0@@ -12,6 +12,14 @@#include <xen/config.h> +#ifdef __ASSEMBLY__ + +/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))Why should this be limited to assembly code? It would seem valid for early C code to see and use as well.
Quoted 8 lines
Quoted 4 lines
With that change, you can drop all the #ifdef'ary
~Andrew
The problem is that the C code in the include can't be included in the assembler files. I suppose that
EARLY_UART_VIRTUAL_ADDRESScould be used in C code.
C code should be using early_printk, not anything which would need to touch EARLY_UART_VIRTUAL_ADDRESS. Ultimately early_printk uses early_putch which is implemented in ASM and is where EARLY_UART_VIRTUAL_ADDRESS should be used (and I suppose is by this patch, I didn't check). (this doesn't mean the #define should be hidden from C, just that it shouldn't be used).
I think your __ASSEMBLY__ #ifdef is ok, but shouldn't it be inside the #idef EARLY_PRINTK?
Quoted 2 lines
I'd still have to ifdef out the C code in the include file for the assembler files.
#ifndef __ASSEMBLY__ and drop the #else if you like, so C sees everything and ASM sees only the relevant define that would be fine too.
Ian.
PATCH v3 1/1 xen/arm: UART addresses are not always aligned to a page.
When calculating the virtual address of the UART, add the page offset of the UART to the mapped address.
Create define EARLY_UART_VIRTUAL_ADDRESS and use instead of FIXMAP_ADDR(FIXMAP_CONSOLE)
--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- xen/arch/arm/arm64/debug.S | 5 +++-- xen/arch/arm/arm64/head.S | 3 ++- xen/include/asm-arm/early_printk.h | 12 ++++++++++++ 5 files changed, 22 insertions(+), 6 deletions(-)
xen/arch/arm/arm32/debug.S +3 -2
@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC
@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * r0: character to print */ GLOBAL(early_putch) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 early_uart_transmit r1, r0 mov pc, lr /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr r1, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* r1 := VA UART base address */ + ldr r1, =EARLY_UART_VIRTUAL_ADDRESS /* r1 := VA UART base address */ early_uart_ready r1, r2 mov pc, lr
xen/arch/arm/arm32/head.S +2 -1
@@ -22,6 +22,7 @@ #include <asm/processor-ca15.h> #include <asm/processor-ca7.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define ZIMAGE_MAGIC_NUMBER 0x016f2818
@@ -356,7 +357,7 @@ paging: strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr r11, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr r11, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */ teq r12, #0 /* Only on boot CPU */
xen/arch/arm/arm64/debug.S +3 -2
@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/early_printk.h> #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC
@@ -26,14 +27,14 @@ /* Print a character on the UART - this function is called by C * x0: character to print */ GLOBAL(early_putch) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS early_uart_ready x15, 1 early_uart_transmit x15, w0 ret /* Flush the UART - this function is called by C */ GLOBAL(early_flush) - ldr x15, =FIXMAP_ADDR(FIXMAP_CONSOLE) /* x15 := VA UART base address */ + ldr x15, =EARLY_UART_VIRTUAL_ADDRESS /* x15 := VA UART base address */ early_uart_ready x15, 1 ret
xen/arch/arm/arm64/head.S +2 -1
@@ -23,6 +23,7 @@ #include <asm/config.h> #include <asm/page.h> #include <asm/asm_defns.h> +#include <asm/early_printk.h> #define PT_PT 0xe7f /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=1 P=1 */ #define PT_MEM 0xe7d /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=111 T=0 P=1 */
@@ -368,7 +369,7 @@ paging: str x2, [x4, x1] /* Map it in the fixmap's slot */ /* Use a virtual address to access the UART. */ - ldr x23, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif /* Map the DTB in the boot misc slot */
xen/include/asm-arm/early_printk.h +12 -0
@@ -14,6 +14,16 @@#ifdef EARLY_PRINTK +/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK)) + +#endif + +#ifndef __ASSEMBLY__ + +#ifdef EARLY_PRINTK +void early_printk (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));void early_panic (const char *fmt, ...) __attribute__((noreturn))
@@ -31,4 +41,6 @@ __attribute__((format (printf, 1, 2))) early_panic(const char *fmt, ...)#endif +#endif /* __ASSEMBLY__ */ +#endif
Signature · 1 line
1.7.11.3
Quoted 8 lines · Jon Fraser
xen/include/asm-arm/early_printk.h +0
-0@@ -14,6 +14,16 @@#ifdef EARLY_PRINTK
xen/include/asm-arm/early_printk.h line 26
Quoted 10 lines
xen/include/asm-arm/early_printk.h +10
-0+/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK)) + +#endif + +#ifndef __ASSEMBLY__ + +#ifdef EARLY_PRINTK +
Is there something wrong with:
#ifdef EARLY_PRINT
+#define EARLY_UART_VIETRUAL_ADDRESS ...
+
+#ifndef __ASSEMBLY__
+
[... existing C code...]
+
+#endif /* !__ASSEMBLY__ */
+
#endif /* EARLY_PRINTK */Rather than two lots of early_printk ifdefery.
Ian.
Quoted 33 lines · Ian Campbell
Quoted 8 lines · Jon Fraser
xen/include/asm-arm/early_printk.h +0
-0@@ -14,6 +14,16 @@#ifdef EARLY_PRINTK xen/include/asm-arm/early_printk.h line 26
Quoted 10 lines
xen/include/asm-arm/early_printk.h +10
-0+/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK)) + +#endif + +#ifndef __ASSEMBLY__ + +#ifdef EARLY_PRINTK +Is there something wrong with:
#ifdef EARLY_PRINT +#define EARLY_UART_VIETRUAL_ADDRESS ... + +#ifndef __ASSEMBLY__ + [... existing C code...] + +#endif /* !__ASSEMBLY__ */ + #endif /* EARLY_PRINTK */
Quoted 4 lines
Rather than two lots of
early_printkifdefery.Ian.
The dummy functions for early_printk and early_panic need to be visible for not EARLY_PRINTK, but not visible for __ASSEMBLY__.
Ian Campbell
Acked-byQuoted 34 lines · Jon Fraser
Quoted 33 lines · Ian Campbell
Quoted 8 lines · Jon Fraser
xen/include/asm-arm/early_printk.h +0
-0@@ -14,6 +14,16 @@#ifdef EARLY_PRINTK xen/include/asm-arm/early_printk.h line 26
Quoted 10 lines
xen/include/asm-arm/early_printk.h +10
-0+/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK)) + +#endif + +#ifndef __ASSEMBLY__ + +#ifdef EARLY_PRINTK +Is there something wrong with:
#ifdef EARLY_PRINT +#define EARLY_UART_VIETRUAL_ADDRESS ... + +#ifndef __ASSEMBLY__ + [... existing C code...] + +#endif /* !__ASSEMBLY__ */ + #endif /* EARLY_PRINTK */
Quoted 8 lines
Quoted 4 lines
Rather than two lots of
early_printkifdefery.Ian.
The dummy functions for
early_printkandearly_panicneed to be visible for notEARLY_PRINTK, but not visible for__ASSEMBLY__.
Ah, thanks, was missing that context from the patch, I should have looked at the original file.
Ian.
Quoted 1 line · Ian Campbell
Acked-by Ian Campbell <[email protected]>
And applied, thanks.
Quoted 8 lines · Jon Fraser
When calculating the virtual address of the UART, add the page offset of the UART to the mapped address.
Create define
EARLY_UART_VIRTUAL_ADDRESSand use instead ofFIXMAP_ADDR(FIXMAP_CONSOLE)Signed-off-by Jon Fraser <[email protected]>---
[...]
Quoted 5 lines
xen/include/asm-arm/early_printk.h +0
-0
xen/include/asm-arm/early_printk.h line 20
Quoted 9 lines
xen/include/asm-arm/early_printk.h +6
-0@@ -12,6 +12,14 @@#include <xen/config.h> +#ifdef __ASSEMBLY__ + +/* need to add the uart address offset in page to the fixmap address */ +#define EARLY_UART_VIRTUAL_ADDRESS \ + (FIXMAP_ADDR(FIXMAP_CONSOLE) +(EARLY_UART_BASE_ADDRESS & ~PAGE_MASK)) +
Aside Andrew's comment, you should only define EARLY_UART_VIRTUAL_ADDRESS when EARLY_PRINTK is enabled.
Signature · 1 line
Julien Grall