Linux Audio

Check our new training course

Loading...
v6.9.4
 1/* SPDX-License-Identifier: GPL-2.0-or-later */
 2#ifndef _ASM_POWERPC_PROBES_H
 3#define _ASM_POWERPC_PROBES_H
 4#ifdef __KERNEL__
 5/*
 6 * Definitions common to probes files
 7 *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 8 * Copyright IBM Corporation, 2012
 9 */
10#include <linux/types.h>
11#include <asm/disassemble.h>
12#include <asm/ppc-opcode.h>
13
14#define BREAKPOINT_INSTRUCTION	PPC_RAW_TRAP()	/* trap */
 
15
16/* Trap definitions per ISA */
17#define IS_TW(instr)		(((instr) & 0xfc0007fe) == 0x7c000008)
18#define IS_TD(instr)		(((instr) & 0xfc0007fe) == 0x7c000088)
19#define IS_TDI(instr)		(((instr) & 0xfc000000) == 0x08000000)
20#define IS_TWI(instr)		(((instr) & 0xfc000000) == 0x0c000000)
21
22#ifdef CONFIG_PPC64
23#define is_trap(instr)		(IS_TW(instr) || IS_TD(instr) || \
24				IS_TWI(instr) || IS_TDI(instr))
25#else
26#define is_trap(instr)		(IS_TW(instr) || IS_TWI(instr))
27#endif /* CONFIG_PPC64 */
28
29#ifdef CONFIG_PPC_ADV_DEBUG_REGS
30#define MSR_SINGLESTEP	(MSR_DE)
31#else
32#define MSR_SINGLESTEP	(MSR_SE)
33#endif
34
35static inline bool can_single_step(u32 inst)
36{
37	switch (get_op(inst)) {
38	case OP_TRAP_64:	return false;
39	case OP_TRAP:		return false;
40	case OP_SC:		return false;
41	case OP_19:
42		switch (get_xop(inst)) {
43		case OP_19_XOP_RFID:		return false;
44		case OP_19_XOP_RFMCI:		return false;
45		case OP_19_XOP_RFDI:		return false;
46		case OP_19_XOP_RFI:		return false;
47		case OP_19_XOP_RFCI:		return false;
48		case OP_19_XOP_RFSCV:		return false;
49		case OP_19_XOP_HRFID:		return false;
50		case OP_19_XOP_URFID:		return false;
51		case OP_19_XOP_STOP:		return false;
52		case OP_19_XOP_DOZE:		return false;
53		case OP_19_XOP_NAP:		return false;
54		case OP_19_XOP_SLEEP:		return false;
55		case OP_19_XOP_RVWINKLE:	return false;
56		}
57		break;
58	case OP_31:
59		switch (get_xop(inst)) {
60		case OP_31_XOP_TRAP:		return false;
61		case OP_31_XOP_TRAP_64:		return false;
62		case OP_31_XOP_MTMSR:		return false;
63		case OP_31_XOP_MTMSRD:		return false;
64		}
65		break;
66	}
67	return true;
68}
69
70/* Enable single stepping for the current task */
71static inline void enable_single_step(struct pt_regs *regs)
72{
73	regs_set_return_msr(regs, regs->msr | MSR_SINGLESTEP);
74#ifdef CONFIG_PPC_ADV_DEBUG_REGS
75	/*
76	 * We turn off Critical Input Exception(CE) to ensure that the single
77	 * step will be for the instruction we have the probe on; if we don't,
78	 * it is possible we'd get the single step reported for CE.
79	 */
80	regs_set_return_msr(regs, regs->msr & ~MSR_CE);
81	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
82#ifdef CONFIG_PPC_47x
83	isync();
84#endif
85#endif
86}
87
88
89#endif /* __KERNEL__ */
90#endif	/* _ASM_POWERPC_PROBES_H */
v4.10.11
 
 1#ifndef _ASM_POWERPC_PROBES_H
 2#define _ASM_POWERPC_PROBES_H
 3#ifdef __KERNEL__
 4/*
 5 * Definitions common to probes files
 6 *
 7 * This program is free software; you can redistribute it and/or modify
 8 * it under the terms of the GNU General Public License as published by
 9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * Copyright IBM Corporation, 2012
22 */
23#include <linux/types.h>
 
 
24
25typedef u32 ppc_opcode_t;
26#define BREAKPOINT_INSTRUCTION	0x7fe00008	/* trap */
27
28/* Trap definitions per ISA */
29#define IS_TW(instr)		(((instr) & 0xfc0007fe) == 0x7c000008)
30#define IS_TD(instr)		(((instr) & 0xfc0007fe) == 0x7c000088)
31#define IS_TDI(instr)		(((instr) & 0xfc000000) == 0x08000000)
32#define IS_TWI(instr)		(((instr) & 0xfc000000) == 0x0c000000)
33
34#ifdef CONFIG_PPC64
35#define is_trap(instr)		(IS_TW(instr) || IS_TD(instr) || \
36				IS_TWI(instr) || IS_TDI(instr))
37#else
38#define is_trap(instr)		(IS_TW(instr) || IS_TWI(instr))
39#endif /* CONFIG_PPC64 */
40
41#ifdef CONFIG_PPC_ADV_DEBUG_REGS
42#define MSR_SINGLESTEP	(MSR_DE)
43#else
44#define MSR_SINGLESTEP	(MSR_SE)
45#endif
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47/* Enable single stepping for the current task */
48static inline void enable_single_step(struct pt_regs *regs)
49{
50	regs->msr |= MSR_SINGLESTEP;
51#ifdef CONFIG_PPC_ADV_DEBUG_REGS
52	/*
53	 * We turn off Critical Input Exception(CE) to ensure that the single
54	 * step will be for the instruction we have the probe on; if we don't,
55	 * it is possible we'd get the single step reported for CE.
56	 */
57	regs->msr &= ~MSR_CE;
58	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
59#ifdef CONFIG_PPC_47x
60	isync();
61#endif
62#endif
63}
64
65
66#endif /* __KERNEL__ */
67#endif	/* _ASM_POWERPC_PROBES_H */