Skip to contentSkip to conversation

GLOBAL() macro for asm code.

RFC PATCH In review Andrew Cooper 3 participants 6 messages Aug 26, 2013 – Aug 27, 2013

lore
Share & tools
lore
#0 lore raw

cover GLOBAL() macro for asm code.

Hello,

This series has been split into two patches, one for arm and one for x86. I figured that this was easier than doing it as a single combined patch, especially as the changes are functionally independent.

x86 has been boot tested, but arm has not even been compile tested as I lack a suitable cross compiler. However, the changes are just text replacement, so I dont expect any issues.

The changes to {svm,vmx}/entry.S will conflict with Jan's series "HVM: produce better binary code", which is why this patch is labled RFC. I also recall that arm{32,64}/mode_switch.S was in the middle of being played with, so might have issues there. The patchs are on top of current staging.

Assuming the principle of the patches is fine, I dont mind in what order these get committed. I can rebase this series on top of shortly upcoming series, or if this gets in quickly, they can rebase on top of this. Either way the conflicts will not be difficult, and I am happy to do whatever the committers feel is easiest.

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Ian Campbell <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Tim Deegan <[email protected]>
#1 lore raw

PATCH 1/2 xen/x86: Introduce and use GLOBAL() in asm code.

Also clean up some cases of misused/opencoded ENTRY()

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>

---

There is an awkward case with 'saved_magic' in wakeup_prot.S which could technically have the .align subsumed into it and become an ENTRY(). It is very definitely data rather than code, so GLOBAL() felt more appropriate.

There were several ENTRY() data symbols (stack_start, boot_cpu_{compat_,}_gdt_table) which had redundant/useless aligns, so also got converted to GLOBAL().

---
 xen/arch/x86/acpi/wakeup_prot.S |   10 +++++-----
 xen/arch/x86/boot/edd.S         |   10 ++++------
 xen/arch/x86/boot/head.S        |    9 +++------
 xen/arch/x86/boot/mem.S         |    9 ++++-----
 xen/arch/x86/boot/trampoline.S  |   15 +++++----------
 xen/arch/x86/boot/video.S       |   23 +++++++++++++----------
 xen/arch/x86/boot/wakeup.S      |    7 ++++---
 xen/arch/x86/boot/x86_64.S      |   29 +++++++++++------------------
 xen/arch/x86/efi/relocs-dummy.S |    5 ++---
 xen/arch/x86/hvm/svm/entry.S    |    3 +--
 xen/arch/x86/hvm/vmx/entry.S    |    7 ++-----
 xen/arch/x86/x86_64/entry.S     |   13 ++++---------
 xen/include/asm-x86/config.h    |    3 +++
 13 files changed, 61 insertions(+), 82 deletions(-)
xen/arch/x86/acpi/wakeup_prot.S +5 -5
index a1e706e..def86d2 100644
@@ -64,9 +64,8 @@ ENTRY(do_suspend_lowlevel)
         call    acpi_enter_sleep_state
         jmp     __ret_point
 
-        .align  16
-        .globl  __ret_point
-__ret_point:
+
+ENTRY(__ret_point)
 
         /* mmu_cr4_features contains latest cr4 setting */
         mov     REF(mmu_cr4_features), GREG(ax)
@@ -118,8 +117,9 @@ __ret_point:
 
 .data
         .align 16
-        .globl   saved_magic
-saved_magic:     .long   0x9abcdef0
+
+GLOBAL(saved_magic)
+        .long   0x9abcdef0
 
 saved_ss:        .word   0
 
xen/arch/x86/boot/edd.S +4 -6
index 2c8df8c..5c80da6 100644
@@ -145,13 +145,11 @@ edd_done:
 opt_edd:
         .byte   0                               # edd=on/off/skipmbr
 
-.globl  boot_edd_info, boot_edd_info_nr
-.globl  boot_mbr_signature, boot_mbr_signature_nr
-boot_edd_info_nr:
+GLOBAL(boot_edd_info_nr)
         .byte   0
