Linux Audio

Check our new training course

Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef __SPARC_PTRACE_H
  3#define __SPARC_PTRACE_H
  4
  5#include <uapi/asm/ptrace.h>
  6
  7#if defined(__sparc__) && defined(__arch64__)
  8#ifndef __ASSEMBLY__
  9
 10#include <linux/compiler.h>
 11#include <linux/threads.h>
 12#include <asm/switch_to.h>
 13
 14static inline int pt_regs_trap_type(struct pt_regs *regs)
 15{
 16	return regs->magic & 0x1ff;
 17}
 18
 19static inline bool pt_regs_is_syscall(struct pt_regs *regs)
 20{
 21	return (regs->tstate & TSTATE_SYSCALL);
 22}
 23
 24static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
 25{
 26	return (regs->tstate &= ~TSTATE_SYSCALL);
 27}
 28
 29#define arch_ptrace_stop_needed() \
 30({	flush_user_windows(); \
 31	get_thread_wsaved() != 0; \
 32})
 33
 34#define arch_ptrace_stop() \
 35	synchronize_user_stack()
 36
 37#define current_pt_regs() \
 38	((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
 39
 40struct global_reg_snapshot {
 41	unsigned long		tstate;
 42	unsigned long		tpc;
 43	unsigned long		tnpc;
 44	unsigned long		o7;
 45	unsigned long		i7;
 46	unsigned long		rpc;
 47	struct thread_info	*thread;
 48	unsigned long		pad1;
 49};
 50
 51struct global_pmu_snapshot {
 52	unsigned long		pcr[4];
 53	unsigned long		pic[4];
 54};
 55
 56union global_cpu_snapshot {
 57	struct global_reg_snapshot	reg;
 58	struct global_pmu_snapshot	pmu;
 59};
 60
 61extern union global_cpu_snapshot global_cpu_snapshot[NR_CPUS];
 62
 63#define force_successful_syscall_return() set_thread_noerror(1)
 64#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
 65#define instruction_pointer(regs) ((regs)->tpc)
 66#define instruction_pointer_set(regs, val) do { \
 67		(regs)->tpc = (val); \
 68		(regs)->tnpc = (val)+4; \
 69	} while (0)
 70#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
 71static inline int is_syscall_success(struct pt_regs *regs)
 72{
 73	return !(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY));
 74}
 75
 76static inline long regs_return_value(struct pt_regs *regs)
 77{
 78	return regs->u_regs[UREG_I0];
 79}
 80#ifdef CONFIG_SMP
 81unsigned long profile_pc(struct pt_regs *);
 82#else
 83#define profile_pc(regs) instruction_pointer(regs)
 84#endif
 85
 86#define MAX_REG_OFFSET (offsetof(struct pt_regs, magic))
 87
 88int regs_query_register_offset(const char *name);
 89unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
 90
 91/**
 92 * regs_get_register() - get register value from its offset
 93 * @regs:	pt_regs from which register value is gotten
 94 * @offset:	offset number of the register.
 95 *
 96 * regs_get_register returns the value of a register whose
 97 * offset from @regs. The @offset is the offset of the register
 98 * in struct pt_regs. If @offset is bigger than MAX_REG_OFFSET,
 99 * this returns 0.
100 */
101static inline unsigned long regs_get_register(struct pt_regs *regs,
102					     unsigned long offset)
103{
104	if (unlikely(offset >= MAX_REG_OFFSET))
105		return 0;
106	if (offset == PT_V9_Y)
107		return *(unsigned int *)((unsigned long)regs + offset);
108	return *(unsigned long *)((unsigned long)regs + offset);
109}
110
111/* Valid only for Kernel mode traps. */
112static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
113{
114	return regs->u_regs[UREG_I6];
115}
116#else /* __ASSEMBLY__ */
117#endif /* __ASSEMBLY__ */
118#else /* (defined(__sparc__) && defined(__arch64__)) */
119#ifndef __ASSEMBLY__
120#include <asm/switch_to.h>
121
122static inline bool pt_regs_is_syscall(struct pt_regs *regs)
123{
124	return (regs->psr & PSR_SYSCALL);
125}
126
127static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
128{
129	return (regs->psr &= ~PSR_SYSCALL);
130}
131
132#define arch_ptrace_stop_needed() \
133({	flush_user_windows(); \
134	current_thread_info()->w_saved != 0;	\
135})
136
137#define arch_ptrace_stop() \
138	synchronize_user_stack()
139
140#define current_pt_regs() \
141	((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
142
143#define user_mode(regs) (!((regs)->psr & PSR_PS))
144#define instruction_pointer(regs) ((regs)->pc)
145#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
146unsigned long profile_pc(struct pt_regs *);
147#else /* (!__ASSEMBLY__) */
148#endif /* (!__ASSEMBLY__) */
149#endif /* (defined(__sparc__) && defined(__arch64__)) */
150#define STACK_BIAS		2047
151
152/* global_reg_snapshot offsets */
153#define GR_SNAP_TSTATE	0x00
154#define GR_SNAP_TPC	0x08
155#define GR_SNAP_TNPC	0x10
156#define GR_SNAP_O7	0x18
157#define GR_SNAP_I7	0x20
158#define GR_SNAP_RPC	0x28
159#define GR_SNAP_THREAD	0x30
160#define GR_SNAP_PAD1	0x38
161
162#endif /* !(__SPARC_PTRACE_H) */
v4.10.11
 
  1#ifndef __SPARC_PTRACE_H
  2#define __SPARC_PTRACE_H
  3
  4#include <uapi/asm/ptrace.h>
  5
  6#if defined(__sparc__) && defined(__arch64__)
  7#ifndef __ASSEMBLY__
  8
 
  9#include <linux/threads.h>
 10#include <asm/switch_to.h>
 11
 12static inline int pt_regs_trap_type(struct pt_regs *regs)
 13{
 14	return regs->magic & 0x1ff;
 15}
 16
 17static inline bool pt_regs_is_syscall(struct pt_regs *regs)
 18{
 19	return (regs->tstate & TSTATE_SYSCALL);
 20}
 21
 22static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
 23{
 24	return (regs->tstate &= ~TSTATE_SYSCALL);
 25}
 26
 27#define arch_ptrace_stop_needed(exit_code, info) \
 28({	flush_user_windows(); \
 29	get_thread_wsaved() != 0; \
 30})
 31
 32#define arch_ptrace_stop(exit_code, info) \
 33	synchronize_user_stack()
 34
 35#define current_pt_regs() \
 36	((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
 37
 38struct global_reg_snapshot {
 39	unsigned long		tstate;
 40	unsigned long		tpc;
 41	unsigned long		tnpc;
 42	unsigned long		o7;
 43	unsigned long		i7;
 44	unsigned long		rpc;
 45	struct thread_info	*thread;
 46	unsigned long		pad1;
 47};
 48
 49struct global_pmu_snapshot {
 50	unsigned long		pcr[4];
 51	unsigned long		pic[4];
 52};
 53
 54union global_cpu_snapshot {
 55	struct global_reg_snapshot	reg;
 56	struct global_pmu_snapshot	pmu;
 57};
 58
 59extern union global_cpu_snapshot global_cpu_snapshot[NR_CPUS];
 60
 61#define force_successful_syscall_return() set_thread_noerror(1)
 62#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
 63#define instruction_pointer(regs) ((regs)->tpc)
 64#define instruction_pointer_set(regs, val) do { \
 65		(regs)->tpc = (val); \
 66		(regs)->tnpc = (val)+4; \
 67	} while (0)
 68#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
 69static inline int is_syscall_success(struct pt_regs *regs)
 70{
 71	return !(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY));
 72}
 73
 74static inline long regs_return_value(struct pt_regs *regs)
 75{
 76	return regs->u_regs[UREG_I0];
 77}
 78#ifdef CONFIG_SMP
 79unsigned long profile_pc(struct pt_regs *);
 80#else
 81#define profile_pc(regs) instruction_pointer(regs)
 82#endif
 83
 84#define MAX_REG_OFFSET (offsetof(struct pt_regs, magic))
 85
 86extern int regs_query_register_offset(const char *name);
 
 87
 88/**
 89 * regs_get_register() - get register value from its offset
 90 * @regs:	pt_regs from which register value is gotten
 91 * @offset:	offset number of the register.
 92 *
 93 * regs_get_register returns the value of a register whose
 94 * offset from @regs. The @offset is the offset of the register
 95 * in struct pt_regs. If @offset is bigger than MAX_REG_OFFSET,
 96 * this returns 0.
 97 */
 98static inline unsigned long regs_get_register(struct pt_regs *regs,
 99					     unsigned long offset)
100{
101	if (unlikely(offset >= MAX_REG_OFFSET))
102		return 0;
103	if (offset == PT_V9_Y)
104		return *(unsigned int *)((unsigned long)regs + offset);
105	return *(unsigned long *)((unsigned long)regs + offset);
106}
107
108/* Valid only for Kernel mode traps. */
109static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
110{
111	return regs->u_regs[UREG_I6];
112}
113#else /* __ASSEMBLY__ */
114#endif /* __ASSEMBLY__ */
115#else /* (defined(__sparc__) && defined(__arch64__)) */
116#ifndef __ASSEMBLY__
117#include <asm/switch_to.h>
118
119static inline bool pt_regs_is_syscall(struct pt_regs *regs)
120{
121	return (regs->psr & PSR_SYSCALL);
122}
123
124static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
125{
126	return (regs->psr &= ~PSR_SYSCALL);
127}
128
129#define arch_ptrace_stop_needed(exit_code, info) \
130({	flush_user_windows(); \
131	current_thread_info()->w_saved != 0;	\
132})
133
134#define arch_ptrace_stop(exit_code, info) \
135	synchronize_user_stack()
136
137#define current_pt_regs() \
138	((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
139
140#define user_mode(regs) (!((regs)->psr & PSR_PS))
141#define instruction_pointer(regs) ((regs)->pc)
142#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
143unsigned long profile_pc(struct pt_regs *);
144#else /* (!__ASSEMBLY__) */
145#endif /* (!__ASSEMBLY__) */
146#endif /* (defined(__sparc__) && defined(__arch64__)) */
147#define STACK_BIAS		2047
148
149/* global_reg_snapshot offsets */
150#define GR_SNAP_TSTATE	0x00
151#define GR_SNAP_TPC	0x08
152#define GR_SNAP_TNPC	0x10
153#define GR_SNAP_O7	0x18
154#define GR_SNAP_I7	0x20
155#define GR_SNAP_RPC	0x28
156#define GR_SNAP_THREAD	0x30
157#define GR_SNAP_PAD1	0x38
158
159#endif /* !(__SPARC_PTRACE_H) */