diff options
author | Jon Medhurst <tixy@yxit.co.uk> | 2011-06-10 12:35:51 -0400 |
---|---|---|
committer | Tixy <tixy@medhuaa1.miniserver.com> | 2011-07-13 13:32:50 -0400 |
commit | 6091dfae4f289b7316b21277c38c8cd519e47f79 (patch) | |
tree | 455036871bb42eb51763bdbfc38784cd95f490dd /arch | |
parent | e9a92859e91acaa67337b4a820040a820906ea4c (diff) |
ARM: kprobes: Add emulate_rd16rn12rm0rs8_rwflags_nopc()
This is the emulation function for the instruction format used by the
ARM multiply-accumulate instructions. These don't allow use of PC so we
don't have to add special cases for this.
This function is used to replace use of prep_emulate_rd16rs8rm0_wflags
and prep_emulate_rd16rn12rs8rm0_wflags.
Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/kernel/kprobes-arm.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/arch/arm/kernel/kprobes-arm.c b/arch/arm/kernel/kprobes-arm.c index f271212a7cd5..d3b0506df410 100644 --- a/arch/arm/kernel/kprobes-arm.c +++ b/arch/arm/kernel/kprobes-arm.c | |||
@@ -984,6 +984,35 @@ emulate_rd12rn16rm0_rwflags_nopc(struct kprobe *p, struct pt_regs *regs) | |||
984 | regs->ARM_cpsr = (regs->ARM_cpsr & ~APSR_MASK) | (cpsr & APSR_MASK); | 984 | regs->ARM_cpsr = (regs->ARM_cpsr & ~APSR_MASK) | (cpsr & APSR_MASK); |
985 | } | 985 | } |
986 | 986 | ||
987 | static void __kprobes | ||
988 | emulate_rd16rn12rm0rs8_rwflags_nopc(struct kprobe *p, struct pt_regs *regs) | ||
989 | { | ||
990 | kprobe_opcode_t insn = p->opcode; | ||
991 | int rd = (insn >> 16) & 0xf; | ||
992 | int rn = (insn >> 12) & 0xf; | ||
993 | int rm = insn & 0xf; | ||
994 | int rs = (insn >> 8) & 0xf; | ||
995 | |||
996 | register unsigned long rdv asm("r2") = regs->uregs[rd]; | ||
997 | register unsigned long rnv asm("r0") = regs->uregs[rn]; | ||
998 | register unsigned long rmv asm("r3") = regs->uregs[rm]; | ||
999 | register unsigned long rsv asm("r1") = regs->uregs[rs]; | ||
1000 | unsigned long cpsr = regs->ARM_cpsr; | ||
1001 | |||
1002 | __asm__ __volatile__ ( | ||
1003 | "msr cpsr_fs, %[cpsr] \n\t" | ||
1004 | BLX("%[fn]") | ||
1005 | "mrs %[cpsr], cpsr \n\t" | ||
1006 | : "=r" (rdv), [cpsr] "=r" (cpsr) | ||
1007 | : "0" (rdv), "r" (rnv), "r" (rmv), "r" (rsv), | ||
1008 | "1" (cpsr), [fn] "r" (p->ainsn.insn_fn) | ||
1009 | : "lr", "memory", "cc" | ||
1010 | ); | ||
1011 | |||
1012 | regs->uregs[rd] = rdv; | ||
1013 | regs->ARM_cpsr = (regs->ARM_cpsr & ~APSR_MASK) | (cpsr & APSR_MASK); | ||
1014 | } | ||
1015 | |||
987 | /* | 1016 | /* |
988 | * For the instruction masking and comparisons in all the "space_*" | 1017 | * For the instruction masking and comparisons in all the "space_*" |
989 | * functions below, Do _not_ rearrange the order of tests unless | 1018 | * functions below, Do _not_ rearrange the order of tests unless |
@@ -1065,12 +1094,14 @@ static const union decode_item arm_cccc_0001_0xx0____1xx0_table[] = { | |||
1065 | /* SMULWy cccc 0001 0010 xxxx xxxx xxxx 1x10 xxxx */ | 1094 | /* SMULWy cccc 0001 0010 xxxx xxxx xxxx 1x10 xxxx */ |
1066 | DECODE_OR (0x0ff000b0, 0x012000a0), | 1095 | DECODE_OR (0x0ff000b0, 0x012000a0), |
1067 | /* SMULxy cccc 0001 0110 xxxx xxxx xxxx 1xx0 xxxx */ | 1096 | /* SMULxy cccc 0001 0110 xxxx xxxx xxxx 1xx0 xxxx */ |
1068 | DECODE_CUSTOM (0x0ff00090, 0x01600080, prep_emulate_rd16rs8rm0_wflags), | 1097 | DECODE_EMULATEX (0x0ff00090, 0x01600080, emulate_rd16rn12rm0rs8_rwflags_nopc, |
1098 | REGS(NOPC, 0, NOPC, 0, NOPC)), | ||
1069 | 1099 | ||
1070 | /* SMLAxy cccc 0001 0000 xxxx xxxx xxxx 1xx0 xxxx */ | 1100 | /* SMLAxy cccc 0001 0000 xxxx xxxx xxxx 1xx0 xxxx */ |
1071 | DECODE_OR (0x0ff00090, 0x01000080), | 1101 | DECODE_OR (0x0ff00090, 0x01000080), |
1072 | /* SMLAWy cccc 0001 0010 xxxx xxxx xxxx 1x00 xxxx */ | 1102 | /* SMLAWy cccc 0001 0010 xxxx xxxx xxxx 1x00 xxxx */ |
1073 | DECODE_CUSTOM (0x0ff000b0, 0x01200080, prep_emulate_rd16rn12rs8rm0_wflags), | 1103 | DECODE_EMULATEX (0x0ff000b0, 0x01200080, emulate_rd16rn12rm0rs8_rwflags_nopc, |
1104 | REGS(NOPC, NOPC, NOPC, 0, NOPC)), | ||
1074 | 1105 | ||
1075 | DECODE_END | 1106 | DECODE_END |
1076 | }; | 1107 | }; |
@@ -1080,13 +1111,15 @@ static const union decode_item arm_cccc_0000_____1001_table[] = { | |||
1080 | 1111 | ||
1081 | /* MUL cccc 0000 0000 xxxx xxxx xxxx 1001 xxxx */ | 1112 | /* MUL cccc 0000 0000 xxxx xxxx xxxx 1001 xxxx */ |
1082 | /* MULS cccc 0000 0001 xxxx xxxx xxxx 1001 xxxx */ | 1113 | /* MULS cccc 0000 0001 xxxx xxxx xxxx 1001 xxxx */ |
1083 | DECODE_CUSTOM (0x0fe000f0, 0x00000090, prep_emulate_rd16rs8rm0_wflags), | 1114 | DECODE_EMULATEX (0x0fe000f0, 0x00000090, emulate_rd16rn12rm0rs8_rwflags_nopc, |
1115 | REGS(NOPC, 0, NOPC, 0, NOPC)), | ||
1084 | 1116 | ||
1085 | /* MLA cccc 0000 0010 xxxx xxxx xxxx 1001 xxxx */ | 1117 | /* MLA cccc 0000 0010 xxxx xxxx xxxx 1001 xxxx */ |
1086 | /* MLAS cccc 0000 0011 xxxx xxxx xxxx 1001 xxxx */ | 1118 | /* MLAS cccc 0000 0011 xxxx xxxx xxxx 1001 xxxx */ |
1087 | DECODE_OR (0x0fe000f0, 0x00200090), | 1119 | DECODE_OR (0x0fe000f0, 0x00200090), |
1088 | /* MLS cccc 0000 0110 xxxx xxxx xxxx 1001 xxxx */ | 1120 | /* MLS cccc 0000 0110 xxxx xxxx xxxx 1001 xxxx */ |
1089 | DECODE_CUSTOM (0x0ff000f0, 0x00600090, prep_emulate_rd16rn12rs8rm0_wflags), | 1121 | DECODE_EMULATEX (0x0ff000f0, 0x00600090, emulate_rd16rn12rm0rs8_rwflags_nopc, |
1122 | REGS(NOPC, NOPC, NOPC, 0, NOPC)), | ||
1090 | 1123 | ||
1091 | /* UMAAL cccc 0000 0100 xxxx xxxx xxxx 1001 xxxx */ | 1124 | /* UMAAL cccc 0000 0100 xxxx xxxx xxxx 1001 xxxx */ |
1092 | DECODE_OR (0x0ff000f0, 0x00400090), | 1125 | DECODE_OR (0x0ff000f0, 0x00400090), |
@@ -1368,7 +1401,8 @@ static const union decode_item arm_cccc_0111_____xxx1_table[] = { | |||
1368 | /* SMMUL cccc 0111 0101 xxxx 1111 xxxx 00x1 xxxx */ | 1401 | /* SMMUL cccc 0111 0101 xxxx 1111 xxxx 00x1 xxxx */ |
1369 | DECODE_OR (0x0ff0f0d0, 0x0750f010), | 1402 | DECODE_OR (0x0ff0f0d0, 0x0750f010), |
1370 | /* USAD8 cccc 0111 1000 xxxx 1111 xxxx 0001 xxxx */ | 1403 | /* USAD8 cccc 0111 1000 xxxx 1111 xxxx 0001 xxxx */ |
1371 | DECODE_CUSTOM (0x0ff0f0f0, 0x0780f010, prep_emulate_rd16rs8rm0_wflags), | 1404 | DECODE_EMULATEX (0x0ff0f0f0, 0x0780f010, emulate_rd16rn12rm0rs8_rwflags_nopc, |
1405 | REGS(NOPC, 0, NOPC, 0, NOPC)), | ||
1372 | 1406 | ||
1373 | /* SMLAD cccc 0111 0000 xxxx xxxx xxxx 00x1 xxxx */ | 1407 | /* SMLAD cccc 0111 0000 xxxx xxxx xxxx 00x1 xxxx */ |
1374 | /* SMLSD cccc 0111 0000 xxxx xxxx xxxx 01x1 xxxx */ | 1408 | /* SMLSD cccc 0111 0000 xxxx xxxx xxxx 01x1 xxxx */ |
@@ -1376,10 +1410,12 @@ static const union decode_item arm_cccc_0111_____xxx1_table[] = { | |||
1376 | /* SMMLA cccc 0111 0101 xxxx xxxx xxxx 00x1 xxxx */ | 1410 | /* SMMLA cccc 0111 0101 xxxx xxxx xxxx 00x1 xxxx */ |
1377 | DECODE_OR (0x0ff000d0, 0x07500010), | 1411 | DECODE_OR (0x0ff000d0, 0x07500010), |
1378 | /* USADA8 cccc 0111 1000 xxxx xxxx xxxx 0001 xxxx */ | 1412 | /* USADA8 cccc 0111 1000 xxxx xxxx xxxx 0001 xxxx */ |
1379 | DECODE_CUSTOM (0x0ff000f0, 0x07800010, prep_emulate_rd16rn12rs8rm0_wflags), | 1413 | DECODE_EMULATEX (0x0ff000f0, 0x07800010, emulate_rd16rn12rm0rs8_rwflags_nopc, |
1414 | REGS(NOPC, NOPCX, NOPC, 0, NOPC)), | ||
1380 | 1415 | ||
1381 | /* SMMLS cccc 0111 0101 xxxx xxxx xxxx 11x1 xxxx */ | 1416 | /* SMMLS cccc 0111 0101 xxxx xxxx xxxx 11x1 xxxx */ |
1382 | DECODE_CUSTOM (0x0ff000d0, 0x075000d0, prep_emulate_rd16rn12rs8rm0_wflags), | 1417 | DECODE_EMULATEX (0x0ff000d0, 0x075000d0, emulate_rd16rn12rm0rs8_rwflags_nopc, |
1418 | REGS(NOPC, NOPC, NOPC, 0, NOPC)), | ||
1383 | 1419 | ||
1384 | /* SBFX cccc 0111 101x xxxx xxxx xxxx x101 xxxx */ | 1420 | /* SBFX cccc 0111 101x xxxx xxxx xxxx x101 xxxx */ |
1385 | /* UBFX cccc 0111 111x xxxx xxxx xxxx x101 xxxx */ | 1421 | /* UBFX cccc 0111 111x xxxx xxxx xxxx x101 xxxx */ |