ia64/xen-unstable

changeset 1131:0f6c3cc5f40c

bitkeeper revision 1.753 (403e2103aB5fs34t3drynDYnNdeFiw)

kernel.c, process.c:
Fix bug in idle-task switching.
author kaf24@scramble.cl.cam.ac.uk
date Thu Feb 26 16:38:27 2004 +0000 (2004-02-26)
parents acd0f2cab313
children 22160502f0cd
files xen/arch/i386/process.c xen/common/kernel.c
line diff
     1.1 --- a/xen/arch/i386/process.c	Thu Feb 26 14:58:10 2004 +0000
     1.2 +++ b/xen/arch/i386/process.c	Thu Feb 26 16:38:27 2004 +0000
     1.3 @@ -235,33 +235,49 @@ void switch_to(struct task_struct *prev_
     1.4      __cli();
     1.5  
     1.6      /* Switch guest general-register state. */
     1.7 -    memcpy(&prev_p->shared_info->execution_context, 
     1.8 -           stack_ec, 
     1.9 -           sizeof(*stack_ec));
    1.10 -    memcpy(stack_ec,
    1.11 -           &next_p->shared_info->execution_context,
    1.12 -           sizeof(*stack_ec));
    1.13 +    if ( !is_idle_task(prev_p) )
    1.14 +    {
    1.15 +        memcpy(&prev_p->shared_info->execution_context, 
    1.16 +               stack_ec, 
    1.17 +               sizeof(*stack_ec));
    1.18 +        unlazy_fpu(prev_p);
    1.19 +        CLEAR_FAST_TRAP(&prev_p->thread);
    1.20 +    }
    1.21 +
    1.22 +    if ( !is_idle_task(next_p) )
    1.23 +    {
    1.24 +        memcpy(stack_ec,
    1.25 +               &next_p->shared_info->execution_context,
    1.26 +               sizeof(*stack_ec));
    1.27  
    1.28 -    /*
    1.29 -     * This is sufficient! If the descriptor DPL differs from CS RPL
    1.30 -     * then we'll #GP. If DS, ES, FS, GS are DPL 0 then they'll be
    1.31 -     * cleared automatically. If SS RPL or DPL differs from CS RPL
    1.32 -     * then we'll #GP.
    1.33 -     */
    1.34 -    if ( (stack_ec->cs & 3) == 0 )
    1.35 -        stack_ec->cs = FLAT_RING1_CS;
    1.36 -    if ( (stack_ec->ss & 3) == 0 )
    1.37 -        stack_ec->ss = FLAT_RING1_DS;
    1.38 +        /*
    1.39 +         * This is sufficient! If the descriptor DPL differs from CS RPL then 
    1.40 +         * we'll #GP. If DS, ES, FS, GS are DPL 0 then they'll be cleared 
    1.41 +         * automatically. If SS RPL or DPL differs from CS RPL then we'll #GP.
    1.42 +         */
    1.43 +        if ( (stack_ec->cs & 3) == 0 )
    1.44 +            stack_ec->cs = FLAT_RING1_CS;
    1.45 +        if ( (stack_ec->ss & 3) == 0 )
    1.46 +            stack_ec->ss = FLAT_RING1_DS;
    1.47 +
    1.48 +        SET_FAST_TRAP(&next_p->thread);
    1.49  
    1.50 -    unlazy_fpu(prev_p);
    1.51 +        /* Switch the guest OS ring-1 stack. */
    1.52 +        tss->esp1 = next->esp1;
    1.53 +        tss->ss1  = next->ss1;
    1.54  
    1.55 -    /* Switch the fast-trap handler. */
    1.56 -    CLEAR_FAST_TRAP(&prev_p->thread);
    1.57 -    SET_FAST_TRAP(&next_p->thread);
    1.58 -
    1.59 -    /* Switch the guest OS ring-1 stack. */
    1.60 -    tss->esp1 = next->esp1;
    1.61 -    tss->ss1  = next->ss1;
    1.62 +        /* Maybe switch the debug registers. */
    1.63 +        if ( next->debugreg[7] )
    1.64 +        {
    1.65 +            loaddebug(next, 0);
    1.66 +            loaddebug(next, 1);
    1.67 +            loaddebug(next, 2);
    1.68 +            loaddebug(next, 3);
    1.69 +            /* no 4 and 5 */
    1.70 +            loaddebug(next, 6);
    1.71 +            loaddebug(next, 7);
    1.72 +        }
    1.73 +    }
    1.74  
    1.75      /* Switch page tables.  */
    1.76      write_cr3_counted(pagetable_val(next_p->mm.pagetable));
    1.77 @@ -272,18 +288,6 @@ void switch_to(struct task_struct *prev_
    1.78      __asm__ __volatile__ ("lgdt %0" : "=m" (*next_p->mm.gdt));
    1.79      load_LDT(next_p);
    1.80  
    1.81 -    /* Maybe switch the debug registers. */
    1.82 -    if ( next->debugreg[7] )
    1.83 -    {
    1.84 -        loaddebug(next, 0);
    1.85 -        loaddebug(next, 1);
    1.86 -        loaddebug(next, 2);
    1.87 -        loaddebug(next, 3);
    1.88 -        /* no 4 and 5 */
    1.89 -        loaddebug(next, 6);
    1.90 -        loaddebug(next, 7);
    1.91 -    }
    1.92 -
    1.93      __sti();
    1.94  }
    1.95  
     2.1 --- a/xen/common/kernel.c	Thu Feb 26 14:58:10 2004 +0000
     2.2 +++ b/xen/common/kernel.c	Thu Feb 26 16:38:27 2004 +0000
     2.3 @@ -224,11 +224,6 @@ void cmain(unsigned long magic, multiboo
     2.4  
     2.5      init_page_allocator(__pa(&_end), MAX_MONITOR_ADDRESS);
     2.6   
     2.7 -    /* These things will get done by do_createdomain() for all other tasks. */
     2.8 -    current->shared_info = (void *)get_free_page(GFP_KERNEL);
     2.9 -    memset(current->shared_info, 0, sizeof(shared_info_t));
    2.10 -    set_fs(USER_DS);
    2.11 -
    2.12      /* Initialise the slab allocator. */
    2.13      kmem_cache_init();
    2.14      kmem_cache_sizes_init(max_page);