2007-10-16 16:27:08 +08:00
|
|
|
/*
|
2007-10-16 16:26:56 +08:00
|
|
|
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SYSDEP_I386_PTRACE_H
|
|
|
|
#define __SYSDEP_I386_PTRACE_H
|
|
|
|
|
2011-08-19 03:01:19 +08:00
|
|
|
#include <generated/user_constants.h>
|
2005-06-14 06:52:10 +08:00
|
|
|
#include "sysdep/faultinfo.h"
|
2005-04-17 06:20:36 +08: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 18:30:21 +08:00
|
|
|
static inline void update_debugregs(int seq) {}
|
2005-04-17 06:20:36 +08: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;
|
|
|
|
|
|
|
|
#define REGS_IP(r) ((r)[HOST_IP])
|
|
|
|
#define REGS_SP(r) ((r)[HOST_SP])
|
|
|
|
#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
|
2011-08-19 03:10:09 +08:00
|
|
|
#define REGS_EAX(r) ((r)[HOST_AX])
|
|
|
|
#define REGS_EBX(r) ((r)[HOST_BX])
|
|
|
|
#define REGS_ECX(r) ((r)[HOST_CX])
|
|
|
|
#define REGS_EDX(r) ((r)[HOST_DX])
|
|
|
|
#define REGS_ESI(r) ((r)[HOST_SI])
|
|
|
|
#define REGS_EDI(r) ((r)[HOST_DI])
|
|
|
|
#define REGS_EBP(r) ((r)[HOST_BP])
|
2005-04-17 06:20:36 +08:00
|
|
|
#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)
|
|
|
|
|
2011-08-19 03:03:59 +08:00
|
|
|
#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
|
2005-04-17 06:20:36 +08:00
|
|
|
#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
|
|
|
|
|
|
|
|
#ifndef PTRACE_SYSEMU_SINGLESTEP
|
|
|
|
#define PTRACE_SYSEMU_SINGLESTEP 32
|
|
|
|
#endif
|
|
|
|
|
2007-10-16 16:26:58 +08:00
|
|
|
struct uml_pt_regs {
|
2007-10-16 16:27:07 +08:00
|
|
|
unsigned long gp[MAX_REG_NR];
|
2011-09-15 07:21:23 +08:00
|
|
|
unsigned long fp[HOST_FPX_SIZE];
|
2007-10-16 16:26:58 +08:00
|
|
|
struct faultinfo faultinfo;
|
|
|
|
long syscall;
|
|
|
|
int is_user;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define EMPTY_UML_PT_REGS { }
|
|
|
|
|
2007-10-16 16:27:07 +08: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 16:26:58 +08:00
|
|
|
#define UPT_ORIG_EAX(r) ((r)->syscall)
|
2007-10-16 16:27:07 +08: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-17 06:20:36 +08: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 16:26:58 +08:00
|
|
|
#define UPT_IS_USER(r) ((r)->is_user)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct syscall_args {
|
|
|
|
unsigned long args[6];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SYSCALL_ARGS(r) ((struct syscall_args) \
|
2007-10-16 16:27:00 +08: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-17 06:20:36 +08:00
|
|
|
|
2007-10-16 16:27:07 +08:00
|
|
|
#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
|
2005-04-17 06:20:36 +08: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 16:26:58 +08:00
|
|
|
#define UPT_FAULTINFO(r) (&(r)->faultinfo)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-16 16:27:15 +08:00
|
|
|
extern void arch_init_registers(int pid);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|