| 1 |
/* -*- linux-c -*- |
| 2 |
* |
| 3 |
* ARM dwarf unwinder header file |
| 4 |
* Copyright (C) 2011 Red Hat, Inc. |
| 5 |
* |
| 6 |
* This file is part of systemtap, and is free software. You can |
| 7 |
* redistribute it and/or modify it under the terms of the GNU General |
| 8 |
* Public License (GPL); either version 2, or (at your option) any |
| 9 |
* later version. |
| 10 |
*/ |
| 11 |
#ifndef _STP_ARM64_UNWIND_H |
| 12 |
#define _STP_ARM64_UNWIND_H |
| 13 |
|
| 14 |
#include <linux/sched.h> |
| 15 |
#include <asm/ptrace.h> |
| 16 |
|
| 17 |
#define _stp_get_unaligned(ptr) (*(ptr)) |
| 18 |
|
| 19 |
#define UNW_PC(frame) (frame)->regs.pc |
| 20 |
#define UNW_SP(frame) (frame)->regs.sp |
| 21 |
|
| 22 |
#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1)) |
| 23 |
|
| 24 |
#define UNW_REGISTER_INFO \ |
| 25 |
PTREGS_INFO(regs[0]), \ |
| 26 |
PTREGS_INFO(regs[1]), \ |
| 27 |
PTREGS_INFO(regs[2]), \ |
| 28 |
PTREGS_INFO(regs[3]), \ |
| 29 |
PTREGS_INFO(regs[4]), \ |
| 30 |
PTREGS_INFO(regs[5]), \ |
| 31 |
PTREGS_INFO(regs[6]), \ |
| 32 |
PTREGS_INFO(regs[7]), \ |
| 33 |
PTREGS_INFO(regs[8]), \ |
| 34 |
PTREGS_INFO(regs[9]), \ |
| 35 |
PTREGS_INFO(regs[10]), \ |
| 36 |
PTREGS_INFO(regs[11]), \ |
| 37 |
PTREGS_INFO(regs[12]), \ |
| 38 |
PTREGS_INFO(regs[13]), \ |
| 39 |
PTREGS_INFO(regs[14]), \ |
| 40 |
PTREGS_INFO(regs[15]), \ |
| 41 |
PTREGS_INFO(regs[16]), \ |
| 42 |
PTREGS_INFO(regs[17]), \ |
| 43 |
PTREGS_INFO(regs[18]), \ |
| 44 |
PTREGS_INFO(regs[19]), \ |
| 45 |
PTREGS_INFO(regs[20]), \ |
| 46 |
PTREGS_INFO(regs[21]), \ |
| 47 |
PTREGS_INFO(regs[22]), \ |
| 48 |
PTREGS_INFO(regs[23]), \ |
| 49 |
PTREGS_INFO(regs[24]), \ |
| 50 |
PTREGS_INFO(regs[25]), \ |
| 51 |
PTREGS_INFO(regs[26]), \ |
| 52 |
PTREGS_INFO(regs[27]), \ |
| 53 |
PTREGS_INFO(regs[28]), \ |
| 54 |
PTREGS_INFO(regs[29]), \ |
| 55 |
PTREGS_INFO(regs[30]), \ |
| 56 |
PTREGS_INFO(sp), \ |
| 57 |
PTREGS_INFO(pc) \ |
| 58 |
|
| 59 |
#define DWARF_REG_MAP(r) \ |
| 60 |
((r >= 0 && r <= 31) ? r /* regs[0-30] + sp */ \ |
| 61 |
: 9999) |
| 62 |
|
| 63 |
#define UNW_PC_IDX 32 |
| 64 |
#define UNW_SP_IDX 31 |
| 65 |
|
| 66 |
/* Use default rules. The stack pointer should be set from the CFA. |
| 67 |
And the instruction pointer should be set from the return address |
| 68 |
column (which normally is the link register (regs[30]). */ |
| 69 |
|
| 70 |
static inline void arch_unw_init_frame_info(struct unwind_frame_info *info, |
| 71 |
/*const*/ struct pt_regs *regs, |
| 72 |
int sanitize) |
| 73 |
{ |
| 74 |
/* FIXME The synthetic generation of pt_regs information does not work. */ |
| 75 |
if (regs == NULL) { |
| 76 |
asm("1:\n\t" |
| 77 |
"stp x0, x1, [%2, #0]\n\t" |
| 78 |
"stp x2, x3, [%2, #16]\n\t" |
| 79 |
"stp x4, x5, [%2, #32]\n\t" |
| 80 |
"stp x6, x7, [%2, #48]\n\t" |
| 81 |
"stp x8, x9, [%2, #64]\n\t" |
| 82 |
"stp x10, x11, [%2, #80]\n\t" |
| 83 |
"stp x12, x13, [%2, #96]\n\t" |
| 84 |
"stp x14, x15, [%2, #112]\n\t" |
| 85 |
"stp x16, x17, [%2, #128]\n\t" |
| 86 |
"stp x18, x19, [%2, #144]\n\t" |
| 87 |
"stp x20, x21, [%2, #160]\n\t" |
| 88 |
"stp x22, x23, [%2, #176]\n\t" |
| 89 |
"stp x24, x25, [%2, #192]\n\t" |
| 90 |
"stp x26, x27, [%2, #208]\n\t" |
| 91 |
"stp x29, x30, [%2, #224]\n\t" |
| 92 |
"mov sp, x16\n\t" |
| 93 |
"str x16, [%2, #240]\n\t" |
| 94 |
"adr x17, 1b\n\t" |
| 95 |
"str x17, [%1, #240]\n\t" |
| 96 |
"ldp x16, x17, [%2, #128]\n\t" |
| 97 |
: "=m" (info->regs), |
| 98 |
"=r" (info->regs.pc) |
| 99 |
: "r" (&info->regs) |
| 100 |
); |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 104 |
if (&info->regs == regs) { /* happens when unwinding kernel->user */ |
| 105 |
info->call_frame = 1; |
| 106 |
return; |
| 107 |
} |
| 108 |
|
| 109 |
memset(info, 0, sizeof(*info)); |
| 110 |
info->regs = *regs; |
| 111 |
} |
| 112 |
|
| 113 |
#endif /* _STP_ARM64_UNWIND_H */ |