linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: tixy@yxit.co.uk (Tixy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] Use generic ARM instruction set condition code checks for kprobes.
Date: Sat, 10 Dec 2011 09:19:00 +0000	[thread overview]
Message-ID: <1323508740.2307.1.camel@computer2> (raw)
In-Reply-To: <20111209185503.19655.37484.stgit@localhost6.localdomain6>

On Fri, 2011-12-09 at 18:55 +0000, Leif Lindholm wrote:
> This patch changes the kprobes implementation to use the generic ARM
> instruction set condition code checks, rather than a dedicated
> implementation.
> 
> Signed-off-by: Leif Lindholm <leif.lindholm@arm.com>

Acked-by: Jon Medhurst <tixy@yxit.co.uk>

> ---
> Tixy's ACK removed as patch modified.
> 
>  arch/arm/kernel/kprobes-test.c |   66 ++++------------------------------------
>  1 files changed, 7 insertions(+), 59 deletions(-)
> 
> diff --git a/arch/arm/kernel/kprobes-test.c b/arch/arm/kernel/kprobes-test.c
> index e17cdd6..1862d8f 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"
>  
> @@ -1050,65 +1052,9 @@ static int test_instance;
>  
>  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;
> +	int ret = arm_check_condition(cc << 28, cpsr);
>  
> -	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;
> +	return (ret != ARM_OPCODE_CONDTEST_FAIL);
>  }
>  
>  static int is_last_scenario;
> @@ -1128,7 +1074,9 @@ 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;
> +		int cc = current_instruction >> 28;
> +
> +		probe_should_run = test_check_cc(cc, cpsr) != 0;
>  		if (scenario == 15)
>  			is_last_scenario = true;
>  
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2011-12-10  9:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 18:54 [PATCH 0/4] Add generic ARM ISA condition code check v3 Leif Lindholm
2011-12-09 18:54 ` [PATCH 1/4] Add generic ARM instruction set condition code checks Leif Lindholm
2011-12-10 13:20   ` Will Deacon
2011-12-09 18:54 ` [PATCH 2/4] Use generic ARM instruction set condition code checks for nwfpe Leif Lindholm
2011-12-10 13:21   ` Will Deacon
2011-12-09 18:54 ` [PATCH 3/4] Add condition code checking to SWP emulation handler Leif Lindholm
2011-12-10 13:22   ` Will Deacon
2011-12-09 18:55 ` [PATCH 4/4] Use generic ARM instruction set condition code checks for kprobes Leif Lindholm
2011-12-10  9:19   ` Tixy [this message]
2011-12-10 13:24   ` Will Deacon
  -- strict thread matches above, loose matches on Subject: below --
2011-12-08 17:31 [PATCH 0/4] Add generic ARM ISA condition code check Leif Lindholm
2011-12-08 17:32 ` [PATCH 4/4] Use generic ARM instruction set condition code checks for kprobes Leif Lindholm
2011-12-09 15:54   ` Will Deacon
2011-12-09 16:17     ` Leif Lindholm
2011-12-09 16:40       ` Will Deacon
2011-12-09 17:48         ` Leif Lindholm
2011-12-09 18:05         ` Jon Medhurst (Tixy)
2011-12-09 18:26           ` Leif Lindholm
2011-12-09 18:26           ` Leif Lindholm
2011-11-25 17:19 [PATCH 0/4] Add generic ARM ISA condition code checks Leif Lindholm
2011-11-25 17:20 ` [PATCH 4/4] Use generic ARM instruction set condition code checks for kprobes Leif Lindholm
2011-11-27 12:24   ` Tixy
2011-11-30 17:02   ` 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=1323508740.2307.1.camel@computer2 \
    --to=tixy@yxit.co.uk \
    --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;
as well as URLs for NNTP newsgroup(s).