ia64/xen-unstable

changeset 6582:e02a45b91043

Avoid code duplication between stringified and
non-stringified asm macros, by stringifying on use
where that is needed.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Sep 01 09:37:54 2005 +0000 (2005-09-01)
parents 832cb25d1f55
children dd668f7527cb
files xen/include/asm-x86/asm_defns.h xen/include/asm-x86/bitops.h xen/include/asm-x86/x86_32/asm_defns.h xen/include/asm-x86/x86_64/asm_defns.h xen/include/xen/config.h
line diff
     1.1 --- a/xen/include/asm-x86/asm_defns.h	Thu Sep 01 09:07:10 2005 +0000
     1.2 +++ b/xen/include/asm-x86/asm_defns.h	Thu Sep 01 09:37:54 2005 +0000
     1.3 @@ -6,11 +6,6 @@
     1.4  #include <asm/asm-offsets.h>
     1.5  #include <asm/processor.h>
     1.6  
     1.7 -#ifndef STR
     1.8 -#define __STR(x) #x
     1.9 -#define STR(x) __STR(x)
    1.10 -#endif
    1.11 -
    1.12  #ifdef __x86_64__
    1.13  #include <asm/x86_64/asm_defns.h>
    1.14  #else
     2.1 --- a/xen/include/asm-x86/bitops.h	Thu Sep 01 09:07:10 2005 +0000
     2.2 +++ b/xen/include/asm-x86/bitops.h	Thu Sep 01 09:37:54 2005 +0000
     2.3 @@ -7,11 +7,6 @@
     2.4  
     2.5  #include <xen/config.h>
     2.6  
     2.7 -#ifndef STR
     2.8 -#define __STR(x) #x
     2.9 -#define STR(x) __STR(x)
    2.10 -#endif
    2.11 -
    2.12  /*
    2.13   * These have to be done with inline assembly: that way the bit-setting
    2.14   * is guaranteed to be atomic. All bit operations return 0 if the bit
     3.1 --- a/xen/include/asm-x86/x86_32/asm_defns.h	Thu Sep 01 09:07:10 2005 +0000
     3.2 +++ b/xen/include/asm-x86/x86_32/asm_defns.h	Thu Sep 01 09:37:54 2005 +0000
     3.3 @@ -1,46 +1,6 @@
     3.4  #ifndef __X86_32_ASM_DEFNS_H__
     3.5  #define __X86_32_ASM_DEFNS_H__
     3.6  
     3.7 -/* Maybe auto-generate the following two cases (quoted vs. unquoted). */
     3.8 -#ifndef __ASSEMBLY__
     3.9 -
    3.10 -#define __SAVE_ALL_PRE                                                  \
    3.11 -        "cld;"                                                          \
    3.12 -        "pushl %eax;"                                                   \
    3.13 -        "pushl %ebp;"                                                   \
    3.14 -        "pushl %edi;"                                                   \
    3.15 -        "pushl %esi;"                                                   \
    3.16 -        "pushl %edx;"                                                   \
    3.17 -        "pushl %ecx;"                                                   \
    3.18 -        "pushl %ebx;"                                                   \
    3.19 -        "testl $"STR(X86_EFLAGS_VM)","STR(UREGS_eflags)"(%esp);"        \
    3.20 -        "jz 2f;"                                                        \
    3.21 -        "call setup_vm86_frame;"                                        \
    3.22 -        "jmp 3f;"                                                       \
    3.23 -        "2:testb $3,"STR(UREGS_cs)"(%esp);"                             \
    3.24 -        "jz 1f;"                                                        \
    3.25 -        "mov %ds,"STR(UREGS_ds)"(%esp);"                                \
    3.26 -        "mov %es,"STR(UREGS_es)"(%esp);"                                \
    3.27 -        "mov %fs,"STR(UREGS_fs)"(%esp);"                                \
    3.28 -        "mov %gs,"STR(UREGS_gs)"(%esp);"                                \
    3.29 -        "3:"
    3.30 -
    3.31 -#define SAVE_ALL_NOSEGREGS(_reg)                \
    3.32 -        __SAVE_ALL_PRE                          \
    3.33 -        "1:"
    3.34 -
    3.35 -#define SET_XEN_SEGMENTS(_reg)                                  \
    3.36 -        "movl $("STR(__HYPERVISOR_DS)"),%e"STR(_reg)"x;"        \
    3.37 -        "mov %e"STR(_reg)"x,%ds;"                              \
    3.38 -        "mov %e"STR(_reg)"x,%es;"
    3.39 -
    3.40 -#define SAVE_ALL(_reg)                          \
    3.41 -        __SAVE_ALL_PRE                          \
    3.42 -        SET_XEN_SEGMENTS(_reg)                  \
    3.43 -        "1:"
    3.44 -
    3.45 -#else
    3.46 -
    3.47  #define __SAVE_ALL_PRE                                  \
    3.48          cld;                                            \
    3.49          pushl %eax;                                     \
    3.50 @@ -50,7 +10,7 @@
    3.51          pushl %edx;                                     \
    3.52          pushl %ecx;                                     \
    3.53          pushl %ebx;                                     \
    3.54 -        testl $X86_EFLAGS_VM,UREGS_eflags(%esp);        \
    3.55 +        testl $(X86_EFLAGS_VM),UREGS_eflags(%esp);      \
    3.56          jz 2f;                                          \
    3.57          call setup_vm86_frame;                          \
    3.58          jmp 3f;                                         \
    3.59 @@ -83,8 +43,6 @@
    3.60  #define PERFC_INCR(_name,_idx)
    3.61  #endif
    3.62  
    3.63 -#endif
    3.64 -
    3.65  #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
    3.66  #define XBUILD_SMP_INTERRUPT(x,v)               \
    3.67  asmlinkage void x(void);                        \
    3.68 @@ -92,7 +50,7 @@ asmlinkage void x(void);                
    3.69      "\n"__ALIGN_STR"\n"                         \
    3.70      STR(x) ":\n\t"                              \
    3.71      "pushl $"#v"<<16\n\t"                       \
    3.72 -    SAVE_ALL(a)                                 \
    3.73 +    STR(SAVE_ALL(a))                            \
    3.74      "call "STR(smp_##x)"\n\t"                   \
    3.75      "jmp ret_from_intr\n");
    3.76  
    3.77 @@ -103,7 +61,7 @@ asmlinkage void x(struct cpu_user_regs *
    3.78  "\n"__ALIGN_STR"\n"                             \
    3.79  STR(x) ":\n\t"                                  \
    3.80      "pushl $"#v"<<16\n\t"                       \
    3.81 -    SAVE_ALL(a)                                 \
    3.82 +    STR(SAVE_ALL(a))                            \
    3.83      "movl %esp,%eax\n\t"                        \
    3.84      "pushl %eax\n\t"                            \
    3.85      "call "STR(smp_##x)"\n\t"                   \
    3.86 @@ -114,7 +72,7 @@ STR(x) ":\n\t"                          
    3.87  __asm__(                                        \
    3.88      "\n" __ALIGN_STR"\n"                        \
    3.89      "common_interrupt:\n\t"                     \
    3.90 -    SAVE_ALL(a)                                 \
    3.91 +    STR(SAVE_ALL(a))                            \
    3.92      "movl %esp,%eax\n\t"                        \
    3.93      "pushl %eax\n\t"                            \
    3.94      "call " STR(do_IRQ) "\n\t"                  \
     4.1 --- a/xen/include/asm-x86/x86_64/asm_defns.h	Thu Sep 01 09:07:10 2005 +0000
     4.2 +++ b/xen/include/asm-x86/x86_64/asm_defns.h	Thu Sep 01 09:37:54 2005 +0000
     4.3 @@ -1,50 +1,6 @@
     4.4  #ifndef __X86_64_ASM_DEFNS_H__
     4.5  #define __X86_64_ASM_DEFNS_H__
     4.6  
     4.7 -/* Maybe auto-generate the following two cases (quoted vs. unquoted). */
     4.8 -#ifndef __ASSEMBLY__
     4.9 -
    4.10 -#define SAVE_ALL                                \
    4.11 -        "cld;"                                  \
    4.12 -        "pushq %rdi;"                           \
    4.13 -        "pushq %rsi;"                           \
    4.14 -        "pushq %rdx;"                           \
    4.15 -        "pushq %rcx;"                           \
    4.16 -        "pushq %rax;"                           \
    4.17 -        "pushq %r8;"                            \
    4.18 -        "pushq %r9;"                            \
    4.19 -        "pushq %r10;"                           \
    4.20 -        "pushq %r11;"                           \
    4.21 -        "pushq %rbx;"                           \
    4.22 -        "pushq %rbp;"                           \
    4.23 -        "pushq %r12;"                           \
    4.24 -        "pushq %r13;"                           \
    4.25 -        "pushq %r14;"                           \
    4.26 -        "pushq %r15;"
    4.27 -
    4.28 -#define RESTORE_ALL                             \
    4.29 -        "popq  %r15;"                           \
    4.30 -        "popq  %r14;"                           \
    4.31 -        "popq  %r13;"                           \
    4.32 -        "popq  %r12;"                           \
    4.33 -        "popq  %rbp;"                           \
    4.34 -        "popq  %rbx;"                           \
    4.35 -        "popq  %r11;"                           \
    4.36 -        "popq  %r10;"                           \
    4.37 -        "popq  %r9;"                            \
    4.38 -        "popq  %r8;"                            \
    4.39 -        "popq  %rax;"                           \
    4.40 -        "popq  %rcx;"                           \
    4.41 -        "popq  %rdx;"                           \
    4.42 -        "popq  %rsi;"                           \
    4.43 -        "popq  %rdi;"
    4.44 -
    4.45 -/* Work around AMD erratum #88 */
    4.46 -#define safe_swapgs                             \
    4.47 -        "mfence; swapgs;"
    4.48 -
    4.49 -#else
    4.50 -
    4.51  #define SAVE_ALL                                \
    4.52          cld;                                    \
    4.53          pushq %rdi;                             \
    4.54 @@ -90,7 +46,9 @@
    4.55  #define PERFC_INCR(_name,_idx)
    4.56  #endif
    4.57  
    4.58 -#endif
    4.59 +/* Work around AMD erratum #88 */
    4.60 +#define safe_swapgs                             \
    4.61 +        "mfence; swapgs;"
    4.62  
    4.63  #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
    4.64  #define XBUILD_SMP_INTERRUPT(x,v)               \
    4.65 @@ -100,7 +58,7 @@ asmlinkage void x(void);                
    4.66      STR(x) ":\n\t"                              \
    4.67      "pushq $0\n\t"                              \
    4.68      "movl $"#v",4(%rsp)\n\t"                    \
    4.69 -    SAVE_ALL                                    \
    4.70 +    STR(SAVE_ALL)                               \
    4.71      "callq "STR(smp_##x)"\n\t"                  \
    4.72      "jmp ret_from_intr\n");
    4.73  
    4.74 @@ -112,7 +70,7 @@ asmlinkage void x(struct cpu_user_regs *
    4.75  STR(x) ":\n\t"                                  \
    4.76      "pushq $0\n\t"                              \
    4.77      "movl $"#v",4(%rsp)\n\t"                    \
    4.78 -    SAVE_ALL                                    \
    4.79 +    STR(SAVE_ALL)                               \
    4.80      "movq %rsp,%rdi\n\t"                        \
    4.81      "callq "STR(smp_##x)"\n\t"                  \
    4.82      "jmp ret_from_intr\n");
    4.83 @@ -121,7 +79,7 @@ STR(x) ":\n\t"                          
    4.84  __asm__(                                        \
    4.85      "\n" __ALIGN_STR"\n"                        \
    4.86      "common_interrupt:\n\t"                     \
    4.87 -    SAVE_ALL                                    \
    4.88 +    STR(SAVE_ALL)                               \
    4.89      "movq %rsp,%rdi\n\t"                        \
    4.90      "callq " STR(do_IRQ) "\n\t"                 \
    4.91      "jmp ret_from_intr\n");
     5.1 --- a/xen/include/xen/config.h	Thu Sep 01 09:07:10 2005 +0000
     5.2 +++ b/xen/include/xen/config.h	Thu Sep 01 09:37:54 2005 +0000
     5.3 @@ -40,4 +40,7 @@
     5.4  #include <xen/compiler.h>
     5.5  #endif
     5.6  
     5.7 +#define __STR(...) #__VA_ARGS__
     5.8 +#define STR(...) __STR(__VA_ARGS__)
     5.9 +
    5.10  #endif /* __XEN_CONFIG_H__ */