diff options
Diffstat (limited to 'arch/arm')
| -rw-r--r-- | arch/arm/Kconfig | 5 | ||||
| -rw-r--r-- | arch/arm/mach-s3c2410/irq.c | 7 | ||||
| -rw-r--r-- | arch/arm/oprofile/Makefile | 2 | ||||
| -rw-r--r-- | arch/arm/oprofile/backtrace.c | 144 | ||||
| -rw-r--r-- | arch/arm/oprofile/init.c | 2 | ||||
| -rw-r--r-- | arch/arm/oprofile/op_arm_model.h | 2 |
6 files changed, 158 insertions, 4 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index c8d94dcd8ef7..620f2ca94ed2 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -361,6 +361,11 @@ config NO_IDLE_HZ | |||
| 361 | Alternatively, if you want dynamic tick automatically enabled | 361 | Alternatively, if you want dynamic tick automatically enabled |
| 362 | during boot, pass "dyntick=enable" via the kernel command string. | 362 | during boot, pass "dyntick=enable" via the kernel command string. |
| 363 | 363 | ||
| 364 | Please note that dynamic tick may affect the accuracy of | ||
| 365 | timekeeping on some platforms depending on the implementation. | ||
| 366 | Currently at least OMAP platform is known to have accurate | ||
| 367 | timekeeping with dynamic tick. | ||
| 368 | |||
| 364 | config ARCH_DISCONTIGMEM_ENABLE | 369 | config ARCH_DISCONTIGMEM_ENABLE |
| 365 | bool | 370 | bool |
| 366 | default (ARCH_LH7A40X && !LH7A40X_CONTIGMEM) | 371 | default (ARCH_LH7A40X && !LH7A40X_CONTIGMEM) |
diff --git a/arch/arm/mach-s3c2410/irq.c b/arch/arm/mach-s3c2410/irq.c index b668c48f4399..cf9f46d88061 100644 --- a/arch/arm/mach-s3c2410/irq.c +++ b/arch/arm/mach-s3c2410/irq.c | |||
| @@ -40,8 +40,11 @@ | |||
| 40 | * 04-Nov-2004 Ben Dooks | 40 | * 04-Nov-2004 Ben Dooks |
| 41 | * Fix standard IRQ wake for EINT0..4 and RTC | 41 | * Fix standard IRQ wake for EINT0..4 and RTC |
| 42 | * | 42 | * |
| 43 | * 22-Feb-2004 Ben Dooks | 43 | * 22-Feb-2005 Ben Dooks |
| 44 | * Fixed edge-triggering on ADC IRQ | 44 | * Fixed edge-triggering on ADC IRQ |
| 45 | * | ||
| 46 | * 28-Jun-2005 Ben Dooks | ||
| 47 | * Mark IRQ_LCD valid | ||
| 45 | */ | 48 | */ |
| 46 | 49 | ||
| 47 | #include <linux/init.h> | 50 | #include <linux/init.h> |
| @@ -366,7 +369,6 @@ static struct irqchip s3c_irq_eint0t4 = { | |||
| 366 | #define INTMSK_UART1 (1UL << (IRQ_UART1 - IRQ_EINT0)) | 369 | #define INTMSK_UART1 (1UL << (IRQ_UART1 - IRQ_EINT0)) |
| 367 | #define INTMSK_UART2 (1UL << (IRQ_UART2 - IRQ_EINT0)) | 370 | #define INTMSK_UART2 (1UL << (IRQ_UART2 - IRQ_EINT0)) |
| 368 | #define INTMSK_ADCPARENT (1UL << (IRQ_ADCPARENT - IRQ_EINT0)) | 371 | #define INTMSK_ADCPARENT (1UL << (IRQ_ADCPARENT - IRQ_EINT0)) |
| 369 | #define INTMSK_LCD (1UL << (IRQ_LCD - IRQ_EINT0)) | ||
| 370 | 372 | ||
| 371 | static inline void | 373 | static inline void |
| 372 | s3c_irqsub_mask(unsigned int irqno, unsigned int parentbit, | 374 | s3c_irqsub_mask(unsigned int irqno, unsigned int parentbit, |
| @@ -716,7 +718,6 @@ void __init s3c24xx_init_irq(void) | |||
| 716 | case IRQ_UART0: | 718 | case IRQ_UART0: |
| 717 | case IRQ_UART1: | 719 | case IRQ_UART1: |
| 718 | case IRQ_UART2: | 720 | case IRQ_UART2: |
| 719 | case IRQ_LCD: | ||
| 720 | case IRQ_ADCPARENT: | 721 | case IRQ_ADCPARENT: |
| 721 | set_irq_chip(irqno, &s3c_irq_level_chip); | 722 | set_irq_chip(irqno, &s3c_irq_level_chip); |
| 722 | set_irq_handler(irqno, do_level_IRQ); | 723 | set_irq_handler(irqno, do_level_IRQ); |
diff --git a/arch/arm/oprofile/Makefile b/arch/arm/oprofile/Makefile index ba1a6e9f2b28..8ffb523e6c77 100644 --- a/arch/arm/oprofile/Makefile +++ b/arch/arm/oprofile/Makefile | |||
| @@ -6,6 +6,6 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ | |||
| 6 | oprofilefs.o oprofile_stats.o \ | 6 | oprofilefs.o oprofile_stats.o \ |
| 7 | timer_int.o ) | 7 | timer_int.o ) |
| 8 | 8 | ||
| 9 | oprofile-y := $(DRIVER_OBJS) init.o | 9 | oprofile-y := $(DRIVER_OBJS) init.o backtrace.o |
| 10 | oprofile-$(CONFIG_CPU_XSCALE) += common.o op_model_xscale.o | 10 | oprofile-$(CONFIG_CPU_XSCALE) += common.o op_model_xscale.o |
| 11 | 11 | ||
diff --git a/arch/arm/oprofile/backtrace.c b/arch/arm/oprofile/backtrace.c new file mode 100644 index 000000000000..ec58d3e2eb8b --- /dev/null +++ b/arch/arm/oprofile/backtrace.c | |||
| @@ -0,0 +1,144 @@ | |||
| 1 | /* | ||
| 2 | * Arm specific backtracing code for oprofile | ||
| 3 | * | ||
| 4 | * Copyright 2005 Openedhand Ltd. | ||
| 5 | * | ||
| 6 | * Author: Richard Purdie <rpurdie@openedhand.com> | ||
| 7 | * | ||
| 8 | * Based on i386 oprofile backtrace code by John Levon, David Smith | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License version 2 as | ||
| 12 | * published by the Free Software Foundation. | ||
| 13 | * | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include <linux/oprofile.h> | ||
| 17 | #include <linux/sched.h> | ||
| 18 | #include <linux/mm.h> | ||
| 19 | #include <asm/ptrace.h> | ||
| 20 | #include <asm/uaccess.h> | ||
| 21 | |||
| 22 | |||
| 23 | /* | ||
| 24 | * The registers we're interested in are at the end of the variable | ||
| 25 | * length saved register structure. The fp points at the end of this | ||
| 26 | * structure so the address of this struct is: | ||
| 27 | * (struct frame_tail *)(xxx->fp)-1 | ||
| 28 | */ | ||
| 29 | struct frame_tail { | ||
| 30 | struct frame_tail *fp; | ||
| 31 | unsigned long sp; | ||
| 32 | unsigned long lr; | ||
| 33 | } __attribute__((packed)); | ||
| 34 | |||
| 35 | |||
| 36 | #ifdef CONFIG_FRAME_POINTER | ||
| 37 | static struct frame_tail* kernel_backtrace(struct frame_tail *tail) | ||
| 38 | { | ||
| 39 | oprofile_add_trace(tail->lr); | ||
| 40 | |||
| 41 | /* frame pointers should strictly progress back up the stack | ||
| 42 | * (towards higher addresses) */ | ||
| 43 | if (tail >= tail->fp) | ||
| 44 | return NULL; | ||
| 45 | |||
| 46 | return tail->fp-1; | ||
| 47 | } | ||
| 48 | #endif | ||
| 49 | |||
| 50 | static struct frame_tail* user_backtrace(struct frame_tail *tail) | ||
| 51 | { | ||
| 52 | struct frame_tail buftail; | ||
| 53 | |||
| 54 | /* hardware pte might not be valid due to dirty/accessed bit emulation | ||
| 55 | * so we use copy_from_user and benefit from exception fixups */ | ||
| 56 | if (copy_from_user(&buftail, tail, sizeof(struct frame_tail))) | ||
| 57 | return NULL; | ||
| 58 | |||
| 59 | oprofile_add_trace(buftail.lr); | ||
| 60 | |||
| 61 | /* frame pointers should strictly progress back up the stack | ||
| 62 | * (towards higher addresses) */ | ||
| 63 | if (tail >= buftail.fp) | ||
| 64 | return NULL; | ||
| 65 | |||
| 66 | return buftail.fp-1; | ||
| 67 | } | ||
| 68 | |||
| 69 | /* Compare two addresses and see if they're on the same page */ | ||
| 70 | #define CMP_ADDR_EQUAL(x,y,offset) ((((unsigned long) x) >> PAGE_SHIFT) \ | ||
| 71 | == ((((unsigned long) y) + offset) >> PAGE_SHIFT)) | ||
| 72 | |||
| 73 | /* check that the page(s) containing the frame tail are present */ | ||
| 74 | static int pages_present(struct frame_tail *tail) | ||
| 75 | { | ||
| 76 | struct mm_struct * mm = current->mm; | ||
| 77 | |||
| 78 | if (!check_user_page_readable(mm, (unsigned long)tail)) | ||
| 79 | return 0; | ||
| 80 | |||
| 81 | if (CMP_ADDR_EQUAL(tail, tail, 8)) | ||
| 82 | return 1; | ||
| 83 | |||
| 84 | if (!check_user_page_readable(mm, ((unsigned long)tail) + 8)) | ||
| 85 | return 0; | ||
| 86 | |||
| 87 | return 1; | ||
| 88 | } | ||
| 89 | |||
| 90 | /* | ||
| 91 | * | | /\ Higher addresses | ||
| 92 | * | | | ||
| 93 | * --------------- stack base (address of current_thread_info) | ||
| 94 | * | thread info | | ||
| 95 | * . . | ||
| 96 | * | stack | | ||
| 97 | * --------------- saved regs->ARM_fp value if valid (frame_tail address) | ||
| 98 | * . . | ||
| 99 | * --------------- struct pt_regs stored on stack (struct pt_regs *) | ||
| 100 | * | | | ||
| 101 | * . . | ||
| 102 | * | | | ||
| 103 | * --------------- %esp | ||
| 104 | * | | | ||
| 105 | * | | \/ Lower addresses | ||
| 106 | * | ||
| 107 | * Thus, &pt_regs <-> stack base restricts the valid(ish) fp values | ||
| 108 | */ | ||
| 109 | static int valid_kernel_stack(struct frame_tail *tail, struct pt_regs *regs) | ||
| 110 | { | ||
| 111 | unsigned long tailaddr = (unsigned long)tail; | ||
| 112 | unsigned long stack = (unsigned long)regs; | ||
| 113 | unsigned long stack_base = (stack & ~(THREAD_SIZE - 1)) + THREAD_SIZE; | ||
| 114 | |||
| 115 | return (tailaddr > stack) && (tailaddr < stack_base); | ||
| 116 | } | ||
| 117 | |||
| 118 | void arm_backtrace(struct pt_regs const *regs, unsigned int depth) | ||
| 119 | { | ||
| 120 | struct frame_tail *tail; | ||
| 121 | unsigned long last_address = 0; | ||
| 122 | |||
| 123 | tail = ((struct frame_tail *) regs->ARM_fp) - 1; | ||
| 124 | |||
| 125 | if (!user_mode(regs)) { | ||
| 126 | |||
| 127 | #ifdef CONFIG_FRAME_POINTER | ||
| 128 | while (depth-- && tail && valid_kernel_stack(tail, regs)) { | ||
| 129 | tail = kernel_backtrace(tail); | ||
| 130 | } | ||
| 131 | #endif | ||
| 132 | return; | ||
| 133 | } | ||
| 134 | |||
| 135 | while (depth-- && tail && !((unsigned long) tail & 3)) { | ||
| 136 | if ((!CMP_ADDR_EQUAL(last_address, tail, 0) | ||
| 137 | || !CMP_ADDR_EQUAL(last_address, tail, 8)) | ||
| 138 | && !pages_present(tail)) | ||
| 139 | return; | ||
| 140 | last_address = (unsigned long) tail; | ||
| 141 | tail = user_backtrace(tail); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
diff --git a/arch/arm/oprofile/init.c b/arch/arm/oprofile/init.c index cce3d3015eb7..d315a3a86c86 100644 --- a/arch/arm/oprofile/init.c +++ b/arch/arm/oprofile/init.c | |||
| @@ -20,6 +20,8 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) | |||
| 20 | ret = pmu_init(ops, &op_xscale_spec); | 20 | ret = pmu_init(ops, &op_xscale_spec); |
| 21 | #endif | 21 | #endif |
| 22 | 22 | ||
| 23 | ops->backtrace = arm_backtrace; | ||
| 24 | |||
| 23 | return ret; | 25 | return ret; |
| 24 | } | 26 | } |
| 25 | 27 | ||
diff --git a/arch/arm/oprofile/op_arm_model.h b/arch/arm/oprofile/op_arm_model.h index 2d4caf4781ad..2148d07484b7 100644 --- a/arch/arm/oprofile/op_arm_model.h +++ b/arch/arm/oprofile/op_arm_model.h | |||
| @@ -24,6 +24,8 @@ struct op_arm_model_spec { | |||
| 24 | extern struct op_arm_model_spec op_xscale_spec; | 24 | extern struct op_arm_model_spec op_xscale_spec; |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | extern void arm_backtrace(struct pt_regs * const regs, unsigned int depth); | ||
| 28 | |||
| 27 | extern int __init pmu_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec); | 29 | extern int __init pmu_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec); |
| 28 | extern void pmu_exit(void); | 30 | extern void pmu_exit(void); |
| 29 | #endif /* OP_ARM_MODEL_H */ | 31 | #endif /* OP_ARM_MODEL_H */ |
