From 1302a542db385c63ec1702dff9495870edf5b095 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 30 Nov 2009 11:04:44 +0800 Subject: Fix build error when !HAVE_NSS * runtime/staprun/staprun_funcs.c (assert_stap_module_permissions): Mark parameters unused. --- runtime/staprun/staprun_funcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/staprun/staprun_funcs.c b/runtime/staprun/staprun_funcs.c index 8f3d84ad..26e8c663 100644 --- a/runtime/staprun/staprun_funcs.c +++ b/runtime/staprun/staprun_funcs.c @@ -507,8 +507,8 @@ check_groups ( void assert_stap_module_permissions( const char *module_path, int module_fd, - const void *module_data, - off_t module_size + const void *module_data __attribute__ ((unused)), + off_t module_size __attribute__ ((unused)) ) { int check_groups_rc; int check_signature_rc; -- cgit From ab7236f68712b18656cb82307e6ca5dbe8de9fa7 Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 30 Nov 2009 13:24:14 -0600 Subject: Don't let _stp_alloc_percpu allocate too much memory. * runtime/alloc.c (_stp_alloc_percpu): Refuses to allocate too much percpu memory. --- runtime/alloc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/alloc.c b/runtime/alloc.c index 439e8a7e..403d20ee 100644 --- a/runtime/alloc.c +++ b/runtime/alloc.c @@ -11,6 +11,8 @@ #ifndef _ALLOC_C_ #define _ALLOC_C_ +#include + static int _stp_allocated_net_memory = 0; #define STP_ALLOC_FLAGS (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN) @@ -233,12 +235,23 @@ static void *_stp_vmalloc(unsigned long size) } +#ifdef PCPU_MIN_UNIT_SIZE +#define _STP_MAX_PERCPU_SIZE PCPU_MIN_UNIT_SIZE +#else +#define _STP_MAX_PERCPU_SIZE 131072 +#endif + static void *_stp_alloc_percpu(size_t size) { + void *ret; + + if (size > _STP_MAX_PERCPU_SIZE) + return NULL; + #ifdef STAPCONF_ALLOC_PERCPU_ALIGN - void *ret = __alloc_percpu(size, 8); + ret = __alloc_percpu(size, 8); #else - void *ret = __alloc_percpu(size); + ret = __alloc_percpu(size); #endif #ifdef DEBUG_MEM if (likely(ret)) { -- cgit From d3b20053a696d3834d4b2cf73afa296464555c85 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 30 Nov 2009 15:27:21 -0500 Subject: PR10653: don't corrupt signal structs in itrace on rawhide utrace * runtime/itrace.c (usr_itrace_report_signal): On modern utrace, must check/propagate utrace_signal_action(). --- runtime/itrace.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/itrace.c b/runtime/itrace.c index 03e1e403..f2ed86f2 100644 --- a/runtime/itrace.c +++ b/runtime/itrace.c @@ -131,9 +131,16 @@ static u32 usr_itrace_report_signal(u32 action, ui = rcu_dereference(engine->data); WARN_ON(!ui); - - if (info->si_signo != SIGTRAP || !ui) - return UTRACE_RESUME; + +#if defined(UTRACE_ORIG_VERSION) + if (info->si_signo != SIGTRAP || !ui) + return UTRACE_RESUME; +#else + if (utrace_signal_action(action) == UTRACE_SIGNAL_HANDLER || + utrace_signal_action(action) == UTRACE_SIGNAL_REPORT || + info->si_signo != SIGTRAP || !ui) + return UTRACE_RESUME | utrace_signal_action(action); +#endif #if defined(UTRACE_ORIG_VERSION) && defined(CONFIG_PPC) /* Because of a ppc utrace bug, we need to stop the task here. -- cgit From 01f8d9fcc10100b16391cf797dc0647e7112c5a9 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Sat, 28 Nov 2009 01:33:36 +0300 Subject: Rename uprobes_ppc64.c to uprobes_ppc.c, use it for ppc32 The code *looks* generic enough, so I think it can be used for ppc32 without modifications. Signed-off-by: Anton Vorontsov --- runtime/uprobes/uprobes_arch.c | 4 +- runtime/uprobes/uprobes_arch.h | 4 +- runtime/uprobes/uprobes_ppc.c | 147 ++++++++++++++++++++++++++++++++++++++++ runtime/uprobes/uprobes_ppc.h | 82 ++++++++++++++++++++++ runtime/uprobes/uprobes_ppc64.c | 147 ---------------------------------------- runtime/uprobes/uprobes_ppc64.h | 82 ---------------------- runtime/uprobes2/uprobes_arch.c | 4 +- runtime/uprobes2/uprobes_arch.h | 4 +- 8 files changed, 237 insertions(+), 237 deletions(-) create mode 100644 runtime/uprobes/uprobes_ppc.c create mode 100644 runtime/uprobes/uprobes_ppc.h delete mode 100644 runtime/uprobes/uprobes_ppc64.c delete mode 100644 runtime/uprobes/uprobes_ppc64.h (limited to 'runtime') diff --git a/runtime/uprobes/uprobes_arch.c b/runtime/uprobes/uprobes_arch.c index 99ef54c8..6c58d5fb 100644 --- a/runtime/uprobes/uprobes_arch.c +++ b/runtime/uprobes/uprobes_arch.c @@ -2,8 +2,8 @@ #include "uprobes_x86_64.c" #elif defined (__i386__) #include "uprobes_i386.c" -#elif defined (__powerpc64__) -#include "uprobes_ppc64.c" +#elif defined (__powerpc__) +#include "uprobes_ppc.c" #elif defined (__s390__) || defined (__s390x__) #include "uprobes_s390.c" #else diff --git a/runtime/uprobes/uprobes_arch.h b/runtime/uprobes/uprobes_arch.h index 0223e280..f642f528 100644 --- a/runtime/uprobes/uprobes_arch.h +++ b/runtime/uprobes/uprobes_arch.h @@ -2,8 +2,8 @@ #include "uprobes_x86_64.h" #elif defined (__i386__) #include "uprobes_i386.h" -#elif defined (__powerpc64__) -#include "uprobes_ppc64.h" +#elif defined (__powerpc__) +#include "uprobes_ppc.h" #elif defined (__s390__) || defined (__s390x__) #include "uprobes_s390.h" #else diff --git a/runtime/uprobes/uprobes_ppc.c b/runtime/uprobes/uprobes_ppc.c new file mode 100644 index 00000000..819ac73d --- /dev/null +++ b/runtime/uprobes/uprobes_ppc.c @@ -0,0 +1,147 @@ +/* + * Userspace Probes (UProbes) for PowerPC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright IBM Corporation, 2007 + */ +/* + * In versions of uprobes built in the SystemTap runtime, this file + * is #included at the end of uprobes.c. + */ + +/* + * Replace the return address with the trampoline address. Returns + * the original return address. + */ +static +unsigned long arch_hijack_uret_addr(unsigned long trampoline_address, + struct pt_regs *regs, struct uprobe_task *utask) +{ + unsigned long orig_ret_addr = regs->link; + + regs->link = trampoline_address; + return orig_ret_addr; +} + +/* + * Get an instruction slot from the process's SSOL area, containing the + * instruction at ppt's probepoint. Point the eip at that slot, in preparation + * for single-stepping out of line. + */ +static +void uprobe_pre_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt, + struct pt_regs *regs) +{ + struct uprobe_ssol_slot *slot; + + slot = uprobe_get_insn_slot(ppt); + if (!slot) { + utask->doomed = 1; + return; + } + regs->nip = (long)slot->insn; +} + + +static inline void calc_offset(struct uprobe_probept *ppt, + struct pt_regs *regs) +{ + int offset = 0; + unsigned int opcode = 0; + unsigned int insn = *ppt->insn; + + opcode = insn >> 26; + switch (opcode) { + case 16: /* bc */ + if ((insn & 2) == 0) { + offset = (signed short)(insn & 0xfffc); + regs->nip = ppt->vaddr + offset; + } + if (insn & 1) + regs->link = ppt->vaddr + MAX_UINSN_BYTES; + break; + case 17: /* sc */ + /* Do we need to do anything */ + break; + case 18: /* b */ + if ((insn & 2) == 0) { + offset = insn & 0x03fffffc; + if (offset & 0x02000000) + offset -= 0x04000000; + regs->nip = ppt->vaddr + offset; + } + if (insn & 1) + regs->link = ppt->vaddr + MAX_UINSN_BYTES; + break; + } +#ifdef UPROBES_DEBUG + printk (KERN_ERR "ppt->vaddr=%p, regs->nip=%p, offset=%ld\n", + ppt->vaddr, regs->nip, offset); + if (insn & 1) + printk (KERN_ERR "regs->link=%p \n", regs->link); +#endif + return; +} + +/* + * Called after single-stepping. ppt->vaddr is the address of the + * instruction which was replaced by a breakpoint instruction. To avoid + * the SMP problems that can occur when we temporarily put back the + * original opcode to single-step, we single-stepped a copy of the + * instruction. + * + * This function prepares to return from the post-single-step + * interrupt. + * + * 1) Typically, the new nip is relative to the copied instruction. We + * need to make it relative to the original instruction. Exceptions are + * branch instructions. + * + * 2) For branch instructions, update the nip if the branch uses + * relative addressing. Update the link instruction to the instruction + * following the original instruction address. + */ + +static +void uprobe_post_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt, + struct pt_regs *regs) +{ + unsigned long copy_nip; + + copy_nip = (unsigned long) ppt->slot->insn; + up_read(&ppt->slot->rwsem); + + /* + * If the single stepped instruction is non-branch instruction + * then update the IP to be relative to probepoint. + */ + if (regs->nip == copy_nip + MAX_UINSN_BYTES) + regs->nip = ppt->vaddr + MAX_UINSN_BYTES; + else + calc_offset(ppt,regs); +} + +static +int arch_validate_probed_insn(struct uprobe_probept *ppt, + struct task_struct *tsk) +{ + if ((unsigned long)ppt->vaddr & 0x03) { + printk(KERN_WARNING + "Attempt to register uprobe at an unaligned addr\n"); + return -EINVAL; + } + return 0; +} diff --git a/runtime/uprobes/uprobes_ppc.h b/runtime/uprobes/uprobes_ppc.h new file mode 100644 index 00000000..56046351 --- /dev/null +++ b/runtime/uprobes/uprobes_ppc.h @@ -0,0 +1,82 @@ +#ifndef _ASM_UPROBES_H +#define _ASM_UPROBES_H +/* + * Userspace Probes (UProbes) for PowerPC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright IBM Corporation, 2007 + */ +#include +#include +#include + +#define BREAKPOINT_SIGNAL SIGTRAP +#define SSTEP_SIGNAL SIGTRAP + +/* Normally defined in Kconfig */ +#define CONFIG_UPROBES_SSOL +#define CONFIG_URETPROBES 1 + +typedef unsigned int uprobe_opcode_t; +#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */ +#define BP_INSN_SIZE 4 +#define MAX_UINSN_BYTES 4 +#define SLOT_IP(tsk) 32 /* instruction pointer slot from include/asm/elf.h */ + +struct uprobe_probept_arch_info {}; +struct uprobe_task_arch_info {}; + +/* Architecture specific switch for where the IP points after a bp hit */ +#define ARCH_BP_INST_PTR(inst_ptr) (inst_ptr) + +struct uprobe_probept; +struct uprobe_task; +struct task_struct; + +/* On powerpc, nip points to the trap. */ +static inline unsigned long arch_get_probept(struct pt_regs *regs) +{ + return (unsigned long)(regs->nip); +} + +static inline void arch_reset_ip_for_sstep(struct pt_regs *regs) +{ +} + +static inline int arch_validate_probed_insn(struct uprobe_probept *ppt, + struct task_struct *tsk); + +static unsigned long arch_hijack_uret_addr(unsigned long trampoline_addr, + struct pt_regs *regs, struct uprobe_task *utask); + +static inline void arch_restore_uret_addr(unsigned long ret_addr, + struct pt_regs *regs) +{ + regs->nip = ret_addr; +} + +static unsigned long arch_get_cur_sp(struct pt_regs *regs) +{ + return (unsigned long)(regs->gpr[1]); +} + +static unsigned long arch_predict_sp_at_ret(struct pt_regs *regs, + struct task_struct *tsk) +{ + return (unsigned long)(regs->gpr[1]); +} + +#endif /* _ASM_UPROBES_H */ diff --git a/runtime/uprobes/uprobes_ppc64.c b/runtime/uprobes/uprobes_ppc64.c deleted file mode 100644 index 819ac73d..00000000 --- a/runtime/uprobes/uprobes_ppc64.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Userspace Probes (UProbes) for PowerPC - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright IBM Corporation, 2007 - */ -/* - * In versions of uprobes built in the SystemTap runtime, this file - * is #included at the end of uprobes.c. - */ - -/* - * Replace the return address with the trampoline address. Returns - * the original return address. - */ -static -unsigned long arch_hijack_uret_addr(unsigned long trampoline_address, - struct pt_regs *regs, struct uprobe_task *utask) -{ - unsigned long orig_ret_addr = regs->link; - - regs->link = trampoline_address; - return orig_ret_addr; -} - -/* - * Get an instruction slot from the process's SSOL area, containing the - * instruction at ppt's probepoint. Point the eip at that slot, in preparation - * for single-stepping out of line. - */ -static -void uprobe_pre_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt, - struct pt_regs *regs) -{ - struct uprobe_ssol_slot *slot; - - slot = uprobe_get_insn_slot(ppt); - if (!slot) { - utask->doomed = 1; - return; - } - regs->nip = (long)slot->insn; -} - - -static inline void calc_offset(struct uprobe_probept *ppt, - struct pt_regs *regs) -{ - int offset = 0; - unsigned int opcode = 0; - unsigned int insn = *ppt->insn; - - opcode = insn >> 26; - switch (opcode) { - case 16: /* bc */ - if ((insn & 2) == 0) { - offset = (signed short)(insn & 0xfffc); - regs->nip = ppt->vaddr + offset; - } - if (insn & 1) - regs->link = ppt->vaddr + MAX_UINSN_BYTES; - break; - case 17: /* sc */ - /* Do we need to do anything */ - break; - case 18: /* b */ - if ((insn & 2) == 0) { - offset = insn & 0x03fffffc; - if (offset & 0x02000000) - offset -= 0x04000000; - regs->nip = ppt->vaddr + offset; - } - if (insn & 1) - regs->link = ppt->vaddr + MAX_UINSN_BYTES; - break; - } -#ifdef UPROBES_DEBUG - printk (KERN_ERR "ppt->vaddr=%p, regs->nip=%p, offset=%ld\n", - ppt->vaddr, regs->nip, offset); - if (insn & 1) - printk (KERN_ERR "regs->link=%p \n", regs->link); -#endif - return; -} - -/* - * Called after single-stepping. ppt->vaddr is the address of the - * instruction which was replaced by a breakpoint instruction. To avoid - * the SMP problems that can occur when we temporarily put back the - * original opcode to single-step, we single-stepped a copy of the - * instruction. - * - * This function prepares to return from the post-single-step - * interrupt. - * - * 1) Typically, the new nip is relative to the copied instruction. We - * need to make it relative to the original instruction. Exceptions are - * branch instructions. - * - * 2) For branch instructions, update the nip if the branch uses - * relative addressing. Update the link instruction to the instruction - * following the original instruction address. - */ - -static -void uprobe_post_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt, - struct pt_regs *regs) -{ - unsigned long copy_nip; - - copy_nip = (unsigned long) ppt->slot->insn; - up_read(&ppt->slot->rwsem); - - /* - * If the single stepped instruction is non-branch instruction - * then update the IP to be relative to probepoint. - */ - if (regs->nip == copy_nip + MAX_UINSN_BYTES) - regs->nip = ppt->vaddr + MAX_UINSN_BYTES; - else - calc_offset(ppt,regs); -} - -static -int arch_validate_probed_insn(struct uprobe_probept *ppt, - struct task_struct *tsk) -{ - if ((unsigned long)ppt->vaddr & 0x03) { - printk(KERN_WARNING - "Attempt to register uprobe at an unaligned addr\n"); - return -EINVAL; - } - return 0; -} diff --git a/runtime/uprobes/uprobes_ppc64.h b/runtime/uprobes/uprobes_ppc64.h deleted file mode 100644 index 56046351..00000000 --- a/runtime/uprobes/uprobes_ppc64.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef _ASM_UPROBES_H -#define _ASM_UPROBES_H -/* - * Userspace Probes (UProbes) for PowerPC - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright IBM Corporation, 2007 - */ -#include -#include -#include - -#define BREAKPOINT_SIGNAL SIGTRAP -#define SSTEP_SIGNAL SIGTRAP - -/* Normally defined in Kconfig */ -#define CONFIG_UPROBES_SSOL -#define CONFIG_URETPROBES 1 - -typedef unsigned int uprobe_opcode_t; -#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */ -#define BP_INSN_SIZE 4 -#define MAX_UINSN_BYTES 4 -#define SLOT_IP(tsk) 32 /* instruction pointer slot from include/asm/elf.h */ - -struct uprobe_probept_arch_info {}; -struct uprobe_task_arch_info {}; - -/* Architecture specific switch for where the IP points after a bp hit */ -#define ARCH_BP_INST_PTR(inst_ptr) (inst_ptr) - -struct uprobe_probept; -struct uprobe_task; -struct task_struct; - -/* On powerpc, nip points to the trap. */ -static inline unsigned long arch_get_probept(struct pt_regs *regs) -{ - return (unsigned long)(regs->nip); -} - -static inline void arch_reset_ip_for_sstep(struct pt_regs *regs) -{ -} - -static inline int arch_validate_probed_insn(struct uprobe_probept *ppt, - struct task_struct *tsk); - -static unsigned long arch_hijack_uret_addr(unsigned long trampoline_addr, - struct pt_regs *regs, struct uprobe_task *utask); - -static inline void arch_restore_uret_addr(unsigned long ret_addr, - struct pt_regs *regs) -{ - regs->nip = ret_addr; -} - -static unsigned long arch_get_cur_sp(struct pt_regs *regs) -{ - return (unsigned long)(regs->gpr[1]); -} - -static unsigned long arch_predict_sp_at_ret(struct pt_regs *regs, - struct task_struct *tsk) -{ - return (unsigned long)(regs->gpr[1]); -} - -#endif /* _ASM_UPROBES_H */ diff --git a/runtime/uprobes2/uprobes_arch.c b/runtime/uprobes2/uprobes_arch.c index 3c86804e..a91d5b6a 100644 --- a/runtime/uprobes2/uprobes_arch.c +++ b/runtime/uprobes2/uprobes_arch.c @@ -1,7 +1,7 @@ #if defined (__x86_64__) || defined(__i386) #include "uprobes_x86.c" -#elif defined (__powerpc64__) -#include "../uprobes/uprobes_ppc64.c" +#elif defined (__powerpc__) +#include "../uprobes/uprobes_ppc.c" #elif defined (__s390__) || defined (__s390x__) #include "../uprobes/uprobes_s390.c" #elif defined (__ia64__) diff --git a/runtime/uprobes2/uprobes_arch.h b/runtime/uprobes2/uprobes_arch.h index 87e0cc83..cce57757 100644 --- a/runtime/uprobes2/uprobes_arch.h +++ b/runtime/uprobes2/uprobes_arch.h @@ -1,7 +1,7 @@ #if defined (__x86_64__) || defined(__i386) #include "uprobes_x86.h" -#elif defined (__powerpc64__) -#include "../uprobes/uprobes_ppc64.h" +#elif defined (__powerpc__) +#include "../uprobes/uprobes_ppc.h" #elif defined (__s390__) || defined (__s390x__) #include "../uprobes/uprobes_s390.h" #elif defined (__ia64__) -- cgit From f5fd3c39dcec944feb8aa91808a8cb8d94dd1e04 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Sat, 28 Nov 2009 01:33:39 +0300 Subject: Rename stack-ppc64.c to stack-ppc.c There should be no functional changes in this patch. Signed-off-by: Anton Vorontsov --- runtime/stack-ppc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ runtime/stack-ppc64.c | 62 --------------------------------------------------- runtime/stack.c | 2 +- 3 files changed, 63 insertions(+), 63 deletions(-) create mode 100644 runtime/stack-ppc.c delete mode 100644 runtime/stack-ppc64.c (limited to 'runtime') diff --git a/runtime/stack-ppc.c b/runtime/stack-ppc.c new file mode 100644 index 00000000..3267194e --- /dev/null +++ b/runtime/stack-ppc.c @@ -0,0 +1,62 @@ +/* -*- linux-c -*- + * ppc64 stack tracing functions + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels, + struct task_struct *tsk) +{ + unsigned long ip, newsp, lr = 0; + int count = 0; + int firstframe = 1; + unsigned long *_sp = (unsigned long *)®_SP(regs); + unsigned long sp = (unsigned long)_sp; + lr = 0; + do { + if (sp < KERNELBASE) + return; + _sp = (unsigned long *) sp; + newsp = _sp[0]; + ip = _sp[2]; + if (!firstframe || ip != lr) { + if (verbose) { + _stp_printf("[0x%016lx] [0x%016lx] ", sp, ip); + _stp_symbol_print(ip); + if (firstframe) + _stp_print(" (unreliable)"); + _stp_print_char('\n'); + } + else + _stp_printf("0x%016lx ", ip); + } + firstframe = 0; + /* + * See if this is an exception frame. + * We look for the "regshere" marker in the current frame. + */ + if ( _sp[12] == 0x7265677368657265ul) { + struct pt_regs *regs = (struct pt_regs *) + (sp + STACK_FRAME_OVERHEAD); + if (verbose) { + _stp_printf("--- Exception: %lx at ",regs->trap); + _stp_symbol_print(regs->nip); + _stp_print_char('\n'); + lr = regs->link; + _stp_print(" LR ="); + _stp_symbol_print(lr); + _stp_print_char('\n'); + firstframe = 1; + } + else { + _stp_printf("0x%016lx ",regs->nip); + _stp_printf("0x%016lx ",regs->link); + } + } + + sp = newsp; + } while (count++ < MAXBACKTRACE); +} diff --git a/runtime/stack-ppc64.c b/runtime/stack-ppc64.c deleted file mode 100644 index 3267194e..00000000 --- a/runtime/stack-ppc64.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- linux-c -*- - * ppc64 stack tracing functions - * - * This file is part of systemtap, and is free software. You can - * redistribute it and/or modify it under the terms of the GNU General - * Public License (GPL); either version 2, or (at your option) any - * later version. - */ - -static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels, - struct task_struct *tsk) -{ - unsigned long ip, newsp, lr = 0; - int count = 0; - int firstframe = 1; - unsigned long *_sp = (unsigned long *)®_SP(regs); - unsigned long sp = (unsigned long)_sp; - lr = 0; - do { - if (sp < KERNELBASE) - return; - _sp = (unsigned long *) sp; - newsp = _sp[0]; - ip = _sp[2]; - if (!firstframe || ip != lr) { - if (verbose) { - _stp_printf("[0x%016lx] [0x%016lx] ", sp, ip); - _stp_symbol_print(ip); - if (firstframe) - _stp_print(" (unreliable)"); - _stp_print_char('\n'); - } - else - _stp_printf("0x%016lx ", ip); - } - firstframe = 0; - /* - * See if this is an exception frame. - * We look for the "regshere" marker in the current frame. - */ - if ( _sp[12] == 0x7265677368657265ul) { - struct pt_regs *regs = (struct pt_regs *) - (sp + STACK_FRAME_OVERHEAD); - if (verbose) { - _stp_printf("--- Exception: %lx at ",regs->trap); - _stp_symbol_print(regs->nip); - _stp_print_char('\n'); - lr = regs->link; - _stp_print(" LR ="); - _stp_symbol_print(lr); - _stp_print_char('\n'); - firstframe = 1; - } - else { - _stp_printf("0x%016lx ",regs->nip); - _stp_printf("0x%016lx ",regs->link); - } - } - - sp = newsp; - } while (count++ < MAXBACKTRACE); -} diff --git a/runtime/stack.c b/runtime/stack.c index 042f44c7..ae899950 100644 --- a/runtime/stack.c +++ b/runtime/stack.c @@ -41,7 +41,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int); #elif defined (__i386__) #include "stack-i386.c" #elif defined (__powerpc64__) -#include "stack-ppc64.c" +#include "stack-ppc.c" #elif defined (__arm__) #include "stack-arm.c" #elif defined (__s390__) || defined (__s390x__) -- cgit From 51280c12d044b671b16ce59396658ac5a0f24650 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Sat, 28 Nov 2009 01:33:42 +0300 Subject: stack-ppc: Adjust for ppc32 Get rid of magic numbers, use appropriate defines from ptrace.h. From now on stack-ppc.c should be suitable for ppc32. Signed-off-by: Anton Vorontsov --- runtime/stack-ppc.c | 4 ++-- runtime/stack.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/stack-ppc.c b/runtime/stack-ppc.c index 3267194e..df2db15d 100644 --- a/runtime/stack-ppc.c +++ b/runtime/stack-ppc.c @@ -21,7 +21,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels, return; _sp = (unsigned long *) sp; newsp = _sp[0]; - ip = _sp[2]; + ip = _sp[STACK_FRAME_LR_SAVE]; if (!firstframe || ip != lr) { if (verbose) { _stp_printf("[0x%016lx] [0x%016lx] ", sp, ip); @@ -38,7 +38,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels, * See if this is an exception frame. * We look for the "regshere" marker in the current frame. */ - if ( _sp[12] == 0x7265677368657265ul) { + if (_sp[STACK_FRAME_MARKER] == STACK_FRAME_REGS_MARKER) { struct pt_regs *regs = (struct pt_regs *) (sp + STACK_FRAME_OVERHEAD); if (verbose) { diff --git a/runtime/stack.c b/runtime/stack.c index ae899950..25dbdbbd 100644 --- a/runtime/stack.c +++ b/runtime/stack.c @@ -40,7 +40,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int); #include "stack-ia64.c" #elif defined (__i386__) #include "stack-i386.c" -#elif defined (__powerpc64__) +#elif defined (__powerpc__) #include "stack-ppc.c" #elif defined (__arm__) #include "stack-arm.c" -- cgit From fb4653ea565018aa26a730db6b59ff64f2c6afa8 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Sat, 28 Nov 2009 01:33:45 +0300 Subject: Share ppc64 and ppc32 code where possible * runtime/copy.c: Can use ppc64's code. * runtime/regs.h: Ditto. * runtime/string.h: Ditto. * tapset/context.stp: Ditto. * tapset/errno.stp: Ditto. Signed-off-by: Anton Vorontsov --- runtime/copy.c | 2 +- runtime/regs.h | 2 +- runtime/string.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/copy.c b/runtime/copy.c index 4fb87253..40f15117 100644 --- a/runtime/copy.c +++ b/runtime/copy.c @@ -105,7 +105,7 @@ do { \ : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ : "memory"); \ } while (0) -#elif defined (__powerpc64__) || defined (__ia64__) || defined (__arm__) +#elif defined (__powerpc__) || defined (__ia64__) || defined (__arm__) #define __stp_strncpy_from_user(dst,src,count,res) \ do { res = __strncpy_from_user(dst, src, count); } while(0) diff --git a/runtime/regs.h b/runtime/regs.h index dc6b50af..08449aa6 100644 --- a/runtime/regs.h +++ b/runtime/regs.h @@ -36,7 +36,7 @@ (((regs)->cr_iip = (x) & ~3UL), (ia64_psr(regs)->ri = (x) & 3UL)) -#elif defined (__powerpc64__) +#elif defined (__powerpc__) #define REG_IP(regs) regs->nip #define REG_SP(regs) regs->gpr[1] diff --git a/runtime/string.h b/runtime/string.h index f4d4cc05..b08304e5 100644 --- a/runtime/string.h +++ b/runtime/string.h @@ -19,14 +19,14 @@ static void _stp_text_str(char *out, char *in, int len, int quoted, int user); * is provided without the paranoid check. Use it if available, fall back * to __get_user() if not. Other archs can use __get_user() as is */ -#ifdef __powerpc64__ +#if defined(__powerpc__) #ifdef __get_user_inatomic #define __stp_get_user(x, ptr) __get_user_inatomic(x, ptr) #else /* __get_user_inatomic */ #define __stp_get_user(x, ptr) __get_user(x, ptr) #endif /* __get_user_inatomic */ -#else /* __powerpc64__ */ +#else /* defined(__powerpc__) */ #define __stp_get_user(x, ptr) __get_user(x, ptr) -#endif /* __powerpc64__ */ +#endif /* defined(__powerpc__) */ #endif /* _STRING_H_ */ -- cgit From b7c4fdcf0991791bf13b144c72767ff6b98cff53 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Sat, 28 Nov 2009 01:33:49 +0300 Subject: Implement _div64 and _mod64 for ppc32 _div64 and _mod64 arch-specific details were taken from gcc/longlong.h, just as it was done for i386. Signed-off-by: Anton Vorontsov --- runtime/arith.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/arith.c b/runtime/arith.c index 4c818a76..a032e9c1 100644 --- a/runtime/arith.c +++ b/runtime/arith.c @@ -20,7 +20,8 @@ /* 64-bit division for 64-bit cpus and i386 */ /* Other 32-bit cpus will need to modify this file. */ -#if defined (__i386__) || defined(__arm__) +#if defined (__i386__) || defined(__arm__) || \ + (defined(__powerpc__) && !defined(__powerpc64__)) static long long _div64 (long long u, long long v); static long long _mod64 (long long u, long long v); #endif @@ -114,7 +115,8 @@ static int _stp_random_pm (unsigned n) -#if defined (__i386__) || defined (__arm__) +#if defined (__i386__) || defined (__arm__) || \ + (defined(__powerpc__) && !defined(__powerpc64__)) /* 64-bit division functions extracted from libgcc */ typedef long long DWtype; @@ -181,6 +183,40 @@ typedef union (count) = __cbtmp ^ 31; \ } while (0) +#elif defined (__powerpc__) +/* these are the ppc versions of these macros from gcc/longlong.h */ + +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ + do { \ + if (__builtin_constant_p (ah) && (ah) == 0) \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \ + : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ + else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0) \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \ + : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ + else if (__builtin_constant_p (bh) && (bh) == 0) \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \ + : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ + else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \ + : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ + else \ + __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \ + : "=r" (sh), "=&r" (sl) \ + : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \ + } while (0) + +#define count_leading_zeros(count, x) \ + __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x)) +#define COUNT_LEADING_ZEROS_0 32 + +#define umul_ppmm(ph, pl, m0, m1) \ + do { \ + USItype __m0 = (m0), __m1 = (m1); \ + __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \ + (pl) = __m0 * __m1; \ + } while (0) + #elif defined (__arm__) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ @@ -548,6 +584,6 @@ static long long _mod64 (long long u, long long v) return w; } -#endif /* __i386__ || __arm__ */ +#endif /* __i386__ || __arm__ || (__powerpc__ && !__powerpc64__) */ #endif /* _ARITH_C_ */ -- cgit From 5f4fd35709b9b3e94873c6e38c574066c470a9e3 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Sat, 28 Nov 2009 01:33:51 +0300 Subject: Change KERNEL_RELOC_SYMBOL to "_stext" on ppc32 Currently staprun fails at send_relocation_kernel(), this is because ppc32 doesn't have ".__start" symbol. I think we should use _stext, just as other arches. Signed-off-by: Anton Vorontsov --- runtime/staprun/staprun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/staprun/staprun.c b/runtime/staprun/staprun.c index 078be4cf..5bd5163a 100644 --- a/runtime/staprun/staprun.c +++ b/runtime/staprun/staprun.c @@ -372,7 +372,7 @@ int send_relocation_kernel () free (line); line=NULL; if (symbol == NULL) continue; /* OOM? */ -#ifdef __powerpc__ +#ifdef __powerpc64__ #define KERNEL_RELOC_SYMBOL ".__start" #else #define KERNEL_RELOC_SYMBOL "_stext" -- cgit From 98c783852039061db8c1611742660aaded0eab77 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Sat, 28 Nov 2009 01:33:47 +0300 Subject: Use proper types for do_div do_div accepts unsigned 64-bit integer type for dividend, signed types would cause do_div's typecheck fail: stat-common.c: In function 'needed_space': stat-common.c:50: error: comparison of distinct pointer types lacks a cast ...same errors in time.c and tapset-timers.cxx's generated code... A fix for time.c is special, on ppc32 cycles_t is 32-bit, so technically we don't need do_div, but since the whole _stp_gettimeofday_ns() operates on 64-bit types we'd better be safe and use uint64_t for the math. Signed-off-by: Anton Vorontsov --- runtime/stat-common.c | 8 ++++---- runtime/time.c | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/stat-common.c b/runtime/stat-common.c index 7123dc8e..f9703049 100644 --- a/runtime/stat-common.c +++ b/runtime/stat-common.c @@ -34,7 +34,7 @@ static int _stp_stat_calc_buckets(int stop, int start, int interval) return buckets; } -static int needed_space(int64_t v) +static int needed_space(uint64_t v) { int space = 0; @@ -134,7 +134,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat { int scale, i, j, val_space, cnt_space; int low_bucket = -1, high_bucket = 0, over = 0, under = 0; - int64_t val, v, valmax = 0; + uint64_t val, v, valmax = 0; int eliding = 0; char *cur_buf = buf, *fake = buf; char **bufptr = (buf == NULL ? &fake : &cur_buf); @@ -186,7 +186,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat if (valmax <= HIST_WIDTH) scale = 1; else { - int64_t tmp = valmax; + uint64_t tmp = valmax; int rem = do_div(tmp, HIST_WIDTH); scale = tmp; if (rem) scale++; @@ -282,7 +282,7 @@ static void _stp_stat_print_histogram(Hist st, stat *sd) _stp_print_flush(); } -static void __stp_stat_add (Hist st, stat *sd, int64_t val) +static void __stp_stat_add (Hist st, stat *sd, uint64_t val) { int n; if (sd->count == 0) { diff --git a/runtime/time.c b/runtime/time.c index 58c23e57..d588370f 100644 --- a/runtime/time.c +++ b/runtime/time.c @@ -275,7 +275,8 @@ static int64_t _stp_gettimeofday_ns(void) { int64_t base; - cycles_t last, delta; + cycles_t last; + uint64_t delta; unsigned int freq; unsigned int seq; stp_time_t *time; -- cgit From 89a75eb6a5a6dc345a718ffbd119651222686026 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 30 Nov 2009 16:29:29 -0500 Subject: uprobes ppc64: UPROBES_DEBUG build fix * runtime/uprobes/uprobes_ppc.c (calc_offset): Fix printk types. --- runtime/uprobes/uprobes_ppc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/uprobes/uprobes_ppc.c b/runtime/uprobes/uprobes_ppc.c index 819ac73d..b625b879 100644 --- a/runtime/uprobes/uprobes_ppc.c +++ b/runtime/uprobes/uprobes_ppc.c @@ -89,9 +89,9 @@ static inline void calc_offset(struct uprobe_probept *ppt, } #ifdef UPROBES_DEBUG printk (KERN_ERR "ppt->vaddr=%p, regs->nip=%p, offset=%ld\n", - ppt->vaddr, regs->nip, offset); + (void*)(long)ppt->vaddr, (void*)(long)regs->nip, (long)offset); if (insn & 1) - printk (KERN_ERR "regs->link=%p \n", regs->link); + printk (KERN_ERR "regs->link=%p \n", (void*)(long)regs->link); #endif return; } -- cgit From 8c859ce37271f35d0b93cd40f121af7b04621238 Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Tue, 1 Dec 2009 15:10:06 -0500 Subject: Make sure system types are defined. --- runtime/staprun/modverify.c | 7 ++++--- runtime/staprun/staprun_funcs.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/staprun/modverify.c b/runtime/staprun/modverify.c index 514f09f0..6f2687bb 100644 --- a/runtime/staprun/modverify.c +++ b/runtime/staprun/modverify.c @@ -28,13 +28,14 @@ #include #include +#include +#include +#include + #include "nsscommon.h" #include "staprun.h" #include "modverify.h" -#include -#include - /* Function: int check_cert_db_permissions (const char *cert_db_path); * * Check that the given certificate directory and its contents have diff --git a/runtime/staprun/staprun_funcs.c b/runtime/staprun/staprun_funcs.c index 26e8c663..9d623c02 100644 --- a/runtime/staprun/staprun_funcs.c +++ b/runtime/staprun/staprun_funcs.c @@ -11,8 +11,6 @@ */ #include "config.h" -#include "staprun.h" -#include "modverify.h" #include #include @@ -20,6 +18,9 @@ #include #include +#include "staprun.h" +#include "modverify.h" + typedef int (*check_module_path_func)(const char *module_path, int module_fd); extern long init_module(void *, unsigned long, const char *); -- cgit From 8d9d8fe1e78b91140f41bdd71351dbea007d70ec Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Tue, 1 Dec 2009 16:43:53 -0500 Subject: Regenerate autotools files using autoreconf to pick up latest Makefile.am changes. --- runtime/staprun/modverify.c | 4 +++- runtime/staprun/staprun_funcs.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/staprun/modverify.c b/runtime/staprun/modverify.c index 6f2687bb..4ed5eb74 100644 --- a/runtime/staprun/modverify.c +++ b/runtime/staprun/modverify.c @@ -19,6 +19,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" +#include "staprun.h" + #include #include @@ -33,7 +36,6 @@ #include #include "nsscommon.h" -#include "staprun.h" #include "modverify.h" /* Function: int check_cert_db_permissions (const char *cert_db_path); diff --git a/runtime/staprun/staprun_funcs.c b/runtime/staprun/staprun_funcs.c index 9d623c02..db58cd4f 100644 --- a/runtime/staprun/staprun_funcs.c +++ b/runtime/staprun/staprun_funcs.c @@ -11,6 +11,7 @@ */ #include "config.h" +#include "staprun.h" #include #include @@ -18,7 +19,6 @@ #include #include -#include "staprun.h" #include "modverify.h" typedef int (*check_module_path_func)(const char *module_path, int module_fd); -- cgit