arch/arm/probes/kprobes/test-core.h

Source file repositories/reference/linux-study-clean/arch/arm/probes/kprobes/test-core.h

File Facts

System
Linux kernel
Corpus path
arch/arm/probes/kprobes/test-core.h
Extension
.h
Size
12762 bytes
Lines
461
Domain
Architecture Layer
Bucket
arch/arm
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct test_arg {
	u8	type;		/* ARG_TYPE_x */
	u8	_padding[7];
};

struct test_arg_regptr {
	u8	type;		/* ARG_TYPE_REG or ARG_TYPE_PTR or ARG_TYPE_REG_MASKED */
	u8	reg;
	u8	_padding[2];
	u32	val;
};

struct test_arg_mem {
	u8	type;		/* ARG_TYPE_MEM */
	u8	index;
	u8	_padding[2];
	u32	val;
};

struct test_arg_end {
	u8	type;		/* ARG_TYPE_END */
	u8	flags;		/* ARG_FLAG_x */
	u16	code_offset;
	u16	branch_offset;
	u16	end_offset;
};


/*
 * Building blocks for test cases.
 *
 * Each test case is wrapped between TESTCASE_START and TESTCASE_END.
 *
 * To specify arguments for a test case the TEST_ARG_{REG,PTR,MEM} macros are
 * used followed by a terminating TEST_ARG_END.
 *
 * After this, the instruction to be tested is defined with TEST_INSTRUCTION.
 * Or for branches, TEST_BRANCH_B and TEST_BRANCH_F (branch forwards/backwards).
 *
 * Some specific test cases may make use of other custom constructs.
 */

#if VERBOSE
#define verbose(fmt, ...) pr_info(fmt, ##__VA_ARGS__)
#else
#define verbose(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

#define TEST_GROUP(title)					\
	verbose("\n");						\
	verbose(title"\n");					\
	verbose("---------------------------------------------------------\n");

#define TESTCASE_START(title)					\
	__asm__ __volatile__ (					\
	".syntax unified				\n\t"	\
	"bl	__kprobes_test_case_start		\n\t"	\
	".pushsection .rodata				\n\t"	\
	"10:						\n\t"	\
	/* don't use .asciz here as 'title' may be */		\
	/* multiple strings to be concatenated.  */		\
	".ascii "#title"				\n\t"	\
	".byte	0					\n\t"	\
	".popsection					\n\t"	\
	".word	10b					\n\t"

#define	TEST_ARG_REG(reg, val)					\
	".byte	"__stringify(ARG_TYPE_REG)"		\n\t"	\
	".byte	"#reg"					\n\t"	\
	".short	0					\n\t"	\
	".word	"#val"					\n\t"

#define	TEST_ARG_PTR(reg, val)					\
	".byte	"__stringify(ARG_TYPE_PTR)"		\n\t"	\
	".byte	"#reg"					\n\t"	\
	".short	0					\n\t"	\
	".word	"#val"					\n\t"

#define	TEST_ARG_MEM(index, val)				\
	".byte	"__stringify(ARG_TYPE_MEM)"		\n\t"	\
	".byte	"#index"				\n\t"	\
	".short	0					\n\t"	\
	".word	"#val"					\n\t"

#define	TEST_ARG_REG_MASKED(reg, val)				\
	".byte	"__stringify(ARG_TYPE_REG_MASKED)"	\n\t"	\
	".byte	"#reg"					\n\t"	\
	".short	0					\n\t"	\
	".word	"#val"					\n\t"

Annotation

Implementation Notes