From: leif.lindholm@arm.com (Leif Lindholm)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] [RFC] Use generic ARM instruction set condition code checks for kprobes.
Date: Mon, 21 Nov 2011 18:31:04 +0000 [thread overview]
Message-ID: <20111121183104.28964.87120.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20111121183046.28964.23829.stgit@localhost6.localdomain6>
This patch changes the kprobes implementation to use the generic ARM
instruction set condition code checks, rather than a dedicated
implementation.
Note, this is a direct interface change, and the resulting code is not
the prettiest, but this is an RFC only.
This code builds and links, but current 3.2-rc2 does not boot on my
Versatile Express board with CONFIG_ARM_KPROBES_TEST enabled either
with or without this patch.
Cc: Tixy <tixy@yxit.co.uk>
Signed-off-by: Leif Lindholm <leif.lindholm@arm.com>
---
arch/arm/kernel/kprobes-test.c | 71 +++-------------------------------------
1 files changed, 5 insertions(+), 66 deletions(-)
diff --git a/arch/arm/kernel/kprobes-test.c b/arch/arm/kernel/kprobes-test.c
index e17cdd6..6f5328a 100644
--- a/arch/arm/kernel/kprobes-test.c
+++ b/arch/arm/kernel/kprobes-test.c
@@ -202,6 +202,8 @@
#include <linux/slab.h>
#include <linux/kprobes.h>
+#include <asm/opcodes.h>
+
#include "kprobes.h"
#include "kprobes-test.h"
@@ -1048,69 +1050,6 @@ static int test_instance;
*/
#define PSR_IGNORE_BITS (PSR_A_BIT | PSR_F_BIT)
-static unsigned long test_check_cc(int cc, unsigned long cpsr)
-{
- unsigned long temp;
-
- switch (cc) {
- case 0x0: /* eq */
- return cpsr & PSR_Z_BIT;
-
- case 0x1: /* ne */
- return (~cpsr) & PSR_Z_BIT;
-
- case 0x2: /* cs */
- return cpsr & PSR_C_BIT;
-
- case 0x3: /* cc */
- return (~cpsr) & PSR_C_BIT;
-
- case 0x4: /* mi */
- return cpsr & PSR_N_BIT;
-
- case 0x5: /* pl */
- return (~cpsr) & PSR_N_BIT;
-
- case 0x6: /* vs */
- return cpsr & PSR_V_BIT;
-
- case 0x7: /* vc */
- return (~cpsr) & PSR_V_BIT;
-
- case 0x8: /* hi */
- cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */
- return cpsr & PSR_C_BIT;
-
- case 0x9: /* ls */
- cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */
- return (~cpsr) & PSR_C_BIT;
-
- case 0xa: /* ge */
- cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
- return (~cpsr) & PSR_N_BIT;
-
- case 0xb: /* lt */
- cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
- return cpsr & PSR_N_BIT;
-
- case 0xc: /* gt */
- temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
- temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */
- return (~temp) & PSR_N_BIT;
-
- case 0xd: /* le */
- temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */
- temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */
- return temp & PSR_N_BIT;
-
- case 0xe: /* al */
- case 0xf: /* unconditional */
- return true;
- }
- BUG();
- return false;
-}
-
static int is_last_scenario;
static int probe_should_run; /* 0 = no, 1 = yes, -1 = unknown */
static int memory_needs_checking;
@@ -1128,7 +1067,7 @@ static unsigned long test_context_cpsr(int scenario)
if (!test_case_is_thumb) {
/* Testing ARM code */
- probe_should_run = test_check_cc(current_instruction >> 28, cpsr) != 0;
+ probe_should_run = arm_check_condition(current_instruction, cpsr) != 0;
if (scenario == 15)
is_last_scenario = true;
@@ -1136,7 +1075,7 @@ static unsigned long test_context_cpsr(int scenario)
/* Testing Thumb code without setting ITSTATE */
if (kprobe_test_cc_position) {
int cc = (current_instruction >> kprobe_test_cc_position) & 0xf;
- probe_should_run = test_check_cc(cc, cpsr) != 0;
+ probe_should_run = arm_check_condition(cc << 28, cpsr) != 0;
}
if (scenario == 15)
@@ -1163,7 +1102,7 @@ static unsigned long test_context_cpsr(int scenario)
cpsr |= (mask & 0x8) << 23; /* ITSTATE<1> */
cpsr |= (mask & 0x10) << 21; /* ITSTATE<0> */
- probe_should_run = test_check_cc((cpsr >> 12) & 0xf, cpsr) != 0;
+ probe_should_run = arm_check_condition(((cpsr >> 12) & 0xf) << 28, cpsr) != 0;
} else {
/* Testing Thumb code with several combinations of ITSTATE */
next prev parent reply other threads:[~2011-11-21 18:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-21 18:30 [PATCH 1/4] [RFC] Add generic ARM instruction set condition code checks Leif Lindholm
2011-11-21 18:30 ` [PATCH 2/4] [RFC] Use generic ARM instruction set condition code checks for nwfpe Leif Lindholm
2011-11-21 18:30 ` [PATCH 3/4] [RFC] Add condition code checking to SWP emulation handler Leif Lindholm
2011-11-21 18:53 ` Will Deacon
2011-11-21 18:31 ` Leif Lindholm [this message]
2011-11-22 9:13 ` [PATCH 4/4] [RFC] Use generic ARM instruction set condition code checks for kprobes Tixy
[not found] ` <4ECE78B6.9040408@arm.com>
2011-11-24 19:40 ` Tixy
2011-11-25 13:29 ` Leif Lindholm
2011-11-21 18:52 ` [PATCH 1/4] [RFC] Add generic ARM instruction set condition code checks Will Deacon
2011-11-21 19:08 ` Russell King - ARM Linux
2011-11-22 10:18 ` Dave Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111121183104.28964.87120.stgit@localhost6.localdomain6 \
--to=leif.lindholm@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox