Skip to contentSkip to conversation

Support multiple ARM platform in Xen

PATCH In review Julien Grall 3 participants 25 messages May 10, 2013 – May 13, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover Support multiple ARM platform in Xen

Hi,

This is the fourth version of the patch series. It's rebased on the latest staging.

Major changes in v4:
- Introduce ioremap_nocache, ioremap_wc, ioremap_cache and use it
- Merge patch "Remove early_ioremap" to "Introduce ioremap_attr"
- Rework device tree printk

Major changes in v3:
- Introduce ioremap_attr, ioreadl, iowritel
- Typoes, hard tab, java doc...
- Make generic UART based on DT architecture agnostic
- Remove hardcoded IRQs in the virtual timer
- Rework device tree printk

Major changes in v2:
- Add platform_poweroff and platform_quirks
- Rework early assembly printk to use
macro instead of function
- Use defines where it's possible in
exynos UART code
- Missing Signed-off-by from Anthony exynos UART code
- Introduce request_dt_irq and setup_dt_irq. request_irq and setup_irq are deprecated for ARM. This part is divided in small patches (one to introduce new function and one to remove the old function) to avoid compilation breakage.

For all changes see in each patch. I have only reposted patch which are not yet acked or changed in v4. All the others patch is in:
git clone -b arm-v4 git://xenbits.xen.org/people/julieng/xen-unstable.git

Xen can boot on both Arndale Board and Versatile Express without recompilation. But there is still some hardcoded part, mainly in assembly.

Things to do:
- Move secondary CPUs bring up code in platform specific
- Move out of Xen the switch between secure mode and hypervisor mode
- Rework dom0 device tree creation
- Use everywhere the new device tree API
- Add a support for SYS MMU

For the moment the ARM specific known bugs are:
- Bash can sometimes crash with: segfault, memory corruption. It's seems it's due to a lack of VPF save/restore in Xen.
- Assert in early code, ie before console is setup, let Xen spinned without an error message.

If you want to try this patch series you can clone:
git clone -b arm-v3 git://xenbits.xen.org/people/julieng/xen-unstable.git

The command line to compile Xen is the same as before. You just need to specify on Xen command line, via the device tree, which UART will be used for the console.

Feel free to test this branch. The wiki page is up-to-date for the arndale board:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Arndale

Cheers,

Anthony PERARD (2):
xen/arm: Add Exynos 4210 UART support xen/arm: Add Exynos 4210 UART support for early printk

Julien Grall (30):
xen/arm: Extend create_xen_entries prototype to take mapping
attribute
xen/mm: Align virtual address on PAGE_SIZE in iounmap xen/arm: Introduce ioremap_attr, ioremap_cache, ioremap_nocache,
ioremap_wc
xen/arm: Add helpers ioreadl/iowritel
xen/arm: Create a hierarchical device tree
xen/arm: Add helpers to use the device tree
xen/arm: Add helpers to retrieve an address from the device tree xen/arm: Add helpers to retrieve an interrupt description from the
device tree
xen/arm: Introduce gic_route_dt_irq
xen/arm: Introduce gic_irq_xlate
xen/arm: Introduce setup_dt_irq
xen/arm: Introduce request_dt_irq
xen/arm: Use hierarchical device tree to retrieve GIC information xen/arm: Retrieve timer interrupts from the device tree xen/arm: Don't hardcode VGIC informations
xen/arm: Don't hardcode virtual timer IRQs
xen/arm: Introduce a generic way to use a device from the device tree xen/arm: New callback in uart_driver to get device tree interrupt
structure
xen/arm: Add generic UART to get the device in the device tree xen/arm: Use device tree API in pl011 UART driver
xen/arm: Use the device tree to map the address range and IRQ to dom0 xen/arm: Allow Xen to run on multiple platform without recompilation xen/arm: WORKAROUND 1:1 memory mapping for dom0
xen/arm: Add versatile express platform
xen/arm: Remove request_irq
xen/arm: Remove setup_irq
xen/arm: Don't use pl011 UART by default for early printk xen/arm: Add platform specific code for the exynos5 xen/arm: WORKAROUND Support kick cpus and switch to hypervisor for
the exynos5
xen/arm64: Remove hardcoded value for gic in assembly code

 config/arm32.mk                          |    1 +
 docs/misc/arm/early-printk.txt           |   15 +
 xen/arch/arm/Makefile                    |    4 +-
 xen/arch/arm/Rules.mk                    |   21 +
 xen/arch/arm/arm32/Makefile              |    4 +-
 xen/arch/arm/arm32/debug-exynos4210.inc  |   77 ++
 xen/arch/arm/arm32/debug-pl011.inc       |   58 ++
 xen/arch/arm/arm32/debug.S               |   33 +
 xen/arch/arm/arm32/head.S                |   84 +-
 xen/arch/arm/arm32/mode_switch.S         |   75 +-
 xen/arch/arm/arm64/Makefile              |    2 +
 xen/arch/arm/arm64/debug-pl011.inc       |   59 ++
 xen/arch/arm/arm64/debug.S               |   33 +
 xen/arch/arm/arm64/head.S                |   69 +-
 xen/arch/arm/arm64/mode_switch.S         |    7 +-
 xen/arch/arm/device.c                    |   74 ++
 xen/arch/arm/domain_build.c              |  191 ++++-
 xen/arch/arm/early_printk.c              |   16 +-
 xen/arch/arm/gic.c                       |  156 +++-
 xen/arch/arm/irq.c                       |    8 +-
 xen/arch/arm/mm.c                        |   57 +-
 xen/arch/arm/platform.c                  |  137 +++
 xen/arch/arm/platforms/Makefile          |    1 +
 xen/arch/arm/platforms/exynos5.c         |  110 +++
 xen/arch/arm/platforms/vexpress.c        |   40 +
 xen/arch/arm/setup.c                     |   14 +-
 xen/arch/arm/shutdown.c                  |   16 +-
 xen/arch/arm/time.c                      |   68 +-
 xen/arch/arm/vgic.c                      |   20 +-
 xen/arch/arm/vtimer.c                    |   13 +-
 xen/arch/arm/xen.lds.S                   |   14 +
 xen/common/device_tree.c                 | 1364 ++++++++++++++++++++++++++++--
 xen/drivers/char/Makefile                |    2 +
 xen/drivers/char/dt-uart.c               |   69 ++
 xen/drivers/char/exynos4210-uart.c       |  365 ++++++++
 xen/drivers/char/pl011.c                 |   88 +-
 xen/drivers/char/serial.c                |   16 +
 xen/drivers/video/arm_hdlcd.c            |    2 +-
 xen/include/asm-arm/config.h             |   15 +-
 xen/include/asm-arm/device.h             |   52 ++
 xen/include/asm-arm/domain.h             |    5 +-
 xen/include/asm-arm/early_printk.h       |    2 +-
 xen/include/asm-arm/exynos4210-uart.h    |  111 +++
 xen/include/asm-arm/gic.h                |   15 +-
 xen/include/asm-arm/irq.h                |    8 +
 xen/include/asm-arm/mm.h                 |   29 +-
 xen/include/asm-arm/page.h               |    2 +
 xen/include/asm-arm/platform.h           |   61 ++
 xen/include/asm-arm/platforms/exynos5.h  |   39 +
 xen/include/asm-arm/platforms/vexpress.h |   14 +
 xen/include/asm-arm/time.h               |   15 +
 xen/include/xen/device_tree.h            |  404 ++++++++-
 xen/include/xen/serial.h                 |   11 +-
 xen/include/xen/vmap.h                   |    4 +-
 54 files changed, 3800 insertions(+), 370 deletions(-)
 create mode 100644 docs/misc/arm/early-printk.txt
 create mode 100644 xen/arch/arm/arm32/debug-exynos4210.inc
 create mode 100644 xen/arch/arm/arm32/debug-pl011.inc
 create mode 100644 xen/arch/arm/arm32/debug.S
 create mode 100644 xen/arch/arm/arm64/debug-pl011.inc
 create mode 100644 xen/arch/arm/arm64/debug.S
 create mode 100644 xen/arch/arm/device.c
 create mode 100644 xen/arch/arm/platform.c
 create mode 100644 xen/arch/arm/platforms/exynos5.c
 create mode 100644 xen/drivers/char/dt-uart.c
 create mode 100644 xen/drivers/char/exynos4210-uart.c
 create mode 100644 xen/include/asm-arm/device.h
 create mode 100644 xen/include/asm-arm/exynos4210-uart.h
 create mode 100644 xen/include/asm-arm/platform.h
 create mode 100644 xen/include/asm-arm/platforms/exynos5.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v4 1/32 xen/arm: Extend create_xen_entries prototype to take mapping attribute