-boot_mbr_signature_nr:
+GLOBAL(boot_mbr_signature_nr)
         .byte   0
-boot_mbr_signature:
+GLOBAL(boot_mbr_signature)
         .fill   EDD_MBR_SIG_MAX*8,1,0
-boot_edd_info:
+GLOBAL(boot_edd_info)
         .fill   512,1,0                         # big enough for a disc sector
xen/arch/x86/boot/head.S +3 -6
index d3cbddb..b12eefb 100644
@@ -195,11 +195,9 @@ __start:
 reloc:
 #include "reloc.S"
 
-        .align 16
-        .globl trampoline_start, trampoline_end
-trampoline_start:
+ENTRY(trampoline_start)
 #include "trampoline.S"
-trampoline_end:
+GLOBAL(trampoline_end)
 
         .text
 __high_start:
@@ -212,8 +210,7 @@ __high_start:
  * to avoid type conflicts with fixed-range MTRRs covering the lowest megabyte
  * of physical memory. In any case the VGA hole should be mapped with type UC.
  */
-        .globl l1_identmap
-l1_identmap:
+GLOBAL(l1_identmap)
         pfn = 0
         .rept L1_PAGETABLE_ENTRIES
         /* VGA hole (0xa0000-0xc0000) should be mapped UC. */
xen/arch/x86/boot/mem.S +4 -5
index 64646205..820aea9 100644
@@ -67,12 +67,11 @@ get_memory_map:
 
         ret
 
-        .globl e820map, e820nr, lowmem_kb, highmem_kb
-e820map:
+GLOBAL(e820map)
         .fill   E820MAX*20,1,0
-e820nr:
+GLOBAL(e820nr)
         .long   0
-lowmem_kb:
+GLOBAL(lowmem_kb)
         .long   0
-highmem_kb:
+GLOBAL(highmem_kb)
         .long   0
xen/arch/x86/boot/trampoline.S +5 -10
index f84ce2a..827f412 100644
@@ -18,8 +18,7 @@
         .long 111b - (off) - .;            \
         .popsection
 
-        .globl trampoline_realmode_entry
-trampoline_realmode_entry:
+GLOBAL(trampoline_realmode_entry)
         mov     %cs,%ax
         mov     %ax,%ds
         movb    $0xA5,bootsym(trampoline_cpu_started)
@@ -57,16 +56,13 @@ trampoline_gdt:
         .long   trampoline_gdt + BOOT_PSEUDORM_DS + 2 - .
         .popsection
 
-        .globl cpuid_ext_features
-cpuid_ext_features:
+GLOBAL(cpuid_ext_features)
         .long   0
 
-        .globl trampoline_xen_phys_start
-trampoline_xen_phys_start:
+GLOBAL(trampoline_xen_phys_start)
         .long   0
 
-        .globl trampoline_cpu_started
-trampoline_cpu_started:
+GLOBAL(trampoline_cpu_started)
         .byte   0
 
         .code32
@@ -206,8 +202,7 @@ trampoline_boot_cpu_entry:
 skip_realmode:
         .byte   0
 
-        .globl kbd_shift_flags
-kbd_shift_flags:
+GLOBAL(kbd_shift_flags)
         .byte   0
 
 rm_idt: .word   256*4-1, 0, 0
xen/arch/x86/boot/video.S +13 -10
index ad6514e..b238bf3 100644
@@ -993,14 +993,17 @@ force_size:     .word   0       # Use this size instead of the one in BIOS vars
 
 vesa_size:      .word   0,0,0   # width x depth x height
 
-                .globl  boot_vid_info, boot_edid_info, boot_edid_caps
 /* If we don't run at all, assume basic video mode 3 at 80x25. */
