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

Changeset 304342e in mainline


Ignore:
Timestamp:
2010-01-08T20:58:33Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
49924b4
Parents:
fabc883
Message:

Add amd64 specific support for kernel stack traces.

Location:
kernel/arch/amd64
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/Makefile.inc

    rfabc883 r304342e  
    3838
    3939FPU_NO_CFLAGS = -mno-sse -mno-sse2
    40 CMN1 = -m64 -mcmodel=kernel -mno-red-zone -fno-unwind-tables
     40CMN1 = -m64 -mcmodel=kernel -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
    4141GCC_CFLAGS += $(CMN1)
    4242ICC_CFLAGS += $(CMN1)
     
    6060        arch/$(KARCH)/src/boot/boot.S \
    6161        arch/$(KARCH)/src/boot/memmap.c \
     62        arch/$(KARCH)/src/debug/stacktrace.c \
     63        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    6264        arch/$(KARCH)/src/pm.c \
    6365        arch/$(KARCH)/src/context.S \
  • kernel/arch/amd64/include/context.h

    rfabc883 r304342e  
    4646#define SP_DELTA     16
    4747
     48#define context_set(c, _pc, stack, size) \
     49        do { \
     50                (c)->pc = (uintptr_t) (_pc); \
     51                (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
     52                (c)->rbp = 0; \
     53        } while (0)
     54
    4855#endif /* KERNEL */
    4956
  • kernel/arch/amd64/include/interrupt.h

    rfabc883 r304342e  
    7070
    7171/** This is passed to interrupt handlers */
    72 typedef struct {
     72typedef struct istate {
    7373        uint64_t rax;
    7474        uint64_t rcx;
     
    8080        uint64_t r10;
    8181        uint64_t r11;
     82        uint64_t rbp;
    8283        uint64_t error_word;
    8384        uint64_t rip;
     
    101102        return istate->rip;
    102103}
     104static inline unative_t istate_get_fp(istate_t *istate)
     105{
     106        return istate->rbp;
     107}
    103108
    104109extern void (* disable_irqs_function)(uint16_t irqmask);
  • kernel/arch/amd64/src/asm_utils.S

    rfabc883 r304342e  
    2727#
    2828
    29 #define IREGISTER_SPACE 72
     29#define IREGISTER_SPACE 80
    3030
    3131#define IOFFSET_RAX     0x0
     
    3838#define IOFFSET_R10     0x38
    3939#define IOFFSET_R11     0x40
     40#define IOFFSET_RBP     0x48
    4041
    4142#  Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word
     
    179180        movq %r10, IOFFSET_R10(%rsp)
    180181        movq %r11, IOFFSET_R11(%rsp)
     182        movq %rbp, IOFFSET_RBP(%rsp)
    181183.endm
    182184
     
    191193        movq IOFFSET_R10(%rsp), %r10
    192194        movq IOFFSET_R11(%rsp), %r11
     195        movq IOFFSET_RBP(%rsp), %rbp
    193196.endm
    194197
     
    235238        cld
    236239
     240        # Stop stack traces here
     241        xorq %rbp, %rbp
     242
    237243        movq $(\i), %rdi        # %rdi - first parameter
    238244        movq %rsp, %rsi         # %rsi - pointer to istate
  • kernel/arch/amd64/src/boot/boot.S

    rfabc883 r304342e  
    174174        call arch_pre_main
    175175       
     176        # create the first stack frame
     177        pushq $0
     178        movq %rsp, %rbp
     179
    176180        call main_bsp
    177181       
  • kernel/arch/amd64/src/interrupt.c

    rfabc883 r304342e  
    5353#include <ddi/irq.h>
    5454#include <symtab.h>
     55#include <stacktrace.h>
    5556
    5657/*
     
    8081            istate->r10, istate->r11);
    8182        printf("%%rsp=%#llx\n", &istate->stack[0]);
     83       
     84        stack_trace_istate(istate);
    8285}
    8386
  • kernel/arch/amd64/src/smp/ap.S

    rfabc883 r304342e  
    9999start64:
    100100        movq (ctx), %rsp
     101        pushq $0
     102        movq %rsp, %rbp
    101103        call main_ap - AP_BOOT_OFFSET + BOOT_OFFSET   # never returns
    102104
Note: See TracChangeset for help on using the changeset viewer.