Changes in v4:
- use "ai" instead of "flags" to reflect field which it goes in.

---
 xen/arch/arm/mm.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
xen/arch/arm/mm.c +5 -4
index 2836cbb..bd7eb1a 100644
@@ -631,7 +631,8 @@ enum xenmap_operation {
 static int create_xen_entries(enum xenmap_operation op,
                               unsigned long virt,
                               unsigned long mfn,
-                              unsigned long nr_mfns)
+                              unsigned long nr_mfns,
+                              unsigned int ai)
 {
     int rc;
     unsigned long addr = virt, addr_end = addr + nr_mfns * PAGE_SIZE;
@@ -664,6 +665,7 @@ static int create_xen_entries(enum xenmap_operation op,
                 }
                 pte = mfn_to_xen_entry(mfn);
                 pte.pt.table = 1;
+                pte.pt.ai = ai;
                 write_pte(&third[third_table_offset(addr)], pte);
                 break;
             case REMOVE:
@@ -693,12 +695,11 @@ int map_pages_to_xen(unsigned long virt,
                      unsigned long nr_mfns,
                      unsigned int flags)
 {
-    ASSERT(flags == PAGE_HYPERVISOR);
-    return create_xen_entries(INSERT, virt, mfn, nr_mfns);
+    return create_xen_entries(INSERT, virt, mfn, nr_mfns, flags);
 }
 void destroy_xen_mappings(unsigned long v, unsigned long e)
 {
-    create_xen_entries(REMOVE, v, 0, (e - v) >> PAGE_SHIFT);
+    create_xen_entries(REMOVE, v, 0, (e - v) >> PAGE_SHIFT, 0);
 }
 
 enum mg { mg_clear, mg_ro, mg_rw, mg_rx };
Signature · 1 line
1.7.10.4
Acked-by on v4 1/32
#2 lore raw

Re: [PATCH V4 01/32] xen/arm: Extend create_xen_entries prototype to take mapping attribute

Quoted 5 lines · Julien Grall

Changes in v4:
- use "ai" instead of "flags" to reflect field which it goes in.

For this sort of meta-comment which isn't intended to go in the final commit in the future please can you precede it with a "---" at the start of a line, then "git am" will do the right thing and strip it for me. e.g.:

-------8<---------------------

---
Changes in v4:
- use "ai" instead of "flags" to reflect field which it goes in.

-------8<---------------------

#3 lore raw

PATCH v4 2/32 xen/mm: Align virtual address on PAGE_SIZE in iounmap

In reply to Julien Grall

ioremap function can unlikely return an unaligned virtual address if the physical address itself is unaligned on a page size.

Changes in v4:
- replace vaddr_t by unsigned int

---
 xen/include/xen/vmap.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/include/xen/vmap.h +3 -1
index 88e5d99..45e9870 100644
@@ -15,7 +15,9 @@ void __iomem *ioremap(paddr_t, size_t);
 
 static inline void iounmap(void __iomem *va)
 {
-    vunmap((void __force *)va);
+    unsigned int addr = (unsigned int)(void __force *)va;
+
+    vunmap((void *)(addr & PAGE_MASK));
 }
 
 void vm_init(void);
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH V4 02/32] xen/mm: Align virtual address on PAGE_SIZE in iounmap

Quoted 18 lines · Julien Grall

ioremap function can unlikely return an unaligned virtual address if the physical address itself is unaligned on a page size.

Changes in v4:
- replace vaddr_t by unsigned int

---
 xen/include/xen/vmap.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/include/xen/vmap.h +0 -0
index 88e5d99..45e9870 100644

xen/include/xen/vmap.h void __iomem *ioremap(paddr_t, size_t); · line 18

Quoted 5 lines
xen/include/xen/vmap.h +1 -1
@@ -15,7 +15,9 @@ void __iomem *ioremap(paddr_t, size_t);
 
 static inline void iounmap(void __iomem *va)
 {
-    vunmap((void __force *)va);
+    unsigned int addr = (unsigned int)(void __force *)va;

Hum I used unsigned int instead of unsigned long. I will resend back this patch.

Quoted 5 lines
xen/include/xen/vmap.h +2 -0
+
+    vunmap((void *)(addr & PAGE_MASK));
 }
 
 void vm_init(void);
Signature · 1 line
Julien
author Acked-by Jan Beulich on v4 2/32
#5 lore raw

Re: [PATCH V4 02/32] xen/mm: Align virtual address on PAGE_SIZE in iounmap

In reply to Julien Grall

ioremap function can unlikely return an unaligned virtual address if the physical address itself is unaligned on a page size.

Changes in v5:
- replace unsigned int by unsigned long

Changes in v4:
- replace vaddr_t by unsigned int

---
 xen/include/xen/vmap.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/include/xen/vmap.h +3 -1
index 88e5d99..daee7f5 100644
@@ -15,7 +15,9 @@ void __iomem *ioremap(paddr_t, size_t);
 
 static inline void iounmap(void __iomem *va)
 {
-    vunmap((void __force *)va);
+    unsigned long addr = (unsigned long)(void __force *)va;
+
+    vunmap((void *)(addr & PAGE_MASK));
 }
 
 void vm_init(void);
Signature · 1 line
Julien
#6 lore raw

Re: [PATCH V4 02/32] xen/mm: Align virtual address on PAGE_SIZE in iounmap

