[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v8 6/7] xen/arm: use alt_instructions_, sdevice_, and more



Start making use of the following arm specific uintptr_t variables:

alt_instructions_, alt_instructions_end_, sdevice_, edevice_,
asdevice_, aedevice_, init_begin_, init_end_, splatform_, eplatform_,

Replacing the corresponding linker symbols. These are all arm specific
changes. It is done to avoid comparing and subtracting pointers pointing
to different objects.

One thing to note is that ideally we would avoid converting
alt_instructions_ and alt_instructions_end_ to pointers as done in
alternative.c because it can lead to comparisions/subtractions between
pointers to different objects. It is not difficult to fix by reworking
the code slightly but out of scope for this patch.

Signed-off-by: Stefano Stabellini <stefanos@xxxxxxxxxx>
---
Changes in v8:
- remove SYMBOL_HIDE
- use new symbol names
- changes are split differently across the patches
---
 xen/arch/arm/alternative.c |  6 +++---
 xen/arch/arm/device.c      | 16 +++++++++++-----
 xen/arch/arm/mm.c          | 23 +++++++++++++----------
 xen/arch/arm/platform.c    |  8 +++++---
 4 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c
index b79536d..7c3f32d 100644
--- a/xen/arch/arm/alternative.c
+++ b/xen/arch/arm/alternative.c
@@ -38,7 +38,7 @@
 #undef virt_to_mfn
 #define virt_to_mfn(va) _mfn(__virt_to_mfn(va))
 
