Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2f23341 in mainline


Ignore:
Timestamp:
2011-05-19T20:04:09Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
326bf65
Parents:
2a922c8
Message:

Fix ia64 regression introduced in mainline,966.
The ia64 stack is actually two stacks in one:

  • the regular memory stack, which is now STACK_SIZE / 2 bytes long
  • and the equally sized RSE stack

Note that ia64 is now the only architecture which effectively uses
only one memory frame for its memory stack.

Location:
kernel/arch/ia64
Files:
4 edited

Legend:

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

    r2a922c8 r2f23341  
    122122}
    123123
    124 /** Return base address of current stack
    125  *
    126  * Return the base address of the current stack.
    127  * The stack is assumed to be STACK_SIZE long.
    128  * The stack must start on page boundary.
    129  *
     124/** Return base address of current memory stack.
     125 *
     126 * The memory stack is assumed to be STACK_SIZE / 2 long. Note that there is
     127 * also the RSE stack, which takes up the upper half of STACK_SIZE.
     128 * The memory stack must start on page boundary.
    130129 */
    131130NO_TRACE static inline uintptr_t get_stack_base(void)
    132131{
    133132        uint64_t value;
    134        
    135         /*
    136          * I'm not sure why but this code inlines badly
    137          * in scheduler, resulting in THE shifting about
    138          * 16B and causing kernel panic.
    139          *
    140          * asm volatile (
    141          *     "and %[value] = %[mask], r12"
    142          *     : [value] "=r" (v)
    143          *     : [mask] "r" (~(STACK_SIZE - 1))
    144          * );
    145          * return v;
    146          *
    147          * The following code has the same semantics but
    148          * inlines correctly.
    149          *
    150          */
    151133       
    152134        asm volatile (
     
    155137        );
    156138       
    157         return (value & (~(STACK_SIZE - 1)));
     139        return (value & (~(STACK_SIZE / 2 - 1)));
    158140}
    159141
  • kernel/arch/ia64/include/context.h

    r2a922c8 r2f23341  
    4949#define SP_DELTA        (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    5050
    51 /* RSE stack starts at the bottom of memory stack. */
     51/* RSE stack starts at the bottom of memory stack, hence the division by 2. */
    5252#define context_set(c, _pc, stack, size)                                                                \
    5353        do {                                                                                            \
    5454                (c)->pc = (uintptr_t) _pc;                                                              \
    55                 (c)->bsp = ((uintptr_t) stack) + ALIGN_UP((size), REGISTER_STACK_ALIGNMENT);            \
     55                (c)->bsp = ((uintptr_t) stack) + ALIGN_UP((size / 2), REGISTER_STACK_ALIGNMENT);        \
    5656                (c)->ar_pfs &= PFM_MASK;                                                                \
    57                 (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - SP_DELTA;           \
     57                (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size / 2), STACK_ALIGNMENT) - SP_DELTA;       \
    5858        } while (0);
    5959
  • kernel/arch/ia64/src/ia64.c

    r2a922c8 r2f23341  
    249249        rsc.mode = 3;                   /* eager mode */
    250250
     251        /*
     252         * Switch to userspace.
     253         *
     254         * When calculating stack addresses, mind the stack split between the
     255         * memory stack and the RSE stack. Each occuppies STACK_SIZE / 2 bytes.
     256         */
    251257        switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    252             ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE -
     258            ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2 -
    253259            ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT),
    254             ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE,
     260            ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2,
    255261            (uintptr_t) kernel_uarg->uspace_uarg, psr.value, rsc.value);
    256262
  • kernel/arch/ia64/src/proc/scheduler.c

    r2a922c8 r2f23341  
    7979         * Record address of kernel stack to bank 0 r23.
    8080         * These values will be found there after switch from userspace.
     81         *
     82         * Mind the 1:1 split of the entire STACK_SIZE long region between the
     83         * memory stack and the RSE stack.
    8184         */
    8285        asm volatile (
     
    8689                "bsw.1\n"
    8790                :
    88                 : "r" (&THREAD->kstack[STACK_SIZE]),
    89                   "r" (&THREAD->kstack[STACK_SIZE - SP_DELTA])
     91                : "r" (&THREAD->kstack[STACK_SIZE / 2]),
     92                  "r" (&THREAD->kstack[STACK_SIZE / 2 - SP_DELTA])
    9093                );
    9194}
Note: See TracChangeset for help on using the changeset viewer.