Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6624cf65 authored by Wang Nan's avatar Wang Nan Committed by Jon Medhurst
Browse files

ARM: kprobes: collects stack consumption for store instructions



This patch uses the previously introduced checker functionality on
store instructions to record their stack consumption information to
arch_probes_insn.

Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
Reviewed-by: default avatarJon Medhurst <tixy@linaro.org>
Signed-off-by: default avatarJon Medhurst <tixy@linaro.org>
parent 83803d97
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ struct arch_probes_insn {
	probes_check_cc			*insn_check_cc;
	probes_insn_singlestep_t	*insn_singlestep;
	probes_insn_fn_t		*insn_fn;
	int				stack_space;
};

#endif
+10 −0
Original line number Diff line number Diff line
@@ -425,6 +425,16 @@ probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
	 */
	probes_opcode_t origin_insn = insn;

	/*
	 * stack_space is initialized to 0 here. Checker functions
	 * should update is value if they find this is a stack store
	 * instruction: positive value means bytes of stack usage,
	 * negitive value means unable to determine stack usage
	 * statically. For instruction doesn't store to stack, checker
	 * do nothing with it.
	 */
	asi->stack_space = 0;

	if (emulate)
		insn = prepare_emulated_insn(insn, asi, thumb);

+3 −3
Original line number Diff line number Diff line
obj-$(CONFIG_KPROBES)		+= core.o actions-common.o
obj-$(CONFIG_KPROBES)		+= core.o actions-common.o checkers-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
obj-$(CONFIG_KPROBES)		+= actions-thumb.o checkers-thumb.o
test-kprobes-objs		+= test-thumb.o
else
obj-$(CONFIG_KPROBES)		+= actions-arm.o
obj-$(CONFIG_KPROBES)		+= actions-arm.o checkers-arm.o
test-kprobes-objs		+= test-arm.o
endif
+2 −1
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@

#include "../decode-arm.h"
#include "core.h"
#include "checkers.h"

#if  __LINUX_ARM_ARCH__ >= 6
#define BLX(reg)	"blx	"reg"		\n\t"
@@ -340,4 +341,4 @@ const union decode_action kprobes_arm_actions[NUM_PROBES_ARM_ACTIONS] = {
	[PROBES_LDMSTM] = {.decoder = kprobe_decode_ldmstm}
};

const struct decode_checker *kprobes_arm_checkers[] = {NULL};
const struct decode_checker *kprobes_arm_checkers[] = {arm_stack_checker, NULL};
+3 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@

#include "../decode-thumb.h"
#include "core.h"
#include "checkers.h"

/* These emulation encodings are functionally equivalent... */
#define t32_emulate_rd8rn16rm0ra12_noflags \
@@ -665,5 +666,5 @@ const union decode_action kprobes_t32_actions[NUM_PROBES_T32_ACTIONS] = {
		.handler = t32_emulate_rdlo12rdhi8rn16rm0_noflags},
};

const struct decode_checker *kprobes_t32_checkers[] = {NULL};
const struct decode_checker *kprobes_t16_checkers[] = {NULL};
const struct decode_checker *kprobes_t32_checkers[] = {t32_stack_checker, NULL};
const struct decode_checker *kprobes_t16_checkers[] = {t16_stack_checker, NULL};
Loading