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

[Xen-devel] [PATCH v8 5/7] xen: use per_cpu_start_, start_bug_frames_, and more



Start making use of the following uintptr_t variables:

per_cpu_start_, per_cpu_data_end_, per_cpu_data_end_,
start_bug_frames_, stop_bug_frames_0_, stop_bug_frames_1_,
stop_bug_frames_2_, stop_bug_frames_3_

Replacing the corresponding linker symbols. It is done to avoid
comparing and subtracting pointers pointing to different objects.

The separation is a bit arbitrary, but all these symbols are declared in
asm files.

One meaningful change is in the size calculation (sz variable) in
setup_virtual_regions, now it needs to take into account the size of the
struct pointer.

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/percpu.c        | 11 ++++++-----
 xen/arch/x86/percpu.c        | 10 +++++-----
 xen/common/virtual_region.c  | 18 +++++++++---------
 xen/include/asm-arm/bug.h    |  8 ++++----
 xen/include/asm-arm/percpu.h |  2 +-
 xen/include/asm-x86/bug.h    | 10 +++++-----
 xen/include/asm-x86/percpu.h |  4 +++-
 7 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/xen/arch/arm/percpu.c b/xen/arch/arm/percpu.c
index 25442c4..91f5ae9 100644
--- a/xen/arch/arm/percpu.c
+++ b/xen/arch/arm/percpu.c
@@ -5,8 +5,8 @@
 #include <xen/rcupdate.h>
 
 unsigned long __per_cpu_offset[NR_CPUS];
-#define INVALID_PERCPU_AREA (-(long)__per_cpu_start)
-#define PERCPU_ORDER (get_order_from_bytes(__per_cpu_data_end-__per_cpu_start))
+#define INVALID_PERCPU_AREA (-(long)per_cpu_start_)
+#define PERCPU_ORDER (get_order_from_bytes(per_cpu_data_end_ - per_cpu_start_))
 
 void __init percpu_init_areas(void)
 {
@@ -22,8 +22,8 @@ static int init_percpu_area(unsigned int cpu)
         return -EBUSY;
     if ( (p = alloc_xenheap_pages(PERCPU_ORDER, 0)) == NULL )
         return -ENOMEM;
-    memset(p, 0, __per_cpu_data_end - __per_cpu_start);
-    __per_cpu_offset[cpu] = p - __per_cpu_start;
+    memset(p, 0, per_cpu_data_end_ - per_cpu_start_);
+    __per_cpu_offset[cpu] = (uintptr_t)p - per_cpu_start_;
     return 0;
 }
 
@@ -37,7 +37,8 @@ static void _free_percpu_area(struct rcu_head *head)
 {
     struct free_info *info = container_of(head, struct free_info, rcu);
     unsigned int cpu = info->cpu;
-    char *p = __per_cpu_start + __per_cpu_offset[cpu];
+    char *p = (char *)(per_cpu_start_ + __per_cpu_offset[cpu]);
+
     free_xenheap_pages(p, PERCPU_ORDER);
     __per_cpu_offset[cpu] = INVALID_PERCPU_AREA;
 }
diff --git a/xen/arch/x86/percpu.c b/xen/arch/x86/percpu.c
index 8be4ebd..58624a3 100644
--- a/xen/arch/x86/percpu.c
+++ b/xen/arch/x86/percpu.c
@@ -12,8 +12,8 @@ unsigned long __per_cpu_offset[NR_CPUS];
  * possible #PF at (NULL + a little) which has security implications in the
  * context of PV guests.
  */
-#define INVALID_PERCPU_AREA (0x8000000000000000L - (long)__per_cpu_start)
-#define PERCPU_ORDER get_order_from_bytes(__per_cpu_data_end - __per_cpu_start)
+#define INVALID_PERCPU_AREA (0x8000000000000000L - (long)per_cpu_start_)
+#define PERCPU_ORDER get_order_from_bytes(per_cpu_data_end_ - per_cpu_start_)
 
 void __init percpu_init_areas(void)
 {
@@ -33,8 +33,8 @@ static int init_percpu_area(unsigned int cpu)
     if ( (p = alloc_xenheap_pages(PERCPU_ORDER, 0)) == NULL )
         return -ENOMEM;
 
-    memset(p, 0, __per_cpu_data_end - __per_cpu_start);
-    __per_cpu_offset[cpu] = p - __per_cpu_start;
+    memset(p, 0, per_cpu_data_end_ - per_cpu_start_);
+    __per_cpu_offset[cpu] = (uintptr_t)p - per_cpu_start_;
 
     return 0;
 }