-boot_vid_mode:  .word   VIDEO_80x25
-boot_vid_info:  .byte   0, 0    /* orig_x, orig_y */
-                .byte   3       /* text mode 3    */
-                .byte   80, 25  /* 80x25          */
-                .byte   1       /* isVGA          */
-                .word   16      /* 8x16 font      */
-                .fill   0x28,1,0
-boot_edid_info: .fill   128,1,0x13
-boot_edid_caps: .word   0x1313
+GLOBAL(boot_vid_mode)
+        .word   VIDEO_80x25
+GLOBAL(boot_vid_info)
+        .byte   0, 0    /* orig_x, orig_y */
+        .byte   3       /* text mode 3    */
+        .byte   80, 25  /* 80x25          */
+        .byte   1       /* isVGA          */
+        .word   16      /* 8x16 font      */
+        .fill   0x28,1,0
+GLOBAL(boot_edid_info)
+        .fill   128,1,0x13
+GLOBAL(boot_edid_caps)
+        .word   0x1313
xen/arch/x86/boot/wakeup.S +4 -3
index b1d4787..a3883c1 100644
@@ -98,9 +98,10 @@ bogus_real_magic:
 
         .align 4
 real_magic:     .long 0x12345678
-         .globl video_mode, video_flags
-video_mode:     .long 0
-video_flags:    .long 0
+GLOBAL(video_mode)
+        .long 0
+GLOBAL(video_flags)
+        .long 0
 trampoline_seg: .word 0
         .pushsection .trampoline_seg, "a"
         .long   trampoline_seg - .
xen/arch/x86/boot/x86_64.S +11 -18
index ed3888d..8f92402 100644
@@ -84,23 +84,21 @@ multiboot_ptr:
         .long   0
 
         .word   0
-        .globl  gdt_descr
-gdt_descr:
+GLOBAL(gdt_descr)
         .word   LAST_RESERVED_GDT_BYTE
         .quad   boot_cpu_gdt_table - FIRST_RESERVED_GDT_BYTE
 
         .word   0,0,0
-        .globl  idt_descr
-idt_descr:
+GLOBAL(idt_descr)
         .word   256*16-1
         .quad   idt_table
 
-ENTRY(stack_start)
+GLOBAL(stack_start)
         .quad   cpu0_stack
 
         .section .data.page_aligned, "aw", @progbits
         .align PAGE_SIZE, 0
-ENTRY(boot_cpu_gdt_table)
+GLOBAL(boot_cpu_gdt_table)
         .quad 0x0000000000000000     /* unused */
         .quad 0x00af9a000000ffff     /* 0xe008 ring 0 code, 64-bit mode   */
         .quad 0x00cf92000000ffff     /* 0xe010 ring 0 data                */
@@ -115,7 +113,7 @@ ENTRY(boot_cpu_gdt_table)
         .align PAGE_SIZE, 0
 /* NB. Even rings != 0 get access to the full 4Gb, as only the            */
 /*     (compatibility) machine->physical mapping table lives there.       */
-ENTRY(boot_cpu_compat_gdt_table)
+GLOBAL(boot_cpu_compat_gdt_table)
         .quad 0x0000000000000000     /* unused */
         .quad 0x00af9a000000ffff     /* 0xe008 ring 0 code, 64-bit mode   */
         .quad 0x00cf92000000ffff     /* 0xe010 ring 0 data                */
@@ -128,12 +126,10 @@ ENTRY(boot_cpu_compat_gdt_table)
         .quad 0x0000910000000000     /* per-CPU entry (limit == cpu)      */
         .align PAGE_SIZE, 0
 
-	.globl __page_tables_start, __page_tables_end
-__page_tables_start:
+GLOBAL(__page_tables_start)
 
 /* Mapping of first 16 megabytes of memory. */
-        .globl l2_identmap
-l2_identmap:
+GLOBAL(l2_identmap)
         .quad sym_phys(l1_identmap) + __PAGE_HYPERVISOR
         pfn = 0
         .rept 7
@@ -143,8 +139,7 @@ l2_identmap:
         .fill 4 * L2_PAGETABLE_ENTRIES - 8, 8, 0
         .size l2_identmap, . - l2_identmap
 
-        .globl l2_xenmap
-l2_xenmap:
+GLOBAL(l2_xenmap)
         idx = 0
         .rept 8
         .quad sym_phys(__image_base__) + (idx << L2_PAGETABLE_SHIFT) + (PAGE_HYPERVISOR | _PAGE_PSE)
