xref: /openbmc/linux/arch/s390/include/asm/ptrace.h (revision 818a330c)
1c6557e7fSMartin Schwidefsky /*
2c6557e7fSMartin Schwidefsky  *  S390 version
3a53c8fabSHeiko Carstens  *    Copyright IBM Corp. 1999, 2000
4c6557e7fSMartin Schwidefsky  *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
5c6557e7fSMartin Schwidefsky  */
6c6557e7fSMartin Schwidefsky #ifndef _S390_PTRACE_H
7c6557e7fSMartin Schwidefsky #define _S390_PTRACE_H
8c6557e7fSMartin Schwidefsky 
99807f759SDavid Howells #include <uapi/asm/ptrace.h>
10c6557e7fSMartin Schwidefsky 
11c6557e7fSMartin Schwidefsky #ifndef __ASSEMBLY__
1263dd9b44SHeiko Carstens 
13e258d719SMartin Schwidefsky #define PSW_KERNEL_BITS	(PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_ASC_HOME | \
14e258d719SMartin Schwidefsky 			 PSW_MASK_EA | PSW_MASK_BA)
15e258d719SMartin Schwidefsky #define PSW_USER_BITS	(PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | \
16e258d719SMartin Schwidefsky 			 PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_MASK_MCHECK | \
17e258d719SMartin Schwidefsky 			 PSW_MASK_PSTATE | PSW_ASC_PRIMARY)
18c6557e7fSMartin Schwidefsky 
19c6557e7fSMartin Schwidefsky /*
20c6557e7fSMartin Schwidefsky  * The pt_regs struct defines the way the registers are stored on
21c6557e7fSMartin Schwidefsky  * the stack during a system call.
22c6557e7fSMartin Schwidefsky  */
23c6557e7fSMartin Schwidefsky struct pt_regs
24c6557e7fSMartin Schwidefsky {
25c6557e7fSMartin Schwidefsky 	unsigned long args[1];
26c6557e7fSMartin Schwidefsky 	psw_t psw;
27c6557e7fSMartin Schwidefsky 	unsigned long gprs[NUM_GPRS];
28c6557e7fSMartin Schwidefsky 	unsigned long orig_gpr2;
29aa33c8cbSMartin Schwidefsky 	unsigned int int_code;
3048f6b00cSMartin Schwidefsky 	unsigned int int_parm;
31aa33c8cbSMartin Schwidefsky 	unsigned long int_parm_long;
32c6557e7fSMartin Schwidefsky };
335e9a2692SMartin Schwidefsky 
345e9a2692SMartin Schwidefsky /*
355e9a2692SMartin Schwidefsky  * Program event recording (PER) register set.
365e9a2692SMartin Schwidefsky  */
375e9a2692SMartin Schwidefsky struct per_regs {
385e9a2692SMartin Schwidefsky 	unsigned long control;		/* PER control bits */
395e9a2692SMartin Schwidefsky 	unsigned long start;		/* PER starting address */
405e9a2692SMartin Schwidefsky 	unsigned long end;		/* PER ending address */
415e9a2692SMartin Schwidefsky };
425e9a2692SMartin Schwidefsky 
435e9a2692SMartin Schwidefsky /*
445e9a2692SMartin Schwidefsky  * PER event contains information about the cause of the last PER exception.
455e9a2692SMartin Schwidefsky  */
465e9a2692SMartin Schwidefsky struct per_event {
475e9a2692SMartin Schwidefsky 	unsigned short cause;		/* PER code, ATMID and AI */
485e9a2692SMartin Schwidefsky 	unsigned long address;		/* PER address */
495e9a2692SMartin Schwidefsky 	unsigned char paid;		/* PER access identification */
505e9a2692SMartin Schwidefsky };
515e9a2692SMartin Schwidefsky 
525e9a2692SMartin Schwidefsky /*
535e9a2692SMartin Schwidefsky  * Simplified per_info structure used to decode the ptrace user space ABI.
545e9a2692SMartin Schwidefsky  */
555e9a2692SMartin Schwidefsky struct per_struct_kernel {
565e9a2692SMartin Schwidefsky 	unsigned long cr9;		/* PER control bits */
575e9a2692SMartin Schwidefsky 	unsigned long cr10;		/* PER starting address */
585e9a2692SMartin Schwidefsky 	unsigned long cr11;		/* PER ending address */
595e9a2692SMartin Schwidefsky 	unsigned long bits;		/* Obsolete software bits */
605e9a2692SMartin Schwidefsky 	unsigned long starting_addr;	/* User specified start address */
615e9a2692SMartin Schwidefsky 	unsigned long ending_addr;	/* User specified end address */
625e9a2692SMartin Schwidefsky 	unsigned short perc_atmid;	/* PER trap ATMID */
635e9a2692SMartin Schwidefsky 	unsigned long address;		/* PER trap instruction address */
645e9a2692SMartin Schwidefsky 	unsigned char access_id;	/* PER trap access identification */
655e9a2692SMartin Schwidefsky };
665e9a2692SMartin Schwidefsky 
67d35339a4SMartin Schwidefsky #define PER_EVENT_MASK			0xEB000000UL
685e9a2692SMartin Schwidefsky 
695e9a2692SMartin Schwidefsky #define PER_EVENT_BRANCH		0x80000000UL
705e9a2692SMartin Schwidefsky #define PER_EVENT_IFETCH		0x40000000UL
715e9a2692SMartin Schwidefsky #define PER_EVENT_STORE			0x20000000UL
725e9a2692SMartin Schwidefsky #define PER_EVENT_STORE_REAL		0x08000000UL
73d35339a4SMartin Schwidefsky #define PER_EVENT_TRANSACTION_END	0x02000000UL
745e9a2692SMartin Schwidefsky #define PER_EVENT_NULLIFICATION		0x01000000UL
755e9a2692SMartin Schwidefsky 
76d35339a4SMartin Schwidefsky #define PER_CONTROL_MASK		0x00e00000UL
775e9a2692SMartin Schwidefsky 
785e9a2692SMartin Schwidefsky #define PER_CONTROL_BRANCH_ADDRESS	0x00800000UL
79d35339a4SMartin Schwidefsky #define PER_CONTROL_SUSPENSION		0x00400000UL
805e9a2692SMartin Schwidefsky #define PER_CONTROL_ALTERATION		0x00200000UL
815e9a2692SMartin Schwidefsky 
82c6557e7fSMartin Schwidefsky /*
83c6557e7fSMartin Schwidefsky  * These are defined as per linux/ptrace.h, which see.
84c6557e7fSMartin Schwidefsky  */
85c6557e7fSMartin Schwidefsky #define arch_has_single_step()	(1)
86818a330cSMartin Schwidefsky #define arch_has_block_step()	(1)
87c6557e7fSMartin Schwidefsky 
88c6557e7fSMartin Schwidefsky #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
89c6557e7fSMartin Schwidefsky #define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
90753c4dd6SMartin Schwidefsky #define user_stack_pointer(regs)((regs)->gprs[15])
91c6557e7fSMartin Schwidefsky #define profile_pc(regs) instruction_pointer(regs)
92952974acSHeiko Carstens 
93d7e7528bSEric Paris static inline long regs_return_value(struct pt_regs *regs)
94d7e7528bSEric Paris {
95d7e7528bSEric Paris 	return regs->gprs[2];
96d7e7528bSEric Paris }
97d7e7528bSEric Paris 
98952974acSHeiko Carstens int regs_query_register_offset(const char *name);
99952974acSHeiko Carstens const char *regs_query_register_name(unsigned int offset);
100952974acSHeiko Carstens unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset);
101952974acSHeiko Carstens unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
102952974acSHeiko Carstens 
103952974acSHeiko Carstens static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
104952974acSHeiko Carstens {
105952974acSHeiko Carstens 	return regs->gprs[15] & PSW_ADDR_INSN;
106952974acSHeiko Carstens }
107952974acSHeiko Carstens 
108c6557e7fSMartin Schwidefsky #endif /* __ASSEMBLY__ */
109c6557e7fSMartin Schwidefsky #endif /* _S390_PTRACE_H */
110