arch/arm/probes/kprobes/test-arm.c

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

File Facts

System
Linux kernel
Corpus path
arch/arm/probes/kprobes/test-arm.c
Extension
.c
Size
62455 bytes
Lines
1364
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

// SPDX-License-Identifier: GPL-2.0-only
/*
 * arch/arm/kernel/kprobes-test-arm.c
 *
 * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <asm/system_info.h>
#include <asm/opcodes.h>
#include <asm/probes.h>

#include "test-core.h"


#define TEST_ISA "32"

#define TEST_ARM_TO_THUMB_INTERWORK_R(code1, reg, val, code2)	\
	TESTCASE_START(code1 #reg code2)			\
	TEST_ARG_REG(reg, val)					\
	TEST_ARG_REG(14, 99f)					\
	TEST_ARG_END("")					\
	"50:	nop			\n\t"			\
	"1:	"code1 #reg code2"	\n\t"			\
	"	bx	lr		\n\t"			\
	".thumb				\n\t"			\
	"3:	adr	lr, 2f		\n\t"			\
	"	bx	lr		\n\t"			\
	".arm				\n\t"			\
	"2:	nop			\n\t"			\
	TESTCASE_END

#define TEST_ARM_TO_THUMB_INTERWORK_P(code1, reg, val, code2)	\
	TESTCASE_START(code1 #reg code2)			\
	TEST_ARG_PTR(reg, val)					\
	TEST_ARG_REG(14, 99f)					\
	TEST_ARG_MEM(15, 3f+1)					\
	TEST_ARG_END("")					\
	"50:	nop			\n\t"			\
	"1:	"code1 #reg code2"	\n\t"			\
	"	bx	lr		\n\t"			\
	".thumb				\n\t"			\
	"3:	adr	lr, 2f		\n\t"			\
	"	bx	lr		\n\t"			\
	".arm				\n\t"			\
	"2:	nop			\n\t"			\
	TESTCASE_END


void kprobe_arm_test_cases(void)
{
	kprobe_test_flags = 0;

	TEST_GROUP("Data-processing (register), (register-shifted register), (immediate)")

#define _DATA_PROCESSING_DNM(op,s,val)						\
	TEST_RR(  op s "eq	r0,  r",1, VAL1,", r",2, val, "")		\
	TEST_RR(  op s "ne	r1,  r",1, VAL1,", r",2, val, ", lsl #3")	\
	TEST_RR(  op s "cs	r2,  r",3, VAL1,", r",2, val, ", lsr #4")	\
	TEST_RR(  op s "cc	r3,  r",3, VAL1,", r",2, val, ", asr #5")	\
	TEST_RR(  op s "mi	r4,  r",5, VAL1,", r",2, N(val),", asr #6")	\
	TEST_RR(  op s "pl	r5,  r",5, VAL1,", r",2, val, ", ror #7")	\
	TEST_RR(  op s "vs	r6,  r",7, VAL1,", r",2, val, ", rrx")		\
	TEST_R(   op s "vc	r6,  r",7, VAL1,", pc, lsl #3")			\
	TEST_R(   op s "vc	r6,  r",7, VAL1,", sp, lsr #4")			\
	TEST_R(   op s "vc	r6,  pc, r",7, VAL1,", asr #5")			\
	TEST_R(   op s "vc	r6,  sp, r",7, VAL1,", ror #6")			\
	TEST_RRR( op s "hi	r8,  r",9, VAL1,", r",14,val, ", lsl r",0, 3,"")\
	TEST_RRR( op s "ls	r9,  r",9, VAL1,", r",14,val, ", lsr r",7, 4,"")\
	TEST_RRR( op s "ge	r10, r",11,VAL1,", r",14,val, ", asr r",7, 5,"")\
	TEST_RRR( op s "lt	r11, r",11,VAL1,", r",14,N(val),", asr r",7, 6,"")\
	TEST_RR(  op s "gt	r12, r13"       ", r",14,val, ", ror r",14,7,"")\
	TEST_RR(  op s "le	r14, r",0, val, ", r13"       ", lsl r",14,8,"")\
	TEST_R(   op s "eq	r0,  r",11,VAL1,", #0xf5")			\
	TEST_R(   op s "ne	r11, r",0, VAL1,", #0xf5000000")		\
	TEST_R(   op s "	r7,  r",8, VAL2,", #0x000af000")		\
	TEST(     op s "	r4,  pc"        ", #0x00005a00")

#define DATA_PROCESSING_DNM(op,val)		\
	_DATA_PROCESSING_DNM(op,"",val)		\
	_DATA_PROCESSING_DNM(op,"s",val)

#define DATA_PROCESSING_NM(op,val)						\
	TEST_RR(  op "ne	r",1, VAL1,", r",2, val, "")			\
	TEST_RR(  op "eq	r",1, VAL1,", r",2, val, ", lsl #3")		\
	TEST_RR(  op "cc	r",3, VAL1,", r",2, val, ", lsr #4")		\
	TEST_RR(  op "cs	r",3, VAL1,", r",2, val, ", asr #5")		\
	TEST_RR(  op "pl	r",5, VAL1,", r",2, N(val),", asr #6")		\
	TEST_RR(  op "mi	r",5, VAL1,", r",2, val, ", ror #7")		\

Annotation

Implementation Notes