In reply to Julien Grall
Quoted 2 lines · Julien Grall

ioremap function can unlikely return an unaligned virtual address if the physical address itself is unaligned on a page size.

On x86 this causes:
In file included from /local/scratch/ianc/devel/committer.git/xen/include/asm/io.h:5,

                 from /local/scratch/ianc/devel/committer.git/xen/include/asm/mc146818rtc.h:8,
                 from rtc.c:26:

/local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h: In function ‘iounmap’:
/local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error: ‘PAGE_MASK’ undeclared (first use in this function) /local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error: (Each undeclared identifier is reported only once /local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error: for each function it appears in.) make[5]: *** [rtc.o] Error 1
make[5]: *** Waiting for unfinished jobs....

Since I had already prepared the branch for commit/push and it was a bit of a faff I will fold in the following patchlet:

xen/include/xen/vmap.h +1 -0
index daee7f5..b1923dd 100644
@@ -2,6 +2,7 @@
 #define __XEN_VMAP_H__
 
 #include <xen/types.h>
+#include <asm/page.h>
 
 void *vm_alloc(unsigned int nr, unsigned int align);
 void vm_free(const void *);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Re: [PATCH V4 02/32] xen/mm: Align virtual address on PAGE_SIZE in iounmap

Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 2 lines · Julien Grall

ioremap function can unlikely return an unaligned virtual address if the physical address itself is unaligned on a page size.

On x86 this causes:
In file included from /local/scratch/ianc/devel/committer.git/xen/include/asm/io.h:5,
from
/local/scratch/ianc/devel/committer.git/xen/include/asm/mc146818rtc.h:8,

                 from rtc.c:26:
Quoted 10 lines

/local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h: In function ‘iounmap’:
/local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error:
‘PAGE_MASK’ undeclared (first use in this function) /local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error:
(Each undeclared identifier is reported only once /local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error:
for each function it appears in.)
make[5]: *** [rtc.o] Error 1
make[5]: *** Waiting for unfinished jobs....

With this and the other two bugs that the recent "ARM-sharing- more-code-with-x86" effort introduced, I wonder whether it's really appropriate for doing this sort of stuff - without proper testing on the x86 side - during the RC phase.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH V4 02/32] xen/mm: Align virtual address on PAGE_SIZE in iounmap

Quoted 22 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 2 lines · Julien Grall

ioremap function can unlikely return an unaligned virtual address if the physical address itself is unaligned on a page size.

On x86 this causes:
In file included from /local/scratch/ianc/devel/committer.git/xen/include/asm/io.h:5,
from
/local/scratch/ianc/devel/committer.git/xen/include/asm/mc146818rtc.h:8,

                 from rtc.c:26:
Quoted 10 lines

/local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h: In function ‘iounmap’:
/local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error:
‘PAGE_MASK’ undeclared (first use in this function) /local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error:
(Each undeclared identifier is reported only once /local/scratch/ianc/devel/committer.git/xen/include/xen/vmap.h:20: error:
for each function it appears in.)
make[5]: *** [rtc.o] Error 1
make[5]: *** Waiting for unfinished jobs....

Quoted 4 lines

With this and the other two bugs that the recent "ARM-sharing- more-code-with-x86" effort introduced, I wonder whether it's really appropriate for doing this sort of stuff - without proper testing on the x86 side - during the RC phase.

That's a good question, which I'm afraid I didn't see until after I had hit push. Sorry. We could revert but I'd rather not.

If it is any consolation I think this was the last major bit of ARM functionality which was to be given such a broad freeze exception. (I hope Stefano or Julien will correct me ASAP if this is wrong)

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#9 lore raw

PATCH v4 3/32 xen/arm: Introduce ioremap_attr, ioremap_cache, ioremap_nocache, ioremap_wc

In reply to Julien Grall

Map physical range in virtual memory with a specific mapping attribute. Also add new mapping attributes for ARM: PAGE_HYPERVISOR_NOCACHE and PAGE_HYPERVISOR_WC.

This function replaces early_ioremap which is only able to deal with 2Mb aligned mapping. Therefore, vmap initialization has been moved earlier.

Changes in v4:
- Update comment
- Merge "Remove early_ioremap" in this commit
- Add ioremap_nocache, ioremap_cache, ioremap_wc for future use when, for instance, SYS MMU will be ported from Linux

---
 xen/arch/arm/mm.c             |   48 +++++++++++------------------------------
 xen/arch/arm/setup.c          |    4 ++--
 xen/drivers/video/arm_hdlcd.c |    2 +-
 xen/include/asm-arm/mm.h      |   19 ++++++++++++++--
 xen/include/asm-arm/page.h    |    2 ++
 5 files changed, 35 insertions(+), 40 deletions(-)
xen/arch/arm/mm.c +13 -35
index bd7eb1a..d1290cd 100644
@@ -38,6 +38,7 @@
 #include <xen/sched.h>
 #include <xen/vmap.h>
 #include <xsm/xsm.h>
+#include <xen/pfn.h>
 
 struct domain *dom_xen, *dom_io, *dom_cow;
 
@@ -567,45 +568,22 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
     frametable_virt_end = FRAMETABLE_VIRT_START + (nr_pages * sizeof(struct page_info));
 }
 
-/* Map the physical memory range start -  start + len into virtual
- * memory and return the virtual address of the mapping.
- * start has to be 2MB aligned.
- * len has to be < VMAP_VIRT_END - VMAP_VIRT_START.
- */
-static __initdata unsigned long early_vmap_start = VMAP_VIRT_END;
-void* __init early_ioremap(paddr_t start, size_t len, unsigned attributes)
+void *__init arch_vmap_virt_end(void)
 {
-    paddr_t end = start + len;
-    unsigned long map_start;
-
-    len = (len + SECOND_SIZE - 1) & ~SECOND_MASK;
-    early_vmap_start -= len;
-
-    ASSERT(!(start & (~SECOND_MASK)));
-    ASSERT(!(early_vmap_start & (~SECOND_MASK)));
-
-    /* The range we need to map is too big */
-    if ( early_vmap_start >= VMAP_VIRT_START )
-        return NULL;
-
-    map_start = early_vmap_start;
-    while ( start < end )
-    {
-        lpae_t e = mfn_to_xen_entry(start >> PAGE_SHIFT);
-        e.pt.ai = attributes;
-        write_pte(xen_second + second_table_offset(map_start), e);
-
-        start += SECOND_SIZE;
-        map_start += SECOND_SIZE;
-    }
-    flush_xen_data_tlb_range_va(early_vmap_start, len);
-
-    return (void*)early_vmap_start;
+    return (void *)VMAP_VIRT_END;
 }
 
-void *__init arch_vmap_virt_end(void)
+/*
+ * This function should only be used to remap device address ranges
+ * TODO: add a check to verify this assumption
+ */
+void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes)
 {
-    return (void *)early_vmap_start;
+    unsigned long pfn = PFN_DOWN(pa);
+    unsigned int offs = pa & (PAGE_SIZE - 1);
+    unsigned int nr = PFN_UP(offs + len);
+
+    return (__vmap(&pfn, nr, 1, 1, attributes) + offs);
 }
 
 static int create_xen_table(lpae_t *entry)
