Jon Fraser
2013-Oct-24 18:35 UTC
[PATCH] xen/arm: UART addresses are not always aligned to a page.
Add the page offset of the UART to the mapped address.
Signed-off-by: Jon Fraser <jfraser@broadcom.com>
---
xen/arch/arm/arm32/debug.S | 5 +++--
xen/arch/arm/arm32/head.S | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/xen/arch/arm/arm32/debug.S b/xen/arch/arm/arm32/debug.S
index ec774cd..e095911 100644
--- a/xen/arch/arm/arm32/debug.S
+++ b/xen/arch/arm/arm32/debug.S
@@ -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
diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index ce1d21a..aa8daec 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -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 */
--
1.7.11.3
Julien Grall
2013-Oct-25 11:28 UTC
Re: [PATCH] xen/arm: UART addresses are not always aligned to a page.
(+Adding ARM maintainers) Hi, On 10/24/2013 07:35 PM, Jon Fraser wrote:> Add the page offset of the UART to the mapped address.Thanks for the patch, can you also modify arm64 code?> Signed-off-by: Jon Fraser <jfraser@broadcom.com> > --- > xen/arch/arm/arm32/debug.S | 5 +++-- > xen/arch/arm/arm32/head.S | 3 ++- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/xen/arch/arm/arm32/debug.S b/xen/arch/arm/arm32/debug.S > index ec774cd..e095911 100644 > --- a/xen/arch/arm/arm32/debug.S > +++ b/xen/arch/arm/arm32/debug.S > @@ -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? -- Julien Grall
Jon Fraser
2013-Oct-25 22:43 UTC
Re: [PATCH] xen/arm: UART addresses are not always aligned to a page.
Sure, I''ll do the arm64 side and fix the include file issue. Won''t be until Monday. Jon -----Original Message----- From: Julien Grall <julien.grall@linaro.org> To: Jon Fraser <jfraser@broadcom.com>, xen-devel@lists.xen.org, Ian Campbell <ian.campbell@citrix.com>, Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Tim Deegan <tim@xen.org> 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, On 10/24/2013 07:35 PM, Jon Fraser wrote:> Add the page offset of the UART to the mapped address.Thanks for the patch, can you also modify arm64 code?> Signed-off-by: Jon Fraser <jfraser@broadcom.com> > --- > xen/arch/arm/arm32/debug.S | 5 +++-- > xen/arch/arm/arm32/head.S | 3 ++- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/xen/arch/arm/arm32/debug.S b/xen/arch/arm/arm32/debug.S > index ec774cd..e095911 100644 > --- a/xen/arch/arm/arm32/debug.S > +++ b/xen/arch/arm/arm32/debug.S > @@ -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?
Jon Fraser
2013-Oct-29 01:28 UTC
[PATCH] xen/arm: UART addresses are not always aligned to a page.
Add the page offset of the UART to the mapped address.
Signed-off-by: Jon Fraser <jfraser@broadcom.com>
---
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(-)
diff --git a/xen/arch/arm/arm32/debug.S b/xen/arch/arm/arm32/debug.S
index ec774cd..43a0cd5 100644
--- a/xen/arch/arm/arm32/debug.S
+++ b/xen/arch/arm/arm32/debug.S
@@ -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
diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index ce1d21a..ae80179 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -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 */
diff --git a/xen/arch/arm/arm64/debug.S b/xen/arch/arm/arm64/debug.S
index 472c157..24d8c60 100644
--- a/xen/arch/arm/arm64/debug.S
+++ b/xen/arch/arm/arm64/debug.S
@@ -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
diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index b8b5902..02a2871 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -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 */
diff --git a/xen/include/asm-arm/asm_defns.h b/xen/include/asm-arm/asm_defns.h
index 36e72ff..5bcaa44 100644
--- a/xen/include/asm-arm/asm_defns.h
+++ b/xen/include/asm-arm/asm_defns.h
@@ -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:
--
1.7.11.3
Julien Grall
2013-Oct-30 18:57 UTC
Re: [PATCH] xen/arm: UART addresses are not always aligned to a page.
On 28 October 2013 18:28, Jon Fraser <jfraser@broadcom.com> wrote:> 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.> Signed-off-by: Jon Fraser <jfraser@broadcom.com> > --- > 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(-)[...]> /* Map the DTB in the boot misc slot */ > diff --git a/xen/include/asm-arm/asm_defns.h b/xen/include/asm-arm/asm_defns.h > index 36e72ff..5bcaa44 100644 > --- a/xen/include/asm-arm/asm_defns.h > +++ b/xen/include/asm-arm/asm_defns.h > @@ -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? -- Julien Grall
Ian Campbell
2013-Oct-31 16:15 UTC
Re: [PATCH] xen/arm: UART addresses are not always aligned to a page.
On Wed, 2013-10-30 at 11:57 -0700, Julien Grall wrote:> On 28 October 2013 18:28, Jon Fraser <jfraser@broadcom.com> wrote: > > /* Map the DTB in the boot misc slot */ > > diff --git a/xen/include/asm-arm/asm_defns.h b/xen/include/asm-arm/asm_defns.h > > index 36e72ff..5bcaa44 100644 > > --- a/xen/include/asm-arm/asm_defns.h > > +++ b/xen/include/asm-arm/asm_defns.h > > @@ -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?I agree with all 3 suggestions here. Ian.