ia64/xen-unstable

changeset 762:5c88e665b5ba

bitkeeper revision 1.460 (3f721160CQuzVfl_qVkHJLnLn6yY1A)

ldt.c:
Xenolinux modify_ldt syscall now silently clamps the segment limit to a safe value. This is needed for brainded new linuxthreads versions which specify a 4GB segment limit.
author kaf24@scramble.cl.cam.ac.uk
date Wed Sep 24 21:49:20 2003 +0000 (2003-09-24)
parents 6c8e1df49bc7
children 57eb11234d3b
files xenolinux-2.4.22-sparse/arch/xeno/kernel/ldt.c
line diff
     1.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/kernel/ldt.c	Wed Sep 24 10:09:49 2003 +0000
     1.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/kernel/ldt.c	Wed Sep 24 21:49:20 2003 +0000
     1.3 @@ -68,7 +68,7 @@ static int write_ldt(void * ptr, unsigne
     1.4  {
     1.5      struct mm_struct * mm = current->mm;
     1.6      __u32 entry_1, entry_2, *lp;
     1.7 -    unsigned long phys_lp;
     1.8 +    unsigned long phys_lp, max_limit;
     1.9      int error;
    1.10      struct modify_ldt_ldt_s ldt_info;
    1.11  
    1.12 @@ -89,6 +89,13 @@ static int write_ldt(void * ptr, unsigne
    1.13              goto out;
    1.14      }
    1.15  
    1.16 +    /*
    1.17 +     * This makes our tests for overlap with Xen space easier. There's no good
    1.18 +     * reason to have a user segment starting this high anyway.
    1.19 +     */
    1.20 +    if (ldt_info.base_addr >= PAGE_OFFSET)
    1.21 +        goto out;
    1.22 +
    1.23      down_write(&mm->mmap_sem);
    1.24      if (!mm->context.segments) {
    1.25          void * segments = vmalloc(LDT_ENTRIES*LDT_ENTRY_SIZE);
    1.26 @@ -122,6 +129,13 @@ static int write_ldt(void * ptr, unsigne
    1.27          }
    1.28      }
    1.29  
    1.30 +    max_limit = HYPERVISOR_VIRT_START - ldt_info.base_addr;
    1.31 +    if ( ldt_info.limit_in_pages )
    1.32 +        max_limit >>= PAGE_SHIFT;
    1.33 +    max_limit--;
    1.34 +    if ( (ldt_info.limit & 0xfffff) > (max_limit & 0xfffff) )
    1.35 +        ldt_info.limit = max_limit;
    1.36 +
    1.37      entry_1 = ((ldt_info.base_addr & 0x0000ffff) << 16) |
    1.38          (ldt_info.limit & 0x0ffff);
    1.39      entry_2 = (ldt_info.base_addr & 0xff000000) |