aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/kprobes-arm.c
diff options
context:
space:
mode:
authorJon Medhurst <tixy@yxit.co.uk>2011-07-06 06:25:18 -0400
committerTixy <tixy@medhuaa1.miniserver.com>2011-07-13 13:32:41 -0400
commit0ab4c02ddae2e1d32d686a7773608f6c44fb2a83 (patch)
treec4555d94262d496fa129a39b02c08d89d135412c /arch/arm/kernel/kprobes-arm.c
parent221bf15ffd2ad6cdc624aa4274f706499501c123 (diff)
ARM: kprobes: Add kprobes-common.c
This file will contain the instruction decoding and emulation code which is common to both ARM and Thumb instruction sets. For now, we will just move over condition_checks from kprobes-arm.c This table is also renamed to kprobe_condition_checks to avoid polluting the public namespace with a too generic name. Signed-off-by: Jon Medhurst <tixy@yxit.co.uk> Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch/arm/kernel/kprobes-arm.c')
-rw-r--r--arch/arm/kernel/kprobes-arm.c92
1 files changed, 1 insertions, 91 deletions
diff --git a/arch/arm/kernel/kprobes-arm.c b/arch/arm/kernel/kprobes-arm.c
index 976ce14c5576..8d4464f9471b 100644
--- a/arch/arm/kernel/kprobes-arm.c
+++ b/arch/arm/kernel/kprobes-arm.c
@@ -1523,96 +1523,6 @@ space_cccc_11xx(kprobe_opcode_t insn, struct arch_specific_insn *asi)
1523 return INSN_REJECTED; 1523 return INSN_REJECTED;
1524} 1524}
1525 1525
1526static unsigned long __kprobes __check_eq(unsigned long cpsr)
1527{
1528 return cpsr & PSR_Z_BIT;
1529}
1530
1531static unsigned long __kprobes __check_ne(unsigned long cpsr)
1532{
1533 return (~cpsr) & PSR_Z_BIT;
1534}
1535
1536static unsigned long __kprobes __check_cs(unsigned long cpsr)
1537{
1538 return cpsr & PSR_C_BIT;
1539}
1540
1541static unsigned long __kprobes __check_cc(unsigned long cpsr)
1542{
1543 return (~cpsr) & PSR_C_BIT;
1544}
1545
1546static unsigned long __kprobes __check_mi(unsigned long cpsr)
1547{
1548 return cpsr & PSR_N_BIT;
1549}
1550
1551static unsigned long __kprobes __check_pl(unsigned long cpsr)
1552{
1553 return (~cpsr) & PSR_N_BIT;
1554}
1555
1556static unsigned long __kprobes __check_vs(unsigned long cpsr)
1557{
1558 return cpsr & PSR_V_BIT;
1559}
1560
1561static unsigned long __kprobes __check_vc(unsigned long cpsr)
1562{
1563 return (~cpsr) & PSR_V_BIT;
1564}
1565
1566static unsigned long __kprobes __check_hi(unsigned long cpsr)
1567{
1568 cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */
1569 return cpsr & PSR_C_BIT;
1570}
1571
1572static unsigned long __kprobes __check_ls(unsigned long cpsr)
1573{
1574 cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */
1575 return (~cpsr) & PSR_C_BIT;
1576}
1577
1578static unsigned long __kprobes __check_ge(unsigned long cpsr)
1579{
1580 cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
1581 return (~cpsr) & PSR_N_BIT;
1582}
1583
1584static unsigned long __kprobes __check_lt(unsigned long cpsr)
1585{
1586 cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
1587 return cpsr & PSR_N_BIT;
1588}
1589
1590static unsigned long __kprobes __check_gt(unsigned long cpsr)
1591{
1592 unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
1593 temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */
1594 return (~temp) & PSR_N_BIT;
1595}
1596
1597static unsigned long __kprobes __check_le(unsigned long cpsr)
1598{
1599 unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
1600 temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */
1601 return temp & PSR_N_BIT;
1602}
1603
1604static unsigned long __kprobes __check_al(unsigned long cpsr)
1605{
1606 return true;
1607}
1608
1609static kprobe_check_cc * const condition_checks[16] = {
1610 &__check_eq, &__check_ne, &__check_cs, &__check_cc,
1611 &__check_mi, &__check_pl, &__check_vs, &__check_vc,
1612 &__check_hi, &__check_ls, &__check_ge, &__check_lt,
1613 &__check_gt, &__check_le, &__check_al, &__check_al
1614};
1615
1616/* Return: 1526/* Return:
1617 * INSN_REJECTED If instruction is one not allowed to kprobe, 1527 * INSN_REJECTED If instruction is one not allowed to kprobe,
1618 * INSN_GOOD If instruction is supported and uses instruction slot, 1528 * INSN_GOOD If instruction is supported and uses instruction slot,
@@ -1628,7 +1538,7 @@ static kprobe_check_cc * const condition_checks[16] = {
1628enum kprobe_insn __kprobes 1538enum kprobe_insn __kprobes
1629arm_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi) 1539arm_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi)
1630{ 1540{
1631 asi->insn_check_cc = condition_checks[insn>>28]; 1541 asi->insn_check_cc = kprobe_condition_checks[insn>>28];
1632 asi->insn[1] = KPROBE_RETURN_INSTRUCTION; 1542 asi->insn[1] = KPROBE_RETURN_INSTRUCTION;
1633 1543
1634 if ((insn & 0xf0000000) == 0xf0000000) 1544 if ((insn & 0xf0000000) == 0xf0000000)