Creation of Cybook 2416 (actually Gen4) repository
This commit is contained in:
28
arch/um/include/aio.h
Normal file
28
arch/um/include/aio.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2004 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef AIO_H__
|
||||
#define AIO_H__
|
||||
|
||||
enum aio_type { AIO_READ, AIO_WRITE, AIO_MMAP };
|
||||
|
||||
struct aio_thread_reply {
|
||||
void *data;
|
||||
int err;
|
||||
};
|
||||
|
||||
struct aio_context {
|
||||
int reply_fd;
|
||||
struct aio_context *next;
|
||||
};
|
||||
|
||||
#define INIT_AIO_CONTEXT { .reply_fd = -1, \
|
||||
.next = NULL }
|
||||
|
||||
extern int submit_aio(enum aio_type type, int fd, char *buf, int len,
|
||||
unsigned long long offset, int reply_fd,
|
||||
struct aio_context *aio);
|
||||
|
||||
#endif
|
||||
52
arch/um/include/chan_kern.h
Normal file
52
arch/um/include/chan_kern.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __CHAN_KERN_H__
|
||||
#define __CHAN_KERN_H__
|
||||
|
||||
#include "linux/tty.h"
|
||||
#include "linux/list.h"
|
||||
#include "linux/console.h"
|
||||
#include "chan_user.h"
|
||||
#include "line.h"
|
||||
|
||||
struct chan {
|
||||
struct list_head list;
|
||||
struct list_head free_list;
|
||||
struct line *line;
|
||||
char *dev;
|
||||
unsigned int primary:1;
|
||||
unsigned int input:1;
|
||||
unsigned int output:1;
|
||||
unsigned int opened:1;
|
||||
unsigned int enabled:1;
|
||||
int fd;
|
||||
const struct chan_ops *ops;
|
||||
void *data;
|
||||
};
|
||||
|
||||
extern void chan_interrupt(struct list_head *chans, struct delayed_work *task,
|
||||
struct tty_struct *tty, int irq);
|
||||
extern int parse_chan_pair(char *str, struct line *line, int device,
|
||||
const struct chan_opts *opts, char **error_out);
|
||||
extern int open_chan(struct list_head *chans);
|
||||
extern int write_chan(struct list_head *chans, const char *buf, int len,
|
||||
int write_irq);
|
||||
extern int console_write_chan(struct list_head *chans, const char *buf,
|
||||
int len);
|
||||
extern int console_open_chan(struct line *line, struct console *co);
|
||||
extern void deactivate_chan(struct list_head *chans, int irq);
|
||||
extern void reactivate_chan(struct list_head *chans, int irq);
|
||||
extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty);
|
||||
extern void enable_chan(struct line *line);
|
||||
extern void close_chan(struct list_head *chans, int delay_free_irq);
|
||||
extern int chan_window_size(struct list_head *chans,
|
||||
unsigned short *rows_out,
|
||||
unsigned short *cols_out);
|
||||
extern int chan_out_fd(struct list_head *chans);
|
||||
extern int chan_config_string(struct list_head *chans, char *str, int size,
|
||||
char **error_out);
|
||||
|
||||
#endif
|
||||
56
arch/um/include/chan_user.h
Normal file
56
arch/um/include/chan_user.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __CHAN_USER_H__
|
||||
#define __CHAN_USER_H__
|
||||
|
||||
#include "init.h"
|
||||
|
||||
struct chan_opts {
|
||||
void (*const announce)(char *dev_name, int dev);
|
||||
char *xterm_title;
|
||||
const int raw;
|
||||
const unsigned long tramp_stack;
|
||||
const int in_kernel;
|
||||
};
|
||||
|
||||
enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE };
|
||||
|
||||
struct chan_ops {
|
||||
char *type;
|
||||
void *(*init)(char *, int, const struct chan_opts *);
|
||||
int (*open)(int, int, int, void *, char **);
|
||||
void (*close)(int, void *);
|
||||
int (*read)(int, char *, void *);
|
||||
int (*write)(int, const char *, int, void *);
|
||||
int (*console_write)(int, const char *, int);
|
||||
int (*window_size)(int, void *, unsigned short *, unsigned short *);
|
||||
void (*free)(void *);
|
||||
int winch;
|
||||
};
|
||||
|
||||
extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops,
|
||||
tty_ops, xterm_ops;
|
||||
|
||||
extern void generic_close(int fd, void *unused);
|
||||
extern int generic_read(int fd, char *c_out, void *unused);
|
||||
extern int generic_write(int fd, const char *buf, int n, void *unused);
|
||||
extern int generic_console_write(int fd, const char *buf, int n);
|
||||
extern int generic_window_size(int fd, void *unused, unsigned short *rows_out,
|
||||
unsigned short *cols_out);
|
||||
extern void generic_free(void *data);
|
||||
|
||||
struct tty_struct;
|
||||
extern void register_winch(int fd, struct tty_struct *tty);
|
||||
extern void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty);
|
||||
|
||||
#define __channel_help(fn, prefix) \
|
||||
__uml_help(fn, prefix "[0-9]*=<channel description>\n" \
|
||||
" Attach a console or serial line to a host channel. See\n" \
|
||||
" http://user-mode-linux.sourceforge.net/input.html for a complete\n" \
|
||||
" description of this switch.\n\n" \
|
||||
);
|
||||
|
||||
#endif
|
||||
38
arch/um/include/choose-mode.h
Normal file
38
arch/um/include/choose-mode.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __CHOOSE_MODE_H__
|
||||
#define __CHOOSE_MODE_H__
|
||||
|
||||
#include "uml-config.h"
|
||||
|
||||
#if defined(UML_CONFIG_MODE_TT) && defined(UML_CONFIG_MODE_SKAS)
|
||||
#define CHOOSE_MODE(tt, skas) (mode_tt ? (tt) : (skas))
|
||||
|
||||
extern int mode_tt;
|
||||
static inline void *__choose_mode(void *tt, void *skas) {
|
||||
return mode_tt ? tt : skas;
|
||||
}
|
||||
|
||||
#define __CHOOSE_MODE(tt, skas) (*( (typeof(tt) *) __choose_mode(&(tt), &(skas))))
|
||||
|
||||
#elif defined(UML_CONFIG_MODE_SKAS)
|
||||
#define CHOOSE_MODE(tt, skas) (skas)
|
||||
|
||||
#elif defined(UML_CONFIG_MODE_TT)
|
||||
#define CHOOSE_MODE(tt, skas) (tt)
|
||||
|
||||
#else
|
||||
#error CONFIG_MODE_SKAS and CONFIG_MODE_TT are both disabled
|
||||
#endif
|
||||
|
||||
#define CHOOSE_MODE_PROC(tt, skas, args...) \
|
||||
CHOOSE_MODE(tt(args), skas(args))
|
||||
|
||||
#ifndef __CHOOSE_MODE
|
||||
#define __CHOOSE_MODE(tt, skas) CHOOSE_MODE(tt, skas)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
28
arch/um/include/common-offsets.h
Normal file
28
arch/um/include/common-offsets.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* for use by sys-$SUBARCH/kernel-offsets.c */
|
||||
|
||||
DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
|
||||
#ifdef CONFIG_MODE_TT
|
||||
OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
|
||||
#endif
|
||||
|
||||
OFFSET(HOST_TASK_REGS, task_struct, thread.regs);
|
||||
OFFSET(HOST_TASK_PID, task_struct, pid);
|
||||
|
||||
DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
|
||||
DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
|
||||
|
||||
DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
|
||||
DEFINE_STR(UM_KERN_ALERT, KERN_ALERT);
|
||||
DEFINE_STR(UM_KERN_CRIT, KERN_CRIT);
|
||||
DEFINE_STR(UM_KERN_ERR, KERN_ERR);
|
||||
DEFINE_STR(UM_KERN_WARNING, KERN_WARNING);
|
||||
DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE);
|
||||
DEFINE_STR(UM_KERN_INFO, KERN_INFO);
|
||||
DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG);
|
||||
|
||||
DEFINE(UM_ELF_CLASS, ELF_CLASS);
|
||||
DEFINE(UM_ELFCLASS32, ELFCLASS32);
|
||||
DEFINE(UM_ELFCLASS64, ELFCLASS64);
|
||||
|
||||
/* For crypto assembler code. */
|
||||
DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
|
||||
19
arch/um/include/elf_user.h
Normal file
19
arch/um/include/elf_user.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2004 Fujitsu Siemens Computers GmbH
|
||||
* Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __ELF_USER_H__
|
||||
#define __ELF_USER_H__
|
||||
|
||||
/* For compilation on a host that doesn't support AT_SYSINFO (Linux 2.4) */
|
||||
|
||||
#ifndef AT_SYSINFO
|
||||
#define AT_SYSINFO 32
|
||||
#endif
|
||||
#ifndef AT_SYSINFO_EHDR
|
||||
#define AT_SYSINFO_EHDR 33
|
||||
#endif
|
||||
|
||||
#endif
|
||||
32
arch/um/include/frame_kern.h
Normal file
32
arch/um/include/frame_kern.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __FRAME_KERN_H_
|
||||
#define __FRAME_KERN_H_
|
||||
|
||||
#define _S(nr) (1<<((nr)-1))
|
||||
#define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP)))
|
||||
|
||||
extern int setup_signal_stack_sc(unsigned long stack_top, int sig,
|
||||
struct k_sigaction *ka,
|
||||
struct pt_regs *regs,
|
||||
sigset_t *mask);
|
||||
extern int setup_signal_stack_si(unsigned long stack_top, int sig,
|
||||
struct k_sigaction *ka,
|
||||
struct pt_regs *regs, siginfo_t *info,
|
||||
sigset_t *mask);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
140
arch/um/include/init.h
Normal file
140
arch/um/include/init.h
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef _LINUX_UML_INIT_H
|
||||
#define _LINUX_UML_INIT_H
|
||||
|
||||
/* These macros are used to mark some functions or
|
||||
* initialized data (doesn't apply to uninitialized data)
|
||||
* as `initialization' functions. The kernel can take this
|
||||
* as hint that the function is used only during the initialization
|
||||
* phase and free up used memory resources after
|
||||
*
|
||||
* Usage:
|
||||
* For functions:
|
||||
*
|
||||
* You should add __init immediately before the function name, like:
|
||||
*
|
||||
* static void __init initme(int x, int y)
|
||||
* {
|
||||
* extern int z; z = x * y;
|
||||
* }
|
||||
*
|
||||
* If the function has a prototype somewhere, you can also add
|
||||
* __init between closing brace of the prototype and semicolon:
|
||||
*
|
||||
* extern int initialize_foobar_device(int, int, int) __init;
|
||||
*
|
||||
* For initialized data:
|
||||
* You should insert __initdata between the variable name and equal
|
||||
* sign followed by value, e.g.:
|
||||
*
|
||||
* static int init_variable __initdata = 0;
|
||||
* static char linux_logo[] __initdata = { 0x32, 0x36, ... };
|
||||
*
|
||||
* Don't forget to initialize data not at file scope, i.e. within a function,
|
||||
* as gcc otherwise puts the data into the bss section and not into the init
|
||||
* section.
|
||||
*
|
||||
* Also note, that this data cannot be "const".
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_INIT_H
|
||||
typedef int (*initcall_t)(void);
|
||||
typedef void (*exitcall_t)(void);
|
||||
|
||||
/* These are for everybody (although not all archs will actually
|
||||
discard it in modules) */
|
||||
#define __init __attribute__ ((__section__ (".init.text")))
|
||||
#define __initdata __attribute__ ((__section__ (".init.data")))
|
||||
#define __exitdata __attribute__ ((__section__(".exit.data")))
|
||||
#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
|
||||
|
||||
#ifdef MODULE
|
||||
#define __exit __attribute__ ((__section__(".exit.text")))
|
||||
#else
|
||||
#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text")))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef MODULE
|
||||
struct uml_param {
|
||||
const char *str;
|
||||
int (*setup_func)(char *, int *);
|
||||
};
|
||||
|
||||
extern initcall_t __uml_initcall_start, __uml_initcall_end;
|
||||
extern initcall_t __uml_postsetup_start, __uml_postsetup_end;
|
||||
extern const char *__uml_help_start, *__uml_help_end;
|
||||
#endif
|
||||
|
||||
#define __uml_initcall(fn) \
|
||||
static initcall_t __uml_initcall_##fn __uml_init_call = fn
|
||||
|
||||
#define __uml_exitcall(fn) \
|
||||
static exitcall_t __uml_exitcall_##fn __uml_exit_call = fn
|
||||
|
||||
extern struct uml_param __uml_setup_start, __uml_setup_end;
|
||||
|
||||
#define __uml_postsetup(fn) \
|
||||
static initcall_t __uml_postsetup_##fn __uml_postsetup_call = fn
|
||||
|
||||
#define __non_empty_string(dummyname,string) \
|
||||
struct __uml_non_empty_string_struct_##dummyname \
|
||||
{ \
|
||||
char _string[sizeof(string)-2]; \
|
||||
}
|
||||
|
||||
#ifndef MODULE
|
||||
#define __uml_setup(str, fn, help...) \
|
||||
__non_empty_string(fn ##_setup, str); \
|
||||
__uml_help(fn, help); \
|
||||
static char __uml_setup_str_##fn[] __initdata = str; \
|
||||
static struct uml_param __uml_setup_##fn __uml_init_setup = { __uml_setup_str_##fn, fn }
|
||||
#else
|
||||
#define __uml_setup(str, fn, help...) \
|
||||
|
||||
#endif
|
||||
|
||||
#define __uml_help(fn, help...) \
|
||||
__non_empty_string(fn ##__help, help); \
|
||||
static char __uml_help_str_##fn[] __initdata = help; \
|
||||
static const char *__uml_help_##fn __uml_setup_help = __uml_help_str_##fn
|
||||
|
||||
/*
|
||||
* Mark functions and data as being only used at initialization
|
||||
* or exit time.
|
||||
*/
|
||||
#define __uml_init_setup __attribute_used__ __attribute__ ((__section__ (".uml.setup.init")))
|
||||
#define __uml_setup_help __attribute_used__ __attribute__ ((__section__ (".uml.help.init")))
|
||||
#define __uml_init_call __attribute_used__ __attribute__ ((__section__ (".uml.initcall.init")))
|
||||
#define __uml_postsetup_call __attribute_used__ __attribute__ ((__section__ (".uml.postsetup.init")))
|
||||
#define __uml_exit_call __attribute_used__ __attribute__ ((__section__ (".uml.exitcall.exit")))
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
#define __define_initcall(level,fn) \
|
||||
static initcall_t __initcall_##fn __attribute_used__ \
|
||||
__attribute__((__section__(".initcall" level ".init"))) = fn
|
||||
|
||||
/* Userspace initcalls shouldn't depend on anything in the kernel, so we'll
|
||||
* make them run first.
|
||||
*/
|
||||
#define __initcall(fn) __define_initcall("1", fn)
|
||||
|
||||
#define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn
|
||||
|
||||
#define __init_call __attribute_used__ __attribute__ ((__section__ (".initcall.init")))
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_UML_INIT_H */
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
22
arch/um/include/initrd.h
Normal file
22
arch/um/include/initrd.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __INITRD_USER_H__
|
||||
#define __INITRD_USER_H__
|
||||
|
||||
extern int load_initrd(char *filename, void *buf, int size);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
30
arch/um/include/irq_kern.h
Normal file
30
arch/um/include/irq_kern.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __IRQ_KERN_H__
|
||||
#define __IRQ_KERN_H__
|
||||
|
||||
#include "linux/interrupt.h"
|
||||
#include "asm/ptrace.h"
|
||||
|
||||
extern int um_request_irq(unsigned int irq, int fd, int type,
|
||||
irq_handler_t handler,
|
||||
unsigned long irqflags, const char * devname,
|
||||
void *dev_id);
|
||||
extern int init_aio_irq(int irq, char *name,
|
||||
irq_handler_t handler);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
37
arch/um/include/irq_user.h
Normal file
37
arch/um/include/irq_user.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __IRQ_USER_H__
|
||||
#define __IRQ_USER_H__
|
||||
|
||||
#include "uml-config.h"
|
||||
|
||||
struct irq_fd {
|
||||
struct irq_fd *next;
|
||||
void *id;
|
||||
int fd;
|
||||
int type;
|
||||
int irq;
|
||||
int pid;
|
||||
int events;
|
||||
int current_events;
|
||||
};
|
||||
|
||||
enum { IRQ_READ, IRQ_WRITE };
|
||||
|
||||
extern void sigio_handler(int sig, union uml_pt_regs *regs);
|
||||
extern int activate_fd(int irq, int fd, int type, void *dev_id);
|
||||
extern void free_irq_by_irq_and_dev(unsigned int irq, void *dev_id);
|
||||
extern void free_irq_by_fd(int fd);
|
||||
extern void reactivate_fd(int fd, int irqnum);
|
||||
extern void deactivate_fd(int fd, int irqnum);
|
||||
extern int deactivate_all_fds(void);
|
||||
extern int activate_ipi(int fd, int pid);
|
||||
|
||||
#ifdef CONFIG_MODE_TT
|
||||
extern void forward_interrupts(int pid);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
40
arch/um/include/kern.h
Normal file
40
arch/um/include/kern.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __KERN_H__
|
||||
#define __KERN_H__
|
||||
|
||||
/* These are all user-mode things which are convenient to call directly
|
||||
* from kernel code and for which writing a wrapper is too much of a pain.
|
||||
* The regular include files can't be included because this file is included
|
||||
* only into kernel code, and user-space includes conflict with kernel
|
||||
* includes.
|
||||
*/
|
||||
|
||||
extern int errno;
|
||||
|
||||
extern int clone(int (*proc)(void *), void *sp, int flags, void *data);
|
||||
extern int sleep(int);
|
||||
extern int printf(const char *fmt, ...);
|
||||
extern char *strerror(int errnum);
|
||||
extern char *ptsname(int __fd);
|
||||
extern int munmap(void *, int);
|
||||
extern void *sbrk(int increment);
|
||||
extern void *malloc(int size);
|
||||
extern void perror(char *err);
|
||||
extern int kill(int pid, int sig);
|
||||
extern int getuid(void);
|
||||
extern int getgid(void);
|
||||
extern int pause(void);
|
||||
extern int write(int, const void *, int);
|
||||
extern void exit(int);
|
||||
extern int close(int);
|
||||
extern int read(unsigned int, char *, int);
|
||||
extern int pipe(int *);
|
||||
extern int sched_yield(void);
|
||||
extern int ptrace(int op, int pid, long addr, long data);
|
||||
|
||||
#endif
|
||||
|
||||
121
arch/um/include/kern_util.h
Normal file
121
arch/um/include/kern_util.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __KERN_UTIL_H__
|
||||
#define __KERN_UTIL_H__
|
||||
|
||||
#include "sysdep/ptrace.h"
|
||||
#include "sysdep/faultinfo.h"
|
||||
|
||||
typedef void (*kern_hndl)(int, union uml_pt_regs *);
|
||||
|
||||
struct kern_handlers {
|
||||
kern_hndl relay_signal;
|
||||
kern_hndl winch;
|
||||
kern_hndl bus_handler;
|
||||
kern_hndl page_fault;
|
||||
kern_hndl sigio_handler;
|
||||
kern_hndl timer_handler;
|
||||
};
|
||||
|
||||
extern const struct kern_handlers handlinfo_kern;
|
||||
|
||||
extern int ncpus;
|
||||
extern char *linux_prog;
|
||||
extern char *gdb_init;
|
||||
extern int kmalloc_ok;
|
||||
extern int jail;
|
||||
extern int nsyscalls;
|
||||
|
||||
#define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK))
|
||||
#define UML_ROUND_UP(addr) \
|
||||
UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
|
||||
|
||||
extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
|
||||
extern unsigned long stack_sp(unsigned long page);
|
||||
extern int kernel_thread_proc(void *data);
|
||||
extern void syscall_segv(int sig);
|
||||
extern int current_pid(void);
|
||||
extern unsigned long alloc_stack(int order, int atomic);
|
||||
extern int do_signal(void);
|
||||
extern int is_stack_fault(unsigned long sp);
|
||||
extern unsigned long segv(struct faultinfo fi, unsigned long ip,
|
||||
int is_user, void *sc);
|
||||
extern int handle_page_fault(unsigned long address, unsigned long ip,
|
||||
int is_write, int is_user, int *code_out);
|
||||
extern void syscall_ready(void);
|
||||
extern void set_tracing(void *t, int tracing);
|
||||
extern int is_tracing(void *task);
|
||||
extern int segv_syscall(void);
|
||||
extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
|
||||
extern int page_size(void);
|
||||
extern unsigned long page_mask(void);
|
||||
extern int need_finish_fork(void);
|
||||
extern void free_stack(unsigned long stack, int order);
|
||||
extern void add_input_request(int op, void (*proc)(int), void *arg);
|
||||
extern char *current_cmd(void);
|
||||
extern void timer_handler(int sig, union uml_pt_regs *regs);
|
||||
extern int set_signals(int enable);
|
||||
extern void force_sigbus(void);
|
||||
extern int pid_to_processor_id(int pid);
|
||||
extern void deliver_signals(void *t);
|
||||
extern int next_trap_index(int max);
|
||||
extern void default_idle(void);
|
||||
extern void finish_fork(void);
|
||||
extern void paging_init(void);
|
||||
extern void init_flush_vm(void);
|
||||
extern void *syscall_sp(void *t);
|
||||
extern void syscall_trace(union uml_pt_regs *regs, int entryexit);
|
||||
extern int hz(void);
|
||||
extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
|
||||
extern int external_pid(void *t);
|
||||
extern void interrupt_end(void);
|
||||
extern void initial_thread_cb(void (*proc)(void *), void *arg);
|
||||
extern int debugger_signal(int status, int pid);
|
||||
extern void debugger_parent_signal(int status, int pid);
|
||||
extern void child_signal(int pid, int status);
|
||||
extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
|
||||
extern int init_parent_proxy(int pid);
|
||||
extern int singlestepping(void *t);
|
||||
extern void check_stack_overflow(void *ptr);
|
||||
extern void relay_signal(int sig, union uml_pt_regs *regs);
|
||||
extern void not_implemented(void);
|
||||
extern int user_context(unsigned long sp);
|
||||
extern void timer_irq(union uml_pt_regs *regs);
|
||||
extern void unprotect_stack(unsigned long stack);
|
||||
extern void do_uml_exitcalls(void);
|
||||
extern int attach_debugger(int idle_pid, int pid, int stop);
|
||||
extern int config_gdb(char *str);
|
||||
extern int remove_gdb(void);
|
||||
extern char *uml_strdup(char *string);
|
||||
extern void unprotect_kernel_mem(void);
|
||||
extern void protect_kernel_mem(void);
|
||||
extern void uml_cleanup(void);
|
||||
extern void set_current(void *t);
|
||||
extern void lock_signalled_task(void *t);
|
||||
extern void IPI_handler(int cpu);
|
||||
extern int jail_setup(char *line, int *add);
|
||||
extern void *get_init_task(void);
|
||||
extern int clear_user_proc(void *buf, int size);
|
||||
extern int copy_to_user_proc(void *to, void *from, int size);
|
||||
extern int copy_from_user_proc(void *to, void *from, int size);
|
||||
extern int strlen_user_proc(char *str);
|
||||
extern long execute_syscall(void *r);
|
||||
extern int smp_sigio_handler(void);
|
||||
extern void *get_current(void);
|
||||
extern struct task_struct *get_task(int pid, int require);
|
||||
extern void machine_halt(void);
|
||||
extern int is_syscall(unsigned long addr);
|
||||
|
||||
extern void free_irq(unsigned int, void *);
|
||||
extern int cpu(void);
|
||||
|
||||
extern void time_init_kern(void);
|
||||
|
||||
/* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
|
||||
extern int __cant_sleep(void);
|
||||
extern void sigio_handler(int sig, union uml_pt_regs *regs);
|
||||
|
||||
#endif
|
||||
105
arch/um/include/line.h
Normal file
105
arch/um/include/line.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __LINE_H__
|
||||
#define __LINE_H__
|
||||
|
||||
#include "linux/list.h"
|
||||
#include "linux/workqueue.h"
|
||||
#include "linux/tty.h"
|
||||
#include "linux/interrupt.h"
|
||||
#include "linux/spinlock.h"
|
||||
#include "linux/mutex.h"
|
||||
#include "chan_user.h"
|
||||
#include "mconsole_kern.h"
|
||||
|
||||
/* There's only one modifiable field in this - .mc.list */
|
||||
struct line_driver {
|
||||
const char *name;
|
||||
const char *device_name;
|
||||
const short major;
|
||||
const short minor_start;
|
||||
const short type;
|
||||
const short subtype;
|
||||
const int read_irq;
|
||||
const char *read_irq_name;
|
||||
const int write_irq;
|
||||
const char *write_irq_name;
|
||||
struct mc_device mc;
|
||||
};
|
||||
|
||||
struct line {
|
||||
struct tty_struct *tty;
|
||||
spinlock_t count_lock;
|
||||
int valid;
|
||||
|
||||
char *init_str;
|
||||
int init_pri;
|
||||
struct list_head chan_list;
|
||||
|
||||
/*This lock is actually, mostly, local to*/
|
||||
spinlock_t lock;
|
||||
int throttled;
|
||||
/* Yes, this is a real circular buffer.
|
||||
* XXX: And this should become a struct kfifo!
|
||||
*
|
||||
* buffer points to a buffer allocated on demand, of length
|
||||
* LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
|
||||
char *buffer;
|
||||
char *head;
|
||||
char *tail;
|
||||
|
||||
int sigio;
|
||||
struct delayed_work task;
|
||||
const struct line_driver *driver;
|
||||
int have_irq;
|
||||
};
|
||||
|
||||
#define LINE_INIT(str, d) \
|
||||
{ .count_lock = SPIN_LOCK_UNLOCKED, \
|
||||
.init_str = str, \
|
||||
.init_pri = INIT_STATIC, \
|
||||
.valid = 1, \
|
||||
.lock = SPIN_LOCK_UNLOCKED, \
|
||||
.driver = d }
|
||||
|
||||
extern void line_close(struct tty_struct *tty, struct file * filp);
|
||||
extern int line_open(struct line *lines, struct tty_struct *tty);
|
||||
extern int line_setup(struct line *lines, unsigned int sizeof_lines,
|
||||
char *init, char **error_out);
|
||||
extern int line_write(struct tty_struct *tty, const unsigned char *buf,
|
||||
int len);
|
||||
extern void line_put_char(struct tty_struct *tty, unsigned char ch);
|
||||
extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
|
||||
extern int line_chars_in_buffer(struct tty_struct *tty);
|
||||
extern void line_flush_buffer(struct tty_struct *tty);
|
||||
extern void line_flush_chars(struct tty_struct *tty);
|
||||
extern int line_write_room(struct tty_struct *tty);
|
||||
extern int line_ioctl(struct tty_struct *tty, struct file * file,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
extern void line_throttle(struct tty_struct *tty);
|
||||
extern void line_unthrottle(struct tty_struct *tty);
|
||||
|
||||
extern char *add_xterm_umid(char *base);
|
||||
extern int line_setup_irq(int fd, int input, int output, struct line *line,
|
||||
void *data);
|
||||
extern void line_close_chan(struct line *line);
|
||||
extern struct tty_driver *register_lines(struct line_driver *line_driver,
|
||||
const struct tty_operations *driver,
|
||||
struct line *lines, int nlines);
|
||||
extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
|
||||
extern void close_lines(struct line *lines, int nlines);
|
||||
|
||||
extern int line_config(struct line *lines, unsigned int sizeof_lines,
|
||||
char *str, const struct chan_opts *opts,
|
||||
char **error_out);
|
||||
extern int line_id(char **str, int *start_out, int *end_out);
|
||||
extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
|
||||
char **error_out);
|
||||
extern int line_get_config(char *dev, struct line *lines,
|
||||
unsigned int sizeof_lines, char *str,
|
||||
int size, char **error_out);
|
||||
|
||||
#endif
|
||||
23
arch/um/include/longjmp.h
Normal file
23
arch/um/include/longjmp.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef __UML_LONGJMP_H
|
||||
#define __UML_LONGJMP_H
|
||||
|
||||
#include "sysdep/archsetjmp.h"
|
||||
#include "os.h"
|
||||
|
||||
extern int setjmp(jmp_buf);
|
||||
extern void longjmp(jmp_buf, int);
|
||||
|
||||
#define UML_LONGJMP(buf, val) do { \
|
||||
longjmp(*buf, val); \
|
||||
} while(0)
|
||||
|
||||
#define UML_SETJMP(buf) ({ \
|
||||
int n; \
|
||||
volatile int enable; \
|
||||
enable = get_signals(); \
|
||||
n = setjmp(*buf); \
|
||||
if(n != 0) \
|
||||
set_signals(enable); \
|
||||
n; })
|
||||
|
||||
#endif
|
||||
109
arch/um/include/mconsole.h
Normal file
109
arch/um/include/mconsole.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
|
||||
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MCONSOLE_H__
|
||||
#define __MCONSOLE_H__
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <stdint.h>
|
||||
#define u32 uint32_t
|
||||
#endif
|
||||
|
||||
#include "sysdep/ptrace.h"
|
||||
|
||||
#define MCONSOLE_MAGIC (0xcafebabe)
|
||||
#define MCONSOLE_MAX_DATA (512)
|
||||
#define MCONSOLE_VERSION 2
|
||||
|
||||
struct mconsole_request {
|
||||
u32 magic;
|
||||
u32 version;
|
||||
u32 len;
|
||||
char data[MCONSOLE_MAX_DATA];
|
||||
};
|
||||
|
||||
struct mconsole_reply {
|
||||
u32 err;
|
||||
u32 more;
|
||||
u32 len;
|
||||
char data[MCONSOLE_MAX_DATA];
|
||||
};
|
||||
|
||||
struct mconsole_notify {
|
||||
u32 magic;
|
||||
u32 version;
|
||||
enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG,
|
||||
MCONSOLE_USER_NOTIFY } type;
|
||||
u32 len;
|
||||
char data[MCONSOLE_MAX_DATA];
|
||||
};
|
||||
|
||||
struct mc_request;
|
||||
|
||||
enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC };
|
||||
|
||||
struct mconsole_command
|
||||
{
|
||||
char *command;
|
||||
void (*handler)(struct mc_request *req);
|
||||
enum mc_context context;
|
||||
};
|
||||
|
||||
struct mc_request
|
||||
{
|
||||
int len;
|
||||
int as_interrupt;
|
||||
|
||||
int originating_fd;
|
||||
unsigned int originlen;
|
||||
unsigned char origin[128]; /* sockaddr_un */
|
||||
|
||||
struct mconsole_request request;
|
||||
struct mconsole_command *cmd;
|
||||
union uml_pt_regs regs;
|
||||
};
|
||||
|
||||
extern char mconsole_socket_name[];
|
||||
|
||||
extern int mconsole_unlink_socket(void);
|
||||
extern int mconsole_reply_len(struct mc_request *req, const char *reply,
|
||||
int len, int err, int more);
|
||||
extern int mconsole_reply(struct mc_request *req, const char *str, int err,
|
||||
int more);
|
||||
|
||||
extern void mconsole_version(struct mc_request *req);
|
||||
extern void mconsole_help(struct mc_request *req);
|
||||
extern void mconsole_halt(struct mc_request *req);
|
||||
extern void mconsole_reboot(struct mc_request *req);
|
||||
extern void mconsole_config(struct mc_request *req);
|
||||
extern void mconsole_remove(struct mc_request *req);
|
||||
extern void mconsole_sysrq(struct mc_request *req);
|
||||
extern void mconsole_cad(struct mc_request *req);
|
||||
extern void mconsole_stop(struct mc_request *req);
|
||||
extern void mconsole_go(struct mc_request *req);
|
||||
extern void mconsole_log(struct mc_request *req);
|
||||
extern void mconsole_proc(struct mc_request *req);
|
||||
extern void mconsole_stack(struct mc_request *req);
|
||||
|
||||
extern int mconsole_get_request(int fd, struct mc_request *req);
|
||||
extern int mconsole_notify(char *sock_name, int type, const void *data,
|
||||
int len);
|
||||
extern char *mconsole_notify_socket(void);
|
||||
extern void lock_notify(void);
|
||||
extern void unlock_notify(void);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
52
arch/um/include/mconsole_kern.h
Normal file
52
arch/um/include/mconsole_kern.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MCONSOLE_KERN_H__
|
||||
#define __MCONSOLE_KERN_H__
|
||||
|
||||
#include "linux/list.h"
|
||||
#include "mconsole.h"
|
||||
|
||||
struct mconsole_entry {
|
||||
struct list_head list;
|
||||
struct mc_request request;
|
||||
};
|
||||
|
||||
/* All these methods are called in process context. */
|
||||
struct mc_device {
|
||||
struct list_head list;
|
||||
char *name;
|
||||
int (*config)(char *, char **);
|
||||
int (*get_config)(char *, char *, int, char **);
|
||||
int (*id)(char **, int *, int *);
|
||||
int (*remove)(int, char **);
|
||||
};
|
||||
|
||||
#define CONFIG_CHUNK(str, size, current, chunk, end) \
|
||||
do { \
|
||||
current += strlen(chunk); \
|
||||
if(current >= size) \
|
||||
str = NULL; \
|
||||
if(str != NULL){ \
|
||||
strcpy(str, chunk); \
|
||||
str += strlen(chunk); \
|
||||
} \
|
||||
if(end) \
|
||||
current++; \
|
||||
} while(0)
|
||||
|
||||
#ifdef CONFIG_MCONSOLE
|
||||
|
||||
extern void mconsole_register_dev(struct mc_device *new);
|
||||
|
||||
#else
|
||||
|
||||
static inline void mconsole_register_dev(struct mc_device *new)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
39
arch/um/include/mem.h
Normal file
39
arch/um/include/mem.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2002, 2003 Jeff Dike (jdike@addtoit.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MEM_H__
|
||||
#define __MEM_H__
|
||||
|
||||
#include "linux/types.h"
|
||||
|
||||
extern int phys_mapping(unsigned long phys, __u64 *offset_out);
|
||||
extern int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w);
|
||||
extern int is_remapped(void *virt);
|
||||
extern int physmem_remove_mapping(void *virt);
|
||||
extern void physmem_forget_descriptor(int fd);
|
||||
|
||||
extern unsigned long uml_physmem;
|
||||
static inline unsigned long to_phys(void *virt)
|
||||
{
|
||||
return(((unsigned long) virt) - uml_physmem);
|
||||
}
|
||||
|
||||
static inline void *to_virt(unsigned long phys)
|
||||
{
|
||||
return((void *) uml_physmem + phys);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
30
arch/um/include/mem_kern.h
Normal file
30
arch/um/include/mem_kern.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2003 Jeff Dike (jdike@addtoit.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MEM_KERN_H__
|
||||
#define __MEM_KERN_H__
|
||||
|
||||
#include "linux/list.h"
|
||||
#include "linux/types.h"
|
||||
|
||||
struct remapper {
|
||||
struct list_head list;
|
||||
int (*proc)(int, unsigned long, int, __u64);
|
||||
};
|
||||
|
||||
extern void register_remapper(struct remapper *info);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
67
arch/um/include/mem_user.h
Normal file
67
arch/um/include/mem_user.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* arch/um/include/mem_user.h
|
||||
*
|
||||
* BRIEF MODULE DESCRIPTION
|
||||
* user side memory interface for support IO memory inside user mode linux
|
||||
*
|
||||
* Copyright (C) 2001 RidgeRun, Inc.
|
||||
* Author: RidgeRun, Inc.
|
||||
* Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MEM_USER_H
|
||||
#define _MEM_USER_H
|
||||
|
||||
struct iomem_region {
|
||||
struct iomem_region *next;
|
||||
char *driver;
|
||||
int fd;
|
||||
int size;
|
||||
unsigned long phys;
|
||||
unsigned long virt;
|
||||
};
|
||||
|
||||
extern struct iomem_region *iomem_regions;
|
||||
extern int iomem_size;
|
||||
|
||||
#define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1))
|
||||
|
||||
extern unsigned long host_task_size;
|
||||
extern unsigned long task_size;
|
||||
|
||||
extern int init_mem_user(void);
|
||||
extern void setup_memory(void *entry);
|
||||
extern unsigned long find_iomem(char *driver, unsigned long *len_out);
|
||||
extern int init_maps(unsigned long physmem, unsigned long iomem,
|
||||
unsigned long highmem);
|
||||
extern unsigned long get_vm(unsigned long len);
|
||||
extern void setup_physmem(unsigned long start, unsigned long usable,
|
||||
unsigned long len, unsigned long long highmem);
|
||||
extern void add_iomem(char *name, int fd, unsigned long size);
|
||||
extern unsigned long phys_offset(unsigned long phys);
|
||||
extern void unmap_physmem(void);
|
||||
extern void map_memory(unsigned long virt, unsigned long phys,
|
||||
unsigned long len, int r, int w, int x);
|
||||
extern unsigned long get_kmem_end(void);
|
||||
|
||||
#endif
|
||||
6
arch/um/include/misc_constants.h
Normal file
6
arch/um/include/misc_constants.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef __MISC_CONSTANT_H_
|
||||
#define __MISC_CONSTANT_H_
|
||||
|
||||
#include <user_constants.h>
|
||||
|
||||
#endif
|
||||
30
arch/um/include/mode.h
Normal file
30
arch/um/include/mode.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MODE_H__
|
||||
#define __MODE_H__
|
||||
|
||||
#include "uml-config.h"
|
||||
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
#include "mode-tt.h"
|
||||
#endif
|
||||
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
#include "mode-skas.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
17
arch/um/include/mode_kern.h
Normal file
17
arch/um/include/mode_kern.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MODE_KERN_H__
|
||||
#define __MODE_KERN_H__
|
||||
|
||||
#ifdef CONFIG_MODE_TT
|
||||
#include "mode_kern_tt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODE_SKAS
|
||||
#include "mode_kern_skas.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
71
arch/um/include/net_kern.h
Normal file
71
arch/um/include/net_kern.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UM_NET_KERN_H
|
||||
#define __UM_NET_KERN_H
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/socket.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
struct uml_net {
|
||||
struct list_head list;
|
||||
struct net_device *dev;
|
||||
struct platform_device pdev;
|
||||
int index;
|
||||
unsigned char mac[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct uml_net_private {
|
||||
struct list_head list;
|
||||
spinlock_t lock;
|
||||
struct net_device *dev;
|
||||
struct timer_list tl;
|
||||
struct net_device_stats stats;
|
||||
struct work_struct work;
|
||||
int fd;
|
||||
unsigned char mac[ETH_ALEN];
|
||||
unsigned short (*protocol)(struct sk_buff *);
|
||||
int (*open)(void *);
|
||||
void (*close)(int, void *);
|
||||
void (*remove)(void *);
|
||||
int (*read)(int, struct sk_buff **skb, struct uml_net_private *);
|
||||
int (*write)(int, struct sk_buff **skb, struct uml_net_private *);
|
||||
|
||||
void (*add_address)(unsigned char *, unsigned char *, void *);
|
||||
void (*delete_address)(unsigned char *, unsigned char *, void *);
|
||||
int (*set_mtu)(int mtu, void *);
|
||||
int user[1];
|
||||
};
|
||||
|
||||
struct net_kern_info {
|
||||
void (*init)(struct net_device *, void *);
|
||||
unsigned short (*protocol)(struct sk_buff *);
|
||||
int (*read)(int, struct sk_buff **skb, struct uml_net_private *);
|
||||
int (*write)(int, struct sk_buff **skb, struct uml_net_private *);
|
||||
};
|
||||
|
||||
struct transport {
|
||||
struct list_head list;
|
||||
const char *name;
|
||||
int (* const setup)(char *, char **, void *);
|
||||
const struct net_user_info *user;
|
||||
const struct net_kern_info *kern;
|
||||
const int private_size;
|
||||
const int setup_size;
|
||||
};
|
||||
|
||||
extern struct net_device *ether_init(int);
|
||||
extern unsigned short ether_protocol(struct sk_buff *);
|
||||
extern struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra);
|
||||
extern int tap_setup_common(char *str, char *type, char **dev_name,
|
||||
char **mac_out, char **gate_addr);
|
||||
extern void register_transport(struct transport *new);
|
||||
extern unsigned short eth_protocol(struct sk_buff *skb);
|
||||
|
||||
#endif
|
||||
53
arch/um/include/net_user.h
Normal file
53
arch/um/include/net_user.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UM_NET_USER_H__
|
||||
#define __UM_NET_USER_H__
|
||||
|
||||
#define ETH_ADDR_LEN (6)
|
||||
#define ETH_HEADER_ETHERTAP (16)
|
||||
#define ETH_HEADER_OTHER (14)
|
||||
#define ETH_MAX_PACKET (1500)
|
||||
|
||||
#define UML_NET_VERSION (4)
|
||||
|
||||
struct net_user_info {
|
||||
void (*init)(void *, void *);
|
||||
int (*open)(void *);
|
||||
void (*close)(int, void *);
|
||||
void (*remove)(void *);
|
||||
int (*set_mtu)(int mtu, void *);
|
||||
void (*add_address)(unsigned char *, unsigned char *, void *);
|
||||
void (*delete_address)(unsigned char *, unsigned char *, void *);
|
||||
int max_packet;
|
||||
};
|
||||
|
||||
extern void ether_user_init(void *data, void *dev);
|
||||
extern void iter_addresses(void *d, void (*cb)(unsigned char *,
|
||||
unsigned char *, void *),
|
||||
void *arg);
|
||||
|
||||
extern void *get_output_buffer(int *len_out);
|
||||
extern void free_output_buffer(void *buffer);
|
||||
|
||||
extern int tap_open_common(void *dev, char *gate_addr);
|
||||
extern void tap_check_ips(char *gate_addr, unsigned char *eth_addr);
|
||||
|
||||
extern void read_output(int fd, char *output_out, int len);
|
||||
|
||||
extern int net_read(int fd, void *buf, int len);
|
||||
extern int net_recvfrom(int fd, void *buf, int len);
|
||||
extern int net_write(int fd, void *buf, int len);
|
||||
extern int net_send(int fd, void *buf, int len);
|
||||
extern int net_sendto(int fd, void *buf, int len, void *to, int sock_len);
|
||||
|
||||
extern void open_addr(unsigned char *addr, unsigned char *netmask, void *arg);
|
||||
extern void close_addr(unsigned char *addr, unsigned char *netmask, void *arg);
|
||||
|
||||
extern char *split_if_spec(char *str, ...);
|
||||
|
||||
extern int dev_netmask(void *d, void *m);
|
||||
|
||||
#endif
|
||||
346
arch/um/include/os.h
Normal file
346
arch/um/include/os.h
Normal file
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __OS_H__
|
||||
#define __OS_H__
|
||||
|
||||
#include "uml-config.h"
|
||||
#include "asm/types.h"
|
||||
#include "../os/include/file.h"
|
||||
#include "sysdep/ptrace.h"
|
||||
#include "kern_util.h"
|
||||
#include "skas/mm_id.h"
|
||||
#include "irq_user.h"
|
||||
#include "sysdep/tls.h"
|
||||
#include "sysdep/archsetjmp.h"
|
||||
|
||||
#define OS_TYPE_FILE 1
|
||||
#define OS_TYPE_DIR 2
|
||||
#define OS_TYPE_SYMLINK 3
|
||||
#define OS_TYPE_CHARDEV 4
|
||||
#define OS_TYPE_BLOCKDEV 5
|
||||
#define OS_TYPE_FIFO 6
|
||||
#define OS_TYPE_SOCK 7
|
||||
|
||||
/* os_access() flags */
|
||||
#define OS_ACC_F_OK 0 /* Test for existence. */
|
||||
#define OS_ACC_X_OK 1 /* Test for execute permission. */
|
||||
#define OS_ACC_W_OK 2 /* Test for write permission. */
|
||||
#define OS_ACC_R_OK 4 /* Test for read permission. */
|
||||
#define OS_ACC_RW_OK (OS_ACC_W_OK | OS_ACC_R_OK) /* Test for RW permission */
|
||||
|
||||
/*
|
||||
* types taken from stat_file() in hostfs_user.c
|
||||
* (if they are wrong here, they are wrong there...).
|
||||
*/
|
||||
struct uml_stat {
|
||||
int ust_dev; /* device */
|
||||
unsigned long long ust_ino; /* inode */
|
||||
int ust_mode; /* protection */
|
||||
int ust_nlink; /* number of hard links */
|
||||
int ust_uid; /* user ID of owner */
|
||||
int ust_gid; /* group ID of owner */
|
||||
unsigned long long ust_size; /* total size, in bytes */
|
||||
int ust_blksize; /* blocksize for filesystem I/O */
|
||||
unsigned long long ust_blocks; /* number of blocks allocated */
|
||||
unsigned long ust_atime; /* time of last access */
|
||||
unsigned long ust_mtime; /* time of last modification */
|
||||
unsigned long ust_ctime; /* time of last change */
|
||||
};
|
||||
|
||||
struct openflags {
|
||||
unsigned int r : 1;
|
||||
unsigned int w : 1;
|
||||
unsigned int s : 1; /* O_SYNC */
|
||||
unsigned int c : 1; /* O_CREAT */
|
||||
unsigned int t : 1; /* O_TRUNC */
|
||||
unsigned int a : 1; /* O_APPEND */
|
||||
unsigned int e : 1; /* O_EXCL */
|
||||
unsigned int cl : 1; /* FD_CLOEXEC */
|
||||
};
|
||||
|
||||
#define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \
|
||||
.t = 0, .a = 0, .e = 0, .cl = 0 })
|
||||
|
||||
static inline struct openflags of_read(struct openflags flags)
|
||||
{
|
||||
flags.r = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_write(struct openflags flags)
|
||||
{
|
||||
flags.w = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_rdwr(struct openflags flags)
|
||||
{
|
||||
return of_read(of_write(flags));
|
||||
}
|
||||
|
||||
static inline struct openflags of_set_rw(struct openflags flags, int r, int w)
|
||||
{
|
||||
flags.r = r;
|
||||
flags.w = w;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_sync(struct openflags flags)
|
||||
{
|
||||
flags.s = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_create(struct openflags flags)
|
||||
{
|
||||
flags.c = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_trunc(struct openflags flags)
|
||||
{
|
||||
flags.t = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_append(struct openflags flags)
|
||||
{
|
||||
flags.a = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_excl(struct openflags flags)
|
||||
{
|
||||
flags.e = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline struct openflags of_cloexec(struct openflags flags)
|
||||
{
|
||||
flags.cl = 1;
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* file.c */
|
||||
extern int os_stat_file(const char *file_name, struct uml_stat *buf);
|
||||
extern int os_stat_fd(const int fd, struct uml_stat *buf);
|
||||
extern int os_access(const char *file, int mode);
|
||||
extern void os_print_error(int error, const char* str);
|
||||
extern int os_get_exec_close(int fd, int *close_on_exec);
|
||||
extern int os_set_exec_close(int fd, int close_on_exec);
|
||||
extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
|
||||
extern int os_window_size(int fd, int *rows, int *cols);
|
||||
extern int os_new_tty_pgrp(int fd, int pid);
|
||||
extern int os_get_ifname(int fd, char *namebuf);
|
||||
extern int os_set_slip(int fd);
|
||||
extern int os_set_owner(int fd, int pid);
|
||||
extern int os_mode_fd(int fd, int mode);
|
||||
|
||||
extern int os_seek_file(int fd, __u64 offset);
|
||||
extern int os_open_file(char *file, struct openflags flags, int mode);
|
||||
extern int os_read_file(int fd, void *buf, int len);
|
||||
extern int os_write_file(int fd, const void *buf, int count);
|
||||
extern int os_file_size(char *file, unsigned long long *size_out);
|
||||
extern int os_file_modtime(char *file, unsigned long *modtime);
|
||||
extern int os_pipe(int *fd, int stream, int close_on_exec);
|
||||
extern int os_set_fd_async(int fd, int owner);
|
||||
extern int os_clear_fd_async(int fd);
|
||||
extern int os_set_fd_block(int fd, int blocking);
|
||||
extern int os_accept_connection(int fd);
|
||||
extern int os_create_unix_socket(char *file, int len, int close_on_exec);
|
||||
extern int os_shutdown_socket(int fd, int r, int w);
|
||||
extern void os_close_file(int fd);
|
||||
extern int os_rcv_fd(int fd, int *helper_pid_out);
|
||||
extern int create_unix_socket(char *file, int len, int close_on_exec);
|
||||
extern int os_connect_socket(char *name);
|
||||
extern int os_file_type(char *file);
|
||||
extern int os_file_mode(char *file, struct openflags *mode_out);
|
||||
extern int os_lock_file(int fd, int excl);
|
||||
extern void os_flush_stdout(void);
|
||||
extern int os_stat_filesystem(char *path, long *bsize_out,
|
||||
long long *blocks_out, long long *bfree_out,
|
||||
long long *bavail_out, long long *files_out,
|
||||
long long *ffree_out, void *fsid_out,
|
||||
int fsid_size, long *namelen_out,
|
||||
long *spare_out);
|
||||
extern int os_change_dir(char *dir);
|
||||
extern int os_fchange_dir(int fd);
|
||||
|
||||
/* start_up.c */
|
||||
extern void os_early_checks(void);
|
||||
extern int can_do_skas(void);
|
||||
extern void os_check_bugs(void);
|
||||
extern void check_host_supports_tls(int *supports_tls, int *tls_min);
|
||||
|
||||
/* Make sure they are clear when running in TT mode. Required by
|
||||
* SEGV_MAYBE_FIXABLE */
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
#define clear_can_do_skas() do { ptrace_faultinfo = proc_mm = 0; } while (0)
|
||||
#else
|
||||
#define clear_can_do_skas() do {} while (0)
|
||||
#endif
|
||||
|
||||
/* mem.c */
|
||||
extern int create_mem_file(unsigned long long len);
|
||||
|
||||
/* process.c */
|
||||
extern unsigned long os_process_pc(int pid);
|
||||
extern int os_process_parent(int pid);
|
||||
extern void os_stop_process(int pid);
|
||||
extern void os_kill_process(int pid, int reap_child);
|
||||
extern void os_kill_ptraced_process(int pid, int reap_child);
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
extern void os_usr1_process(int pid);
|
||||
#endif
|
||||
extern long os_ptrace_ldt(long pid, long addr, long data);
|
||||
|
||||
extern int os_getpid(void);
|
||||
extern int os_getpgrp(void);
|
||||
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
|
||||
extern void stop(void);
|
||||
#endif
|
||||
extern void init_new_thread_signals(void);
|
||||
extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
|
||||
|
||||
extern int os_map_memory(void *virt, int fd, unsigned long long off,
|
||||
unsigned long len, int r, int w, int x);
|
||||
extern int os_protect_memory(void *addr, unsigned long len,
|
||||
int r, int w, int x);
|
||||
extern int os_unmap_memory(void *addr, int len);
|
||||
extern int os_drop_memory(void *addr, int length);
|
||||
extern int can_drop_memory(void);
|
||||
extern void os_flush_stdout(void);
|
||||
|
||||
/* tt.c
|
||||
* for tt mode only (will be deleted in future...)
|
||||
*/
|
||||
extern void forward_ipi(int fd, int pid);
|
||||
extern void kill_child_dead(int pid);
|
||||
extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
|
||||
extern int protect_memory(unsigned long addr, unsigned long len,
|
||||
int r, int w, int x, int must_succeed);
|
||||
extern void forward_pending_sigio(int target);
|
||||
extern int start_fork_tramp(void *arg, unsigned long temp_stack,
|
||||
int clone_flags, int (*tramp)(void *));
|
||||
|
||||
/* uaccess.c */
|
||||
extern unsigned long __do_user_copy(void *to, const void *from, int n,
|
||||
void **fault_addr, void **fault_catcher,
|
||||
void (*op)(void *to, const void *from,
|
||||
int n), int *faulted_out);
|
||||
|
||||
/* execvp.c */
|
||||
extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
|
||||
/* helper.c */
|
||||
extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
|
||||
unsigned long *stack_out);
|
||||
extern int run_helper_thread(int (*proc)(void *), void *arg,
|
||||
unsigned int flags, unsigned long *stack_out,
|
||||
int stack_order);
|
||||
extern int helper_wait(int pid);
|
||||
|
||||
|
||||
/* tls.c */
|
||||
extern int os_set_thread_area(user_desc_t *info, int pid);
|
||||
extern int os_get_thread_area(user_desc_t *info, int pid);
|
||||
|
||||
/* umid.c */
|
||||
extern int umid_file_name(char *name, char *buf, int len);
|
||||
extern int set_umid(char *name);
|
||||
extern char *get_umid(void);
|
||||
|
||||
/* signal.c */
|
||||
extern void set_sigstack(void *sig_stack, int size);
|
||||
extern void remove_sigstack(void);
|
||||
extern void set_handler(int sig, void (*handler)(int), int flags, ...);
|
||||
extern int change_sig(int signal, int on);
|
||||
extern void block_signals(void);
|
||||
extern void unblock_signals(void);
|
||||
extern int get_signals(void);
|
||||
extern int set_signals(int enable);
|
||||
|
||||
/* trap.c */
|
||||
extern void os_fill_handlinfo(struct kern_handlers h);
|
||||
extern void do_longjmp(void *p, int val);
|
||||
|
||||
/* util.c */
|
||||
extern void stack_protections(unsigned long address);
|
||||
extern void task_protections(unsigned long address);
|
||||
extern int raw(int fd);
|
||||
extern void setup_machinename(char *machine_out);
|
||||
extern void setup_hostinfo(void);
|
||||
extern int setjmp_wrapper(void (*proc)(void *, void *), ...);
|
||||
|
||||
/* time.c */
|
||||
#define BILLION (1000 * 1000 * 1000)
|
||||
|
||||
extern void switch_timers(int to_real);
|
||||
extern void idle_sleep(int secs);
|
||||
extern int set_interval(int is_virtual);
|
||||
#ifdef CONFIG_MODE_TT
|
||||
extern void enable_timer(void);
|
||||
#endif
|
||||
extern void disable_timer(void);
|
||||
extern void uml_idle_timer(void);
|
||||
extern unsigned long long os_nsecs(void);
|
||||
|
||||
/* skas/mem.c */
|
||||
extern long run_syscall_stub(struct mm_id * mm_idp,
|
||||
int syscall, unsigned long *args, long expected,
|
||||
void **addr, int done);
|
||||
extern long syscall_stub_data(struct mm_id * mm_idp,
|
||||
unsigned long *data, int data_count,
|
||||
void **addr, void **stub_addr);
|
||||
extern int map(struct mm_id * mm_idp, unsigned long virt,
|
||||
unsigned long len, int r, int w, int x, int phys_fd,
|
||||
unsigned long long offset, int done, void **data);
|
||||
extern int unmap(struct mm_id * mm_idp, void *addr, unsigned long len,
|
||||
int done, void **data);
|
||||
extern int protect(struct mm_id * mm_idp, unsigned long addr,
|
||||
unsigned long len, int r, int w, int x, int done,
|
||||
void **data);
|
||||
|
||||
/* skas/process.c */
|
||||
extern int is_skas_winch(int pid, int fd, void *data);
|
||||
extern int start_userspace(unsigned long stub_stack);
|
||||
extern int copy_context_skas0(unsigned long stack, int pid);
|
||||
extern void userspace(union uml_pt_regs *regs);
|
||||
extern void map_stub_pages(int fd, unsigned long code,
|
||||
unsigned long data, unsigned long stack);
|
||||
extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void));
|
||||
extern void switch_threads(jmp_buf *me, jmp_buf *you);
|
||||
extern int start_idle_thread(void *stack, jmp_buf *switch_buf);
|
||||
extern void initial_thread_cb_skas(void (*proc)(void *),
|
||||
void *arg);
|
||||
extern void halt_skas(void);
|
||||
extern void reboot_skas(void);
|
||||
|
||||
/* irq.c */
|
||||
extern int os_waiting_for_events(struct irq_fd *active_fds);
|
||||
extern int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds);
|
||||
extern void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
||||
struct irq_fd *active_fds, struct irq_fd ***last_irq_ptr2);
|
||||
extern void os_free_irq_later(struct irq_fd *active_fds,
|
||||
int irq, void *dev_id);
|
||||
extern int os_get_pollfd(int i);
|
||||
extern void os_set_pollfd(int i, int fd);
|
||||
extern void os_set_ioignore(void);
|
||||
extern void init_irq_signals(int on_sigstack);
|
||||
|
||||
/* sigio.c */
|
||||
extern int add_sigio_fd(int fd);
|
||||
extern int ignore_sigio_fd(int fd);
|
||||
extern void maybe_sigio_broken(int fd, int read);
|
||||
|
||||
/* skas/trap */
|
||||
extern void sig_handler_common_skas(int sig, void *sc_ptr);
|
||||
extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
|
||||
|
||||
extern int os_arch_prctl(int pid, int code, unsigned long *addr);
|
||||
|
||||
#endif
|
||||
25
arch/um/include/process.h
Normal file
25
arch/um/include/process.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __PROCESS_H__
|
||||
#define __PROCESS_H__
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
extern void sig_handler(int sig, struct sigcontext sc);
|
||||
extern void alarm_handler(int sig, struct sigcontext sc);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
60
arch/um/include/ptrace_user.h
Normal file
60
arch/um/include/ptrace_user.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __PTRACE_USER_H__
|
||||
#define __PTRACE_USER_H__
|
||||
|
||||
#include "sysdep/ptrace_user.h"
|
||||
|
||||
extern int ptrace_getregs(long pid, unsigned long *regs_out);
|
||||
extern int ptrace_setregs(long pid, unsigned long *regs_in);
|
||||
extern int ptrace_getfpregs(long pid, unsigned long *regs_out);
|
||||
extern int ptrace_setfpregs(long pid, unsigned long *regs);
|
||||
extern void arch_enter_kernel(void *task, int pid);
|
||||
extern void arch_leave_kernel(void *task, int pid);
|
||||
extern void ptrace_pokeuser(unsigned long addr, unsigned long data);
|
||||
|
||||
|
||||
/* syscall emulation path in ptrace */
|
||||
|
||||
#ifndef PTRACE_SYSEMU
|
||||
#define PTRACE_SYSEMU 31
|
||||
#endif
|
||||
#ifndef PTRACE_SYSEMU_SINGLESTEP
|
||||
#define PTRACE_SYSEMU_SINGLESTEP 32
|
||||
#endif
|
||||
|
||||
/* On architectures, that started to support PTRACE_O_TRACESYSGOOD
|
||||
* in linux 2.4, there are two different definitions of
|
||||
* PTRACE_SETOPTIONS: linux 2.4 uses 21 while linux 2.6 uses 0x4200.
|
||||
* For binary compatibility, 2.6 also supports the old "21", named
|
||||
* PTRACE_OLDSETOPTION. On these architectures, UML always must use
|
||||
* "21", to ensure the kernel runs on 2.4 and 2.6 host without
|
||||
* recompilation. So, we use PTRACE_OLDSETOPTIONS in UML.
|
||||
* We also want to be able to build the kernel on 2.4, which doesn't
|
||||
* have PTRACE_OLDSETOPTIONS. So, if it is missing, we declare
|
||||
* PTRACE_OLDSETOPTIONS to to be the same as PTRACE_SETOPTIONS.
|
||||
*
|
||||
* On architectures, that start to support PTRACE_O_TRACESYSGOOD on
|
||||
* linux 2.6, PTRACE_OLDSETOPTIONS never is defined, and also isn't
|
||||
* supported by the host kernel. In that case, our trick lets us use
|
||||
* the new 0x4200 with the name PTRACE_OLDSETOPTIONS.
|
||||
*/
|
||||
#ifndef PTRACE_OLDSETOPTIONS
|
||||
#define PTRACE_OLDSETOPTIONS PTRACE_SETOPTIONS
|
||||
#endif
|
||||
|
||||
void set_using_sysemu(int value);
|
||||
int get_using_sysemu(void);
|
||||
extern int sysemu_supported;
|
||||
|
||||
#define SELECT_PTRACE_OPERATION(sysemu_mode, singlestep_mode) \
|
||||
(((int[3][3] ) { \
|
||||
{ PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \
|
||||
{ PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \
|
||||
{ PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, PTRACE_SYSEMU_SINGLESTEP }}) \
|
||||
[sysemu_mode][singlestep_mode])
|
||||
|
||||
#endif
|
||||
21
arch/um/include/registers.h
Normal file
21
arch/um/include/registers.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2004 PathScale, Inc
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __REGISTERS_H
|
||||
#define __REGISTERS_H
|
||||
|
||||
#include "sysdep/ptrace.h"
|
||||
#include "sysdep/archsetjmp.h"
|
||||
|
||||
extern void init_thread_registers(union uml_pt_regs *to);
|
||||
extern int save_fp_registers(int pid, unsigned long *fp_regs);
|
||||
extern int restore_fp_registers(int pid, unsigned long *fp_regs);
|
||||
extern void save_registers(int pid, union uml_pt_regs *regs);
|
||||
extern void restore_registers(int pid, union uml_pt_regs *regs);
|
||||
extern void init_registers(int pid);
|
||||
extern void get_safe_registers(unsigned long * regs, unsigned long * fp_regs);
|
||||
extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
|
||||
|
||||
#endif
|
||||
25
arch/um/include/sigcontext.h
Normal file
25
arch/um/include/sigcontext.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UML_SIGCONTEXT_H__
|
||||
#define __UML_SIGCONTEXT_H__
|
||||
|
||||
#include "sysdep/sigcontext.h"
|
||||
|
||||
extern int sc_size(void *data);
|
||||
extern void sc_to_sc(void *to_ptr, void *from_ptr);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
14
arch/um/include/sigio.h
Normal file
14
arch/um/include/sigio.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SIGIO_H__
|
||||
#define __SIGIO_H__
|
||||
|
||||
extern int write_sigio_irq(int fd);
|
||||
extern int register_sigio_fd(int fd);
|
||||
extern void sigio_lock(void);
|
||||
extern void sigio_unlock(void);
|
||||
|
||||
#endif
|
||||
22
arch/um/include/signal_kern.h
Normal file
22
arch/um/include/signal_kern.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SIGNAL_KERN_H__
|
||||
#define __SIGNAL_KERN_H__
|
||||
|
||||
extern int have_signals(void *t);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
17
arch/um/include/skas/mm_id.h
Normal file
17
arch/um/include/skas/mm_id.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MM_ID_H
|
||||
#define __MM_ID_H
|
||||
|
||||
struct mm_id {
|
||||
union {
|
||||
int mm_fd;
|
||||
int pid;
|
||||
} u;
|
||||
unsigned long stack;
|
||||
};
|
||||
|
||||
#endif
|
||||
23
arch/um/include/skas/mmu-skas.h
Normal file
23
arch/um/include/skas/mmu-skas.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SKAS_MMU_H
|
||||
#define __SKAS_MMU_H
|
||||
|
||||
#include "mm_id.h"
|
||||
#include "asm/ldt.h"
|
||||
|
||||
struct mmu_context_skas {
|
||||
struct mm_id id;
|
||||
unsigned long last_page_table;
|
||||
#ifdef CONFIG_3_LEVEL_PGTABLES
|
||||
unsigned long last_pmd;
|
||||
#endif
|
||||
uml_ldt_t ldt;
|
||||
};
|
||||
|
||||
extern void switch_mm_skas(struct mm_id * mm_idp);
|
||||
|
||||
#endif
|
||||
18
arch/um/include/skas/mode-skas.h
Normal file
18
arch/um/include/skas/mode-skas.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MODE_SKAS_H__
|
||||
#define __MODE_SKAS_H__
|
||||
|
||||
#include <sysdep/ptrace.h>
|
||||
|
||||
extern unsigned long exec_regs[];
|
||||
extern unsigned long exec_fp_regs[];
|
||||
extern unsigned long exec_fpx_regs[];
|
||||
extern int have_fpx_regs;
|
||||
|
||||
extern void kill_off_processes_skas(void);
|
||||
|
||||
#endif
|
||||
39
arch/um/include/skas/mode_kern_skas.h
Normal file
39
arch/um/include/skas/mode_kern_skas.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SKAS_MODE_KERN_H__
|
||||
#define __SKAS_MODE_KERN_H__
|
||||
|
||||
#include "linux/sched.h"
|
||||
#include "asm/page.h"
|
||||
#include "asm/ptrace.h"
|
||||
|
||||
extern void flush_thread_skas(void);
|
||||
extern void switch_to_skas(void *prev, void *next);
|
||||
extern void start_thread_skas(struct pt_regs *regs, unsigned long eip,
|
||||
unsigned long esp);
|
||||
extern int copy_thread_skas(int nr, unsigned long clone_flags,
|
||||
unsigned long sp, unsigned long stack_top,
|
||||
struct task_struct *p, struct pt_regs *regs);
|
||||
extern void release_thread_skas(struct task_struct *task);
|
||||
extern void init_idle_skas(void);
|
||||
extern void flush_tlb_kernel_range_skas(unsigned long start,
|
||||
unsigned long end);
|
||||
extern void flush_tlb_kernel_vm_skas(void);
|
||||
extern void __flush_tlb_one_skas(unsigned long addr);
|
||||
extern void flush_tlb_range_skas(struct vm_area_struct *vma,
|
||||
unsigned long start, unsigned long end);
|
||||
extern void flush_tlb_mm_skas(struct mm_struct *mm);
|
||||
extern void force_flush_all_skas(void);
|
||||
extern long execute_syscall_skas(void *r);
|
||||
extern void before_mem_skas(unsigned long unused);
|
||||
extern unsigned long set_task_sizes_skas(unsigned long *task_size_out);
|
||||
extern int start_uml_skas(void);
|
||||
extern int external_pid_skas(struct task_struct *task);
|
||||
extern int thread_pid_skas(struct task_struct *task);
|
||||
|
||||
#define kmem_end_skas (host_task_size - 1024 * 1024)
|
||||
|
||||
#endif
|
||||
44
arch/um/include/skas/proc_mm.h
Normal file
44
arch/um/include/skas/proc_mm.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SKAS_PROC_MM_H
|
||||
#define __SKAS_PROC_MM_H
|
||||
|
||||
#define MM_MMAP 54
|
||||
#define MM_MUNMAP 55
|
||||
#define MM_MPROTECT 56
|
||||
#define MM_COPY_SEGMENTS 57
|
||||
|
||||
struct mm_mmap {
|
||||
unsigned long addr;
|
||||
unsigned long len;
|
||||
unsigned long prot;
|
||||
unsigned long flags;
|
||||
unsigned long fd;
|
||||
unsigned long offset;
|
||||
};
|
||||
|
||||
struct mm_munmap {
|
||||
unsigned long addr;
|
||||
unsigned long len;
|
||||
};
|
||||
|
||||
struct mm_mprotect {
|
||||
unsigned long addr;
|
||||
unsigned long len;
|
||||
unsigned int prot;
|
||||
};
|
||||
|
||||
struct proc_mm_op {
|
||||
int op;
|
||||
union {
|
||||
struct mm_mmap mmap;
|
||||
struct mm_munmap munmap;
|
||||
struct mm_mprotect mprotect;
|
||||
int copy_segments;
|
||||
} u;
|
||||
};
|
||||
|
||||
#endif
|
||||
24
arch/um/include/skas/skas.h
Normal file
24
arch/um/include/skas/skas.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SKAS_H
|
||||
#define __SKAS_H
|
||||
|
||||
#include "mm_id.h"
|
||||
#include "sysdep/ptrace.h"
|
||||
|
||||
extern int userspace_pid[];
|
||||
extern int proc_mm, ptrace_faultinfo, ptrace_ldt;
|
||||
extern int skas_needs_stub;
|
||||
|
||||
extern int user_thread(unsigned long stack, int flags);
|
||||
extern void new_thread_handler(void);
|
||||
extern void handle_syscall(union uml_pt_regs *regs);
|
||||
extern int new_mm(unsigned long stack);
|
||||
extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
|
||||
extern long execute_syscall_skas(void *r);
|
||||
extern unsigned long current_stub_stack(void);
|
||||
|
||||
#endif
|
||||
18
arch/um/include/skas/stub-data.h
Normal file
18
arch/um/include/skas/stub-data.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __STUB_DATA_H
|
||||
#define __STUB_DATA_H
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
struct stub_data {
|
||||
long offset;
|
||||
int fd;
|
||||
struct itimerval timer;
|
||||
long err;
|
||||
};
|
||||
|
||||
#endif
|
||||
21
arch/um/include/skas/uaccess-skas.h
Normal file
21
arch/um/include/skas/uaccess-skas.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SKAS_UACCESS_H
|
||||
#define __SKAS_UACCESS_H
|
||||
|
||||
#include "asm/errno.h"
|
||||
|
||||
/* No SKAS-specific checking. */
|
||||
#define access_ok_skas(type, addr, size) 0
|
||||
|
||||
extern int copy_from_user_skas(void *to, const void __user *from, int n);
|
||||
extern int copy_to_user_skas(void __user *to, const void *from, int n);
|
||||
extern int strncpy_from_user_skas(char *dst, const char __user *src, int count);
|
||||
extern int __clear_user_skas(void __user *mem, int len);
|
||||
extern int clear_user_skas(void __user *mem, int len);
|
||||
extern int strnlen_user_skas(const void __user *str, int len);
|
||||
|
||||
#endif
|
||||
25
arch/um/include/skas_ptrace.h
Normal file
25
arch/um/include/skas_ptrace.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SKAS_PTRACE_H
|
||||
#define __SKAS_PTRACE_H
|
||||
|
||||
#define PTRACE_FAULTINFO 52
|
||||
#define PTRACE_SWITCH_MM 55
|
||||
|
||||
#include "sysdep/skas_ptrace.h"
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
6
arch/um/include/skas_ptregs.h
Normal file
6
arch/um/include/skas_ptregs.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef __SKAS_PT_REGS_
|
||||
#define __SKAS_PT_REGS_
|
||||
|
||||
#include <user_constants.h>
|
||||
|
||||
#endif
|
||||
12
arch/um/include/syscall.h
Normal file
12
arch/um/include/syscall.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSCALL_USER_H
|
||||
#define __SYSCALL_USER_H
|
||||
|
||||
extern int record_syscall_start(int syscall);
|
||||
extern void record_syscall_end(int index, long result);
|
||||
|
||||
#endif
|
||||
22
arch/um/include/sysdep-i386/archsetjmp.h
Normal file
22
arch/um/include/sysdep-i386/archsetjmp.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* arch/i386/include/klibc/archsetjmp.h
|
||||
*/
|
||||
|
||||
#ifndef _KLIBC_ARCHSETJMP_H
|
||||
#define _KLIBC_ARCHSETJMP_H
|
||||
|
||||
struct __jmp_buf {
|
||||
unsigned int __ebx;
|
||||
unsigned int __esp;
|
||||
unsigned int __ebp;
|
||||
unsigned int __esi;
|
||||
unsigned int __edi;
|
||||
unsigned int __eip;
|
||||
};
|
||||
|
||||
typedef struct __jmp_buf jmp_buf[1];
|
||||
|
||||
#define JB_IP __eip
|
||||
#define JB_SP __esp
|
||||
|
||||
#endif /* _SETJMP_H */
|
||||
9
arch/um/include/sysdep-i386/barrier.h
Normal file
9
arch/um/include/sysdep-i386/barrier.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef __SYSDEP_I386_BARRIER_H
|
||||
#define __SYSDEP_I386_BARRIER_H
|
||||
|
||||
/* Copied from include/asm-i386 for use by userspace. i386 has the option
|
||||
* of using mfence, but I'm just using this, which works everywhere, for now.
|
||||
*/
|
||||
#define mb() asm volatile("lock; addl $0,0(%esp)")
|
||||
|
||||
#endif
|
||||
211
arch/um/include/sysdep-i386/checksum.h
Normal file
211
arch/um/include/sysdep-i386/checksum.h
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UM_SYSDEP_CHECKSUM_H
|
||||
#define __UM_SYSDEP_CHECKSUM_H
|
||||
|
||||
#include "linux/in6.h"
|
||||
#include "linux/string.h"
|
||||
|
||||
/*
|
||||
* computes the checksum of a memory block at buff, length len,
|
||||
* and adds in "sum" (32-bit)
|
||||
*
|
||||
* returns a 32-bit number suitable for feeding into itself
|
||||
* or csum_tcpudp_magic
|
||||
*
|
||||
* this function must be called with even lengths, except
|
||||
* for the last fragment, which may be odd
|
||||
*
|
||||
* it's best to have buff aligned on a 32-bit boundary
|
||||
*/
|
||||
__wsum csum_partial(const void *buff, int len, __wsum sum);
|
||||
|
||||
/*
|
||||
* Note: when you get a NULL pointer exception here this means someone
|
||||
* passed in an incorrect kernel address to one of these functions.
|
||||
*
|
||||
* If you use these functions directly please don't forget the
|
||||
* access_ok().
|
||||
*/
|
||||
|
||||
static __inline__
|
||||
__wsum csum_partial_copy_nocheck(const void *src, void *dst,
|
||||
int len, __wsum sum)
|
||||
{
|
||||
memcpy(dst, src, len);
|
||||
return csum_partial(dst, len, sum);
|
||||
}
|
||||
|
||||
/*
|
||||
* the same as csum_partial, but copies from src while it
|
||||
* checksums, and handles user-space pointer exceptions correctly, when needed.
|
||||
*
|
||||
* here even more important to align src and dst on a 32-bit (or even
|
||||
* better 64-bit) boundary
|
||||
*/
|
||||
|
||||
static __inline__
|
||||
__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
|
||||
int len, __wsum sum, int *err_ptr)
|
||||
{
|
||||
if (copy_from_user(dst, src, len)) {
|
||||
*err_ptr = -EFAULT;
|
||||
return (__force __wsum)-1;
|
||||
}
|
||||
|
||||
return csum_partial(dst, len, sum);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a version of ip_compute_csum() optimized for IP headers,
|
||||
* which always checksum on 4 octet boundaries.
|
||||
*
|
||||
* By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
|
||||
* Arnt Gulbrandsen.
|
||||
*/
|
||||
static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
|
||||
{
|
||||
unsigned int sum;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"movl (%1), %0 ;\n"
|
||||
"subl $4, %2 ;\n"
|
||||
"jbe 2f ;\n"
|
||||
"addl 4(%1), %0 ;\n"
|
||||
"adcl 8(%1), %0 ;\n"
|
||||
"adcl 12(%1), %0 ;\n"
|
||||
"1: adcl 16(%1), %0 ;\n"
|
||||
"lea 4(%1), %1 ;\n"
|
||||
"decl %2 ;\n"
|
||||
"jne 1b ;\n"
|
||||
"adcl $0, %0 ;\n"
|
||||
"movl %0, %2 ;\n"
|
||||
"shrl $16, %0 ;\n"
|
||||
"addw %w2, %w0 ;\n"
|
||||
"adcl $0, %0 ;\n"
|
||||
"notl %0 ;\n"
|
||||
"2: ;\n"
|
||||
/* Since the input registers which are loaded with iph and ipl
|
||||
are modified, we must also specify them as outputs, or gcc
|
||||
will assume they contain their original values. */
|
||||
: "=r" (sum), "=r" (iph), "=r" (ihl)
|
||||
: "1" (iph), "2" (ihl)
|
||||
: "memory");
|
||||
return (__force __sum16)sum;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fold a partial checksum
|
||||
*/
|
||||
|
||||
static inline __sum16 csum_fold(__wsum sum)
|
||||
{
|
||||
__asm__(
|
||||
"addl %1, %0 ;\n"
|
||||
"adcl $0xffff, %0 ;\n"
|
||||
: "=r" (sum)
|
||||
: "r" ((__force u32)sum << 16),
|
||||
"0" ((__force u32)sum & 0xffff0000)
|
||||
);
|
||||
return (__force __sum16)(~(__force u32)sum >> 16);
|
||||
}
|
||||
|
||||
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
|
||||
unsigned short len,
|
||||
unsigned short proto,
|
||||
__wsum sum)
|
||||
{
|
||||
__asm__(
|
||||
"addl %1, %0 ;\n"
|
||||
"adcl %2, %0 ;\n"
|
||||
"adcl %3, %0 ;\n"
|
||||
"adcl $0, %0 ;\n"
|
||||
: "=r" (sum)
|
||||
: "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum));
|
||||
return sum;
|
||||
}
|
||||
|
||||
/*
|
||||
* computes the checksum of the TCP/UDP pseudo-header
|
||||
* returns a 16-bit checksum, already complemented
|
||||
*/
|
||||
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
|
||||
unsigned short len,
|
||||
unsigned short proto,
|
||||
__wsum sum)
|
||||
{
|
||||
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
|
||||
}
|
||||
|
||||
/*
|
||||
* this routine is used for miscellaneous IP-like checksums, mainly
|
||||
* in icmp.c
|
||||
*/
|
||||
|
||||
static inline __sum16 ip_compute_csum(const void *buff, int len)
|
||||
{
|
||||
return csum_fold (csum_partial(buff, len, 0));
|
||||
}
|
||||
|
||||
#define _HAVE_ARCH_IPV6_CSUM
|
||||
static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
|
||||
const struct in6_addr *daddr,
|
||||
__u32 len, unsigned short proto,
|
||||
__wsum sum)
|
||||
{
|
||||
__asm__(
|
||||
"addl 0(%1), %0 ;\n"
|
||||
"adcl 4(%1), %0 ;\n"
|
||||
"adcl 8(%1), %0 ;\n"
|
||||
"adcl 12(%1), %0 ;\n"
|
||||
"adcl 0(%2), %0 ;\n"
|
||||
"adcl 4(%2), %0 ;\n"
|
||||
"adcl 8(%2), %0 ;\n"
|
||||
"adcl 12(%2), %0 ;\n"
|
||||
"adcl %3, %0 ;\n"
|
||||
"adcl %4, %0 ;\n"
|
||||
"adcl $0, %0 ;\n"
|
||||
: "=&r" (sum)
|
||||
: "r" (saddr), "r" (daddr),
|
||||
"r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
|
||||
|
||||
return csum_fold(sum);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy and checksum to user
|
||||
*/
|
||||
#define HAVE_CSUM_COPY_USER
|
||||
static __inline__ __wsum csum_and_copy_to_user(const void *src,
|
||||
void __user *dst,
|
||||
int len, __wsum sum, int *err_ptr)
|
||||
{
|
||||
if (access_ok(VERIFY_WRITE, dst, len)) {
|
||||
if (copy_to_user(dst, src, len)) {
|
||||
*err_ptr = -EFAULT;
|
||||
return (__force __wsum)-1;
|
||||
}
|
||||
|
||||
return csum_partial(src, len, sum);
|
||||
}
|
||||
|
||||
if (len)
|
||||
*err_ptr = -EFAULT;
|
||||
|
||||
return (__force __wsum)-1; /* invalid checksum */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
29
arch/um/include/sysdep-i386/faultinfo.h
Normal file
29
arch/um/include/sysdep-i386/faultinfo.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2004 Fujitsu Siemens Computers GmbH
|
||||
* Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __FAULTINFO_I386_H
|
||||
#define __FAULTINFO_I386_H
|
||||
|
||||
/* this structure contains the full arch-specific faultinfo
|
||||
* from the traps.
|
||||
* On i386, ptrace_faultinfo unfortunately doesn't provide
|
||||
* all the info, since trap_no is missing.
|
||||
* All common elements are defined at the same position in
|
||||
* both structures, thus making it easy to copy the
|
||||
* contents without knowledge about the structure elements.
|
||||
*/
|
||||
struct faultinfo {
|
||||
int error_code; /* in ptrace_faultinfo misleadingly called is_write */
|
||||
unsigned long cr2; /* in ptrace_faultinfo called addr */
|
||||
int trap_no; /* missing in ptrace_faultinfo */
|
||||
};
|
||||
|
||||
#define FAULT_WRITE(fi) ((fi).error_code & 2)
|
||||
#define FAULT_ADDRESS(fi) ((fi).cr2)
|
||||
|
||||
#define PTRACE_FULL_FAULTINFO 0
|
||||
|
||||
#endif
|
||||
22
arch/um/include/sysdep-i386/kernel-offsets.h
Normal file
22
arch/um/include/sysdep-i386/kernel-offsets.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/elf.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <asm/mman.h>
|
||||
|
||||
#define DEFINE(sym, val) \
|
||||
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
|
||||
|
||||
#define STR(x) #x
|
||||
#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : )
|
||||
|
||||
#define BLANK() asm volatile("\n->" : : )
|
||||
|
||||
#define OFFSET(sym, str, mem) \
|
||||
DEFINE(sym, offsetof(struct str, mem));
|
||||
|
||||
void foo(void)
|
||||
{
|
||||
OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
|
||||
#include <common-offsets.h>
|
||||
}
|
||||
232
arch/um/include/sysdep-i386/ptrace.h
Normal file
232
arch/um/include/sysdep-i386/ptrace.h
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_I386_PTRACE_H
|
||||
#define __SYSDEP_I386_PTRACE_H
|
||||
|
||||
#include "uml-config.h"
|
||||
#include "user_constants.h"
|
||||
#include "sysdep/faultinfo.h"
|
||||
#include "choose-mode.h"
|
||||
|
||||
#define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
|
||||
#define MAX_REG_OFFSET (UM_FRAME_SIZE)
|
||||
|
||||
#ifdef UML_CONFIG_PT_PROXY
|
||||
extern void update_debugregs(int seq);
|
||||
#else
|
||||
static inline void update_debugregs(int seq) {}
|
||||
#endif
|
||||
|
||||
|
||||
/* 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;
|
||||
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
#include "sysdep/sc.h"
|
||||
#endif
|
||||
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
|
||||
#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))
|
||||
|
||||
#endif
|
||||
#ifndef PTRACE_SYSEMU_SINGLESTEP
|
||||
#define PTRACE_SYSEMU_SINGLESTEP 32
|
||||
#endif
|
||||
|
||||
union uml_pt_regs {
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
struct tt_regs {
|
||||
long syscall;
|
||||
void *sc;
|
||||
struct faultinfo faultinfo;
|
||||
} tt;
|
||||
#endif
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
struct skas_regs {
|
||||
unsigned long regs[MAX_REG_NR];
|
||||
unsigned long fp[HOST_FP_SIZE];
|
||||
unsigned long xfp[HOST_XFP_SIZE];
|
||||
struct faultinfo faultinfo;
|
||||
long syscall;
|
||||
int is_user;
|
||||
} skas;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define EMPTY_UML_PT_REGS { }
|
||||
|
||||
extern int mode_tt;
|
||||
|
||||
#define UPT_SC(r) ((r)->tt.sc)
|
||||
#define UPT_IP(r) \
|
||||
__CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
|
||||
#define UPT_SP(r) \
|
||||
__CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
|
||||
#define UPT_EFLAGS(r) \
|
||||
__CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
|
||||
#define UPT_EAX(r) \
|
||||
__CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)->skas.regs))
|
||||
#define UPT_EBX(r) \
|
||||
__CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)->skas.regs))
|
||||
#define UPT_ECX(r) \
|
||||
__CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)->skas.regs))
|
||||
#define UPT_EDX(r) \
|
||||
__CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)->skas.regs))
|
||||
#define UPT_ESI(r) \
|
||||
__CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)->skas.regs))
|
||||
#define UPT_EDI(r) \
|
||||
__CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)->skas.regs))
|
||||
#define UPT_EBP(r) \
|
||||
__CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)->skas.regs))
|
||||
#define UPT_ORIG_EAX(r) \
|
||||
__CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
|
||||
#define UPT_CS(r) \
|
||||
__CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
|
||||
#define UPT_SS(r) \
|
||||
__CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
|
||||
#define UPT_DS(r) \
|
||||
__CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
|
||||
#define UPT_ES(r) \
|
||||
__CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
|
||||
#define UPT_FS(r) \
|
||||
__CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
|
||||
#define UPT_GS(r) \
|
||||
__CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
|
||||
|
||||
#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);
|
||||
|
||||
#define UPT_IS_USER(r) \
|
||||
CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
|
||||
|
||||
struct syscall_args {
|
||||
unsigned long args[6];
|
||||
};
|
||||
|
||||
#define SYSCALL_ARGS(r) ((struct syscall_args) \
|
||||
{ .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) } } )
|
||||
|
||||
#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) \
|
||||
CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
|
||||
REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
|
||||
|
||||
#define UPT_RESTART_SYSCALL(r) \
|
||||
CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
|
||||
REGS_RESTART_SYSCALL((r)->skas.regs))
|
||||
|
||||
#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)
|
||||
|
||||
#define UPT_FAULTINFO(r) \
|
||||
CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
75
arch/um/include/sysdep-i386/ptrace_user.h
Normal file
75
arch/um/include/sysdep-i386/ptrace_user.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_I386_PTRACE_USER_H__
|
||||
#define __SYSDEP_I386_PTRACE_USER_H__
|
||||
|
||||
#include <sys/ptrace.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <asm/ptrace.h>
|
||||
|
||||
#define PT_OFFSET(r) ((r) * sizeof(long))
|
||||
|
||||
#define PT_SYSCALL_NR(regs) ((regs)[ORIG_EAX])
|
||||
#define PT_SYSCALL_NR_OFFSET PT_OFFSET(ORIG_EAX)
|
||||
|
||||
#define PT_SYSCALL_ARG1_OFFSET PT_OFFSET(EBX)
|
||||
#define PT_SYSCALL_ARG2_OFFSET PT_OFFSET(ECX)
|
||||
#define PT_SYSCALL_ARG3_OFFSET PT_OFFSET(EDX)
|
||||
#define PT_SYSCALL_ARG4_OFFSET PT_OFFSET(ESI)
|
||||
#define PT_SYSCALL_ARG5_OFFSET PT_OFFSET(EDI)
|
||||
#define PT_SYSCALL_ARG6_OFFSET PT_OFFSET(EBP)
|
||||
|
||||
#define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX)
|
||||
|
||||
#define REGS_SYSCALL_NR EAX /* This is used before a system call */
|
||||
#define REGS_SYSCALL_ARG1 EBX
|
||||
#define REGS_SYSCALL_ARG2 ECX
|
||||
#define REGS_SYSCALL_ARG3 EDX
|
||||
#define REGS_SYSCALL_ARG4 ESI
|
||||
#define REGS_SYSCALL_ARG5 EDI
|
||||
#define REGS_SYSCALL_ARG6 EBP
|
||||
|
||||
#define REGS_IP_INDEX EIP
|
||||
#define REGS_SP_INDEX UESP
|
||||
|
||||
#define PT_IP_OFFSET PT_OFFSET(EIP)
|
||||
#define PT_IP(regs) ((regs)[EIP])
|
||||
#define PT_SP_OFFSET PT_OFFSET(UESP)
|
||||
#define PT_SP(regs) ((regs)[UESP])
|
||||
|
||||
#ifndef FRAME_SIZE
|
||||
#define FRAME_SIZE (17)
|
||||
#endif
|
||||
#define FRAME_SIZE_OFFSET (FRAME_SIZE * sizeof(unsigned long))
|
||||
|
||||
#define FP_FRAME_SIZE (27)
|
||||
#define FPX_FRAME_SIZE (128)
|
||||
|
||||
#ifdef PTRACE_GETREGS
|
||||
#define UM_HAVE_GETREGS
|
||||
#endif
|
||||
|
||||
#ifdef PTRACE_SETREGS
|
||||
#define UM_HAVE_SETREGS
|
||||
#endif
|
||||
|
||||
#ifdef PTRACE_GETFPREGS
|
||||
#define UM_HAVE_GETFPREGS
|
||||
#endif
|
||||
|
||||
#ifdef PTRACE_SETFPREGS
|
||||
#define UM_HAVE_SETFPREGS
|
||||
#endif
|
||||
|
||||
#ifdef PTRACE_GETFPXREGS
|
||||
#define UM_HAVE_GETFPXREGS
|
||||
#endif
|
||||
|
||||
#ifdef PTRACE_SETFPXREGS
|
||||
#define UM_HAVE_SETFPXREGS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
44
arch/um/include/sysdep-i386/sc.h
Normal file
44
arch/um/include/sysdep-i386/sc.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef __SYSDEP_I386_SC_H
|
||||
#define __SYSDEP_I386_SC_H
|
||||
|
||||
#include <user_constants.h>
|
||||
|
||||
#define SC_OFFSET(sc, field) \
|
||||
*((unsigned long *) &(((char *) (sc))[HOST_##field]))
|
||||
#define SC_FP_OFFSET(sc, field) \
|
||||
*((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field]))
|
||||
#define SC_FP_OFFSET_PTR(sc, field, type) \
|
||||
((type *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field]))
|
||||
|
||||
#define SC_IP(sc) SC_OFFSET(sc, SC_IP)
|
||||
#define SC_SP(sc) SC_OFFSET(sc, SC_SP)
|
||||
#define SC_FS(sc) SC_OFFSET(sc, SC_FS)
|
||||
#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
|
||||
#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
|
||||
#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
|
||||
#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
|
||||
#define SC_CS(sc) SC_OFFSET(sc, SC_CS)
|
||||
#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
|
||||
#define SC_EAX(sc) SC_OFFSET(sc, SC_EAX)
|
||||
#define SC_EBX(sc) SC_OFFSET(sc, SC_EBX)
|
||||
#define SC_ECX(sc) SC_OFFSET(sc, SC_ECX)
|
||||
#define SC_EDX(sc) SC_OFFSET(sc, SC_EDX)
|
||||
#define SC_EDI(sc) SC_OFFSET(sc, SC_EDI)
|
||||
#define SC_ESI(sc) SC_OFFSET(sc, SC_ESI)
|
||||
#define SC_EBP(sc) SC_OFFSET(sc, SC_EBP)
|
||||
#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO)
|
||||
#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR)
|
||||
#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2)
|
||||
#define SC_FPSTATE(sc) SC_OFFSET(sc, SC_FPSTATE)
|
||||
#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
|
||||
#define SC_FP_CW(sc) SC_FP_OFFSET(sc, SC_FP_CW)
|
||||
#define SC_FP_SW(sc) SC_FP_OFFSET(sc, SC_FP_SW)
|
||||
#define SC_FP_TAG(sc) SC_FP_OFFSET(sc, SC_FP_TAG)
|
||||
#define SC_FP_IPOFF(sc) SC_FP_OFFSET(sc, SC_FP_IPOFF)
|
||||
#define SC_FP_CSSEL(sc) SC_FP_OFFSET(sc, SC_FP_CSSEL)
|
||||
#define SC_FP_DATAOFF(sc) SC_FP_OFFSET(sc, SC_FP_DATAOFF)
|
||||
#define SC_FP_DATASEL(sc) SC_FP_OFFSET(sc, SC_FP_DATASEL)
|
||||
#define SC_FP_ST(sc) SC_FP_OFFSET_PTR(sc, SC_FP_ST, struct _fpstate)
|
||||
#define SC_FXSR_ENV(sc) SC_FP_OFFSET_PTR(sc, SC_FXSR_ENV, void)
|
||||
|
||||
#endif
|
||||
52
arch/um/include/sysdep-i386/sigcontext.h
Normal file
52
arch/um/include/sysdep-i386/sigcontext.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYS_SIGCONTEXT_I386_H
|
||||
#define __SYS_SIGCONTEXT_I386_H
|
||||
|
||||
#include "uml-config.h"
|
||||
#include <sysdep/sc.h>
|
||||
|
||||
#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
|
||||
|
||||
#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
|
||||
#define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result)
|
||||
|
||||
#define GET_FAULTINFO_FROM_SC(fi,sc) \
|
||||
{ \
|
||||
(fi).cr2 = SC_CR2(sc); \
|
||||
(fi).error_code = SC_ERR(sc); \
|
||||
(fi).trap_no = SC_TRAPNO(sc); \
|
||||
}
|
||||
|
||||
/* ptrace expects that, at the start of a system call, %eax contains
|
||||
* -ENOSYS, so this makes it so.
|
||||
*/
|
||||
#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
|
||||
|
||||
/* This is Page Fault */
|
||||
#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
|
||||
|
||||
/* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
#define SEGV_MAYBE_FIXABLE(fi) ((fi)->trap_no == 0 && ptrace_faultinfo)
|
||||
#else
|
||||
#define SEGV_MAYBE_FIXABLE(fi) 0
|
||||
#endif
|
||||
|
||||
extern unsigned long *sc_sigmask(void *sc_ptr);
|
||||
extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
22
arch/um/include/sysdep-i386/skas_ptrace.h
Normal file
22
arch/um/include/sysdep-i386/skas_ptrace.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_I386_SKAS_PTRACE_H
|
||||
#define __SYSDEP_I386_SKAS_PTRACE_H
|
||||
|
||||
struct ptrace_faultinfo {
|
||||
int is_write;
|
||||
unsigned long addr;
|
||||
};
|
||||
|
||||
struct ptrace_ldt {
|
||||
int func;
|
||||
void *ptr;
|
||||
unsigned long bytecount;
|
||||
};
|
||||
|
||||
#define PTRACE_LDT 54
|
||||
|
||||
#endif
|
||||
102
arch/um/include/sysdep-i386/stub.h
Normal file
102
arch/um/include/sysdep-i386/stub.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_STUB_H
|
||||
#define __SYSDEP_STUB_H
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <asm/ptrace.h>
|
||||
#include <asm/unistd.h>
|
||||
#include <asm/page.h>
|
||||
#include "stub-data.h"
|
||||
#include "kern_constants.h"
|
||||
#include "uml-config.h"
|
||||
|
||||
extern void stub_segv_handler(int sig);
|
||||
extern void stub_clone_handler(void);
|
||||
|
||||
#define STUB_SYSCALL_RET EAX
|
||||
#define STUB_MMAP_NR __NR_mmap2
|
||||
#define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT)
|
||||
|
||||
static inline long stub_syscall0(long syscall)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall1(long syscall, long arg1)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall2(long syscall, long arg1, long arg2)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
|
||||
"c" (arg2));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
|
||||
"c" (arg2), "d" (arg3));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
|
||||
long arg4)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
|
||||
"c" (arg2), "d" (arg3), "S" (arg4));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
|
||||
long arg4, long arg5)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
|
||||
"c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void trap_myself(void)
|
||||
{
|
||||
__asm("int3");
|
||||
}
|
||||
|
||||
static inline void remap_stack(int fd, unsigned long offset)
|
||||
{
|
||||
__asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
|
||||
"movl %7, %%ebx ; movl %%eax, (%%ebx)"
|
||||
: : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA),
|
||||
"c" (UM_KERN_PAGE_SIZE),
|
||||
"d" (PROT_READ | PROT_WRITE),
|
||||
"S" (MAP_FIXED | MAP_SHARED), "D" (fd),
|
||||
"a" (offset),
|
||||
"i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
#endif
|
||||
25
arch/um/include/sysdep-i386/syscalls.h
Normal file
25
arch/um/include/sysdep-i386/syscalls.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#include "asm/unistd.h"
|
||||
#include "sysdep/ptrace.h"
|
||||
|
||||
typedef long syscall_handler_t(struct pt_regs);
|
||||
|
||||
/* Not declared on x86, incompatible declarations on x86_64, so these have
|
||||
* to go here rather than in sys_call_table.c
|
||||
*/
|
||||
extern syscall_handler_t sys_rt_sigaction;
|
||||
|
||||
extern syscall_handler_t old_mmap_i386;
|
||||
|
||||
extern syscall_handler_t *sys_call_table[];
|
||||
|
||||
#define EXECUTE_SYSCALL(syscall, regs) \
|
||||
((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(®s->regs))
|
||||
|
||||
extern long sys_mmap2(unsigned long addr, unsigned long len,
|
||||
unsigned long prot, unsigned long flags,
|
||||
unsigned long fd, unsigned long pgoff);
|
||||
11
arch/um/include/sysdep-i386/thread.h
Normal file
11
arch/um/include/sysdep-i386/thread.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef __UM_THREAD_H
|
||||
#define __UM_THREAD_H
|
||||
|
||||
#include <kern_constants.h>
|
||||
|
||||
#define TASK_DEBUGREGS(task) ((unsigned long *) &(((char *) (task))[HOST_TASK_DEBUGREGS]))
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
32
arch/um/include/sysdep-i386/tls.h
Normal file
32
arch/um/include/sysdep-i386/tls.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _SYSDEP_TLS_H
|
||||
#define _SYSDEP_TLS_H
|
||||
|
||||
# ifndef __KERNEL__
|
||||
|
||||
/* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
|
||||
* may be named user_desc (but in 2.4 and in header matching its API was named
|
||||
* modify_ldt_ldt_s). */
|
||||
|
||||
typedef struct um_dup_user_desc {
|
||||
unsigned int entry_number;
|
||||
unsigned int base_addr;
|
||||
unsigned int limit;
|
||||
unsigned int seg_32bit:1;
|
||||
unsigned int contents:2;
|
||||
unsigned int read_exec_only:1;
|
||||
unsigned int limit_in_pages:1;
|
||||
unsigned int seg_not_present:1;
|
||||
unsigned int useable:1;
|
||||
} user_desc_t;
|
||||
|
||||
# else /* __KERNEL__ */
|
||||
|
||||
# include <asm/ldt.h>
|
||||
typedef struct user_desc user_desc_t;
|
||||
|
||||
# endif /* __KERNEL__ */
|
||||
|
||||
#define GDT_ENTRY_TLS_MIN_I386 6
|
||||
#define GDT_ENTRY_TLS_MIN_X86_64 12
|
||||
|
||||
#endif /* _SYSDEP_TLS_H */
|
||||
26
arch/um/include/sysdep-ia64/ptrace.h
Normal file
26
arch/um/include/sysdep-ia64/ptrace.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_IA64_PTRACE_H
|
||||
#define __SYSDEP_IA64_PTRACE_H
|
||||
|
||||
struct sys_pt_regs {
|
||||
int foo;
|
||||
};
|
||||
|
||||
#define EMPTY_REGS { 0 }
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
20
arch/um/include/sysdep-ia64/sigcontext.h
Normal file
20
arch/um/include/sysdep-ia64/sigcontext.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_IA64_SIGCONTEXT_H
|
||||
#define __SYSDEP_IA64_SIGCONTEXT_H
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
22
arch/um/include/sysdep-ia64/skas_ptrace.h
Normal file
22
arch/um/include/sysdep-ia64/skas_ptrace.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_IA64_SKAS_PTRACE_H
|
||||
#define __SYSDEP_IA64_SKAS_PTRACE_H
|
||||
|
||||
struct ptrace_faultinfo {
|
||||
int is_write;
|
||||
unsigned long addr;
|
||||
};
|
||||
|
||||
struct ptrace_ldt {
|
||||
int func;
|
||||
void *ptr;
|
||||
unsigned long bytecount;
|
||||
};
|
||||
|
||||
#define PTRACE_LDT 54
|
||||
|
||||
#endif
|
||||
20
arch/um/include/sysdep-ia64/syscalls.h
Normal file
20
arch/um/include/sysdep-ia64/syscalls.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_IA64_SYSCALLS_H
|
||||
#define __SYSDEP_IA64_SYSCALLS_H
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
103
arch/um/include/sysdep-ppc/ptrace.h
Normal file
103
arch/um/include/sysdep-ppc/ptrace.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYS_PTRACE_PPC_H
|
||||
#define __SYS_PTRACE_PPC_H
|
||||
|
||||
#include "linux/types.h"
|
||||
|
||||
/* the following taken from <asm-ppc/ptrace.h> */
|
||||
|
||||
#ifdef CONFIG_PPC64
|
||||
#define PPC_REG unsigned long /*long*/
|
||||
#else
|
||||
#define PPC_REG unsigned long
|
||||
#endif
|
||||
struct sys_pt_regs_s {
|
||||
PPC_REG gpr[32];
|
||||
PPC_REG nip;
|
||||
PPC_REG msr;
|
||||
PPC_REG orig_gpr3; /* Used for restarting system calls */
|
||||
PPC_REG ctr;
|
||||
PPC_REG link;
|
||||
PPC_REG xer;
|
||||
PPC_REG ccr;
|
||||
PPC_REG mq; /* 601 only (not used at present) */
|
||||
/* Used on APUS to hold IPL value. */
|
||||
PPC_REG trap; /* Reason for being here */
|
||||
PPC_REG dar; /* Fault registers */
|
||||
PPC_REG dsisr;
|
||||
PPC_REG result; /* Result of a system call */
|
||||
};
|
||||
|
||||
#define NUM_REGS (sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG))
|
||||
|
||||
struct sys_pt_regs {
|
||||
PPC_REG regs[sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG)];
|
||||
};
|
||||
|
||||
#define UM_MAX_REG (PT_FPR0)
|
||||
#define UM_MAX_REG_OFFSET (UM_MAX_REG * sizeof(PPC_REG))
|
||||
|
||||
#define EMPTY_REGS { { [ 0 ... NUM_REGS - 1] = 0 } }
|
||||
|
||||
#define UM_REG(r, n) ((r)->regs[n])
|
||||
|
||||
#define UM_SYSCALL_RET(r) UM_REG(r, PT_R3)
|
||||
#define UM_SP(r) UM_REG(r, PT_R1)
|
||||
#define UM_IP(r) UM_REG(r, PT_NIP)
|
||||
#define UM_ELF_ZERO(r) UM_REG(r, PT_FPSCR)
|
||||
#define UM_SYSCALL_NR(r) UM_REG(r, PT_R0)
|
||||
#define UM_SYSCALL_ARG1(r) UM_REG(r, PT_ORIG_R3)
|
||||
#define UM_SYSCALL_ARG2(r) UM_REG(r, PT_R4)
|
||||
#define UM_SYSCALL_ARG3(r) UM_REG(r, PT_R5)
|
||||
#define UM_SYSCALL_ARG4(r) UM_REG(r, PT_R6)
|
||||
#define UM_SYSCALL_ARG5(r) UM_REG(r, PT_R7)
|
||||
#define UM_SYSCALL_ARG6(r) UM_REG(r, PT_R8)
|
||||
|
||||
#define UM_SYSCALL_NR_OFFSET (PT_R0 * sizeof(PPC_REG))
|
||||
#define UM_SYSCALL_RET_OFFSET (PT_R3 * sizeof(PPC_REG))
|
||||
#define UM_SYSCALL_ARG1_OFFSET (PT_R3 * sizeof(PPC_REG))
|
||||
#define UM_SYSCALL_ARG2_OFFSET (PT_R4 * sizeof(PPC_REG))
|
||||
#define UM_SYSCALL_ARG3_OFFSET (PT_R5 * sizeof(PPC_REG))
|
||||
#define UM_SYSCALL_ARG4_OFFSET (PT_R6 * sizeof(PPC_REG))
|
||||
#define UM_SYSCALL_ARG5_OFFSET (PT_R7 * sizeof(PPC_REG))
|
||||
#define UM_SYSCALL_ARG6_OFFSET (PT_R8 * sizeof(PPC_REG))
|
||||
#define UM_SP_OFFSET (PT_R1 * sizeof(PPC_REG))
|
||||
#define UM_IP_OFFSET (PT_NIP * sizeof(PPC_REG))
|
||||
#define UM_ELF_ZERO_OFFSET (PT_R3 * sizeof(PPC_REG))
|
||||
|
||||
#define UM_SET_SYSCALL_RETURN(_regs, result) \
|
||||
do { \
|
||||
if (result < 0) { \
|
||||
(_regs)->regs[PT_CCR] |= 0x10000000; \
|
||||
UM_SYSCALL_RET((_regs)) = -result; \
|
||||
} else { \
|
||||
UM_SYSCALL_RET((_regs)) = result; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
extern void shove_aux_table(unsigned long sp);
|
||||
#define UM_FIX_EXEC_STACK(sp) shove_aux_table(sp);
|
||||
|
||||
/* These aren't actually defined. The undefs are just to make sure
|
||||
* everyone's clear on the concept.
|
||||
*/
|
||||
#undef UML_HAVE_GETREGS
|
||||
#undef UML_HAVE_GETFPREGS
|
||||
#undef UML_HAVE_SETREGS
|
||||
#undef UML_HAVE_SETFPREGS
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
62
arch/um/include/sysdep-ppc/sigcontext.h
Normal file
62
arch/um/include/sysdep-ppc/sigcontext.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYS_SIGCONTEXT_PPC_H
|
||||
#define __SYS_SIGCONTEXT_PPC_H
|
||||
|
||||
#define DSISR_WRITE 0x02000000
|
||||
|
||||
#define SC_FAULT_ADDR(sc) ({ \
|
||||
struct sigcontext *_sc = (sc); \
|
||||
long retval = -1; \
|
||||
switch (_sc->regs->trap) { \
|
||||
case 0x300: \
|
||||
/* data exception */ \
|
||||
retval = _sc->regs->dar; \
|
||||
break; \
|
||||
case 0x400: \
|
||||
/* instruction exception */ \
|
||||
retval = _sc->regs->nip; \
|
||||
break; \
|
||||
default: \
|
||||
panic("SC_FAULT_ADDR: unhandled trap type\n"); \
|
||||
} \
|
||||
retval; \
|
||||
})
|
||||
|
||||
#define SC_FAULT_WRITE(sc) ({ \
|
||||
struct sigcontext *_sc = (sc); \
|
||||
long retval = -1; \
|
||||
switch (_sc->regs->trap) { \
|
||||
case 0x300: \
|
||||
/* data exception */ \
|
||||
retval = !!(_sc->regs->dsisr & DSISR_WRITE); \
|
||||
break; \
|
||||
case 0x400: \
|
||||
/* instruction exception: not a write */ \
|
||||
retval = 0; \
|
||||
break; \
|
||||
default: \
|
||||
panic("SC_FAULT_ADDR: unhandled trap type\n"); \
|
||||
} \
|
||||
retval; \
|
||||
})
|
||||
|
||||
#define SC_IP(sc) ((sc)->regs->nip)
|
||||
#define SC_SP(sc) ((sc)->regs->gpr[1])
|
||||
#define SEGV_IS_FIXABLE(sc) (1)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
22
arch/um/include/sysdep-ppc/skas_ptrace.h
Normal file
22
arch/um/include/sysdep-ppc/skas_ptrace.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_PPC_SKAS_PTRACE_H
|
||||
#define __SYSDEP_PPC_SKAS_PTRACE_H
|
||||
|
||||
struct ptrace_faultinfo {
|
||||
int is_write;
|
||||
unsigned long addr;
|
||||
};
|
||||
|
||||
struct ptrace_ldt {
|
||||
int func;
|
||||
void *ptr;
|
||||
unsigned long bytecount;
|
||||
};
|
||||
|
||||
#define PTRACE_LDT 54
|
||||
|
||||
#endif
|
||||
53
arch/um/include/sysdep-ppc/syscalls.h
Normal file
53
arch/um/include/sysdep-ppc/syscalls.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
typedef long syscall_handler_t(unsigned long arg1, unsigned long arg2,
|
||||
unsigned long arg3, unsigned long arg4,
|
||||
unsigned long arg5, unsigned long arg6);
|
||||
|
||||
#define EXECUTE_SYSCALL(syscall, regs) \
|
||||
(*sys_call_table[syscall])(UM_SYSCALL_ARG1(®s), \
|
||||
UM_SYSCALL_ARG2(®s), \
|
||||
UM_SYSCALL_ARG3(®s), \
|
||||
UM_SYSCALL_ARG4(®s), \
|
||||
UM_SYSCALL_ARG5(®s), \
|
||||
UM_SYSCALL_ARG6(®s))
|
||||
|
||||
extern syscall_handler_t sys_mincore;
|
||||
extern syscall_handler_t sys_madvise;
|
||||
|
||||
/* old_mmap needs the correct prototype since syscall_kern.c includes
|
||||
* this file.
|
||||
*/
|
||||
int old_mmap(unsigned long addr, unsigned long len,
|
||||
unsigned long prot, unsigned long flags,
|
||||
unsigned long fd, unsigned long offset);
|
||||
|
||||
#define ARCH_SYSCALLS \
|
||||
[ __NR_modify_ldt ] = sys_ni_syscall, \
|
||||
[ __NR_pciconfig_read ] = sys_ni_syscall, \
|
||||
[ __NR_pciconfig_write ] = sys_ni_syscall, \
|
||||
[ __NR_pciconfig_iobase ] = sys_ni_syscall, \
|
||||
[ __NR_pivot_root ] = sys_ni_syscall, \
|
||||
[ __NR_multiplexer ] = sys_ni_syscall, \
|
||||
[ __NR_mmap ] = old_mmap, \
|
||||
[ __NR_madvise ] = sys_madvise, \
|
||||
[ __NR_mincore ] = sys_mincore, \
|
||||
[ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \
|
||||
[ __NR_utimes ] = (syscall_handler_t *) sys_utimes, \
|
||||
[ __NR_fadvise64 ] = (syscall_handler_t *) sys_fadvise64,
|
||||
|
||||
#define LAST_ARCH_SYSCALL __NR_fadvise64
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
24
arch/um/include/sysdep-x86_64/archsetjmp.h
Normal file
24
arch/um/include/sysdep-x86_64/archsetjmp.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* arch/x86_64/include/klibc/archsetjmp.h
|
||||
*/
|
||||
|
||||
#ifndef _KLIBC_ARCHSETJMP_H
|
||||
#define _KLIBC_ARCHSETJMP_H
|
||||
|
||||
struct __jmp_buf {
|
||||
unsigned long __rbx;
|
||||
unsigned long __rsp;
|
||||
unsigned long __rbp;
|
||||
unsigned long __r12;
|
||||
unsigned long __r13;
|
||||
unsigned long __r14;
|
||||
unsigned long __r15;
|
||||
unsigned long __rip;
|
||||
};
|
||||
|
||||
typedef struct __jmp_buf jmp_buf[1];
|
||||
|
||||
#define JB_IP __rip
|
||||
#define JB_SP __rsp
|
||||
|
||||
#endif /* _SETJMP_H */
|
||||
7
arch/um/include/sysdep-x86_64/barrier.h
Normal file
7
arch/um/include/sysdep-x86_64/barrier.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __SYSDEP_X86_64_BARRIER_H
|
||||
#define __SYSDEP_X86_64_BARRIER_H
|
||||
|
||||
/* Copied from include/asm-x86_64 for use by userspace. */
|
||||
#define mb() asm volatile("mfence":::"memory")
|
||||
|
||||
#endif
|
||||
144
arch/um/include/sysdep-x86_64/checksum.h
Normal file
144
arch/um/include/sysdep-x86_64/checksum.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UM_SYSDEP_CHECKSUM_H
|
||||
#define __UM_SYSDEP_CHECKSUM_H
|
||||
|
||||
#include "linux/string.h"
|
||||
#include "linux/in6.h"
|
||||
#include "asm/uaccess.h"
|
||||
|
||||
extern __wsum csum_partial(const void *buff, int len, __wsum sum);
|
||||
|
||||
/*
|
||||
* Note: when you get a NULL pointer exception here this means someone
|
||||
* passed in an incorrect kernel address to one of these functions.
|
||||
*
|
||||
* If you use these functions directly please don't forget the
|
||||
* access_ok().
|
||||
*/
|
||||
|
||||
static __inline__
|
||||
__wsum csum_partial_copy_nocheck(const void *src, void *dst,
|
||||
int len, __wsum sum)
|
||||
{
|
||||
memcpy(dst, src, len);
|
||||
return(csum_partial(dst, len, sum));
|
||||
}
|
||||
|
||||
static __inline__
|
||||
__wsum csum_partial_copy_from_user(const void __user *src,
|
||||
void *dst, int len, __wsum sum,
|
||||
int *err_ptr)
|
||||
{
|
||||
if (copy_from_user(dst, src, len)) {
|
||||
*err_ptr = -EFAULT;
|
||||
return (__force __wsum)-1;
|
||||
}
|
||||
return csum_partial(dst, len, sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* csum_fold - Fold and invert a 32bit checksum.
|
||||
* sum: 32bit unfolded sum
|
||||
*
|
||||
* Fold a 32bit running checksum to 16bit and invert it. This is usually
|
||||
* the last step before putting a checksum into a packet.
|
||||
* Make sure not to mix with 64bit checksums.
|
||||
*/
|
||||
static inline __sum16 csum_fold(__wsum sum)
|
||||
{
|
||||
__asm__(
|
||||
" addl %1,%0\n"
|
||||
" adcl $0xffff,%0"
|
||||
: "=r" (sum)
|
||||
: "r" ((__force u32)sum << 16),
|
||||
"0" ((__force u32)sum & 0xffff0000)
|
||||
);
|
||||
return (__force __sum16)(~(__force u32)sum >> 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* csum_tcpup_nofold - Compute an IPv4 pseudo header checksum.
|
||||
* @saddr: source address
|
||||
* @daddr: destination address
|
||||
* @len: length of packet
|
||||
* @proto: ip protocol of packet
|
||||
* @sum: initial sum to be added in (32bit unfolded)
|
||||
*
|
||||
* Returns the pseudo header checksum the input data. Result is
|
||||
* 32bit unfolded.
|
||||
*/
|
||||
static inline __wsum
|
||||
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
|
||||
unsigned short proto, __wsum sum)
|
||||
{
|
||||
asm(" addl %1, %0\n"
|
||||
" adcl %2, %0\n"
|
||||
" adcl %3, %0\n"
|
||||
" adcl $0, %0\n"
|
||||
: "=r" (sum)
|
||||
: "g" (daddr), "g" (saddr), "g" ((len + proto) << 8), "0" (sum));
|
||||
return sum;
|
||||
}
|
||||
|
||||
/*
|
||||
* computes the checksum of the TCP/UDP pseudo-header
|
||||
* returns a 16-bit checksum, already complemented
|
||||
*/
|
||||
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
|
||||
unsigned short len,
|
||||
unsigned short proto,
|
||||
__wsum sum)
|
||||
{
|
||||
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
|
||||
}
|
||||
|
||||
/**
|
||||
* ip_fast_csum - Compute the IPv4 header checksum efficiently.
|
||||
* iph: ipv4 header
|
||||
* ihl: length of header / 4
|
||||
*/
|
||||
static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
|
||||
{
|
||||
unsigned int sum;
|
||||
|
||||
asm( " movl (%1), %0\n"
|
||||
" subl $4, %2\n"
|
||||
" jbe 2f\n"
|
||||
" addl 4(%1), %0\n"
|
||||
" adcl 8(%1), %0\n"
|
||||
" adcl 12(%1), %0\n"
|
||||
"1: adcl 16(%1), %0\n"
|
||||
" lea 4(%1), %1\n"
|
||||
" decl %2\n"
|
||||
" jne 1b\n"
|
||||
" adcl $0, %0\n"
|
||||
" movl %0, %2\n"
|
||||
" shrl $16, %0\n"
|
||||
" addw %w2, %w0\n"
|
||||
" adcl $0, %0\n"
|
||||
" notl %0\n"
|
||||
"2:"
|
||||
/* Since the input registers which are loaded with iph and ipl
|
||||
are modified, we must also specify them as outputs, or gcc
|
||||
will assume they contain their original values. */
|
||||
: "=r" (sum), "=r" (iph), "=r" (ihl)
|
||||
: "1" (iph), "2" (ihl)
|
||||
: "memory");
|
||||
return (__force __sum16)sum;
|
||||
}
|
||||
|
||||
static inline unsigned add32_with_carry(unsigned a, unsigned b)
|
||||
{
|
||||
asm("addl %2,%0\n\t"
|
||||
"adcl $0,%0"
|
||||
: "=r" (a)
|
||||
: "0" (a), "r" (b));
|
||||
return a;
|
||||
}
|
||||
|
||||
extern __sum16 ip_compute_csum(const void *buff, int len);
|
||||
|
||||
#endif
|
||||
29
arch/um/include/sysdep-x86_64/faultinfo.h
Normal file
29
arch/um/include/sysdep-x86_64/faultinfo.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2004 Fujitsu Siemens Computers GmbH
|
||||
* Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __FAULTINFO_X86_64_H
|
||||
#define __FAULTINFO_X86_64_H
|
||||
|
||||
/* this structure contains the full arch-specific faultinfo
|
||||
* from the traps.
|
||||
* On i386, ptrace_faultinfo unfortunately doesn't provide
|
||||
* all the info, since trap_no is missing.
|
||||
* All common elements are defined at the same position in
|
||||
* both structures, thus making it easy to copy the
|
||||
* contents without knowledge about the structure elements.
|
||||
*/
|
||||
struct faultinfo {
|
||||
int error_code; /* in ptrace_faultinfo misleadingly called is_write */
|
||||
unsigned long cr2; /* in ptrace_faultinfo called addr */
|
||||
int trap_no; /* missing in ptrace_faultinfo */
|
||||
};
|
||||
|
||||
#define FAULT_WRITE(fi) ((fi).error_code & 2)
|
||||
#define FAULT_ADDRESS(fi) ((fi).cr2)
|
||||
|
||||
#define PTRACE_FULL_FAULTINFO 1
|
||||
|
||||
#endif
|
||||
23
arch/um/include/sysdep-x86_64/kernel-offsets.h
Normal file
23
arch/um/include/sysdep-x86_64/kernel-offsets.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/elf.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/mman.h>
|
||||
|
||||
#define DEFINE(sym, val) \
|
||||
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
|
||||
|
||||
#define DEFINE_STR1(x) #x
|
||||
#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " DEFINE_STR1(val) " " #val: : )
|
||||
|
||||
#define BLANK() asm volatile("\n->" : : )
|
||||
|
||||
#define OFFSET(sym, str, mem) \
|
||||
DEFINE(sym, offsetof(struct str, mem));
|
||||
|
||||
void foo(void)
|
||||
{
|
||||
#include <common-offsets.h>
|
||||
}
|
||||
273
arch/um/include/sysdep-x86_64/ptrace.h
Normal file
273
arch/um/include/sysdep-x86_64/ptrace.h
Normal file
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* Copyright 2003 PathScale, Inc.
|
||||
*
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_X86_64_PTRACE_H
|
||||
#define __SYSDEP_X86_64_PTRACE_H
|
||||
|
||||
#include "uml-config.h"
|
||||
#include "user_constants.h"
|
||||
#include "sysdep/faultinfo.h"
|
||||
|
||||
#define MAX_REG_OFFSET (UM_FRAME_SIZE)
|
||||
#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
|
||||
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
#include "sysdep/sc.h"
|
||||
#endif
|
||||
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
#include "skas_ptregs.h"
|
||||
|
||||
#define REGS_IP(r) ((r)[HOST_IP])
|
||||
#define REGS_SP(r) ((r)[HOST_SP])
|
||||
|
||||
#define REGS_RBX(r) ((r)[HOST_RBX])
|
||||
#define REGS_RCX(r) ((r)[HOST_RCX])
|
||||
#define REGS_RDX(r) ((r)[HOST_RDX])
|
||||
#define REGS_RSI(r) ((r)[HOST_RSI])
|
||||
#define REGS_RDI(r) ((r)[HOST_RDI])
|
||||
#define REGS_RBP(r) ((r)[HOST_RBP])
|
||||
#define REGS_RAX(r) ((r)[HOST_RAX])
|
||||
#define REGS_R8(r) ((r)[HOST_R8])
|
||||
#define REGS_R9(r) ((r)[HOST_R9])
|
||||
#define REGS_R10(r) ((r)[HOST_R10])
|
||||
#define REGS_R11(r) ((r)[HOST_R11])
|
||||
#define REGS_R12(r) ((r)[HOST_R12])
|
||||
#define REGS_R13(r) ((r)[HOST_R13])
|
||||
#define REGS_R14(r) ((r)[HOST_R14])
|
||||
#define REGS_R15(r) ((r)[HOST_R15])
|
||||
#define REGS_CS(r) ((r)[HOST_CS])
|
||||
#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
|
||||
#define REGS_SS(r) ((r)[HOST_SS])
|
||||
|
||||
#define HOST_FS_BASE 21
|
||||
#define HOST_GS_BASE 22
|
||||
#define HOST_DS 23
|
||||
#define HOST_ES 24
|
||||
#define HOST_FS 25
|
||||
#define HOST_GS 26
|
||||
|
||||
/* Also defined in asm/ptrace-x86_64.h, but not in libc headers. So, these
|
||||
* are already defined for kernel code, but not for userspace code.
|
||||
*/
|
||||
#ifndef FS_BASE
|
||||
/* These aren't defined in ptrace.h, but exist in struct user_regs_struct,
|
||||
* which is what x86_64 ptrace actually uses.
|
||||
*/
|
||||
#define FS_BASE (HOST_FS_BASE * sizeof(long))
|
||||
#define GS_BASE (HOST_GS_BASE * sizeof(long))
|
||||
#define DS (HOST_DS * sizeof(long))
|
||||
#define ES (HOST_ES * sizeof(long))
|
||||
#define FS (HOST_FS * sizeof(long))
|
||||
#define GS (HOST_GS * sizeof(long))
|
||||
#endif
|
||||
|
||||
#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
|
||||
#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
|
||||
#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_ORIG_RAX(r) ((r)[HOST_ORIG_RAX])
|
||||
|
||||
#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
|
||||
|
||||
#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
|
||||
|
||||
#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
|
||||
|
||||
#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
|
||||
|
||||
#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
|
||||
|
||||
#define REGS_TRAP(r) ((r)->trap_type)
|
||||
|
||||
#define REGS_ERR(r) ((r)->fault_type)
|
||||
|
||||
#endif
|
||||
|
||||
#include "choose-mode.h"
|
||||
|
||||
/* XXX */
|
||||
union uml_pt_regs {
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
struct tt_regs {
|
||||
long syscall;
|
||||
unsigned long orig_rax;
|
||||
void *sc;
|
||||
struct faultinfo faultinfo;
|
||||
} tt;
|
||||
#endif
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
struct skas_regs {
|
||||
unsigned long regs[MAX_REG_NR];
|
||||
unsigned long fp[HOST_FP_SIZE];
|
||||
struct faultinfo faultinfo;
|
||||
long syscall;
|
||||
int is_user;
|
||||
} skas;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define EMPTY_UML_PT_REGS { }
|
||||
|
||||
/* XXX */
|
||||
extern int mode_tt;
|
||||
|
||||
#define UPT_RBX(r) __CHOOSE_MODE(SC_RBX(UPT_SC(r)), REGS_RBX((r)->skas.regs))
|
||||
#define UPT_RCX(r) __CHOOSE_MODE(SC_RCX(UPT_SC(r)), REGS_RCX((r)->skas.regs))
|
||||
#define UPT_RDX(r) __CHOOSE_MODE(SC_RDX(UPT_SC(r)), REGS_RDX((r)->skas.regs))
|
||||
#define UPT_RSI(r) __CHOOSE_MODE(SC_RSI(UPT_SC(r)), REGS_RSI((r)->skas.regs))
|
||||
#define UPT_RDI(r) __CHOOSE_MODE(SC_RDI(UPT_SC(r)), REGS_RDI((r)->skas.regs))
|
||||
#define UPT_RBP(r) __CHOOSE_MODE(SC_RBP(UPT_SC(r)), REGS_RBP((r)->skas.regs))
|
||||
#define UPT_RAX(r) __CHOOSE_MODE(SC_RAX(UPT_SC(r)), REGS_RAX((r)->skas.regs))
|
||||
#define UPT_R8(r) __CHOOSE_MODE(SC_R8(UPT_SC(r)), REGS_R8((r)->skas.regs))
|
||||
#define UPT_R9(r) __CHOOSE_MODE(SC_R9(UPT_SC(r)), REGS_R9((r)->skas.regs))
|
||||
#define UPT_R10(r) __CHOOSE_MODE(SC_R10(UPT_SC(r)), REGS_R10((r)->skas.regs))
|
||||
#define UPT_R11(r) __CHOOSE_MODE(SC_R11(UPT_SC(r)), REGS_R11((r)->skas.regs))
|
||||
#define UPT_R12(r) __CHOOSE_MODE(SC_R12(UPT_SC(r)), REGS_R12((r)->skas.regs))
|
||||
#define UPT_R13(r) __CHOOSE_MODE(SC_R13(UPT_SC(r)), REGS_R13((r)->skas.regs))
|
||||
#define UPT_R14(r) __CHOOSE_MODE(SC_R14(UPT_SC(r)), REGS_R14((r)->skas.regs))
|
||||
#define UPT_R15(r) __CHOOSE_MODE(SC_R15(UPT_SC(r)), REGS_R15((r)->skas.regs))
|
||||
#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
|
||||
#define UPT_FS_BASE(r) \
|
||||
__CHOOSE_MODE(SC_FS_BASE(UPT_SC(r)), REGS_FS_BASE((r)->skas.regs))
|
||||
#define UPT_FS(r) __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
|
||||
#define UPT_GS_BASE(r) \
|
||||
__CHOOSE_MODE(SC_GS_BASE(UPT_SC(r)), REGS_GS_BASE((r)->skas.regs))
|
||||
#define UPT_GS(r) __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
|
||||
#define UPT_DS(r) __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
|
||||
#define UPT_ES(r) __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
|
||||
#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
|
||||
#define UPT_SS(r) __CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
|
||||
#define UPT_ORIG_RAX(r) \
|
||||
__CHOOSE_MODE((r)->tt.orig_rax, REGS_ORIG_RAX((r)->skas.regs))
|
||||
|
||||
#define UPT_IP(r) __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
|
||||
#define UPT_SP(r) __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
|
||||
|
||||
#define UPT_EFLAGS(r) \
|
||||
__CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
|
||||
#define UPT_SC(r) ((r)->tt.sc)
|
||||
#define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
|
||||
#define UPT_SYSCALL_RET(r) UPT_RAX(r)
|
||||
|
||||
extern int user_context(unsigned long sp);
|
||||
|
||||
#define UPT_IS_USER(r) \
|
||||
CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
|
||||
|
||||
#define UPT_SYSCALL_ARG1(r) UPT_RDI(r)
|
||||
#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
|
||||
#define UPT_SYSCALL_ARG3(r) UPT_RDX(r)
|
||||
#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
|
||||
#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
|
||||
#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
|
||||
|
||||
struct syscall_args {
|
||||
unsigned long args[6];
|
||||
};
|
||||
|
||||
#define SYSCALL_ARGS(r) ((struct syscall_args) \
|
||||
{ .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) } } )
|
||||
|
||||
#define UPT_REG(regs, reg) \
|
||||
({ unsigned long val; \
|
||||
switch(reg){ \
|
||||
case R8: val = UPT_R8(regs); break; \
|
||||
case R9: val = UPT_R9(regs); break; \
|
||||
case R10: val = UPT_R10(regs); break; \
|
||||
case R11: val = UPT_R11(regs); break; \
|
||||
case R12: val = UPT_R12(regs); break; \
|
||||
case R13: val = UPT_R13(regs); break; \
|
||||
case R14: val = UPT_R14(regs); break; \
|
||||
case R15: val = UPT_R15(regs); break; \
|
||||
case RIP: val = UPT_IP(regs); break; \
|
||||
case RSP: val = UPT_SP(regs); break; \
|
||||
case RAX: val = UPT_RAX(regs); break; \
|
||||
case RBX: val = UPT_RBX(regs); break; \
|
||||
case RCX: val = UPT_RCX(regs); break; \
|
||||
case RDX: val = UPT_RDX(regs); break; \
|
||||
case RSI: val = UPT_RSI(regs); break; \
|
||||
case RDI: val = UPT_RDI(regs); break; \
|
||||
case RBP: val = UPT_RBP(regs); break; \
|
||||
case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \
|
||||
case CS: val = UPT_CS(regs); break; \
|
||||
case SS: val = UPT_SS(regs); break; \
|
||||
case FS_BASE: val = UPT_FS_BASE(regs); break; \
|
||||
case GS_BASE: val = UPT_GS_BASE(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 EFLAGS: val = UPT_EFLAGS(regs); break; \
|
||||
default : \
|
||||
panic("Bad register in UPT_REG : %d\n", reg); \
|
||||
val = -1; \
|
||||
} \
|
||||
val; \
|
||||
})
|
||||
|
||||
|
||||
#define UPT_SET(regs, reg, val) \
|
||||
({ unsigned long __upt_val = val; \
|
||||
switch(reg){ \
|
||||
case R8: UPT_R8(regs) = __upt_val; break; \
|
||||
case R9: UPT_R9(regs) = __upt_val; break; \
|
||||
case R10: UPT_R10(regs) = __upt_val; break; \
|
||||
case R11: UPT_R11(regs) = __upt_val; break; \
|
||||
case R12: UPT_R12(regs) = __upt_val; break; \
|
||||
case R13: UPT_R13(regs) = __upt_val; break; \
|
||||
case R14: UPT_R14(regs) = __upt_val; break; \
|
||||
case R15: UPT_R15(regs) = __upt_val; break; \
|
||||
case RIP: UPT_IP(regs) = __upt_val; break; \
|
||||
case RSP: UPT_SP(regs) = __upt_val; break; \
|
||||
case RAX: UPT_RAX(regs) = __upt_val; break; \
|
||||
case RBX: UPT_RBX(regs) = __upt_val; break; \
|
||||
case RCX: UPT_RCX(regs) = __upt_val; break; \
|
||||
case RDX: UPT_RDX(regs) = __upt_val; break; \
|
||||
case RSI: UPT_RSI(regs) = __upt_val; break; \
|
||||
case RDI: UPT_RDI(regs) = __upt_val; break; \
|
||||
case RBP: UPT_RBP(regs) = __upt_val; break; \
|
||||
case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
|
||||
case CS: UPT_CS(regs) = __upt_val; break; \
|
||||
case SS: UPT_SS(regs) = __upt_val; break; \
|
||||
case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break; \
|
||||
case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break; \
|
||||
case DS: UPT_DS(regs) = __upt_val; break; \
|
||||
case ES: UPT_ES(regs) = __upt_val; break; \
|
||||
case FS: UPT_FS(regs) = __upt_val; break; \
|
||||
case GS: UPT_GS(regs) = __upt_val; break; \
|
||||
case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
|
||||
default : \
|
||||
panic("Bad register in UPT_SET : %d\n", reg); \
|
||||
break; \
|
||||
} \
|
||||
__upt_val; \
|
||||
})
|
||||
|
||||
#define UPT_SET_SYSCALL_RETURN(r, res) \
|
||||
CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
|
||||
REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
|
||||
|
||||
#define UPT_RESTART_SYSCALL(r) \
|
||||
CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
|
||||
REGS_RESTART_SYSCALL((r)->skas.regs))
|
||||
|
||||
#define UPT_SEGV_IS_FIXABLE(r) \
|
||||
CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
|
||||
REGS_SEGV_IS_FIXABLE(&r->skas))
|
||||
|
||||
#define UPT_FAULTINFO(r) \
|
||||
CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
|
||||
|
||||
#endif
|
||||
83
arch/um/include/sysdep-x86_64/ptrace_user.h
Normal file
83
arch/um/include/sysdep-x86_64/ptrace_user.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2003 PathScale, Inc.
|
||||
*
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_X86_64_PTRACE_USER_H__
|
||||
#define __SYSDEP_X86_64_PTRACE_USER_H__
|
||||
|
||||
#define __FRAME_OFFSETS
|
||||
#include <sys/ptrace.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <asm/ptrace.h>
|
||||
#undef __FRAME_OFFSETS
|
||||
|
||||
#define PT_INDEX(off) ((off) / sizeof(unsigned long))
|
||||
|
||||
#define PT_SYSCALL_NR(regs) ((regs)[PT_INDEX(ORIG_RAX)])
|
||||
#define PT_SYSCALL_NR_OFFSET (ORIG_RAX)
|
||||
|
||||
#define PT_SYSCALL_ARG1(regs) (((unsigned long *) (regs))[PT_INDEX(RDI)])
|
||||
#define PT_SYSCALL_ARG1_OFFSET (RDI)
|
||||
|
||||
#define PT_SYSCALL_ARG2(regs) (((unsigned long *) (regs))[PT_INDEX(RSI)])
|
||||
#define PT_SYSCALL_ARG2_OFFSET (RSI)
|
||||
|
||||
#define PT_SYSCALL_ARG3(regs) (((unsigned long *) (regs))[PT_INDEX(RDX)])
|
||||
#define PT_SYSCALL_ARG3_OFFSET (RDX)
|
||||
|
||||
#define PT_SYSCALL_ARG4(regs) (((unsigned long *) (regs))[PT_INDEX(RCX)])
|
||||
#define PT_SYSCALL_ARG4_OFFSET (RCX)
|
||||
|
||||
#define PT_SYSCALL_ARG5(regs) (((unsigned long *) (regs))[PT_INDEX(R8)])
|
||||
#define PT_SYSCALL_ARG5_OFFSET (R8)
|
||||
|
||||
#define PT_SYSCALL_ARG6(regs) (((unsigned long *) (regs))[PT_INDEX(R9)])
|
||||
#define PT_SYSCALL_ARG6_OFFSET (R9)
|
||||
|
||||
#define PT_SYSCALL_RET_OFFSET (RAX)
|
||||
|
||||
#define PT_IP_OFFSET (RIP)
|
||||
#define PT_IP(regs) ((regs)[PT_INDEX(RIP)])
|
||||
|
||||
#define PT_SP_OFFSET (RSP)
|
||||
#define PT_SP(regs) ((regs)[PT_INDEX(RSP)])
|
||||
|
||||
#define PT_ORIG_RAX_OFFSET (ORIG_RAX)
|
||||
#define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)])
|
||||
|
||||
/* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
|
||||
* it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
|
||||
* 2.4 name and value for 2.4 host compatibility.
|
||||
*/
|
||||
#ifndef PTRACE_OLDSETOPTIONS
|
||||
#define PTRACE_OLDSETOPTIONS 21
|
||||
#endif
|
||||
|
||||
/* These are before the system call, so the system call number is RAX
|
||||
* rather than ORIG_RAX, and arg4 is R10 rather than RCX
|
||||
*/
|
||||
#define REGS_SYSCALL_NR PT_INDEX(RAX)
|
||||
#define REGS_SYSCALL_ARG1 PT_INDEX(RDI)
|
||||
#define REGS_SYSCALL_ARG2 PT_INDEX(RSI)
|
||||
#define REGS_SYSCALL_ARG3 PT_INDEX(RDX)
|
||||
#define REGS_SYSCALL_ARG4 PT_INDEX(R10)
|
||||
#define REGS_SYSCALL_ARG5 PT_INDEX(R8)
|
||||
#define REGS_SYSCALL_ARG6 PT_INDEX(R9)
|
||||
|
||||
#define REGS_IP_INDEX PT_INDEX(RIP)
|
||||
#define REGS_SP_INDEX PT_INDEX(RSP)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
45
arch/um/include/sysdep-x86_64/sc.h
Normal file
45
arch/um/include/sysdep-x86_64/sc.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef __SYSDEP_X86_64_SC_H
|
||||
#define __SYSDEP_X86_64_SC_H
|
||||
|
||||
/* Copyright (C) 2003 - 2004 PathScale, Inc
|
||||
* Released under the GPL
|
||||
*/
|
||||
|
||||
#include <user_constants.h>
|
||||
|
||||
#define SC_OFFSET(sc, field) \
|
||||
*((unsigned long *) &(((char *) (sc))[HOST_##field]))
|
||||
|
||||
#define SC_RBX(sc) SC_OFFSET(sc, SC_RBX)
|
||||
#define SC_RCX(sc) SC_OFFSET(sc, SC_RCX)
|
||||
#define SC_RDX(sc) SC_OFFSET(sc, SC_RDX)
|
||||
#define SC_RSI(sc) SC_OFFSET(sc, SC_RSI)
|
||||
#define SC_RDI(sc) SC_OFFSET(sc, SC_RDI)
|
||||
#define SC_RBP(sc) SC_OFFSET(sc, SC_RBP)
|
||||
#define SC_RAX(sc) SC_OFFSET(sc, SC_RAX)
|
||||
#define SC_R8(sc) SC_OFFSET(sc, SC_R8)
|
||||
#define SC_R9(sc) SC_OFFSET(sc, SC_R9)
|
||||
#define SC_R10(sc) SC_OFFSET(sc, SC_R10)
|
||||
#define SC_R11(sc) SC_OFFSET(sc, SC_R11)
|
||||
#define SC_R12(sc) SC_OFFSET(sc, SC_R12)
|
||||
#define SC_R13(sc) SC_OFFSET(sc, SC_R13)
|
||||
#define SC_R14(sc) SC_OFFSET(sc, SC_R14)
|
||||
#define SC_R15(sc) SC_OFFSET(sc, SC_R15)
|
||||
#define SC_IP(sc) SC_OFFSET(sc, SC_IP)
|
||||
#define SC_SP(sc) SC_OFFSET(sc, SC_SP)
|
||||
#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2)
|
||||
#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR)
|
||||
#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO)
|
||||
#define SC_CS(sc) SC_OFFSET(sc, SC_CS)
|
||||
#define SC_FS(sc) SC_OFFSET(sc, SC_FS)
|
||||
#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
|
||||
#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
|
||||
#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
|
||||
#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
|
||||
#if 0
|
||||
#define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX)
|
||||
#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
|
||||
#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
53
arch/um/include/sysdep-x86_64/sigcontext.h
Normal file
53
arch/um/include/sysdep-x86_64/sigcontext.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2003 PathScale, Inc.
|
||||
*
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_X86_64_SIGCONTEXT_H
|
||||
#define __SYSDEP_X86_64_SIGCONTEXT_H
|
||||
|
||||
#include <sysdep/sc.h>
|
||||
|
||||
#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
|
||||
|
||||
#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
|
||||
#define SC_SET_SYSCALL_RETURN(sc, result) SC_RAX(sc) = (result)
|
||||
|
||||
#define SC_FAULT_ADDR(sc) SC_CR2(sc)
|
||||
#define SC_FAULT_TYPE(sc) SC_ERR(sc)
|
||||
|
||||
#define GET_FAULTINFO_FROM_SC(fi,sc) \
|
||||
{ \
|
||||
(fi).cr2 = SC_CR2(sc); \
|
||||
(fi).error_code = SC_ERR(sc); \
|
||||
(fi).trap_no = SC_TRAPNO(sc); \
|
||||
}
|
||||
|
||||
/* ptrace expects that, at the start of a system call, %eax contains
|
||||
* -ENOSYS, so this makes it so.
|
||||
*/
|
||||
|
||||
#define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0)
|
||||
|
||||
/* This is Page Fault */
|
||||
#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
|
||||
|
||||
/* No broken SKAS API, which doesn't pass trap_no, here. */
|
||||
#define SEGV_MAYBE_FIXABLE(fi) 0
|
||||
|
||||
extern unsigned long *sc_sigmask(void *sc_ptr);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
|
||||
22
arch/um/include/sysdep-x86_64/skas_ptrace.h
Normal file
22
arch/um/include/sysdep-x86_64/skas_ptrace.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_X86_64_SKAS_PTRACE_H
|
||||
#define __SYSDEP_X86_64_SKAS_PTRACE_H
|
||||
|
||||
struct ptrace_faultinfo {
|
||||
int is_write;
|
||||
unsigned long addr;
|
||||
};
|
||||
|
||||
struct ptrace_ldt {
|
||||
int func;
|
||||
void *ptr;
|
||||
unsigned long bytecount;
|
||||
};
|
||||
|
||||
#define PTRACE_LDT 54
|
||||
|
||||
#endif
|
||||
107
arch/um/include/sysdep-x86_64/stub.h
Normal file
107
arch/um/include/sysdep-x86_64/stub.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_STUB_H
|
||||
#define __SYSDEP_STUB_H
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <asm/unistd.h>
|
||||
#include <sysdep/ptrace_user.h>
|
||||
#include "stub-data.h"
|
||||
#include "kern_constants.h"
|
||||
#include "uml-config.h"
|
||||
|
||||
extern void stub_segv_handler(int sig);
|
||||
extern void stub_clone_handler(void);
|
||||
|
||||
#define STUB_SYSCALL_RET PT_INDEX(RAX)
|
||||
#define STUB_MMAP_NR __NR_mmap
|
||||
#define MMAP_OFFSET(o) (o)
|
||||
|
||||
#define __syscall_clobber "r11","rcx","memory"
|
||||
#define __syscall "syscall"
|
||||
|
||||
static inline long stub_syscall0(long syscall)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile (__syscall
|
||||
: "=a" (ret)
|
||||
: "0" (syscall) : __syscall_clobber );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall2(long syscall, long arg1, long arg2)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile (__syscall
|
||||
: "=a" (ret)
|
||||
: "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile (__syscall
|
||||
: "=a" (ret)
|
||||
: "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
|
||||
: __syscall_clobber );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
|
||||
long arg4)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("movq %5,%%r10 ; " __syscall
|
||||
: "=a" (ret)
|
||||
: "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
|
||||
"g" (arg4)
|
||||
: __syscall_clobber, "r10" );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
|
||||
long arg4, long arg5)
|
||||
{
|
||||
long ret;
|
||||
|
||||
__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
|
||||
: "=a" (ret)
|
||||
: "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
|
||||
"g" (arg4), "g" (arg5)
|
||||
: __syscall_clobber, "r10", "r8" );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void trap_myself(void)
|
||||
{
|
||||
__asm("int3");
|
||||
}
|
||||
|
||||
static inline void remap_stack(long fd, unsigned long offset)
|
||||
{
|
||||
__asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
|
||||
"movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
|
||||
"movq %%rax, (%%rbx)":
|
||||
: "a" (STUB_MMAP_NR), "D" (UML_CONFIG_STUB_DATA),
|
||||
"S" (UM_KERN_PAGE_SIZE),
|
||||
"d" (PROT_READ | PROT_WRITE),
|
||||
"g" (MAP_FIXED | MAP_SHARED), "g" (fd),
|
||||
"g" (offset),
|
||||
"i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
|
||||
: __syscall_clobber, "r10", "r8", "r9" );
|
||||
}
|
||||
|
||||
#endif
|
||||
34
arch/um/include/sysdep-x86_64/syscalls.h
Normal file
34
arch/um/include/sysdep-x86_64/syscalls.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2003 PathScale, Inc.
|
||||
*
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __SYSDEP_X86_64_SYSCALLS_H__
|
||||
#define __SYSDEP_X86_64_SYSCALLS_H__
|
||||
|
||||
#include <linux/msg.h>
|
||||
#include <linux/shm.h>
|
||||
|
||||
typedef long syscall_handler_t(void);
|
||||
|
||||
extern syscall_handler_t *sys_call_table[];
|
||||
|
||||
#define EXECUTE_SYSCALL(syscall, regs) \
|
||||
(((long (*)(long, long, long, long, long, long)) \
|
||||
(*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(®s->regs), \
|
||||
UPT_SYSCALL_ARG2(®s->regs), \
|
||||
UPT_SYSCALL_ARG3(®s->regs), \
|
||||
UPT_SYSCALL_ARG4(®s->regs), \
|
||||
UPT_SYSCALL_ARG5(®s->regs), \
|
||||
UPT_SYSCALL_ARG6(®s->regs)))
|
||||
|
||||
extern long old_mmap(unsigned long addr, unsigned long len,
|
||||
unsigned long prot, unsigned long flags,
|
||||
unsigned long fd, unsigned long pgoff);
|
||||
extern syscall_handler_t sys_modify_ldt;
|
||||
extern syscall_handler_t sys_arch_prctl;
|
||||
|
||||
#define NR_syscalls (__NR_syscall_max + 1)
|
||||
|
||||
#endif
|
||||
10
arch/um/include/sysdep-x86_64/thread.h
Normal file
10
arch/um/include/sysdep-x86_64/thread.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __UM_THREAD_H
|
||||
#define __UM_THREAD_H
|
||||
|
||||
#include <kern_constants.h>
|
||||
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
29
arch/um/include/sysdep-x86_64/tls.h
Normal file
29
arch/um/include/sysdep-x86_64/tls.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef _SYSDEP_TLS_H
|
||||
#define _SYSDEP_TLS_H
|
||||
|
||||
# ifndef __KERNEL__
|
||||
|
||||
/* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
|
||||
* may be named user_desc (but in 2.4 and in header matching its API was named
|
||||
* modify_ldt_ldt_s). */
|
||||
|
||||
typedef struct um_dup_user_desc {
|
||||
unsigned int entry_number;
|
||||
unsigned int base_addr;
|
||||
unsigned int limit;
|
||||
unsigned int seg_32bit:1;
|
||||
unsigned int contents:2;
|
||||
unsigned int read_exec_only:1;
|
||||
unsigned int limit_in_pages:1;
|
||||
unsigned int seg_not_present:1;
|
||||
unsigned int useable:1;
|
||||
unsigned int lm:1;
|
||||
} user_desc_t;
|
||||
|
||||
# else /* __KERNEL__ */
|
||||
|
||||
# include <asm/ldt.h>
|
||||
typedef struct user_desc user_desc_t;
|
||||
|
||||
# endif /* __KERNEL__ */
|
||||
#endif /* _SYSDEP_TLS_H */
|
||||
7
arch/um/include/sysrq.h
Normal file
7
arch/um/include/sysrq.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __UM_SYSRQ_H
|
||||
#define __UM_SYSRQ_H
|
||||
|
||||
struct task_struct;
|
||||
extern void show_trace(struct task_struct* task, unsigned long *stack);
|
||||
|
||||
#endif
|
||||
9
arch/um/include/task.h
Normal file
9
arch/um/include/task.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef __TASK_H
|
||||
#define __TASK_H
|
||||
|
||||
#include <kern_constants.h>
|
||||
|
||||
#define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS]))
|
||||
#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID]))
|
||||
|
||||
#endif
|
||||
11
arch/um/include/tempfile.h
Normal file
11
arch/um/include/tempfile.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __TEMPFILE_H__
|
||||
#define __TEMPFILE_H__
|
||||
|
||||
extern int make_tempfile(const char *template, char **tempname, int do_unlink);
|
||||
|
||||
#endif
|
||||
46
arch/um/include/tlb.h
Normal file
46
arch/um/include/tlb.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __TLB_H__
|
||||
#define __TLB_H__
|
||||
|
||||
#include "um_mmu.h"
|
||||
|
||||
struct host_vm_op {
|
||||
enum { NONE, MMAP, MUNMAP, MPROTECT } type;
|
||||
union {
|
||||
struct {
|
||||
unsigned long addr;
|
||||
unsigned long len;
|
||||
unsigned int r:1;
|
||||
unsigned int w:1;
|
||||
unsigned int x:1;
|
||||
int fd;
|
||||
__u64 offset;
|
||||
} mmap;
|
||||
struct {
|
||||
unsigned long addr;
|
||||
unsigned long len;
|
||||
} munmap;
|
||||
struct {
|
||||
unsigned long addr;
|
||||
unsigned long len;
|
||||
unsigned int r:1;
|
||||
unsigned int w:1;
|
||||
unsigned int x:1;
|
||||
} mprotect;
|
||||
} u;
|
||||
};
|
||||
|
||||
extern void force_flush_all(void);
|
||||
extern void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
|
||||
unsigned long end_addr, int force,
|
||||
int (*do_ops)(union mm_context *,
|
||||
struct host_vm_op *, int, int,
|
||||
void **));
|
||||
extern int flush_tlb_kernel_range_common(unsigned long start,
|
||||
unsigned long end);
|
||||
|
||||
#endif
|
||||
18
arch/um/include/tt/debug.h
Normal file
18
arch/um/include/tt/debug.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) and
|
||||
* Lars Brinkhoff.
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UML_TT_DEBUG_H
|
||||
#define __UML_TT_DEBUG_H
|
||||
|
||||
extern int debugger_proxy(int status, pid_t pid);
|
||||
extern void child_proxy(pid_t pid, int status);
|
||||
extern void init_proxy (pid_t pid, int waiting, int status);
|
||||
extern int start_debugger(char *prog, int startup, int stop, int *debugger_fd);
|
||||
extern void fake_child_exit(void);
|
||||
extern int gdb_config(char *str);
|
||||
extern int gdb_remove(int unused);
|
||||
|
||||
#endif
|
||||
12
arch/um/include/tt/mmu-tt.h
Normal file
12
arch/um/include/tt/mmu-tt.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __TT_MMU_H
|
||||
#define __TT_MMU_H
|
||||
|
||||
struct mmu_context_tt {
|
||||
};
|
||||
|
||||
#endif
|
||||
23
arch/um/include/tt/mode-tt.h
Normal file
23
arch/um/include/tt/mode-tt.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __MODE_TT_H__
|
||||
#define __MODE_TT_H__
|
||||
|
||||
#include "sysdep/ptrace.h"
|
||||
|
||||
enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
|
||||
|
||||
extern int tracing_pid;
|
||||
|
||||
extern int tracer(int (*init_proc)(void *), void *sp);
|
||||
extern void sig_handler_common_tt(int sig, void *sc);
|
||||
extern void syscall_handler_tt(int sig, union uml_pt_regs *regs);
|
||||
extern void reboot_tt(void);
|
||||
extern void halt_tt(void);
|
||||
extern int is_tracer_winch(int pid, int fd, void *data);
|
||||
extern void kill_off_processes_tt(void);
|
||||
|
||||
#endif
|
||||
40
arch/um/include/tt/mode_kern_tt.h
Normal file
40
arch/um/include/tt/mode_kern_tt.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __TT_MODE_KERN_H__
|
||||
#define __TT_MODE_KERN_H__
|
||||
|
||||
#include "linux/sched.h"
|
||||
#include "asm/page.h"
|
||||
#include "asm/ptrace.h"
|
||||
#include "asm/uaccess.h"
|
||||
|
||||
extern void switch_to_tt(void *prev, void *next);
|
||||
extern void flush_thread_tt(void);
|
||||
extern void start_thread_tt(struct pt_regs *regs, unsigned long eip,
|
||||
unsigned long esp);
|
||||
extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
|
||||
unsigned long stack_top, struct task_struct *p,
|
||||
struct pt_regs *regs);
|
||||
extern void release_thread_tt(struct task_struct *task);
|
||||
extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
|
||||
extern void init_idle_tt(void);
|
||||
extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end);
|
||||
extern void flush_tlb_kernel_vm_tt(void);
|
||||
extern void __flush_tlb_one_tt(unsigned long addr);
|
||||
extern void flush_tlb_range_tt(struct vm_area_struct *vma,
|
||||
unsigned long start, unsigned long end);
|
||||
extern void flush_tlb_mm_tt(struct mm_struct *mm);
|
||||
extern void force_flush_all_tt(void);
|
||||
extern long execute_syscall_tt(void *r);
|
||||
extern void before_mem_tt(unsigned long brk_start);
|
||||
extern unsigned long set_task_sizes_tt(unsigned long *task_size_out);
|
||||
extern int start_uml_tt(void);
|
||||
extern int external_pid_tt(struct task_struct *task);
|
||||
extern int thread_pid_tt(struct task_struct *task);
|
||||
|
||||
#define kmem_end_tt (host_task_size - ABOVE_KMEM)
|
||||
|
||||
#endif
|
||||
37
arch/um/include/tt/tt.h
Normal file
37
arch/um/include/tt/tt.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __TT_H__
|
||||
#define __TT_H__
|
||||
|
||||
#include "sysdep/ptrace.h"
|
||||
|
||||
extern int gdb_pid;
|
||||
extern int debug;
|
||||
extern int debug_stop;
|
||||
extern int debug_trace;
|
||||
|
||||
extern int honeypot;
|
||||
|
||||
extern int fork_tramp(void *sig_stack);
|
||||
extern int do_proc_op(void *t, int proc_id);
|
||||
extern int tracer(int (*init_proc)(void *), void *sp);
|
||||
extern void attach_process(int pid);
|
||||
extern void tracer_panic(char *format, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
extern void set_init_pid(int pid);
|
||||
extern int set_user_mode(void *task);
|
||||
extern void set_tracing(void *t, int tracing);
|
||||
extern int is_tracing(void *task);
|
||||
extern void syscall_handler(int sig, union uml_pt_regs *regs);
|
||||
extern void exit_kernel(int pid, void *task);
|
||||
extern void do_syscall(void *task, int pid, int local_using_sysemu);
|
||||
extern void do_sigtrap(void *task);
|
||||
extern int is_valid_pid(int pid);
|
||||
extern void remap_data(void *segment_start, void *segment_end, int w);
|
||||
extern long execute_syscall_tt(void *r);
|
||||
|
||||
#endif
|
||||
|
||||
48
arch/um/include/tt/uaccess-tt.h
Normal file
48
arch/um/include/tt/uaccess-tt.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __TT_UACCESS_H
|
||||
#define __TT_UACCESS_H
|
||||
|
||||
#include "linux/string.h"
|
||||
#include "linux/sched.h"
|
||||
#include "asm/processor.h"
|
||||
#include "asm/errno.h"
|
||||
#include "asm/current.h"
|
||||
#include "asm/a.out.h"
|
||||
#include "uml_uaccess.h"
|
||||
|
||||
#define ABOVE_KMEM (16 * 1024 * 1024)
|
||||
|
||||
extern unsigned long end_vm;
|
||||
extern unsigned long uml_physmem;
|
||||
|
||||
#define is_stack(addr, size) \
|
||||
(((unsigned long) (addr) < STACK_TOP) && \
|
||||
((unsigned long) (addr) >= STACK_TOP - ABOVE_KMEM) && \
|
||||
(((unsigned long) (addr) + (size)) <= STACK_TOP))
|
||||
|
||||
#define access_ok_tt(type, addr, size) \
|
||||
(is_stack(addr, size))
|
||||
|
||||
extern unsigned long get_fault_addr(void);
|
||||
|
||||
extern int __do_copy_from_user(void *to, const void *from, int n,
|
||||
void **fault_addr, void **fault_catcher);
|
||||
extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
|
||||
void **fault_addr, void **fault_catcher);
|
||||
extern int __do_clear_user(void *mem, size_t len, void **fault_addr,
|
||||
void **fault_catcher);
|
||||
extern int __do_strnlen_user(const char *str, unsigned long n,
|
||||
void **fault_addr, void **fault_catcher);
|
||||
|
||||
extern int copy_from_user_tt(void *to, const void __user *from, int n);
|
||||
extern int copy_to_user_tt(void __user *to, const void *from, int n);
|
||||
extern int strncpy_from_user_tt(char *dst, const char __user *src, int count);
|
||||
extern int __clear_user_tt(void __user *mem, int len);
|
||||
extern int clear_user_tt(void __user *mem, int len);
|
||||
extern int strnlen_user_tt(const void __user *str, int len);
|
||||
|
||||
#endif
|
||||
26
arch/um/include/ubd_user.h
Normal file
26
arch/um/include/ubd_user.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Copyright (C) 2001 RidgeRun, Inc (glonnon@ridgerun.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UM_UBD_USER_H
|
||||
#define __UM_UBD_USER_H
|
||||
|
||||
extern void ignore_sigwinch_sig(void);
|
||||
extern int start_io_thread(unsigned long sp, int *fds_out);
|
||||
extern int io_thread(void *arg);
|
||||
extern int kernel_fd;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
17
arch/um/include/um_malloc.h
Normal file
17
arch/um/include/um_malloc.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UM_MALLOC_H__
|
||||
#define __UM_MALLOC_H__
|
||||
|
||||
extern void *um_kmalloc(int size);
|
||||
extern void *um_kmalloc_atomic(int size);
|
||||
extern void kfree(const void *ptr);
|
||||
|
||||
extern void *um_vmalloc(int size);
|
||||
extern void *um_vmalloc_atomic(int size);
|
||||
extern void vfree(void *ptr);
|
||||
|
||||
#endif /* __UM_MALLOC_H__ */
|
||||
40
arch/um/include/um_mmu.h
Normal file
40
arch/um/include/um_mmu.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_UM_MMU_H
|
||||
#define __ARCH_UM_MMU_H
|
||||
|
||||
#include "uml-config.h"
|
||||
#include "choose-mode.h"
|
||||
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
#include "mmu-tt.h"
|
||||
#endif
|
||||
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
#include "mmu-skas.h"
|
||||
#endif
|
||||
|
||||
typedef union mm_context {
|
||||
#ifdef UML_CONFIG_MODE_TT
|
||||
struct mmu_context_tt tt;
|
||||
#endif
|
||||
#ifdef UML_CONFIG_MODE_SKAS
|
||||
struct mmu_context_skas skas;
|
||||
#endif
|
||||
} mm_context_t;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
136
arch/um/include/um_uaccess.h
Normal file
136
arch/um/include/um_uaccess.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_UM_UACCESS_H
|
||||
#define __ARCH_UM_UACCESS_H
|
||||
|
||||
#include "choose-mode.h"
|
||||
|
||||
#ifdef CONFIG_MODE_TT
|
||||
#include "uaccess-tt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODE_SKAS
|
||||
#include "uaccess-skas.h"
|
||||
#endif
|
||||
|
||||
#include "asm/fixmap.h"
|
||||
|
||||
#define __under_task_size(addr, size) \
|
||||
(((unsigned long) (addr) < TASK_SIZE) && \
|
||||
(((unsigned long) (addr) + (size)) < TASK_SIZE))
|
||||
|
||||
#define __access_ok_vsyscall(type, addr, size) \
|
||||
((type == VERIFY_READ) && \
|
||||
((unsigned long) (addr) >= FIXADDR_USER_START) && \
|
||||
((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
|
||||
((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
|
||||
|
||||
#define __addr_range_nowrap(addr, size) \
|
||||
((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
|
||||
|
||||
#define access_ok(type, addr, size) \
|
||||
(__addr_range_nowrap(addr, size) && \
|
||||
(__under_task_size(addr, size) || \
|
||||
__access_ok_vsyscall(type, addr, size) || \
|
||||
segment_eq(get_fs(), KERNEL_DS) || \
|
||||
CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)))
|
||||
|
||||
static inline int copy_from_user(void *to, const void __user *from, int n)
|
||||
{
|
||||
return(CHOOSE_MODE_PROC(copy_from_user_tt, copy_from_user_skas, to,
|
||||
from, n));
|
||||
}
|
||||
|
||||
static inline int copy_to_user(void __user *to, const void *from, int n)
|
||||
{
|
||||
return(CHOOSE_MODE_PROC(copy_to_user_tt, copy_to_user_skas, to,
|
||||
from, n));
|
||||
}
|
||||
|
||||
/*
|
||||
* strncpy_from_user: - Copy a NUL terminated string from userspace.
|
||||
* @dst: Destination address, in kernel space. This buffer must be at
|
||||
* least @count bytes long.
|
||||
* @src: Source address, in user space.
|
||||
* @count: Maximum number of bytes to copy, including the trailing NUL.
|
||||
*
|
||||
* Copies a NUL-terminated string from userspace to kernel space.
|
||||
*
|
||||
* On success, returns the length of the string (not including the trailing
|
||||
* NUL).
|
||||
*
|
||||
* If access to userspace fails, returns -EFAULT (some data may have been
|
||||
* copied).
|
||||
*
|
||||
* If @count is smaller than the length of the string, copies @count bytes
|
||||
* and returns @count.
|
||||
*/
|
||||
|
||||
static inline int strncpy_from_user(char *dst, const char __user *src, int count)
|
||||
{
|
||||
return(CHOOSE_MODE_PROC(strncpy_from_user_tt, strncpy_from_user_skas,
|
||||
dst, src, count));
|
||||
}
|
||||
|
||||
/*
|
||||
* __clear_user: - Zero a block of memory in user space, with less checking.
|
||||
* @to: Destination address, in user space.
|
||||
* @n: Number of bytes to zero.
|
||||
*
|
||||
* Zero a block of memory in user space. Caller must check
|
||||
* the specified block with access_ok() before calling this function.
|
||||
*
|
||||
* Returns number of bytes that could not be cleared.
|
||||
* On success, this will be zero.
|
||||
*/
|
||||
static inline int __clear_user(void *mem, int len)
|
||||
{
|
||||
return(CHOOSE_MODE_PROC(__clear_user_tt, __clear_user_skas, mem, len));
|
||||
}
|
||||
|
||||
/*
|
||||
* clear_user: - Zero a block of memory in user space.
|
||||
* @to: Destination address, in user space.
|
||||
* @n: Number of bytes to zero.
|
||||
*
|
||||
* Zero a block of memory in user space.
|
||||
*
|
||||
* Returns number of bytes that could not be cleared.
|
||||
* On success, this will be zero.
|
||||
*/
|
||||
static inline int clear_user(void __user *mem, int len)
|
||||
{
|
||||
return(CHOOSE_MODE_PROC(clear_user_tt, clear_user_skas, mem, len));
|
||||
}
|
||||
|
||||
/*
|
||||
* strlen_user: - Get the size of a string in user space.
|
||||
* @str: The string to measure.
|
||||
* @n: The maximum valid length
|
||||
*
|
||||
* Get the size of a NUL-terminated string in user space.
|
||||
*
|
||||
* Returns the size of the string INCLUDING the terminating NUL.
|
||||
* On exception, returns 0.
|
||||
* If the string is too long, returns a value greater than @n.
|
||||
*/
|
||||
static inline int strnlen_user(const void __user *str, long len)
|
||||
{
|
||||
return(CHOOSE_MODE_PROC(strnlen_user_tt, strnlen_user_skas, str, len));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
24
arch/um/include/uml_uaccess.h
Normal file
24
arch/um/include/uml_uaccess.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __UML_UACCESS_H__
|
||||
#define __UML_UACCESS_H__
|
||||
|
||||
extern int __do_copy_to_user(void *to, const void *from, int n,
|
||||
void **fault_addr, void **fault_catcher);
|
||||
void __do_copy(void *to, const void *from, int n);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
31
arch/um/include/user.h
Normal file
31
arch/um/include/user.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __USER_H__
|
||||
#define __USER_H__
|
||||
|
||||
extern void panic(const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
extern int printk(const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
extern void schedule(void);
|
||||
extern int in_aton(char *str);
|
||||
extern int open_gdb_chan(void);
|
||||
/* These use size_t, however unsigned long is correct on both i386 and x86_64. */
|
||||
extern unsigned long strlcpy(char *, const char *, unsigned long);
|
||||
extern unsigned long strlcat(char *, const char *, unsigned long);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
||||
* Emacs will notice this stuff at the end of the file and automatically
|
||||
* adjust the settings for this buffer only. This must remain at the end
|
||||
* of the file.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
69
arch/um/include/user_util.h
Normal file
69
arch/um/include/user_util.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
|
||||
#ifndef __USER_UTIL_H__
|
||||
#define __USER_UTIL_H__
|
||||
|
||||
#include "sysdep/ptrace.h"
|
||||
|
||||
/* Copied from kernel.h */
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
|
||||
|
||||
extern int mode_tt;
|
||||
|
||||
extern int grantpt(int __fd);
|
||||
extern int unlockpt(int __fd);
|
||||
extern char *ptsname(int __fd);
|
||||
|
||||
struct cpu_task {
|
||||
int pid;
|
||||
void *task;
|
||||
};
|
||||
|
||||
extern struct cpu_task cpu_tasks[];
|
||||
|
||||
extern void (*sig_info[])(int, union uml_pt_regs *);
|
||||
|
||||
extern unsigned long low_physmem;
|
||||
extern unsigned long high_physmem;
|
||||
extern unsigned long uml_physmem;
|
||||
extern unsigned long uml_reserved;
|
||||
extern unsigned long end_vm;
|
||||
extern unsigned long start_vm;
|
||||
extern unsigned long long highmem;
|
||||
|
||||
extern char host_info[];
|
||||
|
||||
extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end;
|
||||
extern unsigned long _unprotected_end;
|
||||
extern unsigned long brk_start;
|
||||
|
||||
extern int pty_output_sigio;
|
||||
extern int pty_close_sigio;
|
||||
|
||||
extern void *add_signal_handler(int sig, void (*handler)(int));
|
||||
extern int linux_main(int argc, char **argv);
|
||||
extern void set_cmdline(char *cmd);
|
||||
extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
|
||||
extern int get_pty(void);
|
||||
extern int switcheroo(int fd, int prot, void *from, void *to, int size);
|
||||
extern void do_exec(int old_pid, int new_pid);
|
||||
extern void tracer_panic(char *msg, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
extern int detach(int pid, int sig);
|
||||
extern int attach(int pid);
|
||||
extern void kill_child_dead(int pid);
|
||||
extern int cont(int pid);
|
||||
extern void check_sigio(void);
|
||||
extern void arch_check_bugs(void);
|
||||
extern int cpu_feature(char *what, char *buf, int len);
|
||||
extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
|
||||
extern int arch_fixup(unsigned long address, void *sc_ptr);
|
||||
extern void arch_init_thread(void);
|
||||
extern int raw(int fd);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user