/*
* arch/arm/kernel/kprobes-test-arm.c
*
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <asm/system_info.h>
#include "kprobes-test.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 "eq" s " r0, r",1, VAL1,", r",2, val, "") \
TEST_RR( op "ne" s " r1, r",1, VAL1,", r",2, val, ", lsl #3") \
TEST_RR( op "cs" s " r2, r",3, VAL1,", r",2, val, ", lsr #4") \
TEST_RR( op "cc" s " r3, r",3, VAL1,", r",2, val, ", asr #5") \
TEST_RR( op "mi" s " r4, r",5, VAL1,", r",2, N(val),", asr #6") \
TEST_RR( op "pl" s " r5, r",5, VAL1,", r",2, val, ", ror #7") \
TEST_RR( op "vs" s " r6, r",7, VAL1,", r",2, val, ", rrx") \
TEST_R( op "vc" s " r6, r",7, VAL1,", pc, lsl #3") \
TEST_R( op "vc" s " r6, r",7, VAL1,", sp, lsr #4") \
TEST_R( op "vc" s " r6, pc, r",7, VAL1,", asr #5") \
TEST_R( op "vc" s " r6, sp, r",7, VAL1,", ror #6") \
TEST_RRR( op "hi" s " r8, r",9, VAL1,", r",14,val, ", lsl r",0, 3,"")\
TEST_RRR( op "ls" s " r9, r",9, VAL1,", r",14,val, ", lsr r",7, 4,"")\
TEST_RRR( op "ge" s " r10, r",11,VAL1,", r",14,val, ", asr r",7, 5,"")\
TEST_RRR( op "lt" s " r11, r",11,VAL1,", r",14,N(val),", asr r",7, 6,"")\
TEST_RR( op "gt" s " r12, r13" ", r",14,val, ", ror r",14,7,"")\
TEST_RR( op "le" s " r14, r",0, val, ", r13" ", lsl r",14,8,"")\
TEST_RR( op s " r12, pc" ", r",14,val, ", ror r",14,7,"")\
TEST_RR( op s " r14, r",0, val, ", pc" ", lsl r",14,8,"")\
TEST_R( op "eq" s " r0, r",11,VAL1,", #0xf5") \
TEST_R( op "ne" s " 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") \
TEST_RR( op "vc r",7, VAL1,", r",2, val, ", rrx") \
TEST_R ( op "vs r",7, VAL1,", pc, lsl #3") \
TEST_R ( op "vs r",7, VAL1,", sp, lsr #4") \
TEST_R( op "vs pc, r",7, VAL1,", asr #5") \
TEST_R( op "vs sp, r",7, VAL1,", ror #6") \
TEST_RRR( op "ls r",9, VAL1,", r",14,val, ", lsl r",0, 3,"") \
TEST_RRR( op "hi r",9, VAL1,", r",14,val, ", lsr r",7, 4,"") \
TEST_RRR( op "lt r",11,VAL1,", r",14,val, ", asr r",7, 5,"") \
TEST_RRR( op "ge r",11,VAL1,", r",14,N(val),", asr r",7, 6,"") \
TEST_RR( op "le r13" ", r",14,val, ", ror r",14,7,"") \
TEST_RR( op "gt r",0, val, ", r13" ", lsl r",14,8,"") \
TEST_RR( op " pc" ", r",14,val, ", ror r",14,7,"") \
TEST_RR( op " r",0, val, ", pc" ", lsl r",14,8,"") \
TEST_R( op "eq r",11,VAL1,", #0xf5") \
TEST_R( op "ne r",0, VAL1,", #0xf5000000") \
TEST_R( op " r",8, VAL2,", #0x000af000")
#define _DATA_PROCESSING_DM(op,s,val) \
TEST_R( op "eq" s " r0, r",1, val, "") \
TEST_R( op "ne" s " r1, r",1, val, ", lsl #3") \
TEST_R( op "cs" s " r2, r",3, val, ", lsr #4") \
TEST_R( op "cc" s " r3, r",3, val, ", asr #5") \
TEST_R( op "mi" s " r4, r",5, N(val),", asr #6") \
TEST_R( op "pl" s " r5, r",5, val, ", ror #7") \
TEST_R( op "vs" s " r6, r",10,val, ", rrx") \
TEST( op "vs" s " r7, pc, lsl #3") \
TEST( op "vs" s " r7, sp, lsr #4") \
TEST_RR( op "vc" s " r8, r",7, val, ", lsl r",0, 3,"") \
TEST_RR( op "hi" s " r9, r",9, val, ", lsr r",7, 4,"") \
TEST_RR( op "ls" s " r10, r",9, val, ", asr r",7, 5,"") \
TEST_RR( op "ge" s " r11, r",11,N(val),", asr r",7, 6,"") \
TEST_RR( op "lt" s " r12, r",11,val, ", ror r",14,7,"") \
TEST_R( op "gt" s " r14, r13" ", lsl r",14,8,"") \
TEST_R( op "le" s " r14, pc" ",