162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * arch/arm/probes/decode-arm.c
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Some code moved here from arch/arm/kernel/kprobes-arm.c
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Copyright (C) 2006, 2007 Motorola Inc.
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/kernel.h>
1262306a36Sopenharmony_ci#include <linux/module.h>
1362306a36Sopenharmony_ci#include <linux/stddef.h>
1462306a36Sopenharmony_ci#include <linux/ptrace.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include "decode.h"
1762306a36Sopenharmony_ci#include "decode-arm.h"
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define sign_extend(x, signbit) ((x) | (0 - ((x) & (1 << (signbit)))))
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define branch_displacement(insn) sign_extend(((insn) & 0xffffff) << 2, 25)
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/*
2462306a36Sopenharmony_ci * To avoid the complications of mimicing single-stepping on a
2562306a36Sopenharmony_ci * processor without a Next-PC or a single-step mode, and to
2662306a36Sopenharmony_ci * avoid having to deal with the side-effects of boosting, we
2762306a36Sopenharmony_ci * simulate or emulate (almost) all ARM instructions.
2862306a36Sopenharmony_ci *
2962306a36Sopenharmony_ci * "Simulation" is where the instruction's behavior is duplicated in
3062306a36Sopenharmony_ci * C code.  "Emulation" is where the original instruction is rewritten
3162306a36Sopenharmony_ci * and executed, often by altering its registers.
3262306a36Sopenharmony_ci *
3362306a36Sopenharmony_ci * By having all behavior of the kprobe'd instruction completed before
3462306a36Sopenharmony_ci * returning from the kprobe_handler(), all locks (scheduler and
3562306a36Sopenharmony_ci * interrupt) can safely be released.  There is no need for secondary
3662306a36Sopenharmony_ci * breakpoints, no race with MP or preemptable kernels, nor having to
3762306a36Sopenharmony_ci * clean up resources counts at a later time impacting overall system
3862306a36Sopenharmony_ci * performance.  By rewriting the instruction, only the minimum registers
3962306a36Sopenharmony_ci * need to be loaded and saved back optimizing performance.
4062306a36Sopenharmony_ci *
4162306a36Sopenharmony_ci * Calling the insnslot_*_rwflags version of a function doesn't hurt
4262306a36Sopenharmony_ci * anything even when the CPSR flags aren't updated by the
4362306a36Sopenharmony_ci * instruction.  It's just a little slower in return for saving
4462306a36Sopenharmony_ci * a little space by not having a duplicate function that doesn't
4562306a36Sopenharmony_ci * update the flags.  (The same optimization can be said for
4662306a36Sopenharmony_ci * instructions that do or don't perform register writeback)
4762306a36Sopenharmony_ci * Also, instructions can either read the flags, only write the
4862306a36Sopenharmony_ci * flags, or read and write the flags.  To save combinations
4962306a36Sopenharmony_ci * rather than for sheer performance, flag functions just assume
5062306a36Sopenharmony_ci * read and write of flags.
5162306a36Sopenharmony_ci */
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_civoid __kprobes simulate_bbl(probes_opcode_t insn,
5462306a36Sopenharmony_ci		struct arch_probes_insn *asi, struct pt_regs *regs)
5562306a36Sopenharmony_ci{
5662306a36Sopenharmony_ci	long iaddr = (long) regs->ARM_pc - 4;
5762306a36Sopenharmony_ci	int disp  = branch_displacement(insn);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci	if (insn & (1 << 24))
6062306a36Sopenharmony_ci		regs->ARM_lr = iaddr + 4;
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci	regs->ARM_pc = iaddr + 8 + disp;
6362306a36Sopenharmony_ci}
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_civoid __kprobes simulate_blx1(probes_opcode_t insn,
6662306a36Sopenharmony_ci		struct arch_probes_insn *asi, struct pt_regs *regs)
6762306a36Sopenharmony_ci{
6862306a36Sopenharmony_ci	long iaddr = (long) regs->ARM_pc - 4;
6962306a36Sopenharmony_ci	int disp = branch_displacement(insn);
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci	regs->ARM_lr = iaddr + 4;
7262306a36Sopenharmony_ci	regs->ARM_pc = iaddr + 8 + disp + ((insn >> 23) & 0x2);
7362306a36Sopenharmony_ci	regs->ARM_cpsr |= PSR_T_BIT;
7462306a36Sopenharmony_ci}
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_civoid __kprobes simulate_blx2bx(probes_opcode_t insn,
7762306a36Sopenharmony_ci		struct arch_probes_insn *asi, struct pt_regs *regs)
7862306a36Sopenharmony_ci{
7962306a36Sopenharmony_ci	int rm = insn & 0xf;
8062306a36Sopenharmony_ci	long rmv = regs->uregs[rm];
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci	if (insn & (1 << 5))
8362306a36Sopenharmony_ci		regs->ARM_lr = (long) regs->ARM_pc;
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci	regs->ARM_pc = rmv & ~0x1;
8662306a36Sopenharmony_ci	regs->ARM_cpsr &= ~PSR_T_BIT;
8762306a36Sopenharmony_ci	if (rmv & 0x1)
8862306a36Sopenharmony_ci		regs->ARM_cpsr |= PSR_T_BIT;
8962306a36Sopenharmony_ci}
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_civoid __kprobes simulate_mrs(probes_opcode_t insn,
9262306a36Sopenharmony_ci		struct arch_probes_insn *asi, struct pt_regs *regs)
9362306a36Sopenharmony_ci{
9462306a36Sopenharmony_ci	int rd = (insn >> 12) & 0xf;
9562306a36Sopenharmony_ci	unsigned long mask = 0xf8ff03df; /* Mask out execution state */
9662306a36Sopenharmony_ci	regs->uregs[rd] = regs->ARM_cpsr & mask;
9762306a36Sopenharmony_ci}
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_civoid __kprobes simulate_mov_ipsp(probes_opcode_t insn,
10062306a36Sopenharmony_ci		struct arch_probes_insn *asi, struct pt_regs *regs)
10162306a36Sopenharmony_ci{
10262306a36Sopenharmony_ci	regs->uregs[12] = regs->uregs[13];
10362306a36Sopenharmony_ci}
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci/*
10662306a36Sopenharmony_ci * For the instruction masking and comparisons in all the "space_*"
10762306a36Sopenharmony_ci * functions below, Do _not_ rearrange the order of tests unless
10862306a36Sopenharmony_ci * you're very, very sure of what you are doing.  For the sake of
10962306a36Sopenharmony_ci * efficiency, the masks for some tests sometimes assume other test
11062306a36Sopenharmony_ci * have been done prior to them so the number of patterns to test
11162306a36Sopenharmony_ci * for an instruction set can be as broad as possible to reduce the
11262306a36Sopenharmony_ci * number of tests needed.
11362306a36Sopenharmony_ci */
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_cistatic const union decode_item arm_1111_table[] = {
11662306a36Sopenharmony_ci	/* Unconditional instructions					*/
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci	/* memory hint		1111 0100 x001 xxxx xxxx xxxx xxxx xxxx */
11962306a36Sopenharmony_ci	/* PLDI (immediate)	1111 0100 x101 xxxx xxxx xxxx xxxx xxxx */
12062306a36Sopenharmony_ci	/* PLDW (immediate)	1111 0101 x001 xxxx xxxx xxxx xxxx xxxx */
12162306a36Sopenharmony_ci	/* PLD (immediate)	1111 0101 x101 xxxx xxxx xxxx xxxx xxxx */
12262306a36Sopenharmony_ci	DECODE_SIMULATE	(0xfe300000, 0xf4100000, PROBES_PRELOAD_IMM),
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci	/* memory hint		1111 0110 x001 xxxx xxxx xxxx xxx0 xxxx */
12562306a36Sopenharmony_ci	/* PLDI (register)	1111 0110 x101 xxxx xxxx xxxx xxx0 xxxx */
12662306a36Sopenharmony_ci	/* PLDW (register)	1111 0111 x001 xxxx xxxx xxxx xxx0 xxxx */
12762306a36Sopenharmony_ci	/* PLD (register)	1111 0111 x101 xxxx xxxx xxxx xxx0 xxxx */
12862306a36Sopenharmony_ci	DECODE_SIMULATE	(0xfe300010, 0xf6100000, PROBES_PRELOAD_REG),
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci	/* BLX (immediate)	1111 101x xxxx xxxx xxxx xxxx xxxx xxxx */
13162306a36Sopenharmony_ci	DECODE_SIMULATE	(0xfe000000, 0xfa000000, PROBES_BRANCH_IMM),
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci	/* CPS			1111 0001 0000 xxx0 xxxx xxxx xx0x xxxx */
13462306a36Sopenharmony_ci	/* SETEND		1111 0001 0000 0001 xxxx xxxx 0000 xxxx */
13562306a36Sopenharmony_ci	/* SRS			1111 100x x1x0 xxxx xxxx xxxx xxxx xxxx */
13662306a36Sopenharmony_ci	/* RFE			1111 100x x0x1 xxxx xxxx xxxx xxxx xxxx */
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci	/* Coprocessor instructions... */
13962306a36Sopenharmony_ci	/* MCRR2		1111 1100 0100 xxxx xxxx xxxx xxxx xxxx */
14062306a36Sopenharmony_ci	/* MRRC2		1111 1100 0101 xxxx xxxx xxxx xxxx xxxx */
14162306a36Sopenharmony_ci	/* LDC2			1111 110x xxx1 xxxx xxxx xxxx xxxx xxxx */
14262306a36Sopenharmony_ci	/* STC2			1111 110x xxx0 xxxx xxxx xxxx xxxx xxxx */
14362306a36Sopenharmony_ci	/* CDP2			1111 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */
14462306a36Sopenharmony_ci	/* MCR2			1111 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */
14562306a36Sopenharmony_ci	/* MRC2			1111 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci	/* Other unallocated instructions...				*/
14862306a36Sopenharmony_ci	DECODE_END
14962306a36Sopenharmony_ci};
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_cistatic const union decode_item arm_cccc_0001_0xx0____0xxx_table[] = {
15262306a36Sopenharmony_ci	/* Miscellaneous instructions					*/
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci	/* MRS cpsr		cccc 0001 0000 xxxx xxxx xxxx 0000 xxxx */
15562306a36Sopenharmony_ci	DECODE_SIMULATEX(0x0ff000f0, 0x01000000, PROBES_MRS,
15662306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, 0)),
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci	/* BX			cccc 0001 0010 xxxx xxxx xxxx 0001 xxxx */
15962306a36Sopenharmony_ci	DECODE_SIMULATE	(0x0ff000f0, 0x01200010, PROBES_BRANCH_REG),
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci	/* BLX (register)	cccc 0001 0010 xxxx xxxx xxxx 0011 xxxx */
16262306a36Sopenharmony_ci	DECODE_SIMULATEX(0x0ff000f0, 0x01200030, PROBES_BRANCH_REG,
16362306a36Sopenharmony_ci						 REGS(0, 0, 0, 0, NOPC)),
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci	/* CLZ			cccc 0001 0110 xxxx xxxx xxxx 0001 xxxx */
16662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff000f0, 0x01600010, PROBES_CLZ,
16762306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, NOPC)),
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci	/* QADD			cccc 0001 0000 xxxx xxxx xxxx 0101 xxxx */
17062306a36Sopenharmony_ci	/* QSUB			cccc 0001 0010 xxxx xxxx xxxx 0101 xxxx */
17162306a36Sopenharmony_ci	/* QDADD		cccc 0001 0100 xxxx xxxx xxxx 0101 xxxx */
17262306a36Sopenharmony_ci	/* QDSUB		cccc 0001 0110 xxxx xxxx xxxx 0101 xxxx */
17362306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f9000f0, 0x01000050, PROBES_SATURATING_ARITHMETIC,
17462306a36Sopenharmony_ci						 REGS(NOPC, NOPC, 0, 0, NOPC)),
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci	/* BXJ			cccc 0001 0010 xxxx xxxx xxxx 0010 xxxx */
17762306a36Sopenharmony_ci	/* MSR			cccc 0001 0x10 xxxx xxxx xxxx 0000 xxxx */
17862306a36Sopenharmony_ci	/* MRS spsr		cccc 0001 0100 xxxx xxxx xxxx 0000 xxxx */
17962306a36Sopenharmony_ci	/* BKPT			1110 0001 0010 xxxx xxxx xxxx 0111 xxxx */
18062306a36Sopenharmony_ci	/* SMC			cccc 0001 0110 xxxx xxxx xxxx 0111 xxxx */
18162306a36Sopenharmony_ci	/* And unallocated instructions...				*/
18262306a36Sopenharmony_ci	DECODE_END
18362306a36Sopenharmony_ci};
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_cistatic const union decode_item arm_cccc_0001_0xx0____1xx0_table[] = {
18662306a36Sopenharmony_ci	/* Halfword multiply and multiply-accumulate			*/
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci	/* SMLALxy		cccc 0001 0100 xxxx xxxx xxxx 1xx0 xxxx */
18962306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff00090, 0x01400080, PROBES_MUL1,
19062306a36Sopenharmony_ci						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci	/* SMULWy		cccc 0001 0010 xxxx xxxx xxxx 1x10 xxxx */
19362306a36Sopenharmony_ci	DECODE_OR	(0x0ff000b0, 0x012000a0),
19462306a36Sopenharmony_ci	/* SMULxy		cccc 0001 0110 xxxx xxxx xxxx 1xx0 xxxx */
19562306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff00090, 0x01600080, PROBES_MUL2,
19662306a36Sopenharmony_ci						 REGS(NOPC, 0, NOPC, 0, NOPC)),
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci	/* SMLAxy		cccc 0001 0000 xxxx xxxx xxxx 1xx0 xxxx */
19962306a36Sopenharmony_ci	DECODE_OR	(0x0ff00090, 0x01000080),
20062306a36Sopenharmony_ci	/* SMLAWy		cccc 0001 0010 xxxx xxxx xxxx 1x00 xxxx */
20162306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff000b0, 0x01200080, PROBES_MUL2,
20262306a36Sopenharmony_ci						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci	DECODE_END
20562306a36Sopenharmony_ci};
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_cistatic const union decode_item arm_cccc_0000_____1001_table[] = {
20862306a36Sopenharmony_ci	/* Multiply and multiply-accumulate				*/
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci	/* MUL			cccc 0000 0000 xxxx xxxx xxxx 1001 xxxx */
21162306a36Sopenharmony_ci	/* MULS			cccc 0000 0001 xxxx xxxx xxxx 1001 xxxx */
21262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fe000f0, 0x00000090, PROBES_MUL2,
21362306a36Sopenharmony_ci						 REGS(NOPC, 0, NOPC, 0, NOPC)),
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci	/* MLA			cccc 0000 0010 xxxx xxxx xxxx 1001 xxxx */
21662306a36Sopenharmony_ci	/* MLAS			cccc 0000 0011 xxxx xxxx xxxx 1001 xxxx */
21762306a36Sopenharmony_ci	DECODE_OR	(0x0fe000f0, 0x00200090),
21862306a36Sopenharmony_ci	/* MLS			cccc 0000 0110 xxxx xxxx xxxx 1001 xxxx */
21962306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff000f0, 0x00600090, PROBES_MUL2,
22062306a36Sopenharmony_ci						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci	/* UMAAL		cccc 0000 0100 xxxx xxxx xxxx 1001 xxxx */
22362306a36Sopenharmony_ci	DECODE_OR	(0x0ff000f0, 0x00400090),
22462306a36Sopenharmony_ci	/* UMULL		cccc 0000 1000 xxxx xxxx xxxx 1001 xxxx */
22562306a36Sopenharmony_ci	/* UMULLS		cccc 0000 1001 xxxx xxxx xxxx 1001 xxxx */
22662306a36Sopenharmony_ci	/* UMLAL		cccc 0000 1010 xxxx xxxx xxxx 1001 xxxx */
22762306a36Sopenharmony_ci	/* UMLALS		cccc 0000 1011 xxxx xxxx xxxx 1001 xxxx */
22862306a36Sopenharmony_ci	/* SMULL		cccc 0000 1100 xxxx xxxx xxxx 1001 xxxx */
22962306a36Sopenharmony_ci	/* SMULLS		cccc 0000 1101 xxxx xxxx xxxx 1001 xxxx */
23062306a36Sopenharmony_ci	/* SMLAL		cccc 0000 1110 xxxx xxxx xxxx 1001 xxxx */
23162306a36Sopenharmony_ci	/* SMLALS		cccc 0000 1111 xxxx xxxx xxxx 1001 xxxx */
23262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f8000f0, 0x00800090, PROBES_MUL1,
23362306a36Sopenharmony_ci						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci	DECODE_END
23662306a36Sopenharmony_ci};
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_cistatic const union decode_item arm_cccc_0001_____1001_table[] = {
23962306a36Sopenharmony_ci	/* Synchronization primitives					*/
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci#if __LINUX_ARM_ARCH__ < 6
24262306a36Sopenharmony_ci	/* Deprecated on ARMv6 and may be UNDEFINED on v7		*/
24362306a36Sopenharmony_ci	/* SMP/SWPB		cccc 0001 0x00 xxxx xxxx xxxx 1001 xxxx */
24462306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fb000f0, 0x01000090, PROBES_SWP,
24562306a36Sopenharmony_ci						 REGS(NOPC, NOPC, 0, 0, NOPC)),
24662306a36Sopenharmony_ci#endif
24762306a36Sopenharmony_ci	/* LDREX/STREX{,D,B,H}	cccc 0001 1xxx xxxx xxxx xxxx 1001 xxxx */
24862306a36Sopenharmony_ci	/* And unallocated instructions...				*/
24962306a36Sopenharmony_ci	DECODE_END
25062306a36Sopenharmony_ci};
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_cistatic const union decode_item arm_cccc_000x_____1xx1_table[] = {
25362306a36Sopenharmony_ci	/* Extra load/store instructions				*/
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci	/* STRHT		cccc 0000 xx10 xxxx xxxx xxxx 1011 xxxx */
25662306a36Sopenharmony_ci	/* ???			cccc 0000 xx10 xxxx xxxx xxxx 11x1 xxxx */
25762306a36Sopenharmony_ci	/* LDRHT		cccc 0000 xx11 xxxx xxxx xxxx 1011 xxxx */
25862306a36Sopenharmony_ci	/* LDRSBT		cccc 0000 xx11 xxxx xxxx xxxx 1101 xxxx */
25962306a36Sopenharmony_ci	/* LDRSHT		cccc 0000 xx11 xxxx xxxx xxxx 1111 xxxx */
26062306a36Sopenharmony_ci	DECODE_REJECT	(0x0f200090, 0x00200090),
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	/* LDRD/STRD lr,pc,{...	cccc 000x x0x0 xxxx 111x xxxx 1101 xxxx */
26362306a36Sopenharmony_ci	DECODE_REJECT	(0x0e10e0d0, 0x0000e0d0),
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci	/* LDRD (register)	cccc 000x x0x0 xxxx xxxx xxxx 1101 xxxx */
26662306a36Sopenharmony_ci	/* STRD (register)	cccc 000x x0x0 xxxx xxxx xxxx 1111 xxxx */
26762306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e5000d0, 0x000000d0, PROBES_LDRSTRD,
26862306a36Sopenharmony_ci						 REGS(NOPCWB, NOPCX, 0, 0, NOPC)),
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci	/* LDRD (immediate)	cccc 000x x1x0 xxxx xxxx xxxx 1101 xxxx */
27162306a36Sopenharmony_ci	/* STRD (immediate)	cccc 000x x1x0 xxxx xxxx xxxx 1111 xxxx */
27262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e5000d0, 0x004000d0, PROBES_LDRSTRD,
27362306a36Sopenharmony_ci						 REGS(NOPCWB, NOPCX, 0, 0, 0)),
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci	/* STRH (register)	cccc 000x x0x0 xxxx xxxx xxxx 1011 xxxx */
27662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e5000f0, 0x000000b0, PROBES_STORE_EXTRA,
27762306a36Sopenharmony_ci						 REGS(NOPCWB, NOPC, 0, 0, NOPC)),
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci	/* LDRH (register)	cccc 000x x0x1 xxxx xxxx xxxx 1011 xxxx */
28062306a36Sopenharmony_ci	/* LDRSB (register)	cccc 000x x0x1 xxxx xxxx xxxx 1101 xxxx */
28162306a36Sopenharmony_ci	/* LDRSH (register)	cccc 000x x0x1 xxxx xxxx xxxx 1111 xxxx */
28262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e500090, 0x00100090, PROBES_LOAD_EXTRA,
28362306a36Sopenharmony_ci						 REGS(NOPCWB, NOPC, 0, 0, NOPC)),
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci	/* STRH (immediate)	cccc 000x x1x0 xxxx xxxx xxxx 1011 xxxx */
28662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e5000f0, 0x004000b0, PROBES_STORE_EXTRA,
28762306a36Sopenharmony_ci						 REGS(NOPCWB, NOPC, 0, 0, 0)),
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci	/* LDRH (immediate)	cccc 000x x1x1 xxxx xxxx xxxx 1011 xxxx */
29062306a36Sopenharmony_ci	/* LDRSB (immediate)	cccc 000x x1x1 xxxx xxxx xxxx 1101 xxxx */
29162306a36Sopenharmony_ci	/* LDRSH (immediate)	cccc 000x x1x1 xxxx xxxx xxxx 1111 xxxx */
29262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e500090, 0x00500090, PROBES_LOAD_EXTRA,
29362306a36Sopenharmony_ci						 REGS(NOPCWB, NOPC, 0, 0, 0)),
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci	DECODE_END
29662306a36Sopenharmony_ci};
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_cistatic const union decode_item arm_cccc_000x_table[] = {
29962306a36Sopenharmony_ci	/* Data-processing (register)					*/
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci	/* <op>S PC, ...	cccc 000x xxx1 xxxx 1111 xxxx xxxx xxxx */
30262306a36Sopenharmony_ci	DECODE_REJECT	(0x0e10f000, 0x0010f000),
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci	/* MOV IP, SP		1110 0001 1010 0000 1100 0000 0000 1101 */
30562306a36Sopenharmony_ci	DECODE_SIMULATE	(0xffffffff, 0xe1a0c00d, PROBES_MOV_IP_SP),
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci	/* TST (register)	cccc 0001 0001 xxxx xxxx xxxx xxx0 xxxx */
30862306a36Sopenharmony_ci	/* TEQ (register)	cccc 0001 0011 xxxx xxxx xxxx xxx0 xxxx */
30962306a36Sopenharmony_ci	/* CMP (register)	cccc 0001 0101 xxxx xxxx xxxx xxx0 xxxx */
31062306a36Sopenharmony_ci	/* CMN (register)	cccc 0001 0111 xxxx xxxx xxxx xxx0 xxxx */
31162306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f900010, 0x01100000, PROBES_DATA_PROCESSING_REG,
31262306a36Sopenharmony_ci						 REGS(ANY, 0, 0, 0, ANY)),
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci	/* MOV (register)	cccc 0001 101x xxxx xxxx xxxx xxx0 xxxx */
31562306a36Sopenharmony_ci	/* MVN (register)	cccc 0001 111x xxxx xxxx xxxx xxx0 xxxx */
31662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fa00010, 0x01a00000, PROBES_DATA_PROCESSING_REG,
31762306a36Sopenharmony_ci						 REGS(0, ANY, 0, 0, ANY)),
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci	/* AND (register)	cccc 0000 000x xxxx xxxx xxxx xxx0 xxxx */
32062306a36Sopenharmony_ci	/* EOR (register)	cccc 0000 001x xxxx xxxx xxxx xxx0 xxxx */
32162306a36Sopenharmony_ci	/* SUB (register)	cccc 0000 010x xxxx xxxx xxxx xxx0 xxxx */
32262306a36Sopenharmony_ci	/* RSB (register)	cccc 0000 011x xxxx xxxx xxxx xxx0 xxxx */
32362306a36Sopenharmony_ci	/* ADD (register)	cccc 0000 100x xxxx xxxx xxxx xxx0 xxxx */
32462306a36Sopenharmony_ci	/* ADC (register)	cccc 0000 101x xxxx xxxx xxxx xxx0 xxxx */
32562306a36Sopenharmony_ci	/* SBC (register)	cccc 0000 110x xxxx xxxx xxxx xxx0 xxxx */
32662306a36Sopenharmony_ci	/* RSC (register)	cccc 0000 111x xxxx xxxx xxxx xxx0 xxxx */
32762306a36Sopenharmony_ci	/* ORR (register)	cccc 0001 100x xxxx xxxx xxxx xxx0 xxxx */
32862306a36Sopenharmony_ci	/* BIC (register)	cccc 0001 110x xxxx xxxx xxxx xxx0 xxxx */
32962306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e000010, 0x00000000, PROBES_DATA_PROCESSING_REG,
33062306a36Sopenharmony_ci						 REGS(ANY, ANY, 0, 0, ANY)),
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci	/* TST (reg-shift reg)	cccc 0001 0001 xxxx xxxx xxxx 0xx1 xxxx */
33362306a36Sopenharmony_ci	/* TEQ (reg-shift reg)	cccc 0001 0011 xxxx xxxx xxxx 0xx1 xxxx */
33462306a36Sopenharmony_ci	/* CMP (reg-shift reg)	cccc 0001 0101 xxxx xxxx xxxx 0xx1 xxxx */
33562306a36Sopenharmony_ci	/* CMN (reg-shift reg)	cccc 0001 0111 xxxx xxxx xxxx 0xx1 xxxx */
33662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f900090, 0x01100010, PROBES_DATA_PROCESSING_REG,
33762306a36Sopenharmony_ci						 REGS(NOPC, 0, NOPC, 0, NOPC)),
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_ci	/* MOV (reg-shift reg)	cccc 0001 101x xxxx xxxx xxxx 0xx1 xxxx */
34062306a36Sopenharmony_ci	/* MVN (reg-shift reg)	cccc 0001 111x xxxx xxxx xxxx 0xx1 xxxx */
34162306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fa00090, 0x01a00010, PROBES_DATA_PROCESSING_REG,
34262306a36Sopenharmony_ci						 REGS(0, NOPC, NOPC, 0, NOPC)),
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ci	/* AND (reg-shift reg)	cccc 0000 000x xxxx xxxx xxxx 0xx1 xxxx */
34562306a36Sopenharmony_ci	/* EOR (reg-shift reg)	cccc 0000 001x xxxx xxxx xxxx 0xx1 xxxx */
34662306a36Sopenharmony_ci	/* SUB (reg-shift reg)	cccc 0000 010x xxxx xxxx xxxx 0xx1 xxxx */
34762306a36Sopenharmony_ci	/* RSB (reg-shift reg)	cccc 0000 011x xxxx xxxx xxxx 0xx1 xxxx */
34862306a36Sopenharmony_ci	/* ADD (reg-shift reg)	cccc 0000 100x xxxx xxxx xxxx 0xx1 xxxx */
34962306a36Sopenharmony_ci	/* ADC (reg-shift reg)	cccc 0000 101x xxxx xxxx xxxx 0xx1 xxxx */
35062306a36Sopenharmony_ci	/* SBC (reg-shift reg)	cccc 0000 110x xxxx xxxx xxxx 0xx1 xxxx */
35162306a36Sopenharmony_ci	/* RSC (reg-shift reg)	cccc 0000 111x xxxx xxxx xxxx 0xx1 xxxx */
35262306a36Sopenharmony_ci	/* ORR (reg-shift reg)	cccc 0001 100x xxxx xxxx xxxx 0xx1 xxxx */
35362306a36Sopenharmony_ci	/* BIC (reg-shift reg)	cccc 0001 110x xxxx xxxx xxxx 0xx1 xxxx */
35462306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e000090, 0x00000010, PROBES_DATA_PROCESSING_REG,
35562306a36Sopenharmony_ci						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci	DECODE_END
35862306a36Sopenharmony_ci};
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_cistatic const union decode_item arm_cccc_001x_table[] = {
36162306a36Sopenharmony_ci	/* Data-processing (immediate)					*/
36262306a36Sopenharmony_ci
36362306a36Sopenharmony_ci	/* MOVW			cccc 0011 0000 xxxx xxxx xxxx xxxx xxxx */
36462306a36Sopenharmony_ci	/* MOVT			cccc 0011 0100 xxxx xxxx xxxx xxxx xxxx */
36562306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fb00000, 0x03000000, PROBES_MOV_HALFWORD,
36662306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, 0)),
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci	/* YIELD		cccc 0011 0010 0000 xxxx xxxx 0000 0001 */
36962306a36Sopenharmony_ci	DECODE_OR	(0x0fff00ff, 0x03200001),
37062306a36Sopenharmony_ci	/* SEV			cccc 0011 0010 0000 xxxx xxxx 0000 0100 */
37162306a36Sopenharmony_ci	DECODE_EMULATE	(0x0fff00ff, 0x03200004, PROBES_SEV),
37262306a36Sopenharmony_ci	/* NOP			cccc 0011 0010 0000 xxxx xxxx 0000 0000 */
37362306a36Sopenharmony_ci	/* WFE			cccc 0011 0010 0000 xxxx xxxx 0000 0010 */
37462306a36Sopenharmony_ci	/* WFI			cccc 0011 0010 0000 xxxx xxxx 0000 0011 */
37562306a36Sopenharmony_ci	DECODE_SIMULATE	(0x0fff00fc, 0x03200000, PROBES_WFE),
37662306a36Sopenharmony_ci	/* DBG			cccc 0011 0010 0000 xxxx xxxx ffff xxxx */
37762306a36Sopenharmony_ci	/* unallocated hints	cccc 0011 0010 0000 xxxx xxxx xxxx xxxx */
37862306a36Sopenharmony_ci	/* MSR (immediate)	cccc 0011 0x10 xxxx xxxx xxxx xxxx xxxx */
37962306a36Sopenharmony_ci	DECODE_REJECT	(0x0fb00000, 0x03200000),
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci	/* <op>S PC, ...	cccc 001x xxx1 xxxx 1111 xxxx xxxx xxxx */
38262306a36Sopenharmony_ci	DECODE_REJECT	(0x0e10f000, 0x0210f000),
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci	/* TST (immediate)	cccc 0011 0001 xxxx xxxx xxxx xxxx xxxx */
38562306a36Sopenharmony_ci	/* TEQ (immediate)	cccc 0011 0011 xxxx xxxx xxxx xxxx xxxx */
38662306a36Sopenharmony_ci	/* CMP (immediate)	cccc 0011 0101 xxxx xxxx xxxx xxxx xxxx */
38762306a36Sopenharmony_ci	/* CMN (immediate)	cccc 0011 0111 xxxx xxxx xxxx xxxx xxxx */
38862306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f900000, 0x03100000, PROBES_DATA_PROCESSING_IMM,
38962306a36Sopenharmony_ci						 REGS(ANY, 0, 0, 0, 0)),
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci	/* MOV (immediate)	cccc 0011 101x xxxx xxxx xxxx xxxx xxxx */
39262306a36Sopenharmony_ci	/* MVN (immediate)	cccc 0011 111x xxxx xxxx xxxx xxxx xxxx */
39362306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fa00000, 0x03a00000, PROBES_DATA_PROCESSING_IMM,
39462306a36Sopenharmony_ci						 REGS(0, ANY, 0, 0, 0)),
39562306a36Sopenharmony_ci
39662306a36Sopenharmony_ci	/* AND (immediate)	cccc 0010 000x xxxx xxxx xxxx xxxx xxxx */
39762306a36Sopenharmony_ci	/* EOR (immediate)	cccc 0010 001x xxxx xxxx xxxx xxxx xxxx */
39862306a36Sopenharmony_ci	/* SUB (immediate)	cccc 0010 010x xxxx xxxx xxxx xxxx xxxx */
39962306a36Sopenharmony_ci	/* RSB (immediate)	cccc 0010 011x xxxx xxxx xxxx xxxx xxxx */
40062306a36Sopenharmony_ci	/* ADD (immediate)	cccc 0010 100x xxxx xxxx xxxx xxxx xxxx */
40162306a36Sopenharmony_ci	/* ADC (immediate)	cccc 0010 101x xxxx xxxx xxxx xxxx xxxx */
40262306a36Sopenharmony_ci	/* SBC (immediate)	cccc 0010 110x xxxx xxxx xxxx xxxx xxxx */
40362306a36Sopenharmony_ci	/* RSC (immediate)	cccc 0010 111x xxxx xxxx xxxx xxxx xxxx */
40462306a36Sopenharmony_ci	/* ORR (immediate)	cccc 0011 100x xxxx xxxx xxxx xxxx xxxx */
40562306a36Sopenharmony_ci	/* BIC (immediate)	cccc 0011 110x xxxx xxxx xxxx xxxx xxxx */
40662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e000000, 0x02000000, PROBES_DATA_PROCESSING_IMM,
40762306a36Sopenharmony_ci						 REGS(ANY, ANY, 0, 0, 0)),
40862306a36Sopenharmony_ci
40962306a36Sopenharmony_ci	DECODE_END
41062306a36Sopenharmony_ci};
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_cistatic const union decode_item arm_cccc_0110_____xxx1_table[] = {
41362306a36Sopenharmony_ci	/* Media instructions						*/
41462306a36Sopenharmony_ci
41562306a36Sopenharmony_ci	/* SEL			cccc 0110 1000 xxxx xxxx xxxx 1011 xxxx */
41662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff000f0, 0x068000b0, PROBES_SATURATE,
41762306a36Sopenharmony_ci						 REGS(NOPC, NOPC, 0, 0, NOPC)),
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_ci	/* SSAT			cccc 0110 101x xxxx xxxx xxxx xx01 xxxx */
42062306a36Sopenharmony_ci	/* USAT			cccc 0110 111x xxxx xxxx xxxx xx01 xxxx */
42162306a36Sopenharmony_ci	DECODE_OR(0x0fa00030, 0x06a00010),
42262306a36Sopenharmony_ci	/* SSAT16		cccc 0110 1010 xxxx xxxx xxxx 0011 xxxx */
42362306a36Sopenharmony_ci	/* USAT16		cccc 0110 1110 xxxx xxxx xxxx 0011 xxxx */
42462306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fb000f0, 0x06a00030, PROBES_SATURATE,
42562306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, NOPC)),
42662306a36Sopenharmony_ci
42762306a36Sopenharmony_ci	/* REV			cccc 0110 1011 xxxx xxxx xxxx 0011 xxxx */
42862306a36Sopenharmony_ci	/* REV16		cccc 0110 1011 xxxx xxxx xxxx 1011 xxxx */
42962306a36Sopenharmony_ci	/* RBIT			cccc 0110 1111 xxxx xxxx xxxx 0011 xxxx */
43062306a36Sopenharmony_ci	/* REVSH		cccc 0110 1111 xxxx xxxx xxxx 1011 xxxx */
43162306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fb00070, 0x06b00030, PROBES_REV,
43262306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, NOPC)),
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci	/* ???			cccc 0110 0x00 xxxx xxxx xxxx xxx1 xxxx */
43562306a36Sopenharmony_ci	DECODE_REJECT	(0x0fb00010, 0x06000010),
43662306a36Sopenharmony_ci	/* ???			cccc 0110 0xxx xxxx xxxx xxxx 1011 xxxx */
43762306a36Sopenharmony_ci	DECODE_REJECT	(0x0f8000f0, 0x060000b0),
43862306a36Sopenharmony_ci	/* ???			cccc 0110 0xxx xxxx xxxx xxxx 1101 xxxx */
43962306a36Sopenharmony_ci	DECODE_REJECT	(0x0f8000f0, 0x060000d0),
44062306a36Sopenharmony_ci	/* SADD16		cccc 0110 0001 xxxx xxxx xxxx 0001 xxxx */
44162306a36Sopenharmony_ci	/* SADDSUBX		cccc 0110 0001 xxxx xxxx xxxx 0011 xxxx */
44262306a36Sopenharmony_ci	/* SSUBADDX		cccc 0110 0001 xxxx xxxx xxxx 0101 xxxx */
44362306a36Sopenharmony_ci	/* SSUB16		cccc 0110 0001 xxxx xxxx xxxx 0111 xxxx */
44462306a36Sopenharmony_ci	/* SADD8		cccc 0110 0001 xxxx xxxx xxxx 1001 xxxx */
44562306a36Sopenharmony_ci	/* SSUB8		cccc 0110 0001 xxxx xxxx xxxx 1111 xxxx */
44662306a36Sopenharmony_ci	/* QADD16		cccc 0110 0010 xxxx xxxx xxxx 0001 xxxx */
44762306a36Sopenharmony_ci	/* QADDSUBX		cccc 0110 0010 xxxx xxxx xxxx 0011 xxxx */
44862306a36Sopenharmony_ci	/* QSUBADDX		cccc 0110 0010 xxxx xxxx xxxx 0101 xxxx */
44962306a36Sopenharmony_ci	/* QSUB16		cccc 0110 0010 xxxx xxxx xxxx 0111 xxxx */
45062306a36Sopenharmony_ci	/* QADD8		cccc 0110 0010 xxxx xxxx xxxx 1001 xxxx */
45162306a36Sopenharmony_ci	/* QSUB8		cccc 0110 0010 xxxx xxxx xxxx 1111 xxxx */
45262306a36Sopenharmony_ci	/* SHADD16		cccc 0110 0011 xxxx xxxx xxxx 0001 xxxx */
45362306a36Sopenharmony_ci	/* SHADDSUBX		cccc 0110 0011 xxxx xxxx xxxx 0011 xxxx */
45462306a36Sopenharmony_ci	/* SHSUBADDX		cccc 0110 0011 xxxx xxxx xxxx 0101 xxxx */
45562306a36Sopenharmony_ci	/* SHSUB16		cccc 0110 0011 xxxx xxxx xxxx 0111 xxxx */
45662306a36Sopenharmony_ci	/* SHADD8		cccc 0110 0011 xxxx xxxx xxxx 1001 xxxx */
45762306a36Sopenharmony_ci	/* SHSUB8		cccc 0110 0011 xxxx xxxx xxxx 1111 xxxx */
45862306a36Sopenharmony_ci	/* UADD16		cccc 0110 0101 xxxx xxxx xxxx 0001 xxxx */
45962306a36Sopenharmony_ci	/* UADDSUBX		cccc 0110 0101 xxxx xxxx xxxx 0011 xxxx */
46062306a36Sopenharmony_ci	/* USUBADDX		cccc 0110 0101 xxxx xxxx xxxx 0101 xxxx */
46162306a36Sopenharmony_ci	/* USUB16		cccc 0110 0101 xxxx xxxx xxxx 0111 xxxx */
46262306a36Sopenharmony_ci	/* UADD8		cccc 0110 0101 xxxx xxxx xxxx 1001 xxxx */
46362306a36Sopenharmony_ci	/* USUB8		cccc 0110 0101 xxxx xxxx xxxx 1111 xxxx */
46462306a36Sopenharmony_ci	/* UQADD16		cccc 0110 0110 xxxx xxxx xxxx 0001 xxxx */
46562306a36Sopenharmony_ci	/* UQADDSUBX		cccc 0110 0110 xxxx xxxx xxxx 0011 xxxx */
46662306a36Sopenharmony_ci	/* UQSUBADDX		cccc 0110 0110 xxxx xxxx xxxx 0101 xxxx */
46762306a36Sopenharmony_ci	/* UQSUB16		cccc 0110 0110 xxxx xxxx xxxx 0111 xxxx */
46862306a36Sopenharmony_ci	/* UQADD8		cccc 0110 0110 xxxx xxxx xxxx 1001 xxxx */
46962306a36Sopenharmony_ci	/* UQSUB8		cccc 0110 0110 xxxx xxxx xxxx 1111 xxxx */
47062306a36Sopenharmony_ci	/* UHADD16		cccc 0110 0111 xxxx xxxx xxxx 0001 xxxx */
47162306a36Sopenharmony_ci	/* UHADDSUBX		cccc 0110 0111 xxxx xxxx xxxx 0011 xxxx */
47262306a36Sopenharmony_ci	/* UHSUBADDX		cccc 0110 0111 xxxx xxxx xxxx 0101 xxxx */
47362306a36Sopenharmony_ci	/* UHSUB16		cccc 0110 0111 xxxx xxxx xxxx 0111 xxxx */
47462306a36Sopenharmony_ci	/* UHADD8		cccc 0110 0111 xxxx xxxx xxxx 1001 xxxx */
47562306a36Sopenharmony_ci	/* UHSUB8		cccc 0110 0111 xxxx xxxx xxxx 1111 xxxx */
47662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f800010, 0x06000010, PROBES_MMI,
47762306a36Sopenharmony_ci						 REGS(NOPC, NOPC, 0, 0, NOPC)),
47862306a36Sopenharmony_ci
47962306a36Sopenharmony_ci	/* PKHBT		cccc 0110 1000 xxxx xxxx xxxx x001 xxxx */
48062306a36Sopenharmony_ci	/* PKHTB		cccc 0110 1000 xxxx xxxx xxxx x101 xxxx */
48162306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff00030, 0x06800010, PROBES_PACK,
48262306a36Sopenharmony_ci						 REGS(NOPC, NOPC, 0, 0, NOPC)),
48362306a36Sopenharmony_ci
48462306a36Sopenharmony_ci	/* ???			cccc 0110 1001 xxxx xxxx xxxx 0111 xxxx */
48562306a36Sopenharmony_ci	/* ???			cccc 0110 1101 xxxx xxxx xxxx 0111 xxxx */
48662306a36Sopenharmony_ci	DECODE_REJECT	(0x0fb000f0, 0x06900070),
48762306a36Sopenharmony_ci
48862306a36Sopenharmony_ci	/* SXTB16		cccc 0110 1000 1111 xxxx xxxx 0111 xxxx */
48962306a36Sopenharmony_ci	/* SXTB			cccc 0110 1010 1111 xxxx xxxx 0111 xxxx */
49062306a36Sopenharmony_ci	/* SXTH			cccc 0110 1011 1111 xxxx xxxx 0111 xxxx */
49162306a36Sopenharmony_ci	/* UXTB16		cccc 0110 1100 1111 xxxx xxxx 0111 xxxx */
49262306a36Sopenharmony_ci	/* UXTB			cccc 0110 1110 1111 xxxx xxxx 0111 xxxx */
49362306a36Sopenharmony_ci	/* UXTH			cccc 0110 1111 1111 xxxx xxxx 0111 xxxx */
49462306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f8f00f0, 0x068f0070, PROBES_EXTEND,
49562306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, NOPC)),
49662306a36Sopenharmony_ci
49762306a36Sopenharmony_ci	/* SXTAB16		cccc 0110 1000 xxxx xxxx xxxx 0111 xxxx */
49862306a36Sopenharmony_ci	/* SXTAB		cccc 0110 1010 xxxx xxxx xxxx 0111 xxxx */
49962306a36Sopenharmony_ci	/* SXTAH		cccc 0110 1011 xxxx xxxx xxxx 0111 xxxx */
50062306a36Sopenharmony_ci	/* UXTAB16		cccc 0110 1100 xxxx xxxx xxxx 0111 xxxx */
50162306a36Sopenharmony_ci	/* UXTAB		cccc 0110 1110 xxxx xxxx xxxx 0111 xxxx */
50262306a36Sopenharmony_ci	/* UXTAH		cccc 0110 1111 xxxx xxxx xxxx 0111 xxxx */
50362306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0f8000f0, 0x06800070, PROBES_EXTEND_ADD,
50462306a36Sopenharmony_ci						 REGS(NOPCX, NOPC, 0, 0, NOPC)),
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ci	DECODE_END
50762306a36Sopenharmony_ci};
50862306a36Sopenharmony_ci
50962306a36Sopenharmony_cistatic const union decode_item arm_cccc_0111_____xxx1_table[] = {
51062306a36Sopenharmony_ci	/* Media instructions						*/
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_ci	/* UNDEFINED		cccc 0111 1111 xxxx xxxx xxxx 1111 xxxx */
51362306a36Sopenharmony_ci	DECODE_REJECT	(0x0ff000f0, 0x07f000f0),
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_ci	/* SMLALD		cccc 0111 0100 xxxx xxxx xxxx 00x1 xxxx */
51662306a36Sopenharmony_ci	/* SMLSLD		cccc 0111 0100 xxxx xxxx xxxx 01x1 xxxx */
51762306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff00090, 0x07400010, PROBES_MUL_ADD_LONG,
51862306a36Sopenharmony_ci						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
51962306a36Sopenharmony_ci
52062306a36Sopenharmony_ci	/* SMUAD		cccc 0111 0000 xxxx 1111 xxxx 00x1 xxxx */
52162306a36Sopenharmony_ci	/* SMUSD		cccc 0111 0000 xxxx 1111 xxxx 01x1 xxxx */
52262306a36Sopenharmony_ci	DECODE_OR	(0x0ff0f090, 0x0700f010),
52362306a36Sopenharmony_ci	/* SMMUL		cccc 0111 0101 xxxx 1111 xxxx 00x1 xxxx */
52462306a36Sopenharmony_ci	DECODE_OR	(0x0ff0f0d0, 0x0750f010),
52562306a36Sopenharmony_ci	/* USAD8		cccc 0111 1000 xxxx 1111 xxxx 0001 xxxx */
52662306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff0f0f0, 0x0780f010, PROBES_MUL_ADD,
52762306a36Sopenharmony_ci						 REGS(NOPC, 0, NOPC, 0, NOPC)),
52862306a36Sopenharmony_ci
52962306a36Sopenharmony_ci	/* SMLAD		cccc 0111 0000 xxxx xxxx xxxx 00x1 xxxx */
53062306a36Sopenharmony_ci	/* SMLSD		cccc 0111 0000 xxxx xxxx xxxx 01x1 xxxx */
53162306a36Sopenharmony_ci	DECODE_OR	(0x0ff00090, 0x07000010),
53262306a36Sopenharmony_ci	/* SMMLA		cccc 0111 0101 xxxx xxxx xxxx 00x1 xxxx */
53362306a36Sopenharmony_ci	DECODE_OR	(0x0ff000d0, 0x07500010),
53462306a36Sopenharmony_ci	/* USADA8		cccc 0111 1000 xxxx xxxx xxxx 0001 xxxx */
53562306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff000f0, 0x07800010, PROBES_MUL_ADD,
53662306a36Sopenharmony_ci						 REGS(NOPC, NOPCX, NOPC, 0, NOPC)),
53762306a36Sopenharmony_ci
53862306a36Sopenharmony_ci	/* SMMLS		cccc 0111 0101 xxxx xxxx xxxx 11x1 xxxx */
53962306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0ff000d0, 0x075000d0, PROBES_MUL_ADD,
54062306a36Sopenharmony_ci						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
54162306a36Sopenharmony_ci
54262306a36Sopenharmony_ci	/* SBFX			cccc 0111 101x xxxx xxxx xxxx x101 xxxx */
54362306a36Sopenharmony_ci	/* UBFX			cccc 0111 111x xxxx xxxx xxxx x101 xxxx */
54462306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fa00070, 0x07a00050, PROBES_BITFIELD,
54562306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, NOPC)),
54662306a36Sopenharmony_ci
54762306a36Sopenharmony_ci	/* BFC			cccc 0111 110x xxxx xxxx xxxx x001 1111 */
54862306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fe0007f, 0x07c0001f, PROBES_BITFIELD,
54962306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, 0)),
55062306a36Sopenharmony_ci
55162306a36Sopenharmony_ci	/* BFI			cccc 0111 110x xxxx xxxx xxxx x001 xxxx */
55262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0fe00070, 0x07c00010, PROBES_BITFIELD,
55362306a36Sopenharmony_ci						 REGS(0, NOPC, 0, 0, NOPCX)),
55462306a36Sopenharmony_ci
55562306a36Sopenharmony_ci	DECODE_END
55662306a36Sopenharmony_ci};
55762306a36Sopenharmony_ci
55862306a36Sopenharmony_cistatic const union decode_item arm_cccc_01xx_table[] = {
55962306a36Sopenharmony_ci	/* Load/store word and unsigned byte				*/
56062306a36Sopenharmony_ci
56162306a36Sopenharmony_ci	/* LDRB/STRB pc,[...]	cccc 01xx x0xx xxxx xxxx xxxx xxxx xxxx */
56262306a36Sopenharmony_ci	DECODE_REJECT	(0x0c40f000, 0x0440f000),
56362306a36Sopenharmony_ci
56462306a36Sopenharmony_ci	/* STRT			cccc 01x0 x010 xxxx xxxx xxxx xxxx xxxx */
56562306a36Sopenharmony_ci	/* LDRT			cccc 01x0 x011 xxxx xxxx xxxx xxxx xxxx */
56662306a36Sopenharmony_ci	/* STRBT		cccc 01x0 x110 xxxx xxxx xxxx xxxx xxxx */
56762306a36Sopenharmony_ci	/* LDRBT		cccc 01x0 x111 xxxx xxxx xxxx xxxx xxxx */
56862306a36Sopenharmony_ci	DECODE_REJECT	(0x0d200000, 0x04200000),
56962306a36Sopenharmony_ci
57062306a36Sopenharmony_ci	/* STR (immediate)	cccc 010x x0x0 xxxx xxxx xxxx xxxx xxxx */
57162306a36Sopenharmony_ci	/* STRB (immediate)	cccc 010x x1x0 xxxx xxxx xxxx xxxx xxxx */
57262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e100000, 0x04000000, PROBES_STORE,
57362306a36Sopenharmony_ci						 REGS(NOPCWB, ANY, 0, 0, 0)),
57462306a36Sopenharmony_ci
57562306a36Sopenharmony_ci	/* LDR (immediate)	cccc 010x x0x1 xxxx xxxx xxxx xxxx xxxx */
57662306a36Sopenharmony_ci	/* LDRB (immediate)	cccc 010x x1x1 xxxx xxxx xxxx xxxx xxxx */
57762306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e100000, 0x04100000, PROBES_LOAD,
57862306a36Sopenharmony_ci						 REGS(NOPCWB, ANY, 0, 0, 0)),
57962306a36Sopenharmony_ci
58062306a36Sopenharmony_ci	/* STR (register)	cccc 011x x0x0 xxxx xxxx xxxx xxxx xxxx */
58162306a36Sopenharmony_ci	/* STRB (register)	cccc 011x x1x0 xxxx xxxx xxxx xxxx xxxx */
58262306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e100000, 0x06000000, PROBES_STORE,
58362306a36Sopenharmony_ci						 REGS(NOPCWB, ANY, 0, 0, NOPC)),
58462306a36Sopenharmony_ci
58562306a36Sopenharmony_ci	/* LDR (register)	cccc 011x x0x1 xxxx xxxx xxxx xxxx xxxx */
58662306a36Sopenharmony_ci	/* LDRB (register)	cccc 011x x1x1 xxxx xxxx xxxx xxxx xxxx */
58762306a36Sopenharmony_ci	DECODE_EMULATEX	(0x0e100000, 0x06100000, PROBES_LOAD,
58862306a36Sopenharmony_ci						 REGS(NOPCWB, ANY, 0, 0, NOPC)),
58962306a36Sopenharmony_ci
59062306a36Sopenharmony_ci	DECODE_END
59162306a36Sopenharmony_ci};
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_cistatic const union decode_item arm_cccc_100x_table[] = {
59462306a36Sopenharmony_ci	/* Block data transfer instructions				*/
59562306a36Sopenharmony_ci
59662306a36Sopenharmony_ci	/* LDM			cccc 100x x0x1 xxxx xxxx xxxx xxxx xxxx */
59762306a36Sopenharmony_ci	/* STM			cccc 100x x0x0 xxxx xxxx xxxx xxxx xxxx */
59862306a36Sopenharmony_ci	DECODE_CUSTOM	(0x0e400000, 0x08000000, PROBES_LDMSTM),
59962306a36Sopenharmony_ci
60062306a36Sopenharmony_ci	/* STM (user registers)	cccc 100x x1x0 xxxx xxxx xxxx xxxx xxxx */
60162306a36Sopenharmony_ci	/* LDM (user registers)	cccc 100x x1x1 xxxx 0xxx xxxx xxxx xxxx */
60262306a36Sopenharmony_ci	/* LDM (exception ret)	cccc 100x x1x1 xxxx 1xxx xxxx xxxx xxxx */
60362306a36Sopenharmony_ci	DECODE_END
60462306a36Sopenharmony_ci};
60562306a36Sopenharmony_ci
60662306a36Sopenharmony_ciconst union decode_item probes_decode_arm_table[] = {
60762306a36Sopenharmony_ci	/*
60862306a36Sopenharmony_ci	 * Unconditional instructions
60962306a36Sopenharmony_ci	 *			1111 xxxx xxxx xxxx xxxx xxxx xxxx xxxx
61062306a36Sopenharmony_ci	 */
61162306a36Sopenharmony_ci	DECODE_TABLE	(0xf0000000, 0xf0000000, arm_1111_table),
61262306a36Sopenharmony_ci
61362306a36Sopenharmony_ci	/*
61462306a36Sopenharmony_ci	 * Miscellaneous instructions
61562306a36Sopenharmony_ci	 *			cccc 0001 0xx0 xxxx xxxx xxxx 0xxx xxxx
61662306a36Sopenharmony_ci	 */
61762306a36Sopenharmony_ci	DECODE_TABLE	(0x0f900080, 0x01000000, arm_cccc_0001_0xx0____0xxx_table),
61862306a36Sopenharmony_ci
61962306a36Sopenharmony_ci	/*
62062306a36Sopenharmony_ci	 * Halfword multiply and multiply-accumulate
62162306a36Sopenharmony_ci	 *			cccc 0001 0xx0 xxxx xxxx xxxx 1xx0 xxxx
62262306a36Sopenharmony_ci	 */
62362306a36Sopenharmony_ci	DECODE_TABLE	(0x0f900090, 0x01000080, arm_cccc_0001_0xx0____1xx0_table),
62462306a36Sopenharmony_ci
62562306a36Sopenharmony_ci	/*
62662306a36Sopenharmony_ci	 * Multiply and multiply-accumulate
62762306a36Sopenharmony_ci	 *			cccc 0000 xxxx xxxx xxxx xxxx 1001 xxxx
62862306a36Sopenharmony_ci	 */
62962306a36Sopenharmony_ci	DECODE_TABLE	(0x0f0000f0, 0x00000090, arm_cccc_0000_____1001_table),
63062306a36Sopenharmony_ci
63162306a36Sopenharmony_ci	/*
63262306a36Sopenharmony_ci	 * Synchronization primitives
63362306a36Sopenharmony_ci	 *			cccc 0001 xxxx xxxx xxxx xxxx 1001 xxxx
63462306a36Sopenharmony_ci	 */
63562306a36Sopenharmony_ci	DECODE_TABLE	(0x0f0000f0, 0x01000090, arm_cccc_0001_____1001_table),
63662306a36Sopenharmony_ci
63762306a36Sopenharmony_ci	/*
63862306a36Sopenharmony_ci	 * Extra load/store instructions
63962306a36Sopenharmony_ci	 *			cccc 000x xxxx xxxx xxxx xxxx 1xx1 xxxx
64062306a36Sopenharmony_ci	 */
64162306a36Sopenharmony_ci	DECODE_TABLE	(0x0e000090, 0x00000090, arm_cccc_000x_____1xx1_table),
64262306a36Sopenharmony_ci
64362306a36Sopenharmony_ci	/*
64462306a36Sopenharmony_ci	 * Data-processing (register)
64562306a36Sopenharmony_ci	 *			cccc 000x xxxx xxxx xxxx xxxx xxx0 xxxx
64662306a36Sopenharmony_ci	 * Data-processing (register-shifted register)
64762306a36Sopenharmony_ci	 *			cccc 000x xxxx xxxx xxxx xxxx 0xx1 xxxx
64862306a36Sopenharmony_ci	 */
64962306a36Sopenharmony_ci	DECODE_TABLE	(0x0e000000, 0x00000000, arm_cccc_000x_table),
65062306a36Sopenharmony_ci
65162306a36Sopenharmony_ci	/*
65262306a36Sopenharmony_ci	 * Data-processing (immediate)
65362306a36Sopenharmony_ci	 *			cccc 001x xxxx xxxx xxxx xxxx xxxx xxxx
65462306a36Sopenharmony_ci	 */
65562306a36Sopenharmony_ci	DECODE_TABLE	(0x0e000000, 0x02000000, arm_cccc_001x_table),
65662306a36Sopenharmony_ci
65762306a36Sopenharmony_ci	/*
65862306a36Sopenharmony_ci	 * Media instructions
65962306a36Sopenharmony_ci	 *			cccc 011x xxxx xxxx xxxx xxxx xxx1 xxxx
66062306a36Sopenharmony_ci	 */
66162306a36Sopenharmony_ci	DECODE_TABLE	(0x0f000010, 0x06000010, arm_cccc_0110_____xxx1_table),
66262306a36Sopenharmony_ci	DECODE_TABLE	(0x0f000010, 0x07000010, arm_cccc_0111_____xxx1_table),
66362306a36Sopenharmony_ci
66462306a36Sopenharmony_ci	/*
66562306a36Sopenharmony_ci	 * Load/store word and unsigned byte
66662306a36Sopenharmony_ci	 *			cccc 01xx xxxx xxxx xxxx xxxx xxxx xxxx
66762306a36Sopenharmony_ci	 */
66862306a36Sopenharmony_ci	DECODE_TABLE	(0x0c000000, 0x04000000, arm_cccc_01xx_table),
66962306a36Sopenharmony_ci
67062306a36Sopenharmony_ci	/*
67162306a36Sopenharmony_ci	 * Block data transfer instructions
67262306a36Sopenharmony_ci	 *			cccc 100x xxxx xxxx xxxx xxxx xxxx xxxx
67362306a36Sopenharmony_ci	 */
67462306a36Sopenharmony_ci	DECODE_TABLE	(0x0e000000, 0x08000000, arm_cccc_100x_table),
67562306a36Sopenharmony_ci
67662306a36Sopenharmony_ci	/* B			cccc 1010 xxxx xxxx xxxx xxxx xxxx xxxx */
67762306a36Sopenharmony_ci	/* BL			cccc 1011 xxxx xxxx xxxx xxxx xxxx xxxx */
67862306a36Sopenharmony_ci	DECODE_SIMULATE	(0x0e000000, 0x0a000000, PROBES_BRANCH),
67962306a36Sopenharmony_ci
68062306a36Sopenharmony_ci	/*
68162306a36Sopenharmony_ci	 * Supervisor Call, and coprocessor instructions
68262306a36Sopenharmony_ci	 */
68362306a36Sopenharmony_ci
68462306a36Sopenharmony_ci	/* MCRR			cccc 1100 0100 xxxx xxxx xxxx xxxx xxxx */
68562306a36Sopenharmony_ci	/* MRRC			cccc 1100 0101 xxxx xxxx xxxx xxxx xxxx */
68662306a36Sopenharmony_ci	/* LDC			cccc 110x xxx1 xxxx xxxx xxxx xxxx xxxx */
68762306a36Sopenharmony_ci	/* STC			cccc 110x xxx0 xxxx xxxx xxxx xxxx xxxx */
68862306a36Sopenharmony_ci	/* CDP			cccc 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */
68962306a36Sopenharmony_ci	/* MCR			cccc 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */
69062306a36Sopenharmony_ci	/* MRC			cccc 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */
69162306a36Sopenharmony_ci	/* SVC			cccc 1111 xxxx xxxx xxxx xxxx xxxx xxxx */
69262306a36Sopenharmony_ci	DECODE_REJECT	(0x0c000000, 0x0c000000),
69362306a36Sopenharmony_ci
69462306a36Sopenharmony_ci	DECODE_END
69562306a36Sopenharmony_ci};
69662306a36Sopenharmony_ci#ifdef CONFIG_ARM_KPROBES_TEST_MODULE
69762306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(probes_decode_arm_table);
69862306a36Sopenharmony_ci#endif
69962306a36Sopenharmony_ci
70062306a36Sopenharmony_cistatic void __kprobes arm_singlestep(probes_opcode_t insn,
70162306a36Sopenharmony_ci		struct arch_probes_insn *asi, struct pt_regs *regs)
70262306a36Sopenharmony_ci{
70362306a36Sopenharmony_ci	regs->ARM_pc += 4;
70462306a36Sopenharmony_ci	asi->insn_handler(insn, asi, regs);
70562306a36Sopenharmony_ci}
70662306a36Sopenharmony_ci
70762306a36Sopenharmony_ci/* Return:
70862306a36Sopenharmony_ci *   INSN_REJECTED     If instruction is one not allowed to kprobe,
70962306a36Sopenharmony_ci *   INSN_GOOD         If instruction is supported and uses instruction slot,
71062306a36Sopenharmony_ci *   INSN_GOOD_NO_SLOT If instruction is supported but doesn't use its slot.
71162306a36Sopenharmony_ci *
71262306a36Sopenharmony_ci * For instructions we don't want to kprobe (INSN_REJECTED return result):
71362306a36Sopenharmony_ci *   These are generally ones that modify the processor state making
71462306a36Sopenharmony_ci *   them "hard" to simulate such as switches processor modes or
71562306a36Sopenharmony_ci *   make accesses in alternate modes.  Any of these could be simulated
71662306a36Sopenharmony_ci *   if the work was put into it, but low return considering they
71762306a36Sopenharmony_ci *   should also be very rare.
71862306a36Sopenharmony_ci */
71962306a36Sopenharmony_cienum probes_insn __kprobes
72062306a36Sopenharmony_ciarm_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
72162306a36Sopenharmony_ci		       bool emulate, const union decode_action *actions,
72262306a36Sopenharmony_ci		       const struct decode_checker *checkers[])
72362306a36Sopenharmony_ci{
72462306a36Sopenharmony_ci	asi->insn_singlestep = arm_singlestep;
72562306a36Sopenharmony_ci	asi->insn_check_cc = probes_condition_checks[insn>>28];
72662306a36Sopenharmony_ci	return probes_decode_insn(insn, asi, probes_decode_arm_table, false,
72762306a36Sopenharmony_ci				  emulate, actions, checkers);
72862306a36Sopenharmony_ci}
729