diff -urNp mapped-base-ref/fs/proc/base.c mapped-base/fs/proc/base.c --- mapped-base-ref/fs/proc/base.c Tue Jul 23 04:32:55 2002 +++ mapped-base/fs/proc/base.c Tue Jul 23 04:33:08 2002 @@ -444,6 +444,58 @@ static struct file_operations proc_mem_o open: mem_open, }; +#ifdef __HAS_ARCH_PROC_MAPPED_BASE +static ssize_t mapbase_read(struct file * file, char * buf, + size_t count, loff_t *ppos) +{ + struct task_struct *task = file->f_dentry->d_inode->u.proc_i.task; + char buffer[64]; + int len; + + sprintf(buffer, "%li", task->map_base); + len=strlen(buffer)+1; + *ppos += len; + if (copy_to_user(buf, buffer, len)) + len = -EFAULT; + + return (len<*ppos)?0:len; +} + +static ssize_t mapbase_write(struct file * file, const char * buf, + size_t count, loff_t *ppos) +{ + struct task_struct *task = file->f_dentry->d_inode->u.proc_i.task; + char buffer[64]; + int len; + unsigned long newbase; + if (!capable(CAP_SYS_ADMIN)) return -EPERM; + memset(buffer, 0, 64); + len = count; + if (len>63) + len = 63; + if (copy_from_user(buffer, buf, len)) + return -EFAULT; + + for (len = 0; len < 64; len++) + if (!buffer[len]) + break; + if (len>60) + return -EFAULT; + + newbase = simple_strtoul(buffer, NULL, 0); + + if (newbase > 0) + task->map_base = newbase; + + return len; +} + +static struct file_operations proc_mapbase_operations = { + read: mapbase_read, + write: mapbase_write, +}; +#endif /* __HAS_ARCH_PROC_MAPPED_BASE */ + static struct inode_operations proc_mem_inode_operations = { permission: proc_permission, }; @@ -540,6 +592,7 @@ enum pid_directory_inos { PROC_PID_MAPS, PROC_PID_CPU, PROC_PID_MOUNTS, + PROC_PID_MAPBASE, PROC_PID_FD_DIR = 0x8000, /* 0x8000-0xffff */ }; @@ -560,6 +613,9 @@ static struct pid_entry base_stuff[] = { E(PROC_PID_ROOT, "root", S_IFLNK|S_IRWXUGO), E(PROC_PID_EXE, "exe", S_IFLNK|S_IRWXUGO), E(PROC_PID_MOUNTS, "mounts", S_IFREG|S_IRUGO), +#ifdef __HAS_ARCH_PROC_MAPPED_BASE + E(PROC_PID_MAPBASE, "mapped_base", S_IFREG|S_IRUSR|S_IWUSR), +#endif {0,0,NULL,0} }; #undef E @@ -912,6 +968,11 @@ static struct dentry *proc_base_lookup(s inode->i_fop = &proc_info_file_operations; inode->u.proc_i.op.proc_read = proc_pid_statm; break; +#ifdef __HAS_ARCH_PROC_MAPPED_BASE + case PROC_PID_MAPBASE: + inode->i_fop = &proc_mapbase_operations; + break; +#endif case PROC_PID_MAPS: inode->i_fop = &proc_maps_operations; break; diff -urNp mapped-base-ref/include/asm-i386/processor.h mapped-base/include/asm-i386/processor.h --- mapped-base-ref/include/asm-i386/processor.h Tue Jul 23 04:32:55 2002 +++ mapped-base/include/asm-i386/processor.h Tue Jul 23 04:33:08 2002 @@ -275,10 +275,12 @@ extern unsigned int mca_pentium_flag; /* This decides where the kernel will search for a free chunk of vm * space during mmap's. */ +#define TASK_UNMAPPED_BASE (current->map_base) + #ifndef CONFIG_05GB -#define TASK_UNMAPPED_BASE (TASK_SIZE / 3) +#define __TASK_UNMAPPED_BASE (TASK_SIZE / 3) #else -#define TASK_UNMAPPED_BASE (TASK_SIZE / 16) +#define __TASK_UNMAPPED_BASE (TASK_SIZE / 16) #endif /* diff -urNp mapped-base-ref/include/asm-s390/processor.h mapped-base/include/asm-s390/processor.h --- mapped-base-ref/include/asm-s390/processor.h Tue Jul 23 04:32:55 2002 +++ mapped-base/include/asm-s390/processor.h Tue Jul 23 04:33:08 2002 @@ -60,7 +60,8 @@ extern struct task_struct *last_task_use /* This decides where the kernel will search for a free chunk of vm * space during mmap's. */ -#define TASK_UNMAPPED_BASE (TASK_SIZE / 2) +#define __TASK_UNMAPPED_BASE (TASK_SIZE / 2) +#define TASK_UNMAPPED_BASE (current->map_base) #define THREAD_SIZE (2*PAGE_SIZE) diff -urNp mapped-base-ref/include/asm-um/processor-generic.h mapped-base/include/asm-um/processor-generic.h --- mapped-base-ref/include/asm-um/processor-generic.h Tue Jul 23 04:32:55 2002 +++ mapped-base/include/asm-um/processor-generic.h Tue Jul 23 04:33:08 2002 @@ -125,7 +125,8 @@ extern unsigned long task_size; /* This decides where the kernel will search for a free chunk of vm * space during mmap's. */ -#define TASK_UNMAPPED_BASE (0x40000000) +#define __TASK_UNMAPPED_BASE (0x40000000) +#define TASK_UNMAPPED_BASE (current->map_base) extern void start_thread(struct pt_regs *regs, unsigned long entry, unsigned long stack); diff -urNp mapped-base-ref/include/linux/sched.h mapped-base/include/linux/sched.h --- mapped-base-ref/include/linux/sched.h Tue Jul 23 04:32:55 2002 +++ mapped-base/include/linux/sched.h Tue Jul 23 04:33:08 2002 @@ -442,6 +442,9 @@ struct task_struct { /* journalling filesystem info */ void *journal_info; + +/* TASK_UNMAPPED_BASE value */ + unsigned long map_base; }; /* @@ -493,6 +496,12 @@ asmlinkage long sys_sched_yield(void); */ extern struct exec_domain default_exec_domain; +#ifndef __TASK_UNMAPPED_BASE +#define __TASK_UNMAPPED_BASE 0UL +#else +#define __HAS_ARCH_PROC_MAPPED_BASE +#endif + /* * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB) @@ -538,6 +547,7 @@ extern struct exec_domain default_exec_d blocked: {{0}}, \ alloc_lock: SPIN_LOCK_UNLOCKED, \ journal_info: NULL, \ + map_base: __TASK_UNMAPPED_BASE, \ }