Skip to content

Commit 0c5f416

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: armv8_deprecated: move aarch32 helper earlier
Subsequent patches will rework the logic in armv8_deprecated.c. In preparation for subsequent changes, this patch moves some shared logic earlier in the file. This will make subsequent diffs simpler and easier to read. At the same time, drop the `__kprobes` annotation from aarch32_check_condition(), as this is only used for traps from compat userspace, and has no risk of recursion within kprobes. As this is the last kprobes annotation in armve8_deprecated.c, we no longer need to include <asm/kprobes.h>. Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: James Morse <[email protected]> Cc: Joey Gouly <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 25eeac0 commit 0c5f416

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

arch/arm64/kernel/armv8_deprecated.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <asm/sysreg.h>
1818
#include <asm/system_misc.h>
1919
#include <asm/traps.h>
20-
#include <asm/kprobes.h>
2120

2221
#define CREATE_TRACE_POINTS
2322
#include "trace-events-emulation.h"
@@ -52,6 +51,25 @@ struct insn_emulation {
5251
int max;
5352
};
5453

54+
#define ARM_OPCODE_CONDTEST_FAIL 0
55+
#define ARM_OPCODE_CONDTEST_PASS 1
56+
#define ARM_OPCODE_CONDTEST_UNCOND 2
57+
58+
#define ARM_OPCODE_CONDITION_UNCOND 0xf
59+
60+
static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
61+
{
62+
u32 cc_bits = opcode >> 28;
63+
64+
if (cc_bits != ARM_OPCODE_CONDITION_UNCOND) {
65+
if ((*aarch32_opcode_cond_checks[cc_bits])(psr))
66+
return ARM_OPCODE_CONDTEST_PASS;
67+
else
68+
return ARM_OPCODE_CONDTEST_FAIL;
69+
}
70+
return ARM_OPCODE_CONDTEST_UNCOND;
71+
}
72+
5573
/*
5674
* Implement emulation of the SWP/SWPB instructions using load-exclusive and
5775
* store-exclusive.
@@ -132,25 +150,6 @@ static int emulate_swpX(unsigned int address, unsigned int *data,
132150
return res;
133151
}
134152

135-
#define ARM_OPCODE_CONDTEST_FAIL 0
136-
#define ARM_OPCODE_CONDTEST_PASS 1
137-
#define ARM_OPCODE_CONDTEST_UNCOND 2
138-
139-
#define ARM_OPCODE_CONDITION_UNCOND 0xf
140-
141-
static unsigned int __kprobes aarch32_check_condition(u32 opcode, u32 psr)
142-
{
143-
u32 cc_bits = opcode >> 28;
144-
145-
if (cc_bits != ARM_OPCODE_CONDITION_UNCOND) {
146-
if ((*aarch32_opcode_cond_checks[cc_bits])(psr))
147-
return ARM_OPCODE_CONDTEST_PASS;
148-
else
149-
return ARM_OPCODE_CONDTEST_FAIL;
150-
}
151-
return ARM_OPCODE_CONDTEST_UNCOND;
152-
}
153-
154153
/*
155154
* swp_handler logs the id of calling process, dissects the instruction, sanity
156155
* checks the memory location, calls emulate_swpX for the actual operation and

0 commit comments

Comments
 (0)