mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
536788fe2d
Calculate TASK_SIZE at run-time by figuring out the host's VMSPLIT - this is needed on i386 if UML is to run on hosts with varying VMSPLITs without recompilation. TASK_SIZE is now defined in terms of a variable, task_size. This gets rid of an include of pgtable.h from processor.h, which can cause include loops. On i386, task_size is calculated early in boot by probing the address space in a binary search to figure out where the boundary between usable and non-usable memory is. This tries to make sure that a page that is considered to be in userspace is, or can be made, read-write. I'm concerned about a system-global VDSO page in kernel memory being hit and considered to be a userspace page. On x86_64, task_size is just the old value of CONFIG_TOP_ADDR. A bunch of config variable are gone now. CONFIG_TOP_ADDR is directly replaced by TASK_SIZE. NEST_LEVEL is gone since the relocation of the stubs makes it irrelevant. All the HOST_VMSPLIT stuff is gone. All references to these in arch/um/Makefile are also gone. I noticed and fixed a missing extern in os.h when adding os_get_task_size. Note: This has been revised to fix the 32-bit UML on 64-bit host bug that Miklos ran into. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
137 lines
2.8 KiB
C
137 lines
2.8 KiB
C
/*
|
|
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
|
* Licensed under the GPL
|
|
*/
|
|
|
|
#ifndef __UM_PROCESSOR_GENERIC_H
|
|
#define __UM_PROCESSOR_GENERIC_H
|
|
|
|
struct pt_regs;
|
|
|
|
struct task_struct;
|
|
|
|
#include "asm/ptrace.h"
|
|
#include "registers.h"
|
|
#include "sysdep/archsetjmp.h"
|
|
|
|
struct mm_struct;
|
|
|
|
struct thread_struct {
|
|
struct task_struct *saved_task;
|
|
/*
|
|
* This flag is set to 1 before calling do_fork (and analyzed in
|
|
* copy_thread) to mark that we are begin called from userspace (fork /
|
|
* vfork / clone), and reset to 0 after. It is left to 0 when called
|
|
* from kernelspace (i.e. kernel_thread() or fork_idle(),
|
|
* as of 2.6.11).
|
|
*/
|
|
int forking;
|
|
struct pt_regs regs;
|
|
int singlestep_syscall;
|
|
void *fault_addr;
|
|
jmp_buf *fault_catcher;
|
|
struct task_struct *prev_sched;
|
|
unsigned long temp_stack;
|
|
jmp_buf *exec_buf;
|
|
struct arch_thread arch;
|
|
jmp_buf switch_buf;
|
|
int mm_count;
|
|
struct {
|
|
int op;
|
|
union {
|
|
struct {
|
|
int pid;
|
|
} fork, exec;
|
|
struct {
|
|
int (*proc)(void *);
|
|
void *arg;
|
|
} thread;
|
|
struct {
|
|
void (*proc)(void *);
|
|
void *arg;
|
|
} cb;
|
|
} u;
|
|
} request;
|
|
};
|
|
|
|
#define INIT_THREAD \
|
|
{ \
|
|
.forking = 0, \
|
|
.regs = EMPTY_REGS, \
|
|
.fault_addr = NULL, \
|
|
.prev_sched = NULL, \
|
|
.temp_stack = 0, \
|
|
.exec_buf = NULL, \
|
|
.arch = INIT_ARCH_THREAD, \
|
|
.request = { 0 } \
|
|
}
|
|
|
|
extern struct task_struct *alloc_task_struct(void);
|
|
|
|
static inline void release_thread(struct task_struct *task)
|
|
{
|
|
}
|
|
|
|
extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
|
|
|
|
static inline void prepare_to_copy(struct task_struct *tsk)
|
|
{
|
|
}
|
|
|
|
|
|
extern unsigned long thread_saved_pc(struct task_struct *t);
|
|
|
|
static inline void mm_copy_segments(struct mm_struct *from_mm,
|
|
struct mm_struct *new_mm)
|
|
{
|
|
}
|
|
|
|
#define init_stack (init_thread_union.stack)
|
|
|
|
/*
|
|
* User space process size: 3GB (default).
|
|
*/
|
|
extern unsigned long task_size;
|
|
|
|
#define TASK_SIZE (task_size)
|
|
|
|
#undef STACK_TOP
|
|
#undef STACK_TOP_MAX
|
|
|
|
extern unsigned long stacksizelim;
|
|
|
|
#define STACK_ROOM (stacksizelim)
|
|
#define STACK_TOP (TASK_SIZE - 2 * PAGE_SIZE)
|
|
#define STACK_TOP_MAX STACK_TOP
|
|
|
|
/* This decides where the kernel will search for a free chunk of vm
|
|
* space during mmap's.
|
|
*/
|
|
#define TASK_UNMAPPED_BASE (0x40000000)
|
|
|
|
extern void start_thread(struct pt_regs *regs, unsigned long entry,
|
|
unsigned long stack);
|
|
|
|
struct cpuinfo_um {
|
|
unsigned long loops_per_jiffy;
|
|
int ipi_pipe[2];
|
|
};
|
|
|
|
extern struct cpuinfo_um boot_cpu_data;
|
|
|
|
#define my_cpu_data cpu_data[smp_processor_id()]
|
|
|
|
#ifdef CONFIG_SMP
|
|
extern struct cpuinfo_um cpu_data[];
|
|
#define current_cpu_data cpu_data[smp_processor_id()]
|
|
#else
|
|
#define cpu_data (&boot_cpu_data)
|
|
#define current_cpu_data boot_cpu_data
|
|
#endif
|
|
|
|
|
|
#define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf)
|
|
extern unsigned long get_wchan(struct task_struct *p);
|
|
|
|
#endif
|