xen/arm: UART addresses are not always aligned to a page.
PATCH 1/1 xen/arm: UART addresses are not always aligned to a page.
Add the page offset of the UART to the mapped address.
--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-)
xen/arch/arm/arm32/debug.S +3 -2
@@ -22,18 +22,19 @@ #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC #endif +#define UART_OFFSET (EARLY_UART_BASE_ADDRESS & ~PAGE_MASK) /* 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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET /* 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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET /* r1 := VA UART base address */ early_uart_ready r1, r2 mov pc, lr
xen/arch/arm/arm32/head.S +2 -1
@@ -355,8 +355,9 @@ paging: mov r4, r4, lsr #18 /* r4 := Slot for FIXMAP(0) */ strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ +#define UART_OFFSET (EARLY_UART_BASE_ADDRESS & ~PAGE_MASK) /* Use a virtual address to access the UART. */ - ldr r11, =FIXMAP_ADDR(FIXMAP_CONSOLE) + ldr r11, =(FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET) #endif /* Map the DTB in the boot misc slot */ teq r12, #0 /* Only on boot CPU */
Signature · 1 line
1.7.11.3
(+Adding ARM maintainers)
Hi,
Quoted 1 line · Jon Fraser
Add the page offset of the UART to the mapped address.
Thanks for the patch, can you also modify arm64 code?
Quoted 11 lines
Signed-off-by Jon Fraser <[email protected]>--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-)xen/arch/arm/arm32/debug.S +0
-0
xen/arch/arm/arm32/debug.S line 30
Quoted 10 lines
xen/arch/arm/arm32/debug.S +2
-1@@ -22,18 +22,19 @@ #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC #endif +#define UART_OFFSET (EARLY_UART_BASE_ADDRESS & ~PAGE_MASK) /* 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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET /* r1 := VA UART base address */
You use FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET in different files. How about creating a define EARLY_UART_VIRTUAL_ADDRESS in asm-arm/early_printk.h?
Signature · 1 line
Julien Grall
Sure, I'll do the arm64 side and fix the include file issue. Won't be until Monday.
Jon
-----Original Message-----
From: Julien Grall <[email protected]>
To: Jon Fraser <[email protected]>, [email protected], Ian Campbell <[email protected]>, Stefano Stabellini <[email protected]>, Tim Deegan <[email protected]>
Subject: Re: [Xen-devel] [PATCH] xen/arm: UART addresses are not always aligned to a page.
Date: Fri, 25 Oct 2013 12:28:34 +0100
(+Adding ARM maintainers)
Hi,
Quoted 1 line · Jon Fraser
Add the page offset of the UART to the mapped address.
Thanks for the patch, can you also modify arm64 code?
Quoted 11 lines
Signed-off-by Jon Fraser <[email protected]>--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-)xen/arch/arm/arm32/debug.S +0
-0
xen/arch/arm/arm32/debug.S line 30
Quoted 10 lines
xen/arch/arm/arm32/debug.S +2
-1@@ -22,18 +22,19 @@ #ifdef EARLY_PRINTK_INC #include EARLY_PRINTK_INC #endif +#define UART_OFFSET (EARLY_UART_BASE_ADDRESS & ~PAGE_MASK) /* 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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET /* r1 := VA UART base address */
You use FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET in different files. How about creating a define EARLY_UART_VIRTUAL_ADDRESS in asm-arm/early_printk.h?
PATCH 1/1 xen/arm: UART addresses are not always aligned to a page.
In reply to Julien GrallAdd the page offset of the UART to the mapped address.
--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 2 +- xen/arch/arm/arm64/debug.S | 4 ++-- xen/arch/arm/arm64/head.S | 2 +- xen/include/asm-arm/asm_defns.h | 3 +++ 5 files changed, 10 insertions(+), 6 deletions(-)
xen/arch/arm/arm32/debug.S +3 -2
@@ -18,6 +18,7 @@ */ #include <asm/config.h> +#include <asm/asm_defns.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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET /* 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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET /* r1 := VA UART base address */ early_uart_ready r1, r2 mov pc, lr
xen/arch/arm/arm32/head.S +1 -1
@@ -356,7 +356,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, =(FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET) #endif /* Map the DTB in the boot misc slot */ teq r12, #0 /* Only on boot CPU */
xen/arch/arm/arm64/debug.S +2 -2
@@ -26,14 +26,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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET 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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET /* x15 := VA UART base address */ early_uart_ready x15, 1 ret
xen/arch/arm/arm64/head.S +1 -1
@@ -368,7 +368,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, =FIXMAP_ADDR(FIXMAP_CONSOLE) + UART_OFFSET #endif /* Map the DTB in the boot misc slot */
xen/include/asm-arm/asm_defns.h +3 -0
@@ -7,6 +7,9 @@#endif #include <asm/processor.h> +/* Offset in page of UART base address */ +#define UART_OFFSET (EARLY_UART_BASE_ADDRESS & ~PAGE_MASK) +#endif /* __ARM_ASM_DEFNS_H__ */ /* * Local variables:
Signature · 1 line
1.7.11.3
Quoted 1 line · Jon Fraser
Add the page offset of the UART to the mapped address.
For the next version can you add [PATCH Vn] in the subject? Where 'n' is the version of the patch.
Quoted 8 lines
Signed-off-by Jon Fraser <[email protected]>--- xen/arch/arm/arm32/debug.S | 5 +++-- xen/arch/arm/arm32/head.S | 2 +- xen/arch/arm/arm64/debug.S | 4 ++-- xen/arch/arm/arm64/head.S | 2 +- xen/include/asm-arm/asm_defns.h | 3 +++ 5 files changed, 10 insertions(+), 6 deletions(-)
[...]
xen/include/asm-arm/asm_defns.h line 12
Quoted 12 lines
/* Map the DTB in the boot misc slot */xen/include/asm-arm/asm_defns.h +3
-0@@ -7,6 +7,9 @@#endif #include <asm/processor.h> +/* Offset in page of UART base address */ +#define UART_OFFSET (EARLY_UART_BASE_ADDRESS & ~PAGE_MASK) +
Actually I would move this define in asm/early-printk.h. It's the best place. Can you also rename the name to EARLY_UART_OFFSET?
In order to avoid numerous FIXMAP(CONSOLE) + UART_OFFSET, is it possible to create a define EARLY_UART_VIRTUAL_ADDRESS and use it everywhere?
Signature · 1 line
Julien Grall
Quoted 17 lines · Julien Grall
xen/include/asm-arm/asm_defns.h line 12
Quoted 12 lines · Jon Fraser
/* Map the DTB in the boot misc slot */xen/include/asm-arm/asm_defns.h +3
-0@@ -7,6 +7,9 @@#endif #include <asm/processor.h> +/* Offset in page of UART base address */ +#define UART_OFFSET (EARLY_UART_BASE_ADDRESS & ~PAGE_MASK) +Actually I would move this define in
asm/early-printk.h. It's the best place. Can you also rename the name toEARLY_UART_OFFSET?
Quoted 3 lines
In order to avoid numerous FIXMAP(CONSOLE) +
UART_OFFSET, is it possible to create a defineEARLY_UART_VIRTUAL_ADDRESSand use it everywhere?
I agree with all 3 suggestions here.
Ian.