2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2003-02-28 00:49:47 +00:00
|
|
|
/*
|
2008-03-25 02:43:17 +00:00
|
|
|
* Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
2003-02-28 00:49:47 +00:00
|
|
|
*/
|
|
|
|
#ifndef _ASM_PTRACE_H
|
|
|
|
#define _ASM_PTRACE_H
|
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <asm/isadep.h>
|
2003-02-28 00:49:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This struct defines the way the registers are stored on the stack during a
|
|
|
|
* system call/exception. As usual the registers k0/k1 aren't being saved.
|
2016-01-12 20:48:26 +00:00
|
|
|
*
|
|
|
|
* If you add a register here, also add it to regoffset_table[] in
|
|
|
|
* arch/mips/kernel/ptrace.c.
|
2003-02-28 00:49:47 +00:00
|
|
|
*/
|
|
|
|
struct pt_regs {
|
2008-03-25 02:43:17 +00:00
|
|
|
#ifdef CONFIG_32BIT
|
2003-02-28 00:49:47 +00:00
|
|
|
/* Pad bytes for argument save space on the stack. */
|
2016-01-12 20:48:26 +00:00
|
|
|
unsigned long pad0[8];
|
2008-03-25 02:43:17 +00:00
|
|
|
#endif
|
2003-02-28 00:49:47 +00:00
|
|
|
|
|
|
|
/* Saved main processor registers. */
|
|
|
|
unsigned long regs[32];
|
|
|
|
|
2008-03-25 02:43:17 +00:00
|
|
|
/* Saved special registers. */
|
|
|
|
unsigned long cp0_status;
|
2003-02-28 00:49:47 +00:00
|
|
|
unsigned long hi;
|
2008-03-25 02:43:17 +00:00
|
|
|
unsigned long lo;
|
|
|
|
#ifdef CONFIG_CPU_HAS_SMARTMIPS
|
|
|
|
unsigned long acx;
|
|
|
|
#endif
|
2003-02-28 00:49:47 +00:00
|
|
|
unsigned long cp0_badvaddr;
|
|
|
|
unsigned long cp0_cause;
|
2008-03-25 02:43:17 +00:00
|
|
|
unsigned long cp0_epc;
|
2016-01-12 20:48:26 +00:00
|
|
|
#ifdef CONFIG_CPU_CAVIUM_OCTEON
|
|
|
|
unsigned long long mpl[6]; /* MTM{0-5} */
|
|
|
|
unsigned long long mtp[6]; /* MTP{0-5} */
|
|
|
|
#endif
|
|
|
|
unsigned long __last[0];
|
|
|
|
} __aligned(8);
|
2003-02-28 00:49:47 +00:00
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
return regs->regs[31];
|
|
|
|
}
|
2003-02-28 00:49:47 +00:00
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
/*
|
|
|
|
* Don't use asm-generic/ptrace.h it defines FP accessors that don't make
|
|
|
|
* sense on MIPS. We rather want an error if they get invoked.
|
|
|
|
*/
|
2003-02-28 00:49:47 +00:00
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
static inline void instruction_pointer_set(struct pt_regs *regs,
|
|
|
|
unsigned long val)
|
|
|
|
{
|
|
|
|
regs->cp0_epc = val;
|
|
|
|
}
|
2003-02-28 00:49:47 +00:00
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
/* Query offset/name of register from its name/offset */
|
|
|
|
extern int regs_query_register_offset(const char *name);
|
|
|
|
#define MAX_REG_OFFSET (offsetof(struct pt_regs, __last))
|
2003-02-28 00:49:47 +00:00
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
/**
|
|
|
|
* regs_get_register() - get register value from its offset
|
|
|
|
* @regs: pt_regs from which register value is gotten.
|
|
|
|
* @offset: offset number of the register.
|
|
|
|
*
|
|
|
|
* regs_get_register returns the value of a register. The @offset is the
|
|
|
|
* offset of the register in struct pt_regs address which specified by @regs.
|
|
|
|
* If @offset is bigger than MAX_REG_OFFSET, this returns 0.
|
|
|
|
*/
|
|
|
|
static inline unsigned long regs_get_register(struct pt_regs *regs,
|
|
|
|
unsigned int offset)
|
|
|
|
{
|
|
|
|
if (unlikely(offset > MAX_REG_OFFSET))
|
|
|
|
return 0;
|
2003-02-28 00:49:47 +00:00
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
return *(unsigned long *)((unsigned long)regs + offset);
|
|
|
|
}
|
2008-03-25 02:43:17 +00:00
|
|
|
|
2003-02-28 00:49:47 +00:00
|
|
|
/*
|
|
|
|
* Does the process account for user or for system time?
|
|
|
|
*/
|
|
|
|
#define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)
|
|
|
|
|
|
|
|
#define instruction_pointer(regs) ((regs)->cp0_epc)
|
2008-03-25 02:43:17 +00:00
|
|
|
#define profile_pc(regs) instruction_pointer(regs)
|
2003-02-28 00:49:47 +00:00
|
|
|
|
2016-01-12 20:48:26 +00:00
|
|
|
/* Helpers for working with the user stack pointer */
|
|
|
|
|
|
|
|
static inline unsigned long user_stack_pointer(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
return regs->regs[29];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void user_stack_pointer_set(struct pt_regs *regs,
|
|
|
|
unsigned long val)
|
|
|
|
{
|
|
|
|
regs->regs[29] = val;
|
|
|
|
}
|
2003-02-28 00:49:47 +00:00
|
|
|
|
|
|
|
#endif /* _ASM_PTRACE_H */
|