2007-10-16 01:27:08 -07:00
/*
2007-10-16 01:26:56 -07:00
* Copyright ( C ) 2000 - 2007 Jeff Dike ( jdike @ { addtoit , linux . intel } . com )
2005-04-16 15:20:36 -07:00
* Licensed under the GPL
*/
# ifndef __SYSDEP_I386_PTRACE_H
# define __SYSDEP_I386_PTRACE_H
# include "user_constants.h"
2005-06-13 15:52:10 -07:00
# include "sysdep/faultinfo.h"
2005-04-16 15:20:36 -07:00
# define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
# define MAX_REG_OFFSET (UM_FRAME_SIZE)
[PATCH] uml: clean arch_switch usage
Call arch_switch also in switch_to_skas, even if it's, for now, a no-op for
that case (and mark this in the comment); this will change soon.
Also, arch_switch for TT mode is actually useless when the PT proxy (a
complicate debugging instrumentation for TT mode) is not enabled. In fact, it
only calls update_debugregs, which checks debugregs_seq against seq (to check
if the registers are up-to-date - seq here means a "version number" of the
registers).
If the ptrace proxy is not enabled, debugregs_seq always stays 0 and
update_debugregs will be a no-op. So, optimize this out (the compiler can't
do it).
Also, I've been disappointed by the fact that it would make a lot of sense if,
after calling a successful
update_debugregs(current->thread.arch.debugregs_seq),
current->thread.arch.debugregs_seq were updated with the new debugregs_seq.
But this is not done. Is this a bug or a feature? For all purposes, it seems
a bug (otherwise the whole mechanism does not make sense, which is also a
possibility to check), which causes some performance only problems (not
correctness), since we write_debugregs when not needed.
Also, as suggested by Jeff, remove a redundant enabling of SIGVTALRM,
comprised in the subsequent local_irq_enable(). I'm just a bit dubious if
ordering matters there...
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-31 02:30:21 -08:00
static inline void update_debugregs ( int seq ) { }
2005-04-16 15:20:36 -07:00
/* syscall emulation path in ptrace */
# ifndef PTRACE_SYSEMU
# define PTRACE_SYSEMU 31
# endif
void set_using_sysemu ( int value ) ;
int get_using_sysemu ( void ) ;
extern int sysemu_supported ;
# include "skas_ptregs.h"
# define REGS_IP(r) ((r)[HOST_IP])
# define REGS_SP(r) ((r)[HOST_SP])
# define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
# define REGS_EAX(r) ((r)[HOST_EAX])
# define REGS_EBX(r) ((r)[HOST_EBX])
# define REGS_ECX(r) ((r)[HOST_ECX])
# define REGS_EDX(r) ((r)[HOST_EDX])
# define REGS_ESI(r) ((r)[HOST_ESI])
# define REGS_EDI(r) ((r)[HOST_EDI])
# define REGS_EBP(r) ((r)[HOST_EBP])
# define REGS_CS(r) ((r)[HOST_CS])
# define REGS_SS(r) ((r)[HOST_SS])
# define REGS_DS(r) ((r)[HOST_DS])
# define REGS_ES(r) ((r)[HOST_ES])
# define REGS_FS(r) ((r)[HOST_FS])
# define REGS_GS(r) ((r)[HOST_GS])
# define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res)
# define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
# ifndef PTRACE_SYSEMU_SINGLESTEP
# define PTRACE_SYSEMU_SINGLESTEP 32
# endif
2007-10-16 01:26:58 -07:00
struct uml_pt_regs {
2007-10-16 01:27:07 -07:00
unsigned long gp [ MAX_REG_NR ] ;
2007-10-16 01:26:58 -07:00
struct faultinfo faultinfo ;
long syscall ;
int is_user ;
2005-04-16 15:20:36 -07:00
} ;
# define EMPTY_UML_PT_REGS { }
2007-10-16 01:27:07 -07:00
# define UPT_IP(r) REGS_IP((r)->gp)
# define UPT_SP(r) REGS_SP((r)->gp)
# define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
# define UPT_EAX(r) REGS_EAX((r)->gp)
# define UPT_EBX(r) REGS_EBX((r)->gp)
# define UPT_ECX(r) REGS_ECX((r)->gp)
# define UPT_EDX(r) REGS_EDX((r)->gp)
# define UPT_ESI(r) REGS_ESI((r)->gp)
# define UPT_EDI(r) REGS_EDI((r)->gp)
# define UPT_EBP(r) REGS_EBP((r)->gp)
2007-10-16 01:26:58 -07:00
# define UPT_ORIG_EAX(r) ((r)->syscall)
2007-10-16 01:27:07 -07:00
# define UPT_CS(r) REGS_CS((r)->gp)
# define UPT_SS(r) REGS_SS((r)->gp)
# define UPT_DS(r) REGS_DS((r)->gp)
# define UPT_ES(r) REGS_ES((r)->gp)
# define UPT_FS(r) REGS_FS((r)->gp)
# define UPT_GS(r) REGS_GS((r)->gp)
2005-04-16 15:20:36 -07:00
# define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
# define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
# define UPT_SYSCALL_ARG3(r) UPT_EDX(r)
# define UPT_SYSCALL_ARG4(r) UPT_ESI(r)
# define UPT_SYSCALL_ARG5(r) UPT_EDI(r)
# define UPT_SYSCALL_ARG6(r) UPT_EBP(r)
extern int user_context ( unsigned long sp ) ;
2007-10-16 01:26:58 -07:00
# define UPT_IS_USER(r) ((r)->is_user)
2005-04-16 15:20:36 -07:00
struct syscall_args {
unsigned long args [ 6 ] ;
} ;
# define SYSCALL_ARGS(r) ((struct syscall_args) \
2007-10-16 01:27:00 -07:00
{ . args = { UPT_SYSCALL_ARG1 ( r ) , \
UPT_SYSCALL_ARG2 ( r ) , \
UPT_SYSCALL_ARG3 ( r ) , \
UPT_SYSCALL_ARG4 ( r ) , \
UPT_SYSCALL_ARG5 ( r ) , \
UPT_SYSCALL_ARG6 ( r ) } } )
2005-04-16 15:20:36 -07:00
# define UPT_REG(regs, reg) \
( { unsigned long val ; \
switch ( reg ) { \
case EIP : val = UPT_IP ( regs ) ; break ; \
case UESP : val = UPT_SP ( regs ) ; break ; \
case EAX : val = UPT_EAX ( regs ) ; break ; \
case EBX : val = UPT_EBX ( regs ) ; break ; \
case ECX : val = UPT_ECX ( regs ) ; break ; \
case EDX : val = UPT_EDX ( regs ) ; break ; \
case ESI : val = UPT_ESI ( regs ) ; break ; \
case EDI : val = UPT_EDI ( regs ) ; break ; \
case EBP : val = UPT_EBP ( regs ) ; break ; \
case ORIG_EAX : val = UPT_ORIG_EAX ( regs ) ; break ; \
case CS : val = UPT_CS ( regs ) ; break ; \
case SS : val = UPT_SS ( regs ) ; break ; \
case DS : val = UPT_DS ( regs ) ; break ; \
case ES : val = UPT_ES ( regs ) ; break ; \
case FS : val = UPT_FS ( regs ) ; break ; \
case GS : val = UPT_GS ( regs ) ; break ; \
case EFL : val = UPT_EFLAGS ( regs ) ; break ; \
default : \
panic ( " Bad register in UPT_REG : %d \n " , reg ) ; \
val = - 1 ; \
} \
val ; \
} )
# define UPT_SET(regs, reg, val) \
do { \
switch ( reg ) { \
case EIP : UPT_IP ( regs ) = val ; break ; \
case UESP : UPT_SP ( regs ) = val ; break ; \
case EAX : UPT_EAX ( regs ) = val ; break ; \
case EBX : UPT_EBX ( regs ) = val ; break ; \
case ECX : UPT_ECX ( regs ) = val ; break ; \
case EDX : UPT_EDX ( regs ) = val ; break ; \
case ESI : UPT_ESI ( regs ) = val ; break ; \
case EDI : UPT_EDI ( regs ) = val ; break ; \
case EBP : UPT_EBP ( regs ) = val ; break ; \
case ORIG_EAX : UPT_ORIG_EAX ( regs ) = val ; break ; \
case CS : UPT_CS ( regs ) = val ; break ; \
case SS : UPT_SS ( regs ) = val ; break ; \
case DS : UPT_DS ( regs ) = val ; break ; \
case ES : UPT_ES ( regs ) = val ; break ; \
case FS : UPT_FS ( regs ) = val ; break ; \
case GS : UPT_GS ( regs ) = val ; break ; \
case EFL : UPT_EFLAGS ( regs ) = val ; break ; \
default : \
panic ( " Bad register in UPT_SET : %d \n " , reg ) ; \
break ; \
} \
} while ( 0 )
# define UPT_SET_SYSCALL_RETURN(r, res) \
2007-10-16 01:26:58 -07:00
REGS_SET_SYSCALL_RETURN ( ( r ) - > regs , ( res ) )
2005-04-16 15:20:36 -07:00
2007-10-16 01:27:07 -07:00
# define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
2005-04-16 15:20:36 -07:00
# define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
# define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
# define UPT_SYSCALL_RET(r) UPT_EAX(r)
2007-10-16 01:26:58 -07:00
# define UPT_FAULTINFO(r) (&(r)->faultinfo)
2005-04-16 15:20:36 -07:00
2007-10-16 01:27:15 -07:00
extern void arch_init_registers ( int pid ) ;
2005-04-16 15:20:36 -07:00
# endif