xen/arch/arm/setup.c +2 -2
index 29447ef..a667db4 100644
@@ -429,6 +429,8 @@ void __init start_xen(unsigned long boot_phys_offset,
     setup_pagetables(boot_phys_offset, get_xen_paddr());
     setup_mm(fdt_paddr, fdt_size);
 
+    vm_init();
+
 #ifdef EARLY_UART_ADDRESS
     /* TODO Need to get device tree or command line for UART address */
     pl011_init(0, FIXMAP_ADDR(FIXMAP_CONSOLE));
@@ -483,8 +485,6 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     console_init_postirq();
 
-    vm_init();
-
     do_presmp_initcalls();
 
     for_each_present_cpu ( i )
xen/drivers/video/arm_hdlcd.c +1 -1
index d0ec13d..72979ea 100644
@@ -211,7 +211,7 @@ void __init video_init(void)
 
     printk(KERN_INFO "Initializing HDLCD driver\n");
 
-    lfb = early_ioremap(framebuffer_start, framebuffer_size, DEV_WC);
+    lfb = ioremap_wc(framebuffer_start, framebuffer_size);
     if ( !lfb )
     {
         printk(KERN_ERR "Couldn't map the framebuffer\n");
xen/include/asm-arm/mm.h +17 -2
index 26c271e..63e1069 100644
@@ -153,8 +153,23 @@ extern void setup_frametable_mappings(paddr_t ps, paddr_t pe);
 extern void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes);
 /* Remove a mapping from a fixmap entry */
 extern void clear_fixmap(unsigned map);
-/* map a 2MB aligned physical range in virtual memory. */
-void* early_ioremap(paddr_t start, size_t len, unsigned attributes);
+/* map a physical range in virtual memory */
+void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned attributes);
+
+static inline void __iomem *ioremap_nocache(paddr_t start, size_t len)
+{
+    return ioremap_attr(start, len, PAGE_HYPERVISOR_NOCACHE);
+}
+
+static inline void __iomem *ioremap_cache(paddr_t start, size_t len)
+{
+    return ioremap_attr(start, len, PAGE_HYPERVISOR);
+}
+
+static inline void __iomem *ioremap_wc(paddr_t start, size_t len)
+{
+    return ioremap_attr(start, len, PAGE_HYPERVISOR_WC);
+}
 
 #define mfn_valid(mfn)        ({                                              \
     unsigned long __m_f_n = (mfn);                                            \
xen/include/asm-arm/page.h +2 -0
index fd6946e..13fbd78 100644
@@ -59,6 +59,8 @@
 #define DEV_CACHED    WRITEBACK
 
 #define PAGE_HYPERVISOR         (MATTR_MEM)
+#define PAGE_HYPERVISOR_NOCACHE (DEV_SHARED)
+#define PAGE_HYPERVISOR_WC      (DEV_WC)
 #define MAP_SMALL_PAGES         PAGE_HYPERVISOR
 
 /*
Signature · 1 line
1.7.10.4
Acked-by on v4 3/32
#10 lore raw

Re: [PATCH V4 03/32] xen/arm: Introduce ioremap_attr, ioremap_cache, ioremap_nocache, ioremap_wc

Quoted 8 lines · Julien Grall

Map physical range in virtual memory with a specific mapping attribute. Also add new mapping attributes for ARM: PAGE_HYPERVISOR_NOCACHE and PAGE_HYPERVISOR_WC.

This function replaces early_ioremap which is only able to deal with 2Mb aligned mapping. Therefore, vmap initialization has been moved earlier.

#11 lore raw

PATCH v4 4/32 xen/arm: Add helpers ioreadl/iowritel

In reply to Julien Grall
---
 xen/include/asm-arm/mm.h |   10 ++++++++++
 1 file changed, 10 insertions(+)
xen/include/asm-arm/mm.h +10 -0
index 63e1069..3749f44 100644
@@ -171,6 +171,16 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len)
     return ioremap_attr(start, len, PAGE_HYPERVISOR_WC);
 }
 
+static inline uint32_t ioreadl(const volatile void __iomem *addr)
+{
+    return (*(volatile uint32_t *)addr);
+}
+
+static inline void iowritel(const volatile void __iomem *addr, uint32_t val)
+{
+    *(volatile uint32_t *)addr = val;
+}
+
 #define mfn_valid(mfn)        ({                                              \
     unsigned long __m_f_n = (mfn);                                            \
     likely(__m_f_n < max_page);                                               \
Signature · 1 line
1.7.10.4
#12 lore raw

Re: [PATCH V4 04/32] xen/arm: Add helpers ioreadl/iowritel

Quoted 10 lines · Julien Grall
---
 xen/include/asm-arm/mm.h |   10 ++++++++++
 1 file changed, 10 insertions(+)
xen/include/asm-arm/mm.h +0 -0
index 63e1069..3749f44 100644

xen/include/asm-arm/mm.h static inline void __iomem *ioremap_wc(paddr_t start, size_t len) · line 177

Quoted 7 lines
xen/include/asm-arm/mm.h +4 -0
@@ -171,6 +171,16 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len)
     return ioremap_attr(start, len, PAGE_HYPERVISOR_WC);
 }
 
+static inline uint32_t ioreadl(const volatile void __iomem *addr)
+{
+    return (*(volatile uint32_t *)addr);
+}

Is volatile here sufficient? I'd have thought some barriers ought to be involved somewhere.

e.g. on Linux the equivalent functionality is:
static inline u32 __raw_readl(const volatile void __iomem *addr)

{
        u32 val;
        asm volatile("ldr %1, %0"
                     : "+Qo" (*(volatile u32 __force *)addr),
                       "=r" (val));
        return val;
}

#define __iormb() rmb()
#define ioread32(p) ({ unsigned int __v = le32_to_cpu((__force __le32)__raw_readl(p)); __iormb(); __v; })

Ian.

Quoted 9 lines
xen/include/asm-arm/mm.h +6 -0
+
+static inline void iowritel(const volatile void __iomem *addr, uint32_t val)
+{
+    *(volatile uint32_t *)addr = val;
+}
+
 #define mfn_valid(mfn)        ({                                              \
     unsigned long __m_f_n = (mfn);                                            \
     likely(__m_f_n < max_page);                                               \
#13 lore raw

Re: [PATCH V4 04/32] xen/arm: Add helpers ioreadl/iowritel

In reply to Julien Grall

Changes in v5:
- Use functions from linux code

---
 xen/include/asm-arm/arm32/io.h |   46 ++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/arm64/io.h |   38 +++++++++++++++++++++++++++++++++
 xen/include/asm-arm/mm.h       |    8 +++++++
 3 files changed, 92 insertions(+)
 create mode 100644 xen/include/asm-arm/arm32/io.h
 create mode 100644 xen/include/asm-arm/arm64/io.h
xen/include/asm-arm/arm32/io.h new file +46 -0
new file mode 100644
index 0000000..0d6da1f
@@ -0,0 +1,46 @@
+/*
+ *  Based on linux arch/arm/include/asm/io.h
+ *
+ *  Copyright (C) 1996-2000 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Modifications:
+ *  16-Sep-1996        RMK     Inlined the inx/outx functions & optimised for both
+ *                     constant addresses and variable addresses.
+ *  04-Dec-1997        RMK     Moved a lot of this stuff to the new architecture
+ *                     specific IO header files.
+ *  27-Mar-1999        PJB     Second parameter of memcpy_toio is const..
+ *  04-Apr-1999        PJB     Added check_signature.
+ *  12-Dec-1999        RMK     More cleanups
+ *  18-Jun-2000 RMK    Removed virt_to_* and friends definitions
+ *  05-Oct-2004 BJD     Moved memory string functions to use void __iomem
+ */
+#ifndef _ARM_ARM32_IO_H
+#define _ARM_ARM32_IO_H
+
+#include <asm/system.h>
+
+static inline uint32_t ioreadl(const volatile void __iomem *addr)
+{
+    uint32_t val;
+
+    asm volatile("ldr %1, %0"
+                 : "+Qo" (*(volatile uint32_t __force *)addr),
+                   "=r" (val));
+    dsb();
+
+    return val;
+}
+
+static inline void iowritel(const volatile void __iomem *addr, uint32_t val)
+{
+    dsb();
+    asm volatile("str %1, %0"
+                 : "+Qo" (*(volatile uint32_t __force *)addr)
+                 : "r" (val));
+}
+
+#endif /* _ARM_ARM32_IO_H */
xen/include/asm-arm/arm64/io.h new file +38 -0
new file mode 100644
index 0000000..ec041cd
@@ -0,0 +1,38 @@
+/*
+ * Based on linux arch/arm64/include/asm/io.h
+ *
+ * Copyright (C) 1996-2000 Russell King
+ * Copyright (C) 2012 ARM Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _ARM_ARM64_IO_H
+#define _ARM_ARM64_IO_H
+
+static inline uint32_t ioreadl(const volatile void __iomem *addr)
+{
+    uint32_t val;
+
+    asm volatile("ldr %w0, [%1]" : "=r" (val) : "r" (addr));
+    dsb();
+
+    return val;
+}
+
+static inline void iowritel(const volatile void __iomem *addr, uint32_t val)
+{
+    dsb();
+    asm volatile("str %w0, [%1]" : : "r" (val), "r" (addr));
+}
+
+#endif /* _ARM_ARM64_IO_H */
xen/include/asm-arm/mm.h +8 -0
index 63e1069..5e7c5a3 100644
@@ -6,6 +6,14 @@
 #include <asm/page.h>
 #include <public/xen.h>
 
