ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 09:42:17 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Amit Bhor, Sameer Dhavale: Codito Technologies 2004
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_ARC_PTRACE_H
|
|
|
|
#define __ASM_ARC_PTRACE_H
|
|
|
|
|
2013-02-11 14:25:33 +00:00
|
|
|
#include <uapi/asm/ptrace.h>
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 09:42:17 +00:00
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
/* THE pt_regs: Defines how regs are saved during entry into kernel */
|
|
|
|
|
|
|
|
struct pt_regs {
|
|
|
|
|
|
|
|
/* Real registers */
|
|
|
|
long bta; /* bta_l1, bta_l2, erbta */
|
2013-07-10 06:10:27 +00:00
|
|
|
|
|
|
|
long lp_start, lp_end, lp_count;
|
|
|
|
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 09:42:17 +00:00
|
|
|
long status32; /* status32_l1, status32_l2, erstatus */
|
|
|
|
long ret; /* ilink1, ilink2 or eret */
|
|
|
|
long blink;
|
|
|
|
long fp;
|
|
|
|
long r26; /* gp */
|
2013-07-10 06:10:27 +00:00
|
|
|
|
|
|
|
long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
|
|
|
|
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 09:42:17 +00:00
|
|
|
long sp; /* user/kernel sp depending on where we came from */
|
|
|
|
long orig_r0;
|
2013-02-11 14:31:24 +00:00
|
|
|
|
2013-06-11 13:26:54 +00:00
|
|
|
/*
|
|
|
|
* To distinguish bet excp, syscall, irq
|
|
|
|
* For traps and exceptions, Exception Cause Register.
|
|
|
|
* ECR: <00> <VV> <CC> <PP>
|
|
|
|
* Last word used by Linux for extra state mgmt (syscall-restart)
|
|
|
|
* For interrupts, use artificial ECR values to note current prio-level
|
|
|
|
*/
|
2013-02-11 14:31:24 +00:00
|
|
|
union {
|
2013-06-11 13:26:54 +00:00
|
|
|
struct {
|
2013-02-11 14:31:24 +00:00
|
|
|
#ifdef CONFIG_CPU_BIG_ENDIAN
|
2013-06-11 13:26:54 +00:00
|
|
|
unsigned long state:8, ecr_vec:8,
|
|
|
|
ecr_cause:8, ecr_param:8;
|
2013-02-11 14:31:24 +00:00
|
|
|
#else
|
2013-06-11 13:26:54 +00:00
|
|
|
unsigned long ecr_param:8, ecr_cause:8,
|
|
|
|
ecr_vec:8, state:8;
|
2013-02-11 14:31:24 +00:00
|
|
|
#endif
|
2013-06-11 13:26:54 +00:00
|
|
|
};
|
|
|
|
unsigned long event;
|
2013-02-11 14:31:24 +00:00
|
|
|
};
|
ARC: pt_regs update #4: r25 saved/restored unconditionally
(This is a VERY IMP change for low level interrupt/exception handling)
-----------------------------------------------------------------------
WHAT
-----------------------------------------------------------------------
* User 25 now saved in pt_regs->user_r25 (vs. tsk->thread_info.user_r25)
* This allows Low level interrupt code to unconditionally save r25
(vs. the prev version which would only do it for U->K transition).
Ofcourse for nested interrupts, only the pt_regs->user_r25 of
bottom-most frame is useful.
* simplifies the interrupt prologue/epilogue
* Needed for ARCv2 ISA code and done here to keep design similar with
ARCompact event handling
-----------------------------------------------------------------------
WHY
-------------------------------------------------------------------------
With CONFIG_ARC_CURR_IN_REG, r25 is used to cache "current" task pointer
in kernel mode. So when entering kernel mode from User Mode
- user r25 is specially safe-kept (it being a callee reg is NOT part of
pt_regs which are saved by default on each interrupt/trap/exception)
- r25 loaded with current task pointer.
Further, if interrupt was taken in kernel mode, this is skipped since we
know that r25 already has valid "current" pointer.
With 2 level of interrupts in ARCompact ISA, detecting this is difficult
but still possible, since we could be in kernel mode but r25 not already saved
(in fact the stack itself might not have been switched).
A. User mode
B. L1 IRQ taken
C. L2 IRQ taken (while on 1st line of L1 ISR)
So in #C, although in kernel mode, r25 not saved (infact SP not
switched at all)
Given that ARcompact has manual stack switching, we could use a bit of
trickey - The low level code would make sure that SP is only set to kernel
mode value at the very end (after saving r25). So a non kernel mode SP,
even if in kernel mode, meant r25 was NOT saved.
The same paradigm won't work in ARCv2 ISA since SP is auto-switched so
it's setting can't be delayed/constrained.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2013-05-28 08:20:41 +00:00
|
|
|
|
|
|
|
long user_r25;
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 09:42:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Callee saved registers - need to be saved only when you are scheduled out */
|
|
|
|
|
|
|
|
struct callee_regs {
|
2013-07-10 06:10:27 +00:00
|
|
|
long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 09:42:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define instruction_pointer(regs) ((regs)->ret)
|
|
|
|
#define profile_pc(regs) instruction_pointer(regs)
|
|
|
|
|
|
|
|
/* return 1 if user mode or 0 if kernel mode */
|
|
|
|
#define user_mode(regs) (regs->status32 & STATUS_U_MASK)
|
|
|
|
|
|
|
|
#define user_stack_pointer(regs)\
|
|
|
|
({ unsigned int sp; \
|
|
|
|
if (user_mode(regs)) \
|
|
|
|
sp = (regs)->sp;\
|
|
|
|
else \
|
|
|
|
sp = -1; \
|
|
|
|
sp; \
|
|
|
|
})
|
2013-01-18 09:42:18 +00:00
|
|
|
|
2013-01-23 11:00:36 +00:00
|
|
|
/* return 1 if PC in delay slot */
|
|
|
|
#define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
|
|
|
|
|
2013-06-11 13:26:54 +00:00
|
|
|
#define in_syscall(regs) ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param)
|
|
|
|
#define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param)
|
2013-01-18 09:42:18 +00:00
|
|
|
|
2013-06-11 13:26:54 +00:00
|
|
|
#define STATE_SCALL_RESTARTED 0x01
|
|
|
|
|
|
|
|
#define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED)
|
|
|
|
#define syscall_restartable(reg) !(reg->state & STATE_SCALL_RESTARTED)
|
2013-01-18 09:42:19 +00:00
|
|
|
|
2013-01-18 09:42:18 +00:00
|
|
|
#define current_pt_regs() \
|
|
|
|
({ \
|
|
|
|
/* open-coded current_thread_info() */ \
|
|
|
|
register unsigned long sp asm ("sp"); \
|
|
|
|
unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
|
2013-05-28 04:04:45 +00:00
|
|
|
(struct pt_regs *)(pg_start + THREAD_SIZE) - 1; \
|
2013-01-18 09:42:18 +00:00
|
|
|
})
|
|
|
|
|
2013-01-22 11:33:59 +00:00
|
|
|
static inline long regs_return_value(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
return regs->r0;
|
|
|
|
}
|
|
|
|
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 09:42:17 +00:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif /* __ASM_PTRACE_H */
|