Changeset 819a768 in mainline


Ignore:
Timestamp:
2010-05-21T22:34:33Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0242621
Parents:
2ee907e
Message:

On sparc64, we have a problem with determining the end of the kernel stack
because the preemptible trap handler cannot easily terminate the stack trace by
writing -STACK_BIAS to %fp as that %fp is unfortunatelly an %sp of the previous
context (user or kernel).

Without sacrifying performance via the FLUSHW instruction, we simply have to
stop tracing when we see the stack frame with %sp created by the SAVE
instruction inside the preemptible trap handler.

Location:
kernel/arch/sparc64
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/include/trap/trap_table.h

    r2ee907e r819a768  
    4242#define TRAP_TABLE_SIZE         (TRAP_TABLE_ENTRY_COUNT * TRAP_TABLE_ENTRY_SIZE)
    4343
     44/*
     45 * The following needs to be in sync with the definition of the istate
     46 * structure. The one STACK_ITEM_SIZE is counted for space holding the 7th
     47 * argument to syscall_handler (i.e. syscall number) and the other
     48 * STACK_ITEM_SIZE is counted because of the required alignment.
     49 */
     50#define PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE \
     51    (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE + \
     52    (2 * STACK_ITEM_SIZE) + (12 * 8))
     53#define SAVED_TSTATE    -(1 * 8)
     54#define SAVED_TPC       -(2 * 8)
     55#define SAVED_TNPC      -(3 * 8)        /* <-- istate_t begins here */
     56#define SAVED_Y         -(4 * 8)
     57#define SAVED_I0        -(5 * 8)
     58#define SAVED_I1        -(6 * 8)
     59#define SAVED_I2        -(7 * 8)
     60#define SAVED_I3        -(8 * 8)
     61#define SAVED_I4        -(9 * 8)
     62#define SAVED_I5        -(10 * 8)
     63#define SAVED_I6        -(11 * 8)
     64#define SAVED_I7        -(12 * 8)
     65
    4466#ifndef __ASM__
    4567
     
    7799.endm
    78100
    79 /*
    80  * The following needs to be in sync with the definition of the istate
    81  * structure. The one STACK_ITEM_SIZE is counted for space holding the 7th
    82  * argument to syscall_handler (i.e. syscall number) and the other
    83  * STACK_ITEM_SIZE is counted because of the required alignment.
    84  */
    85 #define PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE    \
    86     (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE + \
    87     (2 * STACK_ITEM_SIZE) + (12 * 8))
    88 #define SAVED_TSTATE    -(1 * 8)
    89 #define SAVED_TPC       -(2 * 8)
    90 #define SAVED_TNPC      -(3 * 8)        /* <-- istate_t begins here */
    91 #define SAVED_Y         -(4 * 8)
    92 #define SAVED_I0        -(5 * 8)
    93 #define SAVED_I1        -(6 * 8)
    94 #define SAVED_I2        -(7 * 8)
    95 #define SAVED_I3        -(8 * 8)
    96 #define SAVED_I4        -(9 * 8)
    97 #define SAVED_I5        -(10 * 8)
    98 #define SAVED_I6        -(11 * 8)
    99 #define SAVED_I7        -(12 * 8)
    100 
    101101.macro PREEMPTIBLE_HANDLER f
    102102        sethi %hi(\f), %g1
  • kernel/arch/sparc64/src/debug/stacktrace.c

    r2ee907e r819a768  
    3737#include <typedefs.h>
    3838
     39#include <arch.h>
    3940#include <arch/stack.h>
     41#include <arch/trap/trap_table.h>
     42
     43#if defined(SUN4V)
     44#include <arch/sun4v/arch.h>
     45#endif
    4046
    4147#define FRAME_OFFSET_FP_PREV    14
     
    4652bool kernel_frame_pointer_validate(uintptr_t fp)
    4753{
     54        uintptr_t kstack;
     55       
     56#if defined(SUN4U)
     57        kstack = read_from_ag_g6();
     58#elif defined(SUN4V)
     59        kstack = asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_KSTACK);
     60#endif
     61
     62        kstack += STACK_BIAS;
     63        kstack -= PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE;
     64
     65        if (THREAD && (fp == kstack))
     66                return false;
    4867        return fp != 0;
    4968}
Note: See TracChangeset for help on using the changeset viewer.