+#if defined(CONFIG_ARM_32)
+# include <asm/arm32/io.h>
+#elif defined(CONFIG_ARM_64)
+# include <asm/arm64/io.h>
+#else
+# error "unknown ARM variant"
+#endif
+
 /* Align Xen to a 2 MiB boundary. */
 #define XEN_PADDR_ALIGN (1 << 21)
 
Signature · 1 line
1.7.10.4
#14 lore raw

PATCH v4 5/32 xen/arm: Create a hierarchical device tree

In reply to Julien Grall

Add function to parse the device tree and create a hierarchical tree.

This code is based on drivers/of/base.c in linux source.

Changes in v4:
- Replace dt_printk by a macro to avoid double buffering

Changes in v3:
- Remove dt_switch_to_printk
- Use system_state to choose between early_printk and printk
- Remove DT_USE_BY_XEN, instead use DOMID_XEN

Changes in v2:
- s/dom0$/device/ in comment "By default dom0 owns the dom0"
- Use DOMID_XEN instead of DOMID_INVALID for DT_USED_BY_XEN

---
 xen/arch/arm/setup.c          |    1 +
 xen/common/device_tree.c      |  455 ++++++++++++++++++++++++++++++++++++++++-
 xen/include/xen/device_tree.h |   89 ++++++++
 3 files changed, 540 insertions(+), 5 deletions(-)
