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

[Xen-devel] [PATCH v8 3/7] xen/x86: use rodata_start_2M_, init_start_2M_, and more



Start making use of the following uintptr_t variables:

text_start_2M_, text_end_2M_, rodata_start_2M_, rodata_end_2M_,
init_start_2M_, init_end_2M_, rwdata_start_2M_, rwdata_end_2M_

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

These symbols are all x86 specific symbols.

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/x86/setup.c        | 60 ++++++++++++++++++++++-----------------------
 xen/arch/x86/tboot.c        |  8 +++---
 xen/include/asm-x86/mm.h    |  2 +-
 xen/include/asm-x86/setup.h |  8 +++---
 4 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 34949fc4..3a2aa4c 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -578,13 +578,13 @@ static void __init kexec_reserve_area(struct e820map 
*e820)
 
 static inline bool using_2M_mapping(void)
 {
-    return !l1_table_offset((unsigned long)__2M_text_end) &&
-           !l1_table_offset((unsigned long)__2M_rodata_start) &&
-           !l1_table_offset((unsigned long)__2M_rodata_end) &&
-           !l1_table_offset((unsigned long)__2M_init_start) &&
-           !l1_table_offset((unsigned long)__2M_init_end) &&
-           !l1_table_offset((unsigned long)__2M_rwdata_start) &&
-           !l1_table_offset((unsigned long)__2M_rwdata_end);
+    return !l1_table_offset(text_end_2M_) &&
+           !l1_table_offset(rodata_start_2M_) &&
+           !l1_table_offset(rodata_end_2M_) &&
+           !l1_table_offset(init_start_2M_) &&
+           !l1_table_offset(init_end_2M_) &&
+           !l1_table_offset(rwdata_start_2M_) &&
+           !l1_table_offset(rwdata_end_2M_);
 }
 
 static void noinline init_done(void)
@@ -606,8 +606,8 @@ static void noinline init_done(void)
     /* Destroy Xen's mappings, and reuse the pages. */
     if ( using_2M_mapping() )
     {
-        start = (unsigned long)&__2M_init_start,
-        end   = (unsigned long)&__2M_init_end;
+        start = init_start_2M_,
+        end   = init_end_2M_;
     }
     else
     {
@@ -972,7 +972,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
          * respective reserve_e820_ram() invocation below.
          */
         mod[mbi->mods_count].mod_start = virt_to_mfn(stext_);
-        mod[mbi->mods_count].mod_end = (uintptr_t)__2M_rwdata_end - stext_;
+        mod[mbi->mods_count].mod_end = rwdata_end_2M_ - stext_;
     }
 
     modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end);
@@ -1023,7 +1023,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
                      1UL << (PAGE_SHIFT + 32)) )
             e = min(HYPERVISOR_VIRT_END - DIRECTMAP_VIRT_START,
                     1UL << (PAGE_SHIFT + 32));