@@ -165,8 +160,7 @@ l2_fixmap:
         .endr
         .size l2_fixmap, . - l2_fixmap
 
-        .globl l3_identmap
-l3_identmap:
+GLOBAL(l3_identmap)
         idx = 0
         .rept 4
         .quad sym_phys(l2_identmap) + (idx << PAGE_SHIFT) + __PAGE_HYPERVISOR
@@ -190,8 +184,7 @@ l3_xenmap:
         .size l3_xenmap, . - l3_xenmap
 
 /* Top-level master (and idle-domain) page directory. */
-        .globl idle_pg_table
-idle_pg_table:
+GLOBAL(idle_pg_table)
         .quad sym_phys(l3_bootmap) + __PAGE_HYPERVISOR
         idx = 1
         .rept L4_PAGETABLE_ENTRIES - 1
@@ -206,4 +199,4 @@ idle_pg_table:
         .endr
         .size idle_pg_table, . - idle_pg_table
 
-__page_tables_end:
+GLOBAL(__page_tables_end)
xen/arch/x86/efi/relocs-dummy.S +2 -3
index 36c3006..b14c499 100644
@@ -2,11 +2,10 @@
 
 	.section .reloc, "a", @progbits
 	.balign 4
-	.globl __base_relocs_start, __base_relocs_end
-__base_relocs_start:
+GLOBAL(__base_relocs_start)
 	.long 0
 	.long 8
-__base_relocs_end:
+GLOBAL(__base_relocs_end)
 
 	.globl VIRT_START, ALT_START
 	.equ VIRT_START, XEN_VIRT_START
xen/arch/x86/hvm/svm/entry.S +1 -2
index 1969629..a9d48ae 100644
@@ -134,8 +134,7 @@ UNLIKELY_END(svm_trace)
 #endif
 
         STGI
-.globl svm_stgi_label
-svm_stgi_label:
+GLOBAL(svm_stgi_label)
         mov  %rsp,%rdi
         call svm_vmexit_handler
         jmp  svm_asm_do_resume
xen/arch/x86/hvm/vmx/entry.S +2 -5
index 496a62c..e80c30b 100644
@@ -36,9 +36,7 @@
 #define GUEST_RIP    0x681e
 #define GUEST_RFLAGS 0x6820
 
-        ALIGN
-.globl vmx_asm_vmexit_handler
-vmx_asm_vmexit_handler:
+ENTRY(vmx_asm_vmexit_handler)
         push %rdi
         push %rsi
         push %rdx
@@ -87,8 +85,7 @@ vmx_asm_vmexit_handler:
         mov  %rsp,%rdi
         call vmx_vmexit_handler
 
-.globl vmx_asm_do_vmentry
-vmx_asm_do_vmentry:
+GLOBAL(vmx_asm_do_vmentry)
         call vmx_intr_assist
         call nvmx_switch_guest
         ASSERT_NOT_IN_ATOMIC
xen/arch/x86/x86_64/entry.S +4 -9
index 5beeccb..f64e871 100644
@@ -272,8 +272,7 @@ ENTRY(sysenter_entry)
         pushq $FLAT_USER_SS
         pushq $0
         pushfq
-        .globl sysenter_eflags_saved
-sysenter_eflags_saved:
+GLOBAL(sysenter_eflags_saved)
         pushq $3 /* ring 3 null cs */
         pushq $0 /* null rip */
         pushq $0
@@ -479,8 +478,7 @@ ENTRY(ret_from_intr)
 ENTRY(page_fault)
         movl  $TRAP_page_fault,4(%rsp)
 /* No special register assumptions. */
-	.globl handle_exception
-handle_exception:
+GLOBAL(handle_exception)
         SAVE_ALL
 handle_exception_saved:
         testb $X86_EFLAGS_IF>>8,UREGS_eflags+1(%rsp)
@@ -689,11 +687,8 @@ ENTRY(enable_nmis)
 1:
         retq
 
