All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Long <dave.long@linaro.org>
To: "Jon Medhurst (Tixy)" <tixy@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org,
	Rabin Vincent <rabin@rab.in>, Oleg Nesterov <oleg@redhat.com>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 11/13] ARM: Finish renaming ARM kprobes APIs for sharing with uprobes
Date: Fri, 15 Nov 2013 10:45:59 -0500	[thread overview]
Message-ID: <528641B7.2080409@linaro.org> (raw)
In-Reply-To: <1384363014.3392.44.camel@linaro1.home>

On 11/13/13 12:16, Jon Medhurst (Tixy) wrote:
> On Tue, 2013-10-15 at 17:04 -0400, David Long wrote:
>> From: "David A. Long" <dave.long@linaro.org>
>>
>> Use the prefix "probes_" for APIs and definitions to be shared between
>> kprobes and uprobes. Pass additional information into the lower-level decoding
>> functions to avoid having to duplicate architecture-specfific data structures.
>> Make susbsystem-specific APIs static (non-global) again.  Make a couple of utility
>> functions (probes_simulate_nop and probes_emulate_none) sharable and in a common
>> file. Keep the current "action" tables specific to kprobes, as this is where
>> uprobes functionality will be connected up to the instruction interpreter.
>
> That's a rather long list of things this patch is reorganising and makes
> it very difficult to review. For those class of changes which are
> independent of each other, can you do them as separate patches?
>
> Particularly, the change from using the function arguments
>
>      struct kprobe *p
>
> to
>      probes_opcode_t opcode, probes_opcode_t *addr, struct arch_specific_insn *asi
>
> should be in it's own separate patch as that is spread out across multiple files
> and functions.

OK, I will break this down further into separate patches.

