diff options
Diffstat (limited to 'meta-beagleboard-extras')
3 files changed, 294 insertions, 0 deletions
diff --git a/meta-beagleboard-extras/recipes/linux/linux-mainline/ARM-perf-add-support-for-perf-registers-API.diff b/meta-beagleboard-extras/recipes/linux/linux-mainline/ARM-perf-add-support-for-perf-registers-API.diff new file mode 100644 index 0000000..13b251a --- /dev/null +++ b/meta-beagleboard-extras/recipes/linux/linux-mainline/ARM-perf-add-support-for-perf-registers-API.diff | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | From 8221f36672b7a1336c2bf245c394f0b5453784a1 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Will Deacon <will.deacon@arm.com> | ||
| 3 | Date: Thu, 26 Sep 2013 12:36:35 +0100 | ||
| 4 | Subject: [PATCH] ARM: perf: add support for perf registers API | ||
| 5 | |||
| 6 | This patch implements the functions required for the perf registers API, | ||
| 7 | allowing the perf tool to interface kernel register dumps with libunwind | ||
| 8 | in order to provide userspace backtracing. | ||
| 9 | |||
| 10 | B2Qt: Backported for 3.8 kernel | ||
| 11 | |||
| 12 | Cc: Jean Pihet <jean.pihet@linaro.org> | ||
| 13 | Signed-off-by: Will Deacon <will.deacon@arm.com> | ||
| 14 | --- | ||
| 15 | arch/arm/Kconfig | 2 ++ | ||
| 16 | arch/arm/include/uapi/asm/Kbuild | 1 + | ||
| 17 | arch/arm/include/uapi/asm/perf_regs.h | 23 +++++++++++++++++++++++ | ||
| 18 | arch/arm/kernel/Makefile | 1 + | ||
| 19 | arch/arm/kernel/perf_regs.c | 30 ++++++++++++++++++++++++++++++ | ||
| 20 | 5 files changed, 57 insertions(+) | ||
| 21 | create mode 100644 arch/arm/include/uapi/asm/perf_regs.h | ||
| 22 | create mode 100644 arch/arm/kernel/perf_regs.c | ||
| 23 | |||
| 24 | diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig | ||
| 25 | index 67874b8..6f630be 100644 | ||
| 26 | --- a/arch/arm/Kconfig | ||
| 27 | +++ b/arch/arm/Kconfig | ||
| 28 | @@ -46,6 +46,8 @@ config ARM | ||
| 29 | select HAVE_MEMBLOCK | ||
| 30 | select HAVE_OPROFILE if (HAVE_PERF_EVENTS) | ||
| 31 | select HAVE_PERF_EVENTS | ||
| 32 | + select HAVE_PERF_REGS | ||
| 33 | + select HAVE_PERF_USER_STACK_DUMP | ||
| 34 | select HAVE_REGS_AND_STACK_ACCESS_API | ||
| 35 | select HAVE_SYSCALL_TRACEPOINTS | ||
| 36 | select HAVE_UID16 | ||
| 37 | diff --git a/arch/arm/include/uapi/asm/Kbuild b/arch/arm/include/uapi/asm/Kbuild | ||
| 38 | index 47bcb2d..570b82f 100644 | ||
| 39 | --- a/arch/arm/include/uapi/asm/Kbuild | ||
| 40 | +++ b/arch/arm/include/uapi/asm/Kbuild | ||
| 41 | @@ -8,6 +8,7 @@ header-y += hwcap.h | ||
| 42 | header-y += ioctls.h | ||
| 43 | header-y += kvm_para.h | ||
| 44 | header-y += mman.h | ||
| 45 | +header-y += perf_regs.h | ||
| 46 | header-y += posix_types.h | ||
| 47 | header-y += ptrace.h | ||
| 48 | header-y += setup.h | ||
| 49 | diff --git a/arch/arm/include/uapi/asm/perf_regs.h b/arch/arm/include/uapi/asm/perf_regs.h | ||
| 50 | new file mode 100644 | ||
| 51 | index 0000000..ce59448 | ||
| 52 | --- /dev/null | ||
| 53 | +++ b/arch/arm/include/uapi/asm/perf_regs.h | ||
| 54 | @@ -0,0 +1,23 @@ | ||
| 55 | +#ifndef _ASM_ARM_PERF_REGS_H | ||
| 56 | +#define _ASM_ARM_PERF_REGS_H | ||
| 57 | + | ||
| 58 | +enum perf_event_arm_regs { | ||
| 59 | + PERF_REG_ARM_R0, | ||
| 60 | + PERF_REG_ARM_R1, | ||
| 61 | + PERF_REG_ARM_R2, | ||
| 62 | + PERF_REG_ARM_R3, | ||
| 63 | + PERF_REG_ARM_R4, | ||
| 64 | + PERF_REG_ARM_R5, | ||
| 65 | + PERF_REG_ARM_R6, | ||
| 66 | + PERF_REG_ARM_R7, | ||
| 67 | + PERF_REG_ARM_R8, | ||
| 68 | + PERF_REG_ARM_R9, | ||
| 69 | + PERF_REG_ARM_R10, | ||
| 70 | + PERF_REG_ARM_FP, | ||
| 71 | + PERF_REG_ARM_IP, | ||
| 72 | + PERF_REG_ARM_SP, | ||
| 73 | + PERF_REG_ARM_LR, | ||
| 74 | + PERF_REG_ARM_PC, | ||
| 75 | + PERF_REG_ARM_MAX, | ||
| 76 | +}; | ||
| 77 | +#endif /* _ASM_ARM_PERF_REGS_H */ | ||
| 78 | diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile | ||
| 79 | index 5bbec7b..c6ab18f 100644 | ||
| 80 | --- a/arch/arm/kernel/Makefile | ||
| 81 | +++ b/arch/arm/kernel/Makefile | ||
| 82 | @@ -69,6 +69,7 @@ obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o | ||
| 83 | obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o | ||
| 84 | obj-$(CONFIG_CPU_PJ4) += pj4-cp0.o | ||
| 85 | obj-$(CONFIG_IWMMXT) += iwmmxt.o | ||
| 86 | +obj-$(CONFIG_PERF_EVENTS) += perf_regs.o | ||
| 87 | obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o perf_event_cpu.o | ||
| 88 | AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt | ||
| 89 | obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o | ||
| 90 | diff --git a/arch/arm/kernel/perf_regs.c b/arch/arm/kernel/perf_regs.c | ||
| 91 | new file mode 100644 | ||
| 92 | index 0000000..6e4379c | ||
| 93 | --- /dev/null | ||
| 94 | +++ b/arch/arm/kernel/perf_regs.c | ||
| 95 | @@ -0,0 +1,30 @@ | ||
| 96 | + | ||
| 97 | +#include <linux/errno.h> | ||
| 98 | +#include <linux/kernel.h> | ||
| 99 | +#include <linux/perf_event.h> | ||
| 100 | +#include <linux/bug.h> | ||
| 101 | +#include <asm/perf_regs.h> | ||
| 102 | +#include <asm/ptrace.h> | ||
| 103 | + | ||
| 104 | +u64 perf_reg_value(struct pt_regs *regs, int idx) | ||
| 105 | +{ | ||
| 106 | + if (WARN_ON_ONCE((u32)idx >= PERF_REG_ARM_MAX)) | ||
| 107 | + return 0; | ||
| 108 | + | ||
| 109 | + return regs->uregs[idx]; | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +#define REG_RESERVED (~((1ULL << PERF_REG_ARM_MAX) - 1)) | ||
| 113 | + | ||
| 114 | +int perf_reg_validate(u64 mask) | ||
| 115 | +{ | ||
| 116 | + if (!mask || mask & REG_RESERVED) | ||
| 117 | + return -EINVAL; | ||
| 118 | + | ||
| 119 | + return 0; | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +u64 perf_reg_abi(struct task_struct *task) | ||
| 123 | +{ | ||
| 124 | + return PERF_SAMPLE_REGS_ABI_32; | ||
| 125 | +} | ||
| 126 | -- | ||
| 127 | 1.9.1 | ||
| 128 | |||
diff --git a/meta-beagleboard-extras/recipes/linux/linux-mainline/ARM-perf-wire-up-perf_regs-and-unwind-support-for-AR.patch b/meta-beagleboard-extras/recipes/linux/linux-mainline/ARM-perf-wire-up-perf_regs-and-unwind-support-for-AR.patch new file mode 100644 index 0000000..e3e8d21 --- /dev/null +++ b/meta-beagleboard-extras/recipes/linux/linux-mainline/ARM-perf-wire-up-perf_regs-and-unwind-support-for-AR.patch | |||
| @@ -0,0 +1,163 @@ | |||
| 1 | From 26f603c457e0af9f5f6a0ddda66e69978c7f43b4 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Will Deacon <will.deacon@arm.com> | ||
| 3 | Date: Thu, 26 Sep 2013 12:36:36 +0100 | ||
| 4 | Subject: [PATCH] ARM: perf: wire up perf_regs and unwind support for ARM | ||
| 5 | |||
| 6 | This patch hooks in the perf_regs and libunwind code for ARM. | ||
| 7 | |||
| 8 | B2Qt: Backported for 3.8 kernel | ||
| 9 | |||
| 10 | Cc: Jean Pihet <jean.pihet@linaro.org> | ||
| 11 | Signed-off-by: Will Deacon <will.deacon@arm.com> | ||
| 12 | --- | ||
| 13 | tools/perf/Makefile | 4 +++ | ||
| 14 | tools/perf/arch/arm/Makefile | 3 ++ | ||
| 15 | tools/perf/arch/arm/include/perf_regs.h | 54 +++++++++++++++++++++++++++++++++ | ||
| 16 | tools/perf/arch/arm/util/unwind.c | 48 +++++++++++++++++++++++++++++ | ||
| 17 | 4 files changed, 109 insertions(+) | ||
| 18 | create mode 100644 tools/perf/arch/arm/include/perf_regs.h | ||
| 19 | create mode 100644 tools/perf/arch/arm/util/unwind.c | ||
| 20 | |||
| 21 | diff --git a/tools/perf/Makefile b/tools/perf/Makefile | ||
| 22 | index fb1b1c4..316c575 100644 | ||
| 23 | --- a/tools/perf/Makefile | ||
| 24 | +++ b/tools/perf/Makefile | ||
| 25 | @@ -84,6 +84,10 @@ ifeq ($(ARCH),x86_64) | ||
| 26 | NO_PERF_REGS := 0 | ||
| 27 | LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 | ||
| 28 | endif | ||
| 29 | +ifeq ($(ARCH),arm) | ||
| 30 | + NO_PERF_REGS := 0 | ||
| 31 | + LIBUNWIND_LIBS = -lunwind -lunwind-arm | ||
| 32 | +endif | ||
| 33 | |||
| 34 | # Treat warnings as errors unless directed not to | ||
| 35 | ifneq ($(WERROR),0) | ||
| 36 | diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile | ||
| 37 | index 15130b5..fe9b61e 100644 | ||
| 38 | --- a/tools/perf/arch/arm/Makefile | ||
| 39 | +++ b/tools/perf/arch/arm/Makefile | ||
| 40 | @@ -2,3 +2,6 @@ ifndef NO_DWARF | ||
| 41 | PERF_HAVE_DWARF_REGS := 1 | ||
| 42 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o | ||
| 43 | endif | ||
| 44 | +ifndef NO_LIBUNWIND | ||
| 45 | +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o | ||
| 46 | +endif | ||
| 47 | diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h | ||
| 48 | new file mode 100644 | ||
| 49 | index 0000000..2a1cfde | ||
| 50 | --- /dev/null | ||
| 51 | +++ b/tools/perf/arch/arm/include/perf_regs.h | ||
| 52 | @@ -0,0 +1,54 @@ | ||
| 53 | +#ifndef ARCH_PERF_REGS_H | ||
| 54 | +#define ARCH_PERF_REGS_H | ||
| 55 | + | ||
| 56 | +#include <stdlib.h> | ||
| 57 | +#include "../../util/types.h" | ||
| 58 | +#include <asm/perf_regs.h> | ||
| 59 | + | ||
| 60 | +#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1) | ||
| 61 | +#define PERF_REG_IP PERF_REG_ARM_PC | ||
| 62 | +#define PERF_REG_SP PERF_REG_ARM_SP | ||
| 63 | + | ||
| 64 | +static inline const char *perf_reg_name(int id) | ||
| 65 | +{ | ||
| 66 | + switch (id) { | ||
| 67 | + case PERF_REG_ARM_R0: | ||
| 68 | + return "r0"; | ||
| 69 | + case PERF_REG_ARM_R1: | ||
| 70 | + return "r1"; | ||
| 71 | + case PERF_REG_ARM_R2: | ||
| 72 | + return "r2"; | ||
| 73 | + case PERF_REG_ARM_R3: | ||
| 74 | + return "r3"; | ||
| 75 | + case PERF_REG_ARM_R4: | ||
| 76 | + return "r4"; | ||
| 77 | + case PERF_REG_ARM_R5: | ||
| 78 | + return "r5"; | ||
| 79 | + case PERF_REG_ARM_R6: | ||
| 80 | + return "r6"; | ||
| 81 | + case PERF_REG_ARM_R7: | ||
| 82 | + return "r7"; | ||
| 83 | + case PERF_REG_ARM_R8: | ||
| 84 | + return "r8"; | ||
| 85 | + case PERF_REG_ARM_R9: | ||
| 86 | + return "r9"; | ||
| 87 | + case PERF_REG_ARM_R10: | ||
| 88 | + return "r10"; | ||
| 89 | + case PERF_REG_ARM_FP: | ||
| 90 | + return "fp"; | ||
| 91 | + case PERF_REG_ARM_IP: | ||
| 92 | + return "ip"; | ||
| 93 | + case PERF_REG_ARM_SP: | ||
| 94 | + return "sp"; | ||
| 95 | + case PERF_REG_ARM_LR: | ||
| 96 | + return "lr"; | ||
| 97 | + case PERF_REG_ARM_PC: | ||
| 98 | + return "pc"; | ||
| 99 | + default: | ||
| 100 | + return NULL; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + return NULL; | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +#endif /* ARCH_PERF_REGS_H */ | ||
| 107 | diff --git a/tools/perf/arch/arm/util/unwind.c b/tools/perf/arch/arm/util/unwind.c | ||
| 108 | new file mode 100644 | ||
| 109 | index 0000000..da3dc95 | ||
| 110 | --- /dev/null | ||
| 111 | +++ b/tools/perf/arch/arm/util/unwind.c | ||
| 112 | @@ -0,0 +1,48 @@ | ||
| 113 | + | ||
| 114 | +#include <errno.h> | ||
| 115 | +#include <libunwind.h> | ||
| 116 | +#include "perf_regs.h" | ||
| 117 | +#include "../../util/unwind.h" | ||
| 118 | + | ||
| 119 | +int unwind__arch_reg_id(int regnum) | ||
| 120 | +{ | ||
| 121 | + switch (regnum) { | ||
| 122 | + case UNW_ARM_R0: | ||
| 123 | + return PERF_REG_ARM_R0; | ||
| 124 | + case UNW_ARM_R1: | ||
| 125 | + return PERF_REG_ARM_R1; | ||
| 126 | + case UNW_ARM_R2: | ||
| 127 | + return PERF_REG_ARM_R2; | ||
| 128 | + case UNW_ARM_R3: | ||
| 129 | + return PERF_REG_ARM_R3; | ||
| 130 | + case UNW_ARM_R4: | ||
| 131 | + return PERF_REG_ARM_R4; | ||
| 132 | + case UNW_ARM_R5: | ||
| 133 | + return PERF_REG_ARM_R5; | ||
| 134 | + case UNW_ARM_R6: | ||
| 135 | + return PERF_REG_ARM_R6; | ||
| 136 | + case UNW_ARM_R7: | ||
| 137 | + return PERF_REG_ARM_R7; | ||
| 138 | + case UNW_ARM_R8: | ||
| 139 | + return PERF_REG_ARM_R8; | ||
| 140 | + case UNW_ARM_R9: | ||
| 141 | + return PERF_REG_ARM_R9; | ||
| 142 | + case UNW_ARM_R10: | ||
| 143 | + return PERF_REG_ARM_R10; | ||
| 144 | + case UNW_ARM_R11: | ||
| 145 | + return PERF_REG_ARM_FP; | ||
| 146 | + case UNW_ARM_R12: | ||
| 147 | + return PERF_REG_ARM_IP; | ||
| 148 | + case UNW_ARM_R13: | ||
| 149 | + return PERF_REG_ARM_SP; | ||
| 150 | + case UNW_ARM_R14: | ||
| 151 | + return PERF_REG_ARM_LR; | ||
| 152 | + case UNW_ARM_R15: | ||
| 153 | + return PERF_REG_ARM_PC; | ||
| 154 | + default: | ||
| 155 | + pr_err("unwind: invalid reg id %d\n", regnum); | ||
| 156 | + return -EINVAL; | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + return -EINVAL; | ||
| 160 | +} | ||
| 161 | -- | ||
| 162 | 1.9.1 | ||
| 163 | |||
diff --git a/meta-beagleboard-extras/recipes/linux/linux-mainline_3.8.bbappend b/meta-beagleboard-extras/recipes/linux/linux-mainline_3.8.bbappend index f91ea8e..54ef15f 100644 --- a/meta-beagleboard-extras/recipes/linux/linux-mainline_3.8.bbappend +++ b/meta-beagleboard-extras/recipes/linux/linux-mainline_3.8.bbappend | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | |||
| 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 2 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 2 | SRC_URI += "\ | 3 | SRC_URI += "\ |
| 3 | file://0001-AM335x-Adding-SGX-DT-node.patch \ | 4 | file://0001-AM335x-Adding-SGX-DT-node.patch \ |
| 4 | file://0002-AM33XX-Invoke-hwmod-deassert-for-SGX-graphics-device.patch \ | 5 | file://0002-AM33XX-Invoke-hwmod-deassert-for-SGX-graphics-device.patch \ |
| 5 | file://0003-video-da8xx-fb-Add-API-to-register-wait-for-vsync-ca.patch \ | 6 | file://0003-video-da8xx-fb-Add-API-to-register-wait-for-vsync-ca.patch \ |
| 7 | file://ARM-perf-add-support-for-perf-registers-API.diff \ | ||
| 8 | file://ARM-perf-wire-up-perf_regs-and-unwind-support-for-AR.patch \ | ||
| 6 | " | 9 | " |
| 7 | 10 | ||
| 8 | INSANE_SKIP_${PN} = "installed-vs-shipped" | 11 | INSANE_SKIP_${PN} = "installed-vs-shipped" |