-/* No op trap handler.  Required for kexec crash path.  This is not
- * declared with the ENTRY() macro to avoid wasted alignment space.
- */
-.globl trap_nop
-trap_nop:
+/* No op trap handler.  Required for kexec crash path. */
+GLOBAL(trap_nop)
         iretq
 
 
xen/include/asm-x86/config.h +3 -0
index f387cd6..cc42a88 100644
@@ -80,6 +80,9 @@
   .globl name;                                  \
   ALIGN;                                        \
   name:
+#define GLOBAL(name)                            \
+  .globl name;                                  \
+  name:
 #endif
 
 #define NR_hypercalls 64
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/2 xen/arm: Introduce and use GLOBAL() in asm code.

In reply to Andrew Cooper
CC Ian Campbell <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Tim Deegan <[email protected]>

--

This patch is not tested as I dont have an arm cross-compiler, but is it fairly mechanical text replacement.

---
 xen/arch/arm/arm32/debug.S       |    6 ++----
 xen/arch/arm/arm32/entry.S       |    3 +--
 xen/arch/arm/arm32/mode_switch.S |    7 ++-----
 xen/arch/arm/arm32/proc-v7.S     |    3 +--
 xen/arch/arm/arm64/debug.S       |    6 ++----
 xen/arch/arm/arm64/mode_switch.S |    4 +---
 xen/include/asm-arm/config.h     |    3 +++
 7 files changed, 12 insertions(+), 20 deletions(-)
xen/arch/arm/arm32/debug.S +2 -4
index 92f5724..ec774cd 100644
@@ -23,18 +23,16 @@
 #include EARLY_PRINTK_INC
 #endif
 
-.globl early_putch
 /* Print a character on the UART - this function is called by C
  * r0: character to print */
-early_putch:
+GLOBAL(early_putch)
         ldr   r1, =FIXMAP_ADDR(FIXMAP_CONSOLE)  /* r1 := VA UART base address */
         early_uart_ready r1, r2
         early_uart_transmit r1, r0
         mov   pc, lr
 
-.globl early_flush
 /* Flush the UART - this function is called by C */
-early_flush:
+GLOBAL(early_flush)
         ldr   r1, =FIXMAP_ADDR(FIXMAP_CONSOLE)  /* r1 := VA UART base address */
         early_uart_ready r1, r2
         mov   pc, lr
xen/arch/arm/arm32/entry.S +1 -2
index 81d5990..774e7c6 100644
@@ -65,9 +65,8 @@ trap_##trap:                                                            \
         bic sp, #7; /* Align the stack pointer (noop on guest trap) */  \
         b do_trap_##trap
 
-.globl hyp_traps_vector
         .align 5
-hyp_traps_vector:
+GLOBAL(hyp_traps_vector)
         .word 0                         /* 0x00 - Reset */
         b trap_undefined_instruction    /* 0x04 - Undefined Instruction */
         b trap_supervisor_call          /* 0x08 - Supervisor Call */
xen/arch/arm/arm32/mode_switch.S +2 -5
index 3500eb0..2cd5888 100644
@@ -29,8 +29,7 @@
  * TODO: Move this code either later (via platform specific desc) or in a bootwrapper
  * r5: Machine ID
  * Clobber r0 r2 */
-.globl kick_cpus
-kick_cpus:
+GLOBAL(kick_cpus)
         ldr   r0, =MACH_TYPE_SMDK5250
         teq   r5, r0                          /* Are we running on the arndale? */
         beq   kick_cpus_arndale
@@ -79,9 +78,7 @@ kick_cpus_sgi:
  * integration with the bootloader/firmware so that Xen always starts
  * in Hyp mode.
  * Clobber r0 - r4 */
-
-.globl enter_hyp_mode
-enter_hyp_mode:
+GLOBAL(enter_hyp_mode)
         mov   r3, lr                 /* Put return address in non-banked reg */
         cpsid aif, #0x16             /* Enter Monitor mode */
         mrc   CP32(r0, SCR)
