ia64/xen-unstable

changeset 1807:7acde7c89f37

bitkeeper revision 1.1099 (40f6f756_UAMBuGEnf4DcZB7Z3xbwg)

Truncate TLS segments to avoid overlap with Xen private area.
author kaf24@scramble.cl.cam.ac.uk
date Thu Jul 15 21:29:58 2004 +0000 (2004-07-15)
parents 81936d3b712c
children e6bff1f485f8 2243a562032d
files linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c
line diff
     1.1 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c	Thu Jul 15 15:54:53 2004 +0000
     1.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/process.c	Thu Jul 15 21:29:58 2004 +0000
     1.3 @@ -331,6 +331,24 @@ void prepare_to_copy(struct task_struct 
     1.4  	unlazy_fpu(tsk);
     1.5  }
     1.6  
     1.7 +/* NB. This Xen-specific function is inlined in 'write_ldt'. */
     1.8 +static int truncate_user_desc(struct user_desc *info)
     1.9 +{
    1.10 +	unsigned long max_limit;
    1.11 +
    1.12 +	if (info->base_addr >= PAGE_OFFSET)
    1.13 +		return 0;
    1.14 +
    1.15 +	max_limit = HYPERVISOR_VIRT_START - info->base_addr;
    1.16 +	if (info->limit_in_pages)
    1.17 +		max_limit >>= PAGE_SHIFT;
    1.18 +	max_limit--;
    1.19 +	if ((info->limit & 0xfffff) > (max_limit & 0xfffff))
    1.20 +		info->limit = max_limit;
    1.21 +
    1.22 +	return 1;
    1.23 +}
    1.24 +
    1.25  int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
    1.26  	unsigned long unused,
    1.27  	struct task_struct * p, struct pt_regs * regs)
    1.28 @@ -381,6 +399,9 @@ int copy_thread(int nr, unsigned long cl
    1.29  		if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
    1.30  			goto out;
    1.31  
    1.32 +		if (!truncate_user_desc(&info))
    1.33 +			goto out;
    1.34 +
    1.35  		desc = p->thread.tls_array + idx - GDT_ENTRY_TLS_MIN;
    1.36  		desc->a = LDT_entry_a(&info);
    1.37  		desc->b = LDT_entry_b(&info);
    1.38 @@ -696,6 +717,9 @@ asmlinkage int sys_set_thread_area(struc
    1.39  		return -EFAULT;
    1.40  	idx = info.entry_number;
    1.41  
    1.42 +	if (!truncate_user_desc(&info))
    1.43 +		return -EINVAL;
    1.44 +
    1.45  	/*
    1.46  	 * index -1 means the kernel should try to find and
    1.47  	 * allocate an empty descriptor: