All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, julien.grall@arm.com,
	sstabellini@kernel.org, JBeulich@suse.com,
	Stefano Stabellini <stefanos@xilinx.com>
Subject: [PATCH v8 7/7] xen/arm: use alt_instructions_, trampoline_rel_start_, start_vpci_array_, and more
Date: Tue, 15 Jan 2019 15:35:58 -0800	[thread overview]
Message-ID: <1547595358-16379-7-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <wt35AlsJdPHayD9a>

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@xilinx.com>
---
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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-01-15 23:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <wt35AlsJdPHayD9a>
2019-01-15 23:35 ` [PATCH v8 1/7] xen: add assembly variables corresponding to linker symbols Stefano Stabellini
2019-01-17 16:12   ` Jan Beulich
2019-01-15 23:35 ` [PATCH v8 2/7] xen: use start_, end_, and more Stefano Stabellini
2019-01-17 16:24   ` Jan Beulich
2019-01-15 23:35 ` [PATCH v8 3/7] xen/x86: use rodata_start_2M_, init_start_2M_, " Stefano Stabellini
2019-01-15 23:35 ` [PATCH v8 4/7] xen: use initcall_start_, ctors_start_, " Stefano Stabellini
2019-01-17 16:07   ` Jan Beulich
2019-01-15 23:35 ` [PATCH v8 5/7] xen: use per_cpu_start_, start_bug_frames_, " Stefano Stabellini
2019-01-15 23:35 ` [PATCH v8 6/7] xen/arm: use alt_instructions_, sdevice_, " Stefano Stabellini
2019-01-15 23:35 ` Stefano Stabellini [this message]
2019-01-17 15:58   ` [PATCH v8 7/7] xen/arm: use alt_instructions_, trampoline_rel_start_, start_vpci_array_, " Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1547595358-16379-7-git-send-email-sstabellini@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=stefanos@xilinx.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.