-#define reloc_size ((__pa(__2M_rwdata_end) + mask) & ~mask)
+#define reloc_size ((__pa(rwdata_end_2M_) + mask) & ~mask)
         /* Is the region suitable for relocating Xen? */
         if ( !xen_phys_start && e <= limit )
         {
@@ -1104,7 +1104,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             /* The only data mappings to be relocated are in the Xen area. */
             pl2e = __va(__pa(l2_xenmap));
             /*
-             * Undo the temporary-hooking of the l1_identmap.  __2M_text_start
+             * Undo the temporary-hooking of the l1_identmap.  text_start_2M_
              * is contained in this PTE.
              */
             BUG_ON(using_2M_mapping() &&
@@ -1126,22 +1126,22 @@ void __init noreturn __start_xen(unsigned long mbi_p)
                     continue;
                 }
 
-                if ( i < l2_table_offset((unsigned long)&__2M_text_end) )
+                if ( i < l2_table_offset(text_end_2M_) )
                 {
                     flags = PAGE_HYPERVISOR_RX | _PAGE_PSE;
                 }
-                else if ( i >= l2_table_offset((unsigned 
long)&__2M_rodata_start) &&
-                          i <  l2_table_offset((unsigned 
long)&__2M_rodata_end) )
+                else if ( i >= l2_table_offset(rodata_start_2M_) &&
+                          i <  l2_table_offset(rodata_end_2M_) )
                 {
                     flags = PAGE_HYPERVISOR_RO | _PAGE_PSE;
                 }
-                else if ( i >= l2_table_offset((unsigned 
long)&__2M_init_start) &&
-                          i <  l2_table_offset((unsigned long)&__2M_init_end) )
+                else if ( i >= l2_table_offset(init_start_2M_) &&
+                          i <  l2_table_offset(init_end_2M_) )
                 {
                     flags = PAGE_HYPERVISOR_RWX | _PAGE_PSE;
                 }
-                else if ( (i >= l2_table_offset((unsigned 
long)&__2M_rwdata_start) &&
-                           i <  l2_table_offset((unsigned 
long)&__2M_rwdata_end)) )
+                else if ( (i >= l2_table_offset(rwdata_start_2M_) &&
+                           i <  l2_table_offset(rwdata_end_2M_)) )
                 {
                     flags = PAGE_HYPERVISOR_RW | _PAGE_PSE;
                 }
@@ -1238,7 +1238,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         panic("Not enough memory to relocate Xen\n");
 
     /* This needs to remain in sync with xen_in_range(). */
-    reserve_e820_ram(&boot_e820, __pa(stext_), __pa(__2M_rwdata_end));
+    reserve_e820_ram(&boot_e820, __pa(stext_), __pa(rwdata_end_2M_));
 
     /* Late kexec reservation (dynamic start address). */
     kexec_reserve_area(&boot_e820);
@@ -1394,22 +1394,22 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     {
         /* Mark .text as RX (avoiding the first 2M superpage). */
         modify_xen_mappings(XEN_VIRT_START + MB(2),
-                            (unsigned long)&__2M_text_end,
+                            text_end_2M_,
                             PAGE_HYPERVISOR_RX);
 
         /* Mark .rodata as RO. */
-        modify_xen_mappings((unsigned long)&__2M_rodata_start,
-                            (unsigned long)&__2M_rodata_end,
+        modify_xen_mappings(rodata_start_2M_,
+                            rodata_end_2M_,
                             PAGE_HYPERVISOR_RO);
 
         /* Mark .data and .bss as RW. */
-        modify_xen_mappings((unsigned long)&__2M_rwdata_start,
-                            (unsigned long)&__2M_rwdata_end,
+        modify_xen_mappings(rwdata_start_2M_,
+                            rwdata_end_2M_,
                             PAGE_HYPERVISOR_RW);
 
         /* Drop the remaining mappings in the shattered superpage. */
-        destroy_xen_mappings((unsigned long)&__2M_rwdata_end,
-                             ROUNDUP((unsigned long)&__2M_rwdata_end, MB(2)));
+        destroy_xen_mappings(rwdata_end_2M_,
+                             ROUNDUP(rwdata_end_2M_, MB(2)));
     }
 
     nr_pages = 0;
@@ -1871,10 +1871,10 @@ int __hwdom_init xen_in_range(unsigned long mfn)
 
         /* hypervisor .text + .rodata */
         xen_regions[region_ro].s = __pa(stext_);
-        xen_regions[region_ro].e = __pa(&__2M_rodata_end);
+        xen_regions[region_ro].e = __pa(rodata_end_2M_);
         /* hypervisor .data + .bss */
-        xen_regions[region_rw].s = __pa(&__2M_rwdata_start);
-        xen_regions[region_rw].e = __pa(&__2M_rwdata_end);
+        xen_regions[region_rw].s = __pa(rwdata_start_2M_);
+        xen_regions[region_rw].e = __pa(rwdata_end_2M_);
     }
 
     start = (paddr_t)mfn << PAGE_SHIFT;
diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c
index 620303e..7c11cdb 100644
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -374,12 +374,12 @@ void tboot_shutdown(uint32_t shutdown_type)
                                               bootsym_phys(trampoline_start);
         /* hypervisor .text + .rodata */
         g_tboot_shared->mac_regions[1].start = (uint64_t)__pa(stext_);
-        g_tboot_shared->mac_regions[1].size = __pa(&__2M_rodata_end) -
+        g_tboot_shared->mac_regions[1].size = __pa(rodata_end_2M_) -
                                               __pa(stext_);
         /* hypervisor .data + .bss */
-        g_tboot_shared->mac_regions[2].start = 
(uint64_t)__pa(&__2M_rwdata_start);
-        g_tboot_shared->mac_regions[2].size = __pa(&__2M_rwdata_end) -
-                                              __pa(&__2M_rwdata_start);
+        g_tboot_shared->mac_regions[2].start = 
(uint64_t)__pa(rwdata_start_2M_);
+        g_tboot_shared->mac_regions[2].size = __pa(rwdata_end_2M_) -
+                                              __pa(rwdata_start_2M_);
 
         /*
          * MAC domains and other Xen memory
diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
index 3b07d12..904e84b 100644
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -281,7 +281,7 @@ struct page_info
     (__mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(_mfn(mfn))))
 #define is_xen_fixed_mfn(mfn)                     \
     ((((mfn) << PAGE_SHIFT) >= __pa(stext_)) &&  \
-     (((mfn) << PAGE_SHIFT) <= __pa(&__2M_rwdata_end)))
+     (((mfn) << PAGE_SHIFT) <= __pa(rwdata_end_2M_)))
 
 #define PRtype_info "016lx"/* should only be used for printk's */
 
diff --git a/xen/include/asm-x86/setup.h b/xen/include/asm-x86/setup.h
index bb4c385..d52bee2 100644
--- a/xen/include/asm-x86/setup.h
+++ b/xen/include/asm-x86/setup.h
@@ -7,10 +7,10 @@
 /* vCPU pointer used prior to there being a valid one around */
 #define INVALID_VCPU ((struct vcpu *)0xccccccccccccc000UL)
 
-extern const char __2M_text_start[], __2M_text_end[];
-extern const char __2M_rodata_start[], __2M_rodata_end[];
-extern char __2M_init_start[], __2M_init_end[];
-extern char __2M_rwdata_start[], __2M_rwdata_end[];
+extern uintptr_t text_start_2M_, text_end_2M_;
+extern uintptr_t rodata_start_2M_, rodata_end_2M_;
+extern uintptr_t init_start_2M_, init_end_2M_;
+extern uintptr_t rwdata_start_2M_, rwdata_end_2M_;
 
 extern unsigned long xenheap_initial_phys_start;
 
-- 
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®.