xen/arch/arm/arm32/proc-v7.S +1 -2
index 0ab3845..e38d5a4 100644
@@ -20,8 +20,7 @@
 #include <asm/asm_defns.h>
 #include <asm/arm32/processor.h>
 
-.globl v7_init
-v7_init:
+GLOBAL(v7_init)
         /* Set up the SMP bit in ACTLR */
         mrc   CP32(r0, ACTLR)
         orr   r0, r0, #(ACTLR_V7_SMP) /* enable SMP bit */
xen/arch/arm/arm64/debug.S +2 -4
index c7b5e6c..472c157 100644
@@ -23,18 +23,16 @@
 #include EARLY_PRINTK_INC
 #endif
 
-.globl early_putch
 /* Print a character on the UART - this function is called by C
  * x0: character to print */
-early_putch:
+GLOBAL(early_putch)
         ldr   x15, =FIXMAP_ADDR(FIXMAP_CONSOLE)
         early_uart_ready x15, 1
         early_uart_transmit x15, w0
         ret
 
-.globl early_flush
 /* Flush the UART - this function is called by C */
-early_flush:
+GLOBAL(early_flush)
         ldr   x15, =FIXMAP_ADDR(FIXMAP_CONSOLE)  /* x15 := VA UART base address */
         early_uart_ready x15, 1
         ret
xen/arch/arm/arm64/mode_switch.S +1 -3
index 4125ac4..ea64f22 100644
@@ -34,9 +34,7 @@
  * integration with the bootloader/firmware so that Xen always starts
  * at EL2.
  */
-
-.globl enter_el2_mode
-enter_el2_mode:
+GLOBAL(enter_el2_mode)
         mov     x0, #0x30                       // RES1
         orr     x0, x0, #(1 << 0)               // Non-secure EL1
         orr     x0, x0, #(1 << 8)               // HVC enable
xen/include/asm-arm/config.h +3 -0
index 259d4c6..604088e 100644
@@ -63,6 +63,9 @@
   .globl name;                                  \
   ALIGN;                                        \
   name:
+#define GLOBAL(name)                            \
+  .globl name;                                  \
+  name:
 #define END(name) \
   .size name, .-name
 #define ENDPROC(name) \
Signature · 1 line
1.7.10.4
Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] xen/arm: Introduce and use GLOBAL() in asm code.

Quoted 1 line · Andrew Cooper
Quoted 7 lines
CC Stefano Stabellini <[email protected]>
CC Tim Deegan <[email protected]>

--

This patch is not tested as I dont have an arm cross-compiler, but is it fairly mechanical text replacement.

Thanks. I'll build test it as usual while I commit it.

#4 lore raw

Re: [PATCH 2/2] xen/arm: Introduce and use GLOBAL() in asm code.

Quoted 4 lines · Ian Campbell
Quoted 1 line · Andrew Cooper

build tested + applied

Quoted 4 lines
Quoted 4 lines
CC Stefano Stabellini <[email protected]>
CC Tim Deegan <[email protected]>

--

FYI this needs to be either "---" or "-- " to have the desired effect. In fact I'm only 100% positive about the former...

#5 lore raw
In reply to Andrew Cooper
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper

Hello,

This series has been split into two patches, one for arm and one for x86. I figured that this was easier than doing it as a single combined patch, especially as the changes are functionally independent.

x86 has been boot tested, but arm has not even been compile tested as I lack a
suitable cross compiler. However, the changes are just text replacement, so I
dont expect any issues.

The changes to {svm,vmx}/entry.S will conflict with Jan's series "HVM:
produce
better binary code", which is why this patch is labled RFC. I also recall that arm{32,64}/mode_switch.S was in the middle of being played with, so might
have issues there. The patchs are on top of current staging.

Quoted 8 lines

Assuming the principle of the patches is fine, I dont mind in what order these
get committed. I can rebase this series on top of shortly upcoming series, or
if this gets in quickly, they can rebase on top of this. Either way the conflicts will not be difficult, and I am happy to do whatever the committers
feel is easiest.

The x86 one is fine by me; I'll just queue this up behind my VMX/SVM series, fixing up the fallout at once.

Jan