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

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



Start making use of the following x86 specific uintptr_t variables:

alt_instructions_, alt_instructions_end_, trampoline_rel_start_,
trampoline_rel_stop_, trampoline_seg_start_, trampoline_seg_stop_,
init_begin_, init_end_, start_vpci_array_, end_vpci_array_

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

bss_start_, bss_end_ have been removed because they are not used.
Another meaningful change is in the calculation of NUM_VPCI_INIT: now it
needs to take into account the size of the struct pointer.

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/x86/alternative.c  |  5 +++--
 xen/arch/x86/efi/efi-boot.h | 12 ++++++------
 xen/arch/x86/setup.c        |  8 ++++----
 xen/drivers/vpci/vpci.c     | 11 +++++++----
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index b8c819a..bdbb9bd 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -29,7 +29,7 @@
 
 #define MAX_PATCH_LEN (255-1)
 
-extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
+extern uintptr_t alt_instructions_, alt_instructions_end_;
 
 #ifdef K8_NOP1
 static const unsigned char k8nops[] init_or_livepatch_const = {
@@ -273,7 +273,8 @@ static int __init nmi_apply_alternatives(const struct 
cpu_user_regs *regs,
         /* Disable WP to allow patching read-only pages. */
         write_cr0(cr0 & ~X86_CR0_WP);
 
-        apply_alternatives(__alt_instructions, __alt_instructions_end);
+        apply_alternatives((struct alt_instr *)alt_instructions_,
+                           (struct alt_instr *)alt_instructions_end_);
 
         write_cr0(cr0);
 
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 5789d2c..33e39bd 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -98,8 +98,8 @@ static void __init efi_arch_relocate_image(unsigned long 
delta)
     }
 }
 
-extern const s32 __trampoline_rel_start[], __trampoline_rel_stop[];
-extern const s32 __trampoline_seg_start[], __trampoline_seg_stop[];
+extern uintptr_t trampoline_rel_start_, trampoline_rel_stop_;
+extern uintptr_t trampoline_seg_start_, trampoline_seg_stop_;
 
 static void __init relocate_trampoline(unsigned long phys)
 {
@@ -111,12 +111,12 @@ static void __init relocate_trampoline(unsigned long phys)
         return;
 
     /* Apply relocations to trampoline. */
-    for ( trampoline_ptr = __trampoline_rel_start;
-          trampoline_ptr < __trampoline_rel_stop;
+    for ( trampoline_ptr = (const s32 *)trampoline_rel_start_;
+          (uintptr_t)trampoline_ptr < trampoline_rel_stop_;
           ++trampoline_ptr )
         *(u32 *)(*trampoline_ptr + (long)trampoline_ptr) += phys;
-    for ( trampoline_ptr = __trampoline_seg_start;
-          trampoline_ptr < __trampoline_seg_stop;
+    for ( trampoline_ptr = (const s32 *)trampoline_seg_start_;
+          (uintptr_t)trampoline_ptr < trampoline_seg_stop_;
           ++trampoline_ptr )
         *(u16 *)(*trampoline_ptr + (long)trampoline_ptr) = phys >> 4;
 }
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 3a2aa4c..3f0d597 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -252,7 +252,7 @@ void __init discard_initial_images(void)
     initial_images = NULL;
 }
 
-extern char __init_begin[], __init_end[], __bss_start[], __bss_end[];
+extern uintptr_t init_begin_, init_end_;
 
 static void __init init_idle_domain(void)
 {
@@ -600,7 +600,7 @@ static void noinline init_done(void)
     unregister_init_virtual_region();
 
     /* Zero the .init code and data. */
-    for ( va = __init_begin; va < _p(__init_end); va += PAGE_SIZE )
+    for ( va = (void *)init_begin_; (uintptr_t)va < init_end_; va += PAGE_SIZE 
)
         clear_page(va);
 
     /* Destroy Xen's mappings, and reuse the pages. */
@@ -611,8 +611,8 @@ static void noinline init_done(void)
     }
     else
     {
-        start = (unsigned long)&__init_begin;
-        end   = (unsigned long)&__init_end;
+        start = init_begin_;
+        end   = init_end_;
     }
 
     destroy_xen_mappings(start, end);
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 82607bd..6eafd00 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -31,9 +31,10 @@ struct vpci_register {
 };
 
 #ifdef __XEN__
-extern vpci_register_init_t *const __start_vpci_array[];
-extern vpci_register_init_t *const __end_vpci_array[];
-#define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
+extern uintptr_t start_vpci_array_;
+extern uintptr_t end_vpci_array_;
+#define NUM_VPCI_INIT ((end_vpci_array_ - start_vpci_array_) / \
+                       (sizeof(vpci_register_init_t *)))
 
 void vpci_remove_device(struct pci_dev *pdev)
 {
@@ -58,6 +59,8 @@ int __hwdom_init vpci_add_handlers(struct pci_dev *pdev)
 {
     unsigned int i;
     int rc = 0;
+    vpci_register_init_t **start_vpci_array = (vpci_register_init_t **)
+                                              start_vpci_array_;
 
     if ( !has_vpci(pdev->domain) )
         return 0;
@@ -71,7 +74,7 @@ int __hwdom_init vpci_add_handlers(struct pci_dev *pdev)
 
     for ( i = 0; i < NUM_VPCI_INIT; i++ )
     {
-        rc = __start_vpci_array[i](pdev);
+        rc = start_vpci_array[i](pdev);
         if ( rc )
             break;
     }
-- 
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®.