> I have a few general comments on this patch...
>
> 1. I don't think we actually need to pass 'probes_opcode_t *addr' to the
> simulation functions, this will be the same as regs->ARM_pc (except that
> for thumb code 'addr' has bit0 set, which we don't actually care about).
> So drop the new 'addr' argument, and we can also delete the definition of
> thumb_probe_pc() and replace its use with 'regs->ARM_pc + 4'

I had some trouble getting that to work before, but I'll try again.

> 2. Now we pass 'probes_opcode_t opcode' to simulation functions a lot of
> them end up doing the redundant...
>
>     kprobe_opcode_t insn = opcode
>
> I would suggest deleting all of these assignments and either rename all
> use of 'insn' to 'opcode' or just changing the function argument name to
> 'insn'.

OK, I'll have a go at that.

> 3. I've a comment about the change to probes_decode_insn, I've snipped
> the rest of the patch...
>
> [...]
>>   int __kprobes
>> -kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>> +probes_decode_insn(probes_opcode_t insn, struct arch_specific_insn *asi,
>>   				const union decode_item *table, bool thumb,
>> -				const union decode_item *actions)
>> +				bool usermode, const union decode_item *actions)
>>   {
>
> The new argument 'usermode' is named for the use you are using it for,
> i.e. uprobes, I think the code is more intuitive if it was called
> something like 'no_emulate', because what the argument does is force all
> emulate operations to become 'custom'.
>
> Perhaps to avoid double negatives like !no_emulate, the logic of the
> argument could be inverted and it called 'use_emulation' or something.

Or maybe just "emulate".

>> -	const struct decode_header *h = (struct decode_header *)table;
>> -	const struct decode_header *next;
>> +	struct decode_header *h = (struct decode_header *)table;
>> +	struct decode_header *next;
>>   	bool matched = false;
>>
>> -	insn = prepare_emulated_insn(insn, asi, thumb);
>> +	if (!usermode)
>> +		insn = prepare_emulated_insn(insn, asi, thumb);
>>
>>   	for (;; h = next) {
>>   		enum decode_type type = h->type_regs.bits & DECODE_TYPE_MASK;
>> @@ -401,7 +412,7 @@ kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>>   		if (!matched && (insn & h->mask.bits) != h->value.bits)
>>   			continue;
>>
>> -		if (!decode_regs(&insn, regs))
>> +		if (!decode_regs(&insn, regs, !usermode))
>>   			return INSN_REJECTED;
>>
>>   		switch (type) {
>> @@ -414,7 +425,8 @@ kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>>
>>   		case DECODE_TYPE_CUSTOM: {
>>   			struct decode_custom *d = (struct decode_custom *)h;
>> -			return actions[d->decoder.bits].decoder(insn, asi, h);
>> +			return actions[d->decoder.bits].decoder(insn,
>> +					asi, h);
>>   		}
>>
>>   		case DECODE_TYPE_SIMULATE: {
>> @@ -425,6 +437,11 @@ kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>>
>>   		case DECODE_TYPE_EMULATE: {
>>   			struct decode_emulate *d = (struct decode_emulate *)h;
>> +
>> +			if (usermode)
>> +				return actions[d->handler.bits].decoder(insn,
>> +								asi, h);
>> +
>>   			asi->insn_handler = actions[d->handler.bits].handler;
>>   			set_emulated_insn(insn, asi, thumb);
>>   			return INSN_GOOD;
>
> [...]
>


WARNING: multiple messages have this Message-ID (diff)
From: dave.long@linaro.org (David Long)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 11/13] ARM: Finish renaming ARM kprobes APIs for sharing with uprobes
Date: Fri, 15 Nov 2013 10:45:59 -0500	[thread overview]
Message-ID: <528641B7.2080409@linaro.org> (raw)
In-Reply-To: <1384363014.3392.44.camel@linaro1.home>

On 11/13/13 12:16, Jon Medhurst (Tixy) wrote:
> On Tue, 2013-10-15 at 17:04 -0400, David Long wrote:
>> From: "David A. Long" <dave.long@linaro.org>
>>
>> Use the prefix "probes_" for APIs and definitions to be shared between
>> kprobes and uprobes. Pass additional information into the lower-level decoding
>> functions to avoid having to duplicate architecture-specfific data structures.
>> Make susbsystem-specific APIs static (non-global) again.  Make a couple of utility
>> functions (probes_simulate_nop and probes_emulate_none) sharable and in a common
>> file. Keep the current "action" tables specific to kprobes, as this is where
>> uprobes functionality will be connected up to the instruction interpreter.
>
> That's a rather long list of things this patch is reorganising and makes
> it very difficult to review. For those class of changes which are
> independent of each other, can you do them as separate patches?
>
> Particularly, the change from using the function arguments
>
>      struct kprobe *p
>
> to
>      probes_opcode_t opcode, probes_opcode_t *addr, struct arch_specific_insn *asi
>
> should be in it's own separate patch as that is spread out across multiple files
> and functions.

OK, I will break this down further into separate patches.

> I have a few general comments on this patch...
>
> 1. I don't think we actually need to pass 'probes_opcode_t *addr' to the
> simulation functions, this will be the same as regs->ARM_pc (except that
> for thumb code 'addr' has bit0 set, which we don't actually care about).
> So drop the new 'addr' argument, and we can also delete the definition of
> thumb_probe_pc() and replace its use with 'regs->ARM_pc + 4'

I had some trouble getting that to work before, but I'll try again.

> 2. Now we pass 'probes_opcode_t opcode' to simulation functions a lot of
> them end up doing the redundant...
>
>     kprobe_opcode_t insn = opcode
>
> I would suggest deleting all of these assignments and either rename all
> use of 'insn' to 'opcode' or just changing the function argument name to
> 'insn'.

OK, I'll have a go at that.

> 3. I've a comment about the change to probes_decode_insn, I've snipped
> the rest of the patch...
>
> [...]
>>   int __kprobes
>> -kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>> +probes_decode_insn(probes_opcode_t insn, struct arch_specific_insn *asi,
>>   				const union decode_item *table, bool thumb,
>> -				const union decode_item *actions)
>> +				bool usermode, const union decode_item *actions)
>>   {
>
> The new argument 'usermode' is named for the use you are using it for,
> i.e. uprobes, I think the code is more intuitive if it was called
> something like 'no_emulate', because what the argument does is force all
> emulate operations to become 'custom'.
>
> Perhaps to avoid double negatives like !no_emulate, the logic of the
> argument could be inverted and it called 'use_emulation' or something.

Or maybe just "emulate".

>> -	const struct decode_header *h = (struct decode_header *)table;
>> -	const struct decode_header *next;
>> +	struct decode_header *h = (struct decode_header *)table;
>> +	struct decode_header *next;
>>   	bool matched = false;
>>
>> -	insn = prepare_emulated_insn(insn, asi, thumb);
>> +	if (!usermode)
>> +		insn = prepare_emulated_insn(insn, asi, thumb);
>>
>>   	for (;; h = next) {
>>   		enum decode_type type = h->type_regs.bits & DECODE_TYPE_MASK;
>> @@ -401,7 +412,7 @@ kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>>   		if (!matched && (insn & h->mask.bits) != h->value.bits)
>>   			continue;
>>
>> -		if (!decode_regs(&insn, regs))
>> +		if (!decode_regs(&insn, regs, !usermode))
>>   			return INSN_REJECTED;
>>
>>   		switch (type) {
>> @@ -414,7 +425,8 @@ kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>>
>>   		case DECODE_TYPE_CUSTOM: {
>>   			struct decode_custom *d = (struct decode_custom *)h;
>> -			return actions[d->decoder.bits].decoder(insn, asi, h);
>> +			return actions[d->decoder.bits].decoder(insn,
>> +					asi, h);
>>   		}
>>
>>   		case DECODE_TYPE_SIMULATE: {
>> @@ -425,6 +437,11 @@ kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
>>
>>   		case DECODE_TYPE_EMULATE: {
>>   			struct decode_emulate *d = (struct decode_emulate *)h;
>> +
>> +			if (usermode)
>> +				return actions[d->handler.bits].decoder(insn,
>> +								asi, h);
>> +
>>   			asi->insn_handler = actions[d->handler.bits].handler;
>>   			set_emulated_insn(insn, asi, thumb);
>>   			return INSN_GOOD;
>
> [...]
>

  reply	other threads:[~2013-11-15 15:46 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 21:04 [PATCH v2 00/13] uprobes: Add uprobes support for ARM David Long
2013-10-15 21:04 ` David Long
2013-10-15 21:04 ` [PATCH v2 01/13] uprobes: move function declarations out of arch David Long
2013-10-15 21:04   ` David Long
2013-11-05 16:01   ` Oleg Nesterov
2013-11-05 16:01     ` Oleg Nesterov
2013-11-05 18:16     ` Oleg Nesterov
2013-11-05 18:16       ` Oleg Nesterov
2013-11-05 19:01       ` [PATCH] uprobes: Export write_opcode() as uprobe_write_opcode() Oleg Nesterov
2013-11-05 19:01         ` Oleg Nesterov
2013-11-05 19:55         ` David Long
2013-11-05 19:55           ` David Long
2013-11-05 19:13       ` [PATCH v2 01/13] uprobes: move function declarations out of arch David Long
2013-11-05 19:13         ` David Long
2013-10-15 21:04 ` [PATCH v2 02/13] uprobes: allow ignoring of probe hits David Long
2013-10-15 21:04   ` David Long
2013-10-19 17:02   ` Oleg Nesterov
2013-10-19 17:02     ` Oleg Nesterov
2013-10-22  3:45     ` David Long
2013-10-22  3:45       ` David Long
2013-10-22 11:25       ` Oleg Nesterov
2013-10-22 11:25         ` Oleg Nesterov
2013-10-22 23:56         ` David Long
2013-10-22 23:56           ` David Long
2013-10-28 18:54     ` Oleg Nesterov
2013-10-28 18:54       ` Oleg Nesterov
2013-10-30 21:11       ` David Long
2013-10-30 21:11         ` David Long
2013-10-15 21:04 ` [PATCH v2 03/13] uprobes: allow arch access to xol slot David Long
2013-10-15 21:04   ` David Long
2013-10-19 16:36   ` Oleg Nesterov
2013-10-19 16:36     ` Oleg Nesterov
2013-10-23  0:03     ` David Long
2013-10-23  0:03       ` David Long
2013-10-29 15:40       ` Oleg Nesterov
2013-10-29 15:40         ` Oleg Nesterov
2013-11-04 19:49         ` [PATCH] uprobes: introduce arch_uprobe->ixol Oleg Nesterov
2013-11-04 19:49           ` Oleg Nesterov
2013-11-04 21:25           ` David Long
2013-11-04 21:25             ` David Long
2013-11-05 16:04           ` David Long
2013-11-05 16:04             ` David Long
2013-11-05 18:01             ` Oleg Nesterov
2013-11-05 18:01               ` Oleg Nesterov
2013-11-05 18:45               ` David Long
2013-11-05 18:45                 ` David Long
2013-10-15 21:04 ` [PATCH v2 04/13] uprobes: allow arch-specific initialization David Long
2013-10-15 21:04   ` David Long
2013-10-19 16:42   ` Oleg Nesterov
2013-10-19 16:42     ` Oleg Nesterov
2013-10-23  1:21     ` David Long
2013-10-23  1:21       ` David Long
2013-10-28 18:58       ` Oleg Nesterov
2013-10-28 18:58         ` Oleg Nesterov
2013-10-31 18:41         ` David Long
2013-10-31 18:41           ` David Long
2013-11-01 13:52           ` Oleg Nesterov
2013-11-01 13:52             ` Oleg Nesterov
2013-11-04  3:24             ` David Long
2013-11-04  3:24               ` David Long
2013-10-15 21:04 ` [PATCH v2 05/13] uprobes: add arch write opcode hook David Long
2013-10-15 21:04   ` David Long
2013-10-19 16:50   ` Oleg Nesterov
2013-10-19 16:50     ` Oleg Nesterov
2013-10-23 18:20     ` David Long
2013-10-23 18:20       ` David Long
2013-10-28 19:49       ` Oleg Nesterov
2013-10-28 19:49         ` Oleg Nesterov
2013-10-29 19:59         ` Oleg Nesterov
2013-10-29 19:59           ` Oleg Nesterov
2013-11-02  3:33           ` David Long
2013-11-02  3:33             ` David Long
2013-11-02 14:03             ` Oleg Nesterov
2013-11-02 14:03               ` Oleg Nesterov
2013-10-15 21:04 ` [PATCH v2 06/13] ARM: move shared uprobe/kprobe definitions into new include file David Long
2013-10-15 21:04   ` David Long
2013-10-15 21:04 ` [PATCH v2 07/13] ARM: move generic thumb instruction parsing code to new files for use by other features David Long
2013-11-13 17:09   ` Jon Medhurst (Tixy)
2013-11-13 17:09     ` Jon Medhurst (Tixy)
2013-11-14 14:13     ` David Long
2013-11-14 14:13       ` David Long
2013-10-15 21:04 ` [PATCH v2 08/13] ARM: use a function table for determining instruction interpreter actions David Long
2013-11-13 17:11   ` Jon Medhurst (Tixy)
2013-11-13 17:11     ` Jon Medhurst (Tixy)
2013-11-14 15:17     ` David Long
2013-11-14 15:17       ` David Long
2013-10-15 21:04 ` [PATCH v2 09/13] ARM: Disable jprobe selftests in thumb kernels David Long
2013-10-15 21:04   ` David Long
2013-11-07 17:26   ` Jon Medhurst (Tixy)
2013-11-07 17:26     ` Jon Medhurst (Tixy)
2013-11-10 22:57     ` David Long
2013-11-10 22:57       ` David Long
2013-10-15 21:04 ` [PATCH v2 10/13] kprobes: Remove uneeded kernel dependency on struct arch_specific_insn David Long
2013-10-15 21:04   ` David Long
2013-11-13 17:13   ` Jon Medhurst (Tixy)
2013-11-13 17:13     ` Jon Medhurst (Tixy)
2013-11-14  2:02     ` Masami Hiramatsu
2013-11-14  2:02       ` Masami Hiramatsu
2013-11-14 14:15       ` Jon Medhurst (Tixy)
2013-11-14 14:15         ` Jon Medhurst (Tixy)
2013-11-14 20:33         ` David Long
2013-11-14 20:33           ` David Long
2013-11-15 10:23           ` Masami Hiramatsu
2013-11-15 10:23             ` Masami Hiramatsu
2013-11-15 15:16             ` David Long
2013-11-15 15:16               ` David Long
2013-11-15 10:11         ` Re: " Masami Hiramatsu
2013-11-15 10:11           ` Masami Hiramatsu
2013-11-14  1:20   ` Masami Hiramatsu
2013-11-14  1:20     ` Masami Hiramatsu
2013-10-15 21:04 ` [PATCH v2 11/13] ARM: Finish renaming ARM kprobes APIs for sharing with uprobes David Long
2013-10-15 21:04   ` David Long
2013-11-13 17:16   ` Jon Medhurst (Tixy)
2013-11-13 17:16     ` Jon Medhurst (Tixy)
2013-11-15 15:45     ` David Long [this message]
2013-11-15 15:45       ` David Long
2013-10-15 21:04 ` [PATCH v2 12/13] ARM: add uprobes support David Long
2013-10-15 21:04   ` David Long
2013-10-15 21:04 ` [PATCH v2 13/13] ARM: Remove uprobes dependency on kprobes David Long
2013-10-15 21:04   ` David Long

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=528641B7.2080409@linaro.org \
    --to=dave.long@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=rabin@rab.in \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=tixy@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.