Changeset 128359eb in mainline for kernel/arch


Ignore:
Timestamp:
2020-06-12T16:46:32Z (5 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ffccdff0
Parents:
94e75cf
Message:

Replace get_stack_base() with builtin_frame_address(0)

The usage of an intrinsic function to obtain the current stack pointer
should provide the compuler more room for performance optimizations than
the hand-written (and volatile) inline assembly block.

Location:
kernel/arch
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/include/arch/asm.h

    r94e75cf r128359eb  
    188188}
    189189
    190 _NO_TRACE static inline uintptr_t get_stack_base(void)
    191 {
    192         /*
    193          * On real hardware this returns the address of the bottom
    194          * of the current CPU stack. The current_t structure is stored
    195          * on the bottom of stack and this is used to identify the
    196          * current CPU, current task, current thread and current
    197          * address space.
    198          */
    199 
    200         return 0;
    201 }
    202 
    203190#endif
    204191
  • kernel/arch/amd64/include/arch/asm.h

    r94e75cf r128359eb  
    4242
    4343#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
    44 
    45 /** Return base address of current stack.
    46  *
    47  * Return the base address of the current stack.
    48  * The stack is assumed to be STACK_SIZE bytes long.
    49  * The stack must start on page boundary.
    50  *
    51  */
    52 _NO_TRACE static inline uintptr_t get_stack_base(void)
    53 {
    54         uintptr_t v;
    55 
    56         asm volatile (
    57             "andq %%rsp, %[v]\n"
    58             : [v] "=r" (v)
    59             : "0" (~((uint64_t) STACK_SIZE - 1))
    60         );
    61 
    62         return v;
    63 }
    6444
    6545_NO_TRACE static inline void cpu_sleep(void)
  • kernel/arch/arm32/include/arch/asm.h

    r94e75cf r128359eb  
    9595}
    9696
    97 /** Return base address of current stack.
    98  *
    99  * Return the base address of the current stack.
    100  * The stack is assumed to be STACK_SIZE bytes long.
    101  * The stack must start on page boundary.
    102  *
    103  */
    104 _NO_TRACE static inline uintptr_t get_stack_base(void)
    105 {
    106         uintptr_t v;
    107 
    108         asm volatile (
    109             "and %[v], sp, %[size]\n"
    110             : [v] "=r" (v)
    111             : [size] "r" (~(STACK_SIZE - 1))
    112         );
    113 
    114         return v;
    115 }
    116 
    11797extern void cpu_halt(void) __attribute__((noreturn));
    11898extern void asm_delay_loop(uint32_t t);
  • kernel/arch/arm32/include/arch/context.h

    r94e75cf r128359eb  
    4242#include <arch/regutils.h>
    4343
    44 /* Put one item onto the stack to support get_stack_base() and align it up. */
     44/* Put one item onto the stack to support CURRENT and align it up. */
    4545#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4646
  • kernel/arch/arm64/include/arch/asm.h

    r94e75cf r128359eb  
    5252{
    5353        asm volatile ("wfe");
    54 }
    55 
    56 /** Return base address of current stack.
    57  *
    58  * Return the base address of the current stack.
    59  * The stack is assumed to be STACK_SIZE bytes long.
    60  * The stack must start on page boundary.
    61  */
    62 _NO_TRACE static inline uintptr_t get_stack_base(void)
    63 {
    64         uintptr_t v;
    65 
    66         asm volatile (
    67             "mov %[v], sp\n"
    68             "and %[v], %[v], %[size]\n"
    69             : [v] "=&r" (v)
    70             : [size] "r" (~((uint64_t) STACK_SIZE - 1))
    71         );
    72 
    73         return v;
    7454}
    7555
  • kernel/arch/arm64/include/arch/context.h

    r94e75cf r128359eb  
    4141#include <arch/stack.h>
    4242
    43 /* Put one item onto the stack to support get_stack_base() and align it up. */
     43/* Put one item onto the stack to support CURRENT and align it up. */
    4444#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4545
  • kernel/arch/ia32/include/arch/asm.h

    r94e75cf r128359eb  
    348348
    349349#endif /* PROCESSOR_i486 */
    350 
    351 /** Return base address of current stack
    352  *
    353  * Return the base address of the current stack.
    354  * The stack is assumed to be STACK_SIZE bytes long.
    355  * The stack must start on page boundary.
    356  *
    357  */
    358 _NO_TRACE static inline uintptr_t get_stack_base(void)
    359 {
    360         uintptr_t v;
    361 
    362         asm volatile (
    363             "andl %%esp, %[v]\n"
    364             : [v] "=r" (v)
    365             : "0" (~(STACK_SIZE - 1))
    366         );
    367 
    368         return v;
    369 }
    370350
    371351/** Invalidate TLB Entry.
  • kernel/arch/ia32/include/arch/context.h

    r94e75cf r128359eb  
    4545 * First for pop of the saved register, second during ret instruction.
    4646 *
    47  * One item is put onto stack to support get_stack_base().
     47 * One item is put onto stack to support CURRENT.
    4848 */
    4949#define SP_DELTA  (8 + STACK_ITEM_SIZE)
  • kernel/arch/ia64/include/arch/asm.h

    r94e75cf r128359eb  
    160160}
    161161
    162 /** Return base address of current memory stack.
    163  *
    164  * The memory stack is assumed to be STACK_SIZE / 2 long. Note that there is
    165  * also the RSE stack, which takes up the upper half of STACK_SIZE.
    166  * The memory stack must start on page boundary.
    167  */
    168 _NO_TRACE static inline uintptr_t get_stack_base(void)
    169 {
    170         uint64_t value;
    171 
    172         asm volatile (
    173             "mov %[value] = r12"
    174             : [value] "=r" (value)
    175         );
    176 
    177         return (value & (~(STACK_SIZE / 2 - 1)));
    178 }
    179 
    180162/** Return Processor State Register.
    181163 *
  • kernel/arch/ia64/include/arch/context.h

    r94e75cf r128359eb  
    4646 * No need to allocate scratch area.
    4747 *
    48  * One item is put onto the stack to support get_stack_base().
     48 * One item is put onto the stack to support CURRENT.
    4949 */
    5050#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
  • kernel/arch/mips32/include/arch/asm.h

    r94e75cf r128359eb  
    4545}
    4646
    47 /** Return base address of current stack
    48  *
    49  * Return the base address of the current stack.
    50  * The stack is assumed to be STACK_SIZE bytes long.
    51  * The stack must start on page boundary.
    52  *
    53  */
    54 _NO_TRACE static inline uintptr_t get_stack_base(void)
    55 {
    56         uintptr_t base;
    57 
    58         asm volatile (
    59             "and %[base], $29, %[mask]\n"
    60             : [base] "=r" (base)
    61             : [mask] "r" (~(STACK_SIZE - 1))
    62         );
    63 
    64         return base;
    65 }
    66 
    6747_NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
    6848{
  • kernel/arch/mips32/include/arch/context.h

    r94e75cf r128359eb  
    4141
    4242/*
    43  * Put one item onto the stack to support get_stack_base() and align it up.
     43 * Put one item onto the stack to support CURRENT and align it up.
    4444 */
    4545#define SP_DELTA  (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
  • kernel/arch/ppc32/include/arch/asm.h

    r94e75cf r128359eb  
    163163}
    164164
    165 /** Return base address of current stack.
    166  *
    167  * Return the base address of the current stack.
    168  * The stack is assumed to be STACK_SIZE bytes long.
    169  * The stack must start on page boundary.
    170  *
    171  */
    172 _NO_TRACE static inline uintptr_t get_stack_base(void)
    173 {
    174         uintptr_t base;
    175 
    176         asm volatile (
    177             "and %[base], %%sp, %[mask]\n"
    178             : [base] "=r" (base)
    179             : [mask] "r" (~(STACK_SIZE - 1))
    180         );
    181 
    182         return base;
    183 }
    184 
    185165_NO_TRACE static inline void cpu_sleep(void)
    186166{
  • kernel/arch/riscv64/include/arch/asm.h

    r94e75cf r128359eb  
    9191}
    9292
    93 _NO_TRACE static inline uintptr_t get_stack_base(void)
    94 {
    95         uintptr_t base;
    96 
    97         asm volatile (
    98             "and %[base], sp, %[mask]\n"
    99             : [base] "=r" (base)
    100             : [mask] "r" (~(STACK_SIZE - 1))
    101         );
    102 
    103         return base;
    104 }
    105 
    10693_NO_TRACE static inline void cpu_sleep(void)
    10794{
  • kernel/arch/sparc64/include/arch/asm.h

    r94e75cf r128359eb  
    382382}
    383383
    384 /** Return base address of current stack.
    385  *
    386  * Return the base address of the current stack.
    387  * The stack is assumed to be STACK_SIZE bytes long.
    388  * The stack must start on page boundary.
    389  *
    390  */
    391 _NO_TRACE static inline uintptr_t get_stack_base(void)
    392 {
    393         uintptr_t unbiased_sp;
    394 
    395         asm volatile (
    396             "add %%sp, %[stack_bias], %[unbiased_sp]\n"
    397             : [unbiased_sp] "=r" (unbiased_sp)
    398             : [stack_bias] "i" (STACK_BIAS)
    399         );
    400 
    401         return ALIGN_DOWN(unbiased_sp, STACK_SIZE);
    402 }
    403 
    404384/** Read Version Register.
    405385 *
Note: See TracChangeset for help on using the changeset viewer.