History log of /arch/arm/kernel/kprobes-common.c
Revision Date Author Comments
888be25402021a425da3e85e2d5a954d7509286e 08-Nov-2013 Ben Dooks <ben.dooks@codethink.co.uk> ARM: probes: fix instruction fetch order with <asm/opcodes.h>

If we are running BE8, the data and instruction endianness do not
match, so use <asm/opcodes.h> to correctly translate memory accesses
into ARM instructions.

Acked-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
[taras.kondratiuk@linaro.org: fixed Thumb instruction fetch order]
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
b4cd605ca92d9a8a2f71355cb45dd943ebcb0c97 06-Mar-2014 David A. Long <dave.long@linaro.org> ARM: Make arch_specific_insn a define for new arch_probes_insn structure

Because the common underlying code for ARM kprobes and uprobes needs
to share a common architecrure-specific context structure, and because
the generic kprobes include file insists on defining this to a dummy
structure when kprobes is not configured, a new common structure is
required which can exist when uprobes is configured without kprobes.
In this case kprobes will define a dummy structure, but without the
define aliasing the two structure tags it will not affect uprobes and
the shared probes code.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
47e190fafde49ff8ca732fa137e39cb2b8baba8c 07-Mar-2014 David A. Long <dave.long@linaro.org> ARM: Change the remaining shared kprobes/uprobes symbols to something generic

Any more ARM kprobes/uprobes symbols which have "kprobe" in the name must be
changed to the more generic "probes" or other non-kprobes specific symbol.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
44a0a59c535004eac9f18210cb2ce10b23861630 06-Mar-2014 David A. Long <dave.long@linaro.org> ARM: Rename the shared kprobes/uprobe return value enum

Change the name of kprobes_insn to probes_insn so it can be shared between
kprobes and uprobes without confusion.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
f145d664df502585618b12ed68c681f82153e02a 06-Mar-2014 David A. Long <dave.long@linaro.org> ARM: Make the kprobes condition_check symbol names more generic

In preparation for sharing the ARM kprobes instruction interpreting
code with uprobes, make the symbols names less kprobes-specific.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
7579f4b3764337b39087d10496af0e741cbfe570 07-Mar-2014 David A. Long <dave.long@linaro.org> ARM: Remove use of struct kprobe from generic probes code

Change the generic ARM probes code to pass in the opcode and architecture-specific
structure separately instead of using struct kprobe, so we do not pollute
code being used only for uprobes or other non-kprobes instruction
interpretation.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
3e6cd394bb10c2d65322e5f5d2ff0a9074d903a1 07-Mar-2014 David A. Long <dave.long@linaro.org> ARM: use a function table for determining instruction interpreter action

Make the instruction interpreter call back to semantic action functions
through a function pointer array provided by the invoker. The interpreter
decodes the instructions into groups and uses the group number to index
into the supplied array. kprobes and uprobes code will each supply their
own array of functions.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
c18377c303787ded44b7decd7dee694db0f205e9 07-Mar-2014 David A. Long <dave.long@linaro.org> ARM: Move generic arm instruction parsing code to new files for sharing between features

Move the arm version of the kprobes instruction parsing code into more generic
files from where it can be used by uprobes and possibly other subsystems. The
symbol names will be made more generic in a subsequent part of this patchset.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
21254ebc9e509967317ad8c6922797e21137ad53 07-Mar-2014 David A. Long <dave.long@linaro.org> ARM: Fix missing includes in kprobes sources

Make sure includes in ARM kprobes sources are done explicitly. Do not
rely on includes from other includes.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
9f97da78bf018206fb623cd351d454af2f105fe0 28-Mar-2012 David Howells <dhowells@redhat.com> Disintegrate asm/system.h for ARM

Disintegrate asm/system.h for ARM.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Russell King <linux@arm.linux.org.uk>
cc: linux-arm-kernel@lists.infradead.org
df4fa1f8dde23db25f50e49535d2c7db0005f9ad 01-Jul-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Add alu_write_pc()

This writes a new value to PC which was obtained as the result of an ARM
ALU instruction. For ARMv7 and later this performs interworking.

