Skip to content

Commit

Permalink
ARM: probes: move all probe code to dedicate directory
Browse files Browse the repository at this point in the history
In discussion on LKML (https://lkml.org/lkml/2014/11/28/158), Russell
King suggests to move all probe related code to arch/arm/probes. This
patch does the work. Due to dependency on 'arch/arm/kernel/patch.h', this
patch also moves patch.h to 'arch/arm/include/asm/patch.h', and related
'#include' directives are also midified to '#include <asm/patch.h>'.

Following is an overview of this patch:

 ./arch/arm/kernel/               ./arch/arm/probes/
 |-- Makefile                     |-- Makefile
 |-- probes-arm.c          ==>    |-- decode-arm.c
 |-- probes-arm.h          ==>    |-- decode-arm.h
 |-- probes-thumb.c        ==>    |-- decode-thumb.c
 |-- probes-thumb.h        ==>    |-- decode-thumb.h
 |-- probes.c              ==>    |-- decode.c
 |-- probes.h              ==>    |-- decode.h
 |                                |-- kprobes
 |                                |   |-- Makefile
 |-- kprobes-arm.c         ==>    |   |-- actions-arm.c
 |-- kprobes-common.c      ==>    |   |-- actions-common.c
 |-- kprobes-thumb.c       ==>    |   |-- actions-thumb.c
 |-- kprobes.c             ==>    |   |-- core.c
 |-- kprobes.h             ==>    |   |-- core.h
 |-- kprobes-test-arm.c    ==>    |   |-- test-arm.c
 |-- kprobes-test.c        ==>    |   |-- test-core.c
 |-- kprobes-test.h        ==>    |   |-- test-core.h
 |-- kprobes-test-thumb.c  ==>    |   `-- test-thumb.c
 |                                `-- uprobes
 |                                    |-- Makefile
 |-- uprobes-arm.c         ==>        |-- actions-arm.c
 |-- uprobes.c             ==>        |-- core.c
 |-- uprobes.h             ==>        `-- core.h
 |
 `-- patch.h               ==>    arch/arm/include/asm/patch.h

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
  • Loading branch information
Wang Nan authored and Jon Medhurst committed Jan 9, 2015
1 parent b1940cd commit fca08f3
Show file tree
Hide file tree
Showing 27 changed files with 69 additions and 57 deletions.
1 change: 1 addition & 0 deletions arch/arm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ core-$(CONFIG_KVM_ARM_HOST) += arch/arm/kvm/

# If we have a machine-specific directory, then include it in the build.
core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
core-y += arch/arm/probes/
core-y += arch/arm/net/
core-y += arch/arm/crypto/
core-y += arch/arm/firmware/
Expand Down
File renamed without changes.
16 changes: 2 additions & 14 deletions arch/arm/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,8 @@ obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
obj-$(CONFIG_UPROBES) += probes.o probes-arm.o uprobes.o uprobes-arm.o
obj-$(CONFIG_KPROBES) += probes.o kprobes.o kprobes-common.o patch.o
ifdef CONFIG_THUMB2_KERNEL
obj-$(CONFIG_KPROBES) += kprobes-thumb.o probes-thumb.o
else
obj-$(CONFIG_KPROBES) += kprobes-arm.o probes-arm.o
endif
obj-$(CONFIG_ARM_KPROBES_TEST) += test-kprobes.o
test-kprobes-objs := kprobes-test.o
ifdef CONFIG_THUMB2_KERNEL
test-kprobes-objs += kprobes-test-thumb.o
else
test-kprobes-objs += kprobes-test-arm.o
endif
# Main staffs in KPROBES are in arch/arm/probes/ .
obj-$(CONFIG_KPROBES) += patch.o
obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
obj-$(CONFIG_ARM_THUMBEE) += thumbee.o
obj-$(CONFIG_KGDB) += kgdb.o patch.o
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/jump_label.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <linux/kernel.h>
#include <linux/jump_label.h>
#include <asm/patch.h>

#include "insn.h"
#include "patch.h"

#ifdef HAVE_JUMP_LABEL

Expand Down
3 changes: 1 addition & 2 deletions arch/arm/kernel/kgdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
#include <linux/kgdb.h>
#include <linux/uaccess.h>

#include <asm/patch.h>
#include <asm/traps.h>

#include "patch.h"

struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] =
{
{ "r0", 4, offsetof(struct pt_regs, ARM_r0)},
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/kernel/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include <asm/fixmap.h>
#include <asm/smp_plat.h>
#include <asm/opcodes.h>

#include "patch.h"
#include <asm/patch.h>

struct patch {
void *addr;
Expand Down
7 changes: 7 additions & 0 deletions arch/arm/probes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
obj-$(CONFIG_UPROBES) += decode.o decode-arm.o uprobes/
obj-$(CONFIG_KPROBES) += decode.o kprobes/
ifdef CONFIG_THUMB2_KERNEL
obj-$(CONFIG_KPROBES) += decode-thumb.o
else
obj-$(CONFIG_KPROBES) += decode-arm.o
endif
7 changes: 4 additions & 3 deletions arch/arm/kernel/probes-arm.c → arch/arm/probes/decode-arm.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* arch/arm/kernel/probes-arm.c
*
* arch/arm/probes/decode-arm.c
*
* Some code moved here from arch/arm/kernel/kprobes-arm.c
*
Expand All @@ -20,8 +21,8 @@
#include <linux/stddef.h>
#include <linux/ptrace.h>

#include "probes.h"
#include "probes-arm.h"
#include "decode.h"
#include "decode-arm.h"

#define sign_extend(x, signbit) ((x) | (0 - ((x) & (1 << (signbit)))))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/probes-arm.h
* arch/arm/probes/decode-arm.h
*
* Copyright 2013 Linaro Ltd.
* Written by: David A. Long
Expand All @@ -15,6 +15,8 @@
#ifndef _ARM_KERNEL_PROBES_ARM_H
#define _ARM_KERNEL_PROBES_ARM_H

#include "decode.h"

enum probes_arm_action {
PROBES_EMULATE_NONE,
PROBES_SIMULATE_NOP,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/probes-thumb.c
* arch/arm/probes/decode-thumb.c
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
Expand All @@ -12,8 +12,8 @@
#include <linux/kernel.h>
#include <linux/module.h>

#include "probes.h"
#include "probes-thumb.h"
#include "decode.h"
#include "decode-thumb.h"


static const union decode_item t32_table_1110_100x_x0xx[] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/probes-thumb.h
* arch/arm/probes/decode-thumb.h
*
* Copyright 2013 Linaro Ltd.
* Written by: David A. Long
Expand All @@ -15,6 +15,8 @@
#ifndef _ARM_KERNEL_PROBES_THUMB_H
#define _ARM_KERNEL_PROBES_THUMB_H

#include "decode.h"

/*
* True if current instruction is in an IT block.
*/
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/kernel/probes.c → arch/arm/probes/decode.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/probes.c
* arch/arm/probes/decode.c
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
Expand All @@ -17,7 +17,7 @@
#include <asm/ptrace.h>
#include <linux/bug.h>

#include "probes.h"
#include "decode.h"


#ifndef find_str_pc_offset
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/probes.h → arch/arm/probes/decode.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/probes.h
* arch/arm/probes/decode.h
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
Expand Down
11 changes: 11 additions & 0 deletions arch/arm/probes/kprobes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
obj-$(CONFIG_KPROBES) += core.o actions-common.o
obj-$(CONFIG_ARM_KPROBES_TEST) += test-kprobes.o
test-kprobes-objs := test-core.o

ifdef CONFIG_THUMB2_KERNEL
obj-$(CONFIG_KPROBES) += actions-thumb.o
test-kprobes-objs += test-thumb.o
else
obj-$(CONFIG_KPROBES) += actions-arm.o
test-kprobes-objs += test-arm.o
endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/kprobes-decode.c
* arch/arm/probes/kprobes/actions-arm.c
*
* Copyright (C) 2006, 2007 Motorola Inc.
*
Expand Down Expand Up @@ -62,8 +62,8 @@
#include <linux/kprobes.h>
#include <linux/ptrace.h>

#include "kprobes.h"
#include "probes-arm.h"
#include "../decode-arm.h"
#include "core.h"

#if __LINUX_ARM_ARCH__ >= 6
#define BLX(reg) "blx "reg" \n\t"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/kprobes-common.c
* arch/arm/probes/kprobes/actions-common.c
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
Expand All @@ -15,7 +15,7 @@
#include <linux/kprobes.h>
#include <asm/opcodes.h>

#include "kprobes.h"
#include "core.h"


static void __kprobes simulate_ldm1stm1(probes_opcode_t insn,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/kprobes-thumb.c
* arch/arm/probes/kprobes/actions-thumb.c
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
Expand All @@ -13,8 +13,8 @@
#include <linux/ptrace.h>
#include <linux/kprobes.h>

#include "kprobes.h"
#include "probes-thumb.h"
#include "../decode-thumb.h"
#include "core.h"

/* These emulation encodings are functionally equivalent... */
#define t32_emulate_rd8rn16rm0ra12_noflags \
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/kernel/kprobes.c → arch/arm/probes/kprobes/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#include <asm/cacheflush.h>
#include <linux/percpu.h>
#include <linux/bug.h>
#include <asm/patch.h>

#include "kprobes.h"
#include "probes-arm.h"
#include "probes-thumb.h"
#include "patch.h"
#include "../decode-arm.h"
#include "../decode-thumb.h"
#include "core.h"

#define MIN_STACK_SIZE(addr) \
min((unsigned long)MAX_STACK_SIZE, \
Expand Down
3 changes: 2 additions & 1 deletion arch/arm/kernel/kprobes.h → arch/arm/probes/kprobes/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#ifndef _ARM_KERNEL_KPROBES_H
#define _ARM_KERNEL_KPROBES_H

#include "probes.h"
#include <asm/kprobes.h>
#include "../decode.h"

/*
* These undefined instructions must be unique and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <asm/system_info.h>
#include <asm/opcodes.h>

#include "kprobes-test.h"
#include "test-core.h"


#define TEST_ISA "32"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@
#include <linux/bug.h>
#include <asm/opcodes.h>

#include "kprobes.h"
#include "probes-arm.h"
#include "probes-thumb.h"
#include "kprobes-test.h"
#include "core.h"
#include "test-core.h"
#include "../decode-arm.h"
#include "../decode-thumb.h"


#define BENCHMARKING 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/kprobes-test.h
* arch/arm/probes/kprobes/test-core.h
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* arch/arm/kernel/kprobes-test-thumb.c
* arch/arm/probes/kprobes/test-thumb.c
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
Expand All @@ -12,7 +12,7 @@
#include <linux/module.h>
#include <asm/opcodes.h>

#include "kprobes-test.h"
#include "test-core.h"


#define TEST_ISA "16"
Expand Down
1 change: 1 addition & 0 deletions arch/arm/probes/uprobes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-$(CONFIG_UPROBES) += core.o actions-arm.o
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include <linux/uprobes.h>
#include <linux/module.h>

#include "probes.h"
#include "probes-arm.h"
#include "uprobes.h"
#include "../decode.h"
#include "../decode-arm.h"
#include "core.h"

static int uprobes_substitute_pc(unsigned long *pinsn, u32 oregs)
{
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/kernel/uprobes.c → arch/arm/probes/uprobes/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <asm/opcodes.h>
#include <asm/traps.h>

#include "probes.h"
#include "probes-arm.h"
#include "uprobes.h"
#include "../decode.h"
#include "../decode-arm.h"
#include "core.h"

#define UPROBE_TRAP_NR UINT_MAX

Expand Down
File renamed without changes.

0 comments on commit fca08f3

Please sign in to comment.