@@ -49,7 +49,7 @@ static void _free_percpu_area(struct rcu_head *head)
 {
     struct free_info *info = container_of(head, struct free_info, rcu);
     unsigned int cpu = info->cpu;
-    char *p = __per_cpu_start + __per_cpu_offset[cpu];
+    char *p = (char *)(per_cpu_start_ + __per_cpu_offset[cpu]);
 
     free_xenheap_pages(p, PERCPU_ORDER);
     __per_cpu_offset[cpu] = INVALID_PERCPU_AREA;
diff --git a/xen/common/virtual_region.c b/xen/common/virtual_region.c
index 1637453..d048016 100644
--- a/xen/common/virtual_region.c
+++ b/xen/common/virtual_region.c
@@ -99,15 +99,15 @@ void __init setup_virtual_regions(const struct 
exception_table_entry *start,
 {
     size_t sz;
     unsigned int i;
-    static const struct bug_frame *const __initconstrel bug_frames[] = {
-        __start_bug_frames,
-        __stop_bug_frames_0,
-        __stop_bug_frames_1,
-        __stop_bug_frames_2,
+    const uintptr_t bug_frames[] = {
+        start_bug_frames_,
+        stop_bug_frames_0_,
+        stop_bug_frames_1_,
+        stop_bug_frames_2_,
 #ifdef CONFIG_X86
-        __stop_bug_frames_3,
+        stop_bug_frames_3_,
 #endif
-        NULL
+        0
     };
 
     core.start = (char *)start_;
@@ -119,8 +119,8 @@ void __init setup_virtual_regions(const struct 
exception_table_entry *start,
     {
         const struct bug_frame *s;
 
-        s = bug_frames[i - 1];
-        sz = bug_frames[i] - s;
+        s = (struct bug_frame *)bug_frames[i - 1];
+        sz = (bug_frames[i] - bug_frames[i - 1]) / sizeof(struct bug_frame *);
 
         core.frame[i - 1].n_bugs = sz;
         core.frame[i - 1].bugs = s;
diff --git a/xen/include/asm-arm/bug.h b/xen/include/asm-arm/bug.h
index 36c8033..8720241 100644
--- a/xen/include/asm-arm/bug.h
+++ b/xen/include/asm-arm/bug.h
@@ -70,10 +70,10 @@ struct bug_frame {
     unreachable();                                              \
 } while (0)
 
-extern const struct bug_frame __start_bug_frames[],
-                              __stop_bug_frames_0[],
-                              __stop_bug_frames_1[],
-                              __stop_bug_frames_2[];
+extern uintptr_t start_bug_frames_,
+                 stop_bug_frames_0_,
+                 stop_bug_frames_1_,
+                 stop_bug_frames_2_;
 
 #endif /* __ARM_BUG_H__ */
 /*
diff --git a/xen/include/asm-arm/percpu.h b/xen/include/asm-arm/percpu.h
index 6263e77..2cb50ed 100644
--- a/xen/include/asm-arm/percpu.h
+++ b/xen/include/asm-arm/percpu.h
@@ -6,7 +6,7 @@
 #include <xen/types.h>
 #include <asm/sysregs.h>
 
-extern char __per_cpu_start[], __per_cpu_data_end[];
+extern uintptr_t per_cpu_start_, per_cpu_data_end_;
 extern unsigned long __per_cpu_offset[NR_CPUS];
 void percpu_init_areas(void);
 
diff --git a/xen/include/asm-x86/bug.h b/xen/include/asm-x86/bug.h
index 9bb4a19..32cd2c4 100644
--- a/xen/include/asm-x86/bug.h
+++ b/xen/include/asm-x86/bug.h
@@ -72,11 +72,11 @@ struct bug_frame {
     unreachable();                                              \
 } while (0)
 
-extern const struct bug_frame __start_bug_frames[],
-                              __stop_bug_frames_0[],
-                              __stop_bug_frames_1[],
-                              __stop_bug_frames_2[],
-                              __stop_bug_frames_3[];
+extern uintptr_t start_bug_frames_,
+                 stop_bug_frames_0_,
+                 stop_bug_frames_1_,
+                 stop_bug_frames_2_,
+                 stop_bug_frames_3_;
 
 #else  /* !__ASSEMBLY__ */
 
diff --git a/xen/include/asm-x86/percpu.h b/xen/include/asm-x86/percpu.h
index 51562b9..a1e1569 100644
--- a/xen/include/asm-x86/percpu.h
+++ b/xen/include/asm-x86/percpu.h
@@ -2,7 +2,9 @@
 #define __X86_PERCPU_H__
 
 #ifndef __ASSEMBLY__
-extern char __per_cpu_start[], __per_cpu_data_end[];
+#include <xen/types.h>
+
+extern uintptr_t per_cpu_start_, per_cpu_data_end_;
 extern unsigned long __per_cpu_offset[NR_CPUS];
 void percpu_init_areas(void);
 #endif
-- 
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®.