xen/arch/arm/setup.c +1 -0
index a667db4..81bc956 100644
@@ -430,6 +430,7 @@ void __init start_xen(unsigned long boot_phys_offset,
     setup_mm(fdt_paddr, fdt_size);
 
     vm_init();
+    dt_unflatten_host_device_tree();
 
 #ifdef EARLY_UART_ADDRESS
     /* TODO Need to get device tree or command line for UART address */
xen/common/device_tree.c +450 -5

495 lines not on this page · raw message

xen/include/xen/device_tree.h +89 -0

105 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#16 lore raw

PATCH v4 19/32 xen/arm: Add generic UART to get the device in the device tree

In reply to Julien Grall

This generic UART will find the right UART via xen command line with dtuart=myserial.

"myserial" is the alias of the UART in the device tree. Xen will retrieve the information via the device tree and call the initialization function for this specific UART thanks to the device API.

Changes in v3:
- Rename arm-uart.c (resp. arm_uart_init) to dt-uart.c (resp. dt_uart_init)
- Remove serial_arm_defaults and replace by a string options
- Let the specific UART driver to get its base address in the DT
- Add SERHND_DTUART. The value is stolen to SERHND_COM1. Bump the value would needs some rework...

Changes in v2:
- Use dtuart parameter instead of com1. The first one is more arm while the latter is more x86

---
 xen/arch/arm/setup.c         |    3 +-
 xen/drivers/char/Makefile    |    1 +
 xen/drivers/char/dt-uart.c   |   69 ++++++++++++++++++++++++++++++++++++++++++
 xen/drivers/char/serial.c    |    6 ++++
 xen/include/asm-arm/config.h |    2 +-
 xen/include/xen/serial.h     |    5 ++-
 6 files changed, 83 insertions(+), 3 deletions(-)
 create mode 100644 xen/drivers/char/dt-uart.c
xen/arch/arm/setup.c +2 -1
index fc53117..2e331d3 100644
@@ -436,8 +436,9 @@ void __init start_xen(unsigned long boot_phys_offset,
 #ifdef EARLY_UART_ADDRESS
     /* TODO Need to get device tree or command line for UART address */
     pl011_init(0, FIXMAP_ADDR(FIXMAP_CONSOLE));
-    console_init_preirq();
 #endif
+    dt_uart_init();
+    console_init_preirq();
 
     system_state = SYS_STATE_boot;
 
xen/drivers/char/Makefile +1 -0
index ab2246d..9c067f9 100644
@@ -2,4 +2,5 @@ obj-y += console.o
 obj-$(HAS_NS16550) += ns16550.o
 obj-$(HAS_PL011) += pl011.o
 obj-$(HAS_EHCI) += ehci-dbgp.o
+obj-$(CONFIG_ARM) += dt-uart.o
 obj-y += serial.o
xen/drivers/char/dt-uart.c new file +69 -0

69 lines not on this page · raw message

xen/drivers/char/serial.c +6 -0
index 0ae7e4d..e1c3f47 100644
@@ -271,6 +271,12 @@ int __init serial_parse_handle(char *conf)
         goto common;
     }
 
+    if ( !strncmp(conf, "dtuart", 5) )
+    {
+        handle = SERHND_DTUART;
+        goto common;
+    }
+
     if ( strncmp(conf, "com", 3) )
         goto fail;
 
xen/include/asm-arm/config.h +1 -1
index 98a3a43..8ed72f5 100644
@@ -39,7 +39,7 @@
 
 #define CONFIG_VIDEO 1
 
-#define OPT_CONSOLE_STR "com1"
+#define OPT_CONSOLE_STR "dtuart"
 
 #ifdef MAX_PHYS_CPUS
 #define NR_CPUS MAX_PHYS_CPUS
xen/include/xen/serial.h +4 -1
index 5de5171..8af3bc4 100644
@@ -9,6 +9,7 @@
 #ifndef __XEN_SERIAL_H__
 #define __XEN_SERIAL_H__
 
+#include <xen/init.h>
 #include <xen/spinlock.h>
 
 struct cpu_user_regs;
@@ -76,10 +77,11 @@ struct uart_driver {
 };
 
 /* 'Serial handles' are composed from the following fields. */
-#define SERHND_IDX      (3<<0) /* COM1, COM2, or DBGP?                    */
+#define SERHND_IDX      (3<<0) /* COM1, COM2, DBGP, DTUART?               */
 # define SERHND_COM1    (0<<0)
 # define SERHND_COM2    (1<<0)
 # define SERHND_DBGP    (2<<0)
+# define SERHND_DTUART  (0<<0) /* Steal SERHND_COM1 value */
 #define SERHND_HI       (1<<2) /* Mux/demux each transferred char by MSB. */
 #define SERHND_LO       (1<<3) /* Ditto, except that the MSB is cleared.  */
 #define SERHND_COOKED   (1<<4) /* Newline/carriage-return translation?    */
@@ -156,6 +158,7 @@ void ns16550_init(int index, struct ns16550_defaults *defaults);
 void ehci_dbgp_init(void);
 
 void pl011_init(int index, unsigned long register_base_address);
+void __init dt_uart_init(void);
 
 struct physdev_dbgp_op;
 int dbgp_op(const struct physdev_dbgp_op *);
Signature · 1 line
1.7.10.4
#17 lore raw

PATCH v4 20/32 xen/arm: Use device tree API in pl011 UART driver

In reply to Julien Grall

Allow UART driver to retrieve all its information in the device tree. It's possible to choose the pl011 driver via the Xen command line.

Changes in v4:
- Use ioremap_nocache instead of ioremap_attr(..., PAGE_HYPERVISOR_NOCACHE)
- Print a warning if config != ""

Changes in v3:
- Remove the usage of serial_arm_defaults
- Get the base address from the DT and map it with ioremap_attr
- Allow only 1 PL011 assigned to SERHND_DTUART
- Replace DT_USED_BY_XEN by DOMID_XEN

Changes in v2:
- Rework TODO
- Use the new function setup_dt_irq

---
 xen/arch/arm/gic.c       |    4 ---
 xen/arch/arm/setup.c     |    4 ---
 xen/drivers/char/pl011.c |   88 +++++++++++++++++++++++++++++++++++++---------
 xen/include/xen/serial.h |    1 -
 4 files changed, 72 insertions(+), 25 deletions(-)
xen/arch/arm/gic.c +0 -4
index 761f570..648b1a0 100644
@@ -505,10 +505,6 @@ void gic_route_spis(void)
     int seridx;
     const struct dt_irq *irq;
 
-    /* XXX should get these from DT */
-    /* UART */
-    gic_route_irq(37, 0, 1u << smp_processor_id(), 0xa0);
-
     for ( seridx = 0; seridx <= SERHND_IDX; seridx++ )
     {
         if ( (irq = serial_dt_irq(seridx)) == NULL )
xen/arch/arm/setup.c +0 -4
index 2e331d3..e5f4459 100644
@@ -433,10 +433,6 @@ void __init start_xen(unsigned long boot_phys_offset,
     dt_unflatten_host_device_tree();
     dt_irq_xlate = gic_irq_xlate;
 
-#ifdef EARLY_UART_ADDRESS
-    /* TODO Need to get device tree or command line for UART address */
-    pl011_init(0, FIXMAP_ADDR(FIXMAP_CONSOLE));
-#endif
     dt_uart_init();
     console_init_preirq();
 
xen/drivers/char/pl011.c +72 -16

140 lines not on this page · raw message

xen/include/xen/serial.h +0 -1
index 8af3bc4..9caf776 100644
@@ -157,7 +157,6 @@ struct ns16550_defaults {
 void ns16550_init(int index, struct ns16550_defaults *defaults);
 void ehci_dbgp_init(void);
 
-void pl011_init(int index, unsigned long register_base_address);
 void __init dt_uart_init(void);
 
 struct physdev_dbgp_op;
Signature · 1 line
1.7.10.4
#18 lore raw

PATCH v4 22/32 xen/arm: Allow Xen to run on multiple platform without recompilation

In reply to Julien Grall

Xen can include various platform support (ie: exynos5, versatile express...) and choose during boot time a set of callbacks for the current board. These callbacks will be called in places where each board can have specific code. For the moment the callbacks are:
- platform_init: additional initialization for the platform
- platform_init_time: some platform (ie: Exynos 5) needs to initialize the timer with an uncommon way
- platform_specific_mapping: add mapping to dom0 which are not specified in the device tree
- platform_reset: reset the platform
- platform_poweroff: poweroff the platform
- platform_quirks: list of quirks for a specific board.

Changes in v4:
- More precision in the TODO

Changes in v3:
- Remove platform_{read,write}
- Move platform_init_time before reading the timer frequency

Changes in v2:
- Add platform_poweroff
- Add platform_quirks

---
 xen/arch/arm/Makefile          |    1 +
 xen/arch/arm/domain_build.c    |    4 ++
 xen/arch/arm/platform.c        |  137 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/setup.c           |    3 +
 xen/arch/arm/shutdown.c        |    2 +
 xen/arch/arm/time.c            |    6 ++
 xen/arch/arm/xen.lds.S         |    7 ++
 xen/include/asm-arm/platform.h |   55 ++++++++++++++++
 8 files changed, 215 insertions(+)
 create mode 100644 xen/arch/arm/platform.c
 create mode 100644 xen/include/asm-arm/platform.h
xen/arch/arm/Makefile +1 -0
index 4955a21..2717f26 100644
@@ -18,6 +18,7 @@ obj-y += p2m.o
 obj-y += percpu.o
 obj-y += guestcopy.o
 obj-y += physdev.o
+obj-y += platform.o
 obj-y += setup.o
 obj-y += time.o
 obj-y += smpboot.o
xen/arch/arm/domain_build.c +4 -0
index 9a2ccad..75c3006 100644
@@ -12,6 +12,7 @@
 #include <xen/libfdt/libfdt.h>
 #include <xen/guest_access.h>
 #include <asm/setup.h>
+#include <asm/platform.h>
 
 #include <asm/gic.h>
 #include <xen/irq.h>
@@ -513,6 +514,9 @@ int construct_dom0(struct domain *d)
         return rc;
 
     map_devices_from_device_tree(d);
+    rc = platform_specific_mapping(d);
+    if ( rc < 0 )
+        return rc;
 
     /* The following loads use the domain's p2m */
     p2m_load_VTTBR(d);
xen/arch/arm/platform.c new file +137 -0

137 lines not on this page · raw message

xen/arch/arm/setup.c +3 -0
index e5f4459..da2a734 100644
@@ -42,6 +42,7 @@
 #include <asm/early_printk.h>
 #include <asm/gic.h>
 #include <asm/cpufeature.h>
+#include <asm/platform.h>
 
 struct cpuinfo_arm __read_mostly boot_cpu_data;
 
@@ -440,6 +441,8 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     processor_id();
 
+    platform_init();
+
     init_xen_time();
 
     gic_init();
xen/arch/arm/shutdown.c +2 -0
index 61b5280..0903842 100644
@@ -5,6 +5,7 @@
 #include <xen/lib.h>
 #include <xen/mm.h>
 #include <xen/smp.h>
+#include <asm/platform.h>
 
 static void raw_machine_reset(void)
 {
@@ -21,6 +22,7 @@ static void raw_machine_reset(void)
     dsb(); isb();
     clear_fixmap(FIXMAP_MISC);
 #endif
+    platform_reset();
 }
 
 static void halt_this_cpu(void *arg)
xen/arch/arm/time.c +6 -0
index 2e928bc..db849cf 100644
@@ -33,6 +33,7 @@
 #include <asm/time.h>
 #include <asm/gic.h>
 #include <asm/cpufeature.h>
+#include <asm/platform.h>
 
 /*
  * Unfortunately the hypervisor timer interrupt appears to be buggy in
@@ -123,11 +124,16 @@ int __init init_xen_time(void)
            timer_irq[TIMER_HYP_PPI].irq,
            timer_irq[TIMER_VIRT_PPI].irq);
 
+    res = platform_init_time();
+    if ( res )
+        return res;
+
     /* Check that this CPU supports the Generic Timer interface */
     if ( !cpu_has_gentimer )
         panic("CPU does not support the Generic Timer v1 interface.\n");
 
     cpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000;
+
     boot_count = READ_SYSREG64(CNTPCT_EL0);
     printk("Using generic timer at %lu KHz\n", cpu_khz);
 
xen/arch/arm/xen.lds.S +7 -0
index deab040..3b60668 100644
@@ -77,6 +77,13 @@ SECTIONS
 #endif
 
   . = ALIGN(8);
+  .arch.info : {
+      _splatform = .;
+      *(.arch.info)
+      _eplatform = .;
+  } :text
+
+  . = ALIGN(8);
   .dev.info : {
       _sdevice = .;
       *(.dev.info)
xen/include/asm-arm/platform.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#19 lore raw

PATCH v4 24/32 xen/arm: Add versatile express platform

In reply to Julien Grall

This platform contains nearly nothing specific except the reset function.

Changes in v4:
- Use ioremap_nocache
- Directly give SP810_ADDRESS without page alignment

Changes in v3:
- Use ioremap_attr instead of fixmap

Changes in v2:
- Add TODO to retrieve reset base address in the DT

---
 xen/arch/arm/platforms/vexpress.c        |   40 ++++++++++++++++++++++++++++++
 xen/arch/arm/shutdown.c                  |   14 -----------
 xen/include/asm-arm/config.h             |    3 ---
 xen/include/asm-arm/platforms/vexpress.h |    3 +++
 4 files changed, 43 insertions(+), 17 deletions(-)
xen/arch/arm/platforms/vexpress.c +40 -0
index fd4ce74..8fc30c4 100644
@@ -18,7 +18,9 @@
  */
 
 #include <asm/platforms/vexpress.h>
+#include <asm/platform.h>
 #include <xen/mm.h>
+#include <xen/vmap.h>
 
 #define DCC_SHIFT      26
 #define FUNCTION_SHIFT 20
@@ -91,6 +93,44 @@ out:
 }
 
 /*
+ * TODO: Get base address from the device tree
+ * See arm,vexpress-reset node
+ */
+static void vexpress_reset(void)
+{
+    void __iomem *sp810;
+
+    /* Use the SP810 system controller to force a reset */
+    sp810 = ioremap_nocache(SP810_ADDRESS, PAGE_SIZE);
+
+    if ( !sp810 )
+    {
+        dprintk(XENLOG_ERR, "Unable to map SP810\n");
+        return;
+    }
+
+    /* switch to slow mode */
+    iowritel(sp810, 0x3);
+    dsb(); isb();
+    /* writing any value to SCSYSSTAT reg will reset the system */
+    iowritel(sp810 + 4, 0x1);
+    dsb(); isb();
+
+    iounmap(sp810);
+}
+
+static const char const *vexpress_dt_compat[] __initdata =
+{
+    "arm,vexpress",
+    NULL
+};
+
+PLATFORM_START(vexpress, "VERSATILE EXPRESS")
+    .compatible = vexpress_dt_compat,
+    .reset = vexpress_reset,
+PLATFORM_END
+
+/*
  * Local variables:
  * mode: C
  * c-file-style: "BSD"
xen/arch/arm/shutdown.c +0 -14
index 0903842..767cc12 100644
@@ -3,25 +3,11 @@
 #include <xen/cpu.h>
 #include <xen/delay.h>
 #include <xen/lib.h>
-#include <xen/mm.h>
 #include <xen/smp.h>
 #include <asm/platform.h>
 
 static void raw_machine_reset(void)
 {
-    /* XXX get this from device tree */
-#ifdef SP810_ADDRESS
-    /* Use the SP810 system controller to force a reset */
-    volatile uint32_t *sp810;
-    set_fixmap(FIXMAP_MISC, SP810_ADDRESS >> PAGE_SHIFT, DEV_SHARED);
-    sp810 = ((uint32_t *)
-             (FIXMAP_ADDR(FIXMAP_MISC) + (SP810_ADDRESS & ~PAGE_MASK)));
-    sp810[0] = 0x3; /* switch to slow mode */
-    dsb(); isb();
-    sp810[1] = 0x1; /* writing any value to SCSYSSTAT reg will reset system */
-    dsb(); isb();
-    clear_fixmap(FIXMAP_MISC);
-#endif
     platform_reset();
 }
 
xen/include/asm-arm/config.h +0 -3
index 8ed72f5..7599202 100644
@@ -149,9 +149,6 @@ extern unsigned long frametable_virt_end;
 #define GIC_CR_OFFSET 0x2000
 #define GIC_HR_OFFSET 0x4000 /* Guess work http://lists.infradead.org/pipermail/linux-arm-kernel/2011-September/064219.html */
 #define GIC_VR_OFFSET 0x6000 /* Virtual Machine CPU interface) */
-/* Board-specific: base address of system controller */
-#define SP810_ADDRESS 0x1C020000
-
 
 #endif /* __ARM_CONFIG_H__ */
 /*
xen/include/asm-arm/platforms/vexpress.h +3 -0
index 67f8fef..5cf3aba 100644
@@ -23,6 +23,9 @@
 #define V2M_SYS_CFG_OSC4      4
 #define V2M_SYS_CFG_OSC5      5
 
+/* Board-specific: base address of system controller */
+#define SP810_ADDRESS 0x1C020000
+
 #ifndef __ASSEMBLY__
 #include <xen/inttypes.h>
 
Signature · 1 line
1.7.10.4
#21 lore raw

PATCH v4 28/32 xen/arm: Add Exynos 4210 UART support

In reply to Julien Grall

From: Anthony PERARD <[email protected]>

Changes in v4:
- Use ioremap_nocache instead of ioremap_attr(..., PAGE_HYPERVISOR_NOCACHE)
- Add warning if config != ""

Changes in v3:
- Directly get the base address from the DT and map it with ioremap_attr
- Use ioreadl/iowritel
- Typoes
- Remove the remaining //

Changes in v2:
- Use defines where it's possible
- Move UART definition in a separate header. Will be used for early UART
- Replace all // by /* ... */
- Add Anthony as first author

---
 config/arm32.mk                       |    1 +
 xen/drivers/char/Makefile             |    1 +
 xen/drivers/char/exynos4210-uart.c    |  365 +++++++++++++++++++++++++++++++++
 xen/include/asm-arm/exynos4210-uart.h |  111 ++++++++++
 4 files changed, 478 insertions(+)
 create mode 100644 xen/drivers/char/exynos4210-uart.c
 create mode 100644 xen/include/asm-arm/exynos4210-uart.h
config/arm32.mk +1 -0
index f64f0c1..d8e958b 100644
@@ -8,6 +8,7 @@ CONFIG_ARM_$(XEN_OS) := y
 CFLAGS += -marm
 
 HAS_PL011 := y
+HAS_EXYNOS4210 := y
 
 # Use only if calling $(LD) directly.
 #LDFLAGS_DIRECT_OpenBSD = _obsd
xen/drivers/char/Makefile +1 -0
index 9c067f9..37543f0 100644
@@ -1,6 +1,7 @@
 obj-y += console.o
 obj-$(HAS_NS16550) += ns16550.o
 obj-$(HAS_PL011) += pl011.o
+obj-$(HAS_EXYNOS4210) += exynos4210-uart.o
 obj-$(HAS_EHCI) += ehci-dbgp.o
 obj-$(CONFIG_ARM) += dt-uart.o
 obj-y += serial.o
xen/drivers/char/exynos4210-uart.c new file +365 -0

365 lines not on this page · raw message

xen/include/asm-arm/exynos4210-uart.h new file +111 -0

111 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#22 lore raw

PATCH v4 30/32 xen/arm: Add platform specific code for the exynos5

In reply to Julien Grall

Changes in v4:
- Use ioremap_nocache instead of ioremap_attr(..., PAGE_HYPERVISOR_NOCACHE)

Changes in v3:
- Remove hard tab
- Typoes
- Replace platform_{read,write} call to ioremap_attr, ioreadl, iowritel

Changes in v2:
- Add dom0 1:1 mapping quirk for the arndale board
- s/mapping/mappings/ in comment
- Remove debug trap (unnecessary with linux 3.9)

---
 xen/arch/arm/platforms/Makefile         |    1 +
 xen/arch/arm/platforms/exynos5.c        |  110 +++++++++++++++++++++++++++++++
 xen/include/asm-arm/platforms/exynos5.h |   39 +++++++++++
 3 files changed, 150 insertions(+)
 create mode 100644 xen/arch/arm/platforms/exynos5.c
 create mode 100644 xen/include/asm-arm/platforms/exynos5.h
xen/arch/arm/platforms/Makefile +1 -0
index 4313e95..ff2b65b 100644
@@ -1 +1,2 @@
 obj-y += vexpress.o
+obj-y += exynos5.o
xen/arch/arm/platforms/exynos5.c new file +110 -0

110 lines not on this page · raw message

xen/include/asm-arm/platforms/exynos5.h new file +39 -0
new file mode 100644
index 0000000..ee5bdfa
@@ -0,0 +1,39 @@
+#ifndef __ASM_ARM_PLATFORMS_EXYNOS5_H
+#define __ASM_ASM_PLATFORMS_EXYSNO5_H
+
+#define EXYNOS5_MCT_BASE            0x101c0000
+#define EXYNOS5_MCT_G_TCON          0x240       /* Relative to MCT_BASE */
+#define EXYNOS5_MCT_G_TCON_START    (1 << 8)
+
+#define EXYNOS5_PA_CHIPID           0x10000000
+#define EXYNOS5_PA_TIMER            0x12dd0000
+/* Base address of system controller */
+#define EXYNOS5_PA_PMU              0x10040000
+
+#define EXYNOS5_SWRESET             0x0400      /* Relative to PA_PMU */
+
+#define S5P_PA_SYSRAM   0x02020000
+
+/* Constants below is only used in assembly because the DTS is not yet parsed */
+#ifdef __ASSEMBLY__
+
+/* GIC Base Address */
+#define EXYNOS5_GIC_BASE_ADDRESS    0x10480000
+
+/* Timer's frequency */
+#define EXYNOS5_TIMER_FREQUENCY     (24 * 1000 * 1000) /* 24 MHz */
+
+/* Arndale machine ID */
+#define MACH_TYPE_SMDK5250          3774
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_ARM_PLATFORMS_EXYNOS5_H */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
1.7.10.4
#23 lore raw
In reply to Julien Grall
Quoted 3 lines · Julien Grall

For all changes see in each patch. I have only reposted patch which are not yet acked or changed in v4. All the others patch is in:
git clone -b arm-v4 git://xenbits.xen.org/people/julieng/xen-unstable.git

I started from this and merged the resent ("v5") versions of "Align virtual address on PAGE_SIZE in iounmap" and "xen/arm: Add helpers ioreadl/iowritel" in the right places. Then I applied the various acks and committed. I think I got everything but since this was a little more involved than my usual shovelling routine please do confirm I didn't miss (or mess up) anything.

Thanks!

Ian.

#24 lore raw
Quoted 5 lines · Ian Campbell
Quoted 3 lines · Julien Grall

For all changes see in each patch. I have only reposted patch which are not yet acked or changed in v4. All the others patch is in:
git clone -b arm-v4 git://xenbits.xen.org/people/julieng/xen-unstable.git

Quoted 7 lines

I started from this and merged the resent ("v5") versions of "Align virtual address on PAGE_SIZE in iounmap" and "xen/arm: Add helpers ioreadl/iowritel" in the right places. Then I applied the various acks and committed. I think I got everything but since this was a little more involved than my usual shovelling routine please do confirm I didn't miss (or mess up) anything.

I have found all my patches in staging. Thanks for the merge!

Cheers,

Signature · 1 line
Julien