-extern const struct alt_instr __alt_instructions[], __alt_instructions_end[];
+extern uintptr_t alt_instructions_, alt_instructions_end_;
 
 struct alt_region {
     const struct alt_instr *begin;
@@ -203,8 +203,8 @@ static int __apply_alternatives_multi_stop(void *unused)
         /* Re-mapping Xen is not expected to fail during boot. */
         BUG_ON(!xenmap);
 
-        region.begin = __alt_instructions;
-        region.end = __alt_instructions_end;
+        region.begin = (const struct alt_instr *)alt_instructions_;
+        region.end = (const struct alt_instr *)alt_instructions_end_;
 
         ret = __apply_alternatives(&region, (uintptr_t)xenmap - start_);
         /* The patching is not expected to fail during boot. */
diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 70cd6c1..3e2d759 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -22,8 +22,8 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 
-extern const struct device_desc _sdevice[], _edevice[];
-extern const struct acpi_device_desc _asdevice[], _aedevice[];
+extern uintptr_t sdevice_, edevice_;
+extern uintptr_t asdevice_, aedevice_;
 
 int __init device_init(struct dt_device_node *dev, enum device_class class,
                        const void *data)
@@ -35,7 +35,9 @@ int __init device_init(struct dt_device_node *dev, enum 
device_class class,
     if ( !dt_device_is_available(dev) || dt_device_for_passthrough(dev) )
         return  -ENODEV;
 
-    for ( desc = _sdevice; desc != _edevice; desc++ )
+    for ( desc = (struct device_desc *)sdevice_;
+          (uintptr_t)desc != edevice_;
+          desc++ )
     {
         if ( desc->class != class )
             continue;
@@ -56,7 +58,9 @@ int __init acpi_device_init(enum device_class class, const 
void *data, int class
 {
     const struct acpi_device_desc *desc;
 
-    for ( desc = _asdevice; desc != _aedevice; desc++ )
+    for ( desc = (struct acpi_device_desc *)asdevice_;
+          (uintptr_t)desc != aedevice_;
+          desc++ )
     {
         if ( ( desc->class != class ) || ( desc->class_type != class_type ) )
             continue;
@@ -75,7 +79,9 @@ enum device_class device_get_class(const struct 
dt_device_node *dev)
 
     ASSERT(dev != NULL);
 
-    for ( desc = _sdevice; desc != _edevice; desc++ )
+    for ( desc = (struct device_desc *)sdevice_;
+          (uintptr_t)desc != edevice_;
+          desc++ )
     {
         if ( dt_match_node(desc->dt_match, dev) )
             return desc->class;
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 01ae2cc..9c80e03 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -157,7 +157,7 @@ unsigned long frametable_virt_end __read_mostly;
 unsigned long max_page;
 unsigned long total_pages;
 
-extern char __init_begin[], __init_end[];
+extern uintptr_t init_begin_, init_end_;
 
 /* Checking VA memory layout alignment. */
 static inline void check_memory_layout_alignment_constraints(void) {
@@ -1073,7 +1073,9 @@ int modify_xen_mappings(unsigned long s, unsigned long e, 
unsigned int flags)
 }
 
 enum mg { mg_clear, mg_ro, mg_rw, mg_rx };
-static void set_pte_flags_on_range(const char *p, unsigned long l, enum mg mg)
+static void set_pte_flags_on_range(const uintptr_t p,
+                                   unsigned long l,
+                                   enum mg mg)
 {
     lpae_t pte;
     int i;
@@ -1084,8 +1086,8 @@ static void set_pte_flags_on_range(const char *p, 
unsigned long l, enum mg mg)
     ASSERT(!((unsigned long) p & ~PAGE_MASK));
     ASSERT(!(l & ~PAGE_MASK));
 
-    for ( i = (p - _start) / PAGE_SIZE; 
-          i < (p + l - _start) / PAGE_SIZE; 
+    for ( i = (p - start_) / PAGE_SIZE;
+          i < (p + l - start_) / PAGE_SIZE;
           i++ )
     {
         pte = xen_xenmap[i];
@@ -1121,26 +1123,27 @@ static void set_pte_flags_on_range(const char *p, 
unsigned long l, enum mg mg)
 /* Release all __init and __initdata ranges to be reused */
 void free_init_memory(void)
 {
-    paddr_t pa = virt_to_maddr(__init_begin);
-    unsigned long len = __init_end - __init_begin;
+    paddr_t pa = virt_to_maddr(init_begin_);
+    unsigned long len = init_end_ - init_begin_;
     uint32_t insn;
     unsigned int i, nr = len / sizeof(insn);
     uint32_t *p;
 
-    set_pte_flags_on_range(__init_begin, len, mg_rw);
+    set_pte_flags_on_range(init_begin_, len, mg_rw);
 #ifdef CONFIG_ARM_32
     /* udf instruction i.e (see A8.8.247 in ARM DDI 0406C.c) */
     insn = 0xe7f000f0;
 #else
     insn = AARCH64_BREAK_FAULT;
 #endif
-    p = (uint32_t *)__init_begin;
+    p = (uint32_t *)init_begin_;
     for ( i = 0; i < nr; i++ )
         *(p + i) = insn;
 
-    set_pte_flags_on_range(__init_begin, len, mg_clear);
+    set_pte_flags_on_range(init_begin_, len, mg_clear);
     init_domheap_pages(pa, pa + len);
-    printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
+    printk("Freed %"PRIxPTR"kB init memory.\n",
+           (init_end_ - init_begin_) >> 10);
 }
 
 void arch_dump_shared_mem_info(void)
diff --git a/xen/arch/arm/platform.c b/xen/arch/arm/platform.c
index 8eb0b6e..a79eb53 100644
--- a/xen/arch/arm/platform.c
+++ b/xen/arch/arm/platform.c
@@ -22,7 +22,7 @@
 #include <xen/init.h>
 #include <asm/psci.h>
 
-extern const struct platform_desc _splatform[], _eplatform[];
+extern uintptr_t splatform_, eplatform_;
 
 /* Pointer to the current platform description */
 static const struct platform_desc *platform;
@@ -51,14 +51,16 @@ void __init platform_init(void)
     ASSERT(platform == NULL);
 
     /* Looking for the platform description */
-    for ( platform = _splatform; platform != _eplatform; platform++ )
+    for ( platform = (struct platform_desc *)splatform_;
+          (uintptr_t)platform != eplatform_;
+          platform++ )
     {
         if ( platform_is_compatible(platform) )
             break;
     }
 
     /* We don't have specific operations for this platform */
-    if ( platform == _eplatform )
+    if ( (uintptr_t)platform == eplatform_ )
     {
         /* TODO: dump DT machine compatible node */
         printk(XENLOG_INFO "Platform: Generic System\n");
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.