On ARM kernels we shouldn't encounter any ALU instructions trying to
switch to Thumb mode so support for this isn't strictly necessary.
However, the approach taken in all other instruction decoding is for us
to avoid unpredictable modification of the PC for security reasons. This
is usually achieved by rejecting insertion of probes on problematic
instruction, but for ALU instructions we can't do this as it depends on
the contents of the CPU registers at the time the probe is hit. So, as
we require some form of run-time checking to trap undesirable PC
modification, we may as well simulate the instructions correctly, i.e.
in the way they would behave in the absence of a probe.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
3d4a99785abee0687f8fad9a055d2f0c61a9dd57 14-Jun-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Optimise emulation of LDM and STM

This patch improves the performance of LDM and STM instruction
emulation. This is desirable because.

- jprobes and kretprobes probe the first instruction in a function and,
when the frame pointer is omitted, this instruction is often a STM
used to push registers onto the stack.

- The STM and LDM instructions are common in the body and tail of
functions.

- At the same time as being a common instruction form, they also have
one of the slowest and most complicated simulation routines.

The approach taken to optimisation is to use emulation rather than
simulation, that is, a modified form of the instruction is run with
an appropriate register context.

Benchmarking on an OMAP3530 shows the optimised emulation is between 2
and 3 times faster than the simulation routines. On a Kirkwood based
device the relative performance was very significantly better than this.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
235a4ce79feb8d5351f9164981bc57d5e29f974b 07-Jul-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Add common decoding function for LDM and STM

The encoding of these instructions is substantially the same for both
ARM and Thumb, so we can have common decoding and simulation functions.

This patch moves the simulation functions from kprobes-arm.c to
kprobes-common.c. It also adds a new simulation function
(simulate_ldm1_pc) for the case where we load into PC because this may
need to interwork.

The instruction decoding is done by a custom function
(kprobe_decode_ldmstm) rather than just relying on decoding table
entries because we will later be adding optimisation code.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
263e368a2f1f960db07d7524a4a3e7df951f1f72 10-Jun-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Add load_write_pc()

This writes a value to PC which was obtained as the result of a
LDR or LDM instruction. For ARMv5T and later this must perform
interworking.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
3f92dfed6a9a5f490128c8e7cc6a64dfe412994f 02-Jul-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Decode 16-bit Thumb hint instructions

For hints which may have observable effects, like SEV (send event), we
use kprobe_emulate_none which emulates the hint by executing the
original instruction.

For NOP we simulate the instruction using kprobe_simulate_nop, which
does nothing. As probes execute with interrupts disabled this is also
used for hints which may block for an indefinite time, like WFE (wait
for event).

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
0d1a095aa1e6e2a233bfb1729e15233e77f69d54 26-Apr-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Infrastructure for table driven decoding of CPU instructions

The existing ARM instruction decoding functions are a mass of if/else
code. Rather than follow this pattern for Thumb instruction decoding
this patch implements an infrastructure for a new table driven scheme.

This has several advantages:

- Reduces the kernel size by approx 2kB. (The ARM instruction decoding
will eventually have -3.1kB code, +1.3kB data; with similar or better
estimated savings for Thumb decoding.)

- Allows programmatic checking of decoding consistency and test case
coverage.

- Provides more uniform source code and is therefore, arguably, clearer.

For a detailed explanation of how decoding tables work see the in-source
documentation in kprobes.h, and also for kprobe_decode_insn().

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
aea490299f7f0412f884a4895bc96211d8d8dbaf 07-Jul-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Make str_pc_offset a constant on ARMv7

The str_pc_offset value is architecturally defined on ARMv7 onwards so
we can make it a compile time constant. This means on Thumb kernels the
runtime checking code isn't needed, which saves us from having to fix it
to work for Thumb.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
6c8df3300f60cae54aeb2a6dda8efe7ffe16a322 07-Jul-2011 Jon Medhurst <tixy@yxit.co.uk> ARM: kprobes: Move find_str_pc_offset into kprobes-common.c

Move str_pc_offset into kprobes-common.c as it will be needed by common
code later.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
0ab4c02ddae2e1d32d686a7773608f6c44fb2a83 06-Jul-2011 Jon Medhurst <tixy@yxit.co.uk> 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>