ia64/xen-unstable

changeset 1701:0641c37d44f8

bitkeeper revision 1.1041.1.19 (40eb3b38u9R9sLb2ifQLhA21eo0MYQ)

Merge ssh://xenbk@gandalf//var/bk/djm/xeno-unstable-common.bk
into kirby.fc.hp.com:/home/djm/src/xen/xeno-unstable-common.bk
author djm@kirby.fc.hp.com
date Tue Jul 06 23:52:24 2004 +0000 (2004-07-06)
parents b8ad289cb612 5a555cd41a9e
children 5b7ee1537994 ab1f2db9e634
files xen/arch/x86/domain.c xen/arch/x86/idle0_task.c xen/common/domain.c xen/include/xen/mm.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Tue Jul 06 20:42:40 2004 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Tue Jul 06 23:52:24 2004 +0000
     1.3 @@ -185,6 +185,70 @@ void machine_power_off(void)
     1.4      machine_restart(0);
     1.5  }
     1.6  
     1.7 +/* this belongs in include/asm, but there doesn't seem to be a suitable place */
     1.8 +void free_perdomain_pt(struct domain *d)
     1.9 +{
    1.10 +    free_page((unsigned long)d->mm.perdomain_pt);
    1.11 +}
    1.12 +
    1.13 +void arch_do_createdomain(struct domain *d)
    1.14 +{
    1.15 +    d->shared_info = (void *)get_free_page();
    1.16 +    memset(d->shared_info, 0, PAGE_SIZE);
    1.17 +    SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
    1.18 +    machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
    1.19 +                           PAGE_SHIFT] = 0x80000000UL;  /* debug */
    1.20 +
    1.21 +    d->mm.perdomain_pt = (l1_pgentry_t *)get_free_page();
    1.22 +    memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
    1.23 +    machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
    1.24 +                           PAGE_SHIFT] = 0x0fffdeadUL;  /* debug */
    1.25 +}
    1.26 +
    1.27 +void arch_final_setup_guestos(struct domain *p, full_execution_context_t *c)
    1.28 +{
    1.29 +    unsigned long phys_basetab;
    1.30 +    int i;
    1.31 +
    1.32 +    clear_bit(DF_DONEFPUINIT, &p->flags);
    1.33 +    if ( c->flags & ECF_I387_VALID )
    1.34 +        set_bit(DF_DONEFPUINIT, &p->flags);
    1.35 +    memcpy(&p->shared_info->execution_context,
    1.36 +           &c->cpu_ctxt,
    1.37 +           sizeof(p->shared_info->execution_context));
    1.38 +    memcpy(&p->thread.i387,
    1.39 +           &c->fpu_ctxt,
    1.40 +           sizeof(p->thread.i387));
    1.41 +    memcpy(p->thread.traps,
    1.42 +           &c->trap_ctxt,
    1.43 +           sizeof(p->thread.traps));
    1.44 +#ifdef ARCH_HAS_FAST_TRAP
    1.45 +    SET_DEFAULT_FAST_TRAP(&p->thread);
    1.46 +    (void)set_fast_trap(p, c->fast_trap_idx);
    1.47 +#endif
    1.48 +    p->mm.ldt_base = c->ldt_base;
    1.49 +    p->mm.ldt_ents = c->ldt_ents;
    1.50 +    SET_GDT_ENTRIES(p, DEFAULT_GDT_ENTRIES);
    1.51 +    SET_GDT_ADDRESS(p, DEFAULT_GDT_ADDRESS);
    1.52 +    if ( c->gdt_ents != 0 )
    1.53 +        (void)set_gdt(p,
    1.54 +                      c->gdt_frames,
    1.55 +                      c->gdt_ents);
    1.56 +    p->thread.guestos_ss = c->guestos_ss;
    1.57 +    p->thread.guestos_sp = c->guestos_esp;
    1.58 +    for ( i = 0; i < 8; i++ )
    1.59 +        (void)set_debugreg(p, i, c->debugreg[i]);
    1.60 +    p->event_selector    = c->event_callback_cs;
    1.61 +    p->event_address     = c->event_callback_eip;
    1.62 +    p->failsafe_selector = c->failsafe_callback_cs;
    1.63 +    p->failsafe_address  = c->failsafe_callback_eip;
    1.64 +    
    1.65 +    phys_basetab = c->pt_base;
    1.66 +    p->mm.pagetable = mk_pagetable(phys_basetab);
    1.67 +    get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], p, 
    1.68 +                      PGT_base_page_table);
    1.69 +}
    1.70 +
    1.71  #if defined(__i386__)
    1.72  
    1.73  void new_thread(struct domain *p,
     2.1 --- a/xen/arch/x86/idle0_task.c	Tue Jul 06 20:42:40 2004 +0000
     2.2 +++ b/xen/arch/x86/idle0_task.c	Tue Jul 06 23:52:24 2004 +0000
     2.3 @@ -2,6 +2,17 @@
     2.4  #include <xen/sched.h>
     2.5  #include <asm/desc.h>
     2.6  
     2.7 +#define IDLE0_TASK(_t)           \
     2.8 +{                                \
     2.9 +    processor:   0,              \
    2.10 +    domain:      IDLE_DOMAIN_ID, \
    2.11 +    mm:          IDLE0_MM,       \
    2.12 +    addr_limit:  KERNEL_DS,      \
    2.13 +    thread:      INIT_THREAD,    \
    2.14 +    flags:       1<<DF_IDLETASK, \
    2.15 +    refcnt:      ATOMIC_INIT(1)  \
    2.16 +}
    2.17 +
    2.18  struct domain idle0_task = IDLE0_TASK(idle0_task);
    2.19  
    2.20  /*
     3.1 --- a/xen/common/domain.c	Tue Jul 06 20:42:40 2004 +0000
     3.2 +++ b/xen/common/domain.c	Tue Jul 06 23:52:24 2004 +0000
     3.3 @@ -44,6 +44,10 @@ rwlock_t tasklist_lock __cacheline_align
     3.4  struct domain *task_hash[TASK_HASH_SIZE];
     3.5  struct domain *task_list;
     3.6  
     3.7 +void arch_do_createdomain(struct domain *);
     3.8 +void arch_final_setup_guestos(struct domain *, full_execution_context_t *c);
     3.9 +void free_perdomain_pt(struct domain *);
    3.10 +
    3.11  struct domain *do_createdomain(domid_t dom_id, unsigned int cpu)
    3.12  {
    3.13      char buf[100];
    3.14 @@ -83,16 +87,7 @@ struct domain *do_createdomain(domid_t d
    3.15          INIT_LIST_HEAD(&d->page_list);
    3.16          d->max_pages = d->tot_pages = 0;
    3.17  
    3.18 -        d->shared_info = (void *)get_free_page();
    3.19 -        memset(d->shared_info, 0, PAGE_SIZE);
    3.20 -        SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
    3.21 -        machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
    3.22 -                               PAGE_SHIFT] = 0x80000000UL;  /* debug */
    3.23 -
    3.24 -        d->mm.perdomain_pt = (l1_pgentry_t *)get_free_page();
    3.25 -        memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
    3.26 -        machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
    3.27 -                               PAGE_SHIFT] = 0x0fffdeadUL;  /* debug */
    3.28 +	arch_do_createdomain(d);
    3.29  
    3.30          /* Per-domain PCI-device list. */
    3.31          spin_lock_init(&d->pcidev_lock);
    3.32 @@ -446,7 +441,7 @@ void domain_destruct(struct domain *d)
    3.33  
    3.34      destroy_event_channels(d);
    3.35  
    3.36 -    free_page((unsigned long)d->mm.perdomain_pt);
    3.37 +    free_perdomain_pt(d);
    3.38      free_page((unsigned long)d->shared_info);
    3.39  
    3.40      free_domain_struct(d);
    3.41 @@ -460,8 +455,7 @@ void domain_destruct(struct domain *d)
    3.42   */
    3.43  int final_setup_guestos(struct domain *p, dom0_builddomain_t *builddomain)
    3.44  {
    3.45 -    unsigned long phys_basetab;
    3.46 -    int i, rc = 0;
    3.47 +    int rc = 0;
    3.48      full_execution_context_t *c;
    3.49  
    3.50      if ( (c = kmalloc(sizeof(*c))) == NULL )
    3.51 @@ -479,43 +473,7 @@ int final_setup_guestos(struct domain *p
    3.52          goto out;
    3.53      }
    3.54      
    3.55 -    clear_bit(DF_DONEFPUINIT, &p->flags);
    3.56 -    if ( c->flags & ECF_I387_VALID )
    3.57 -        set_bit(DF_DONEFPUINIT, &p->flags);
    3.58 -    memcpy(&p->shared_info->execution_context,
    3.59 -           &c->cpu_ctxt,
    3.60 -           sizeof(p->shared_info->execution_context));
    3.61 -    memcpy(&p->thread.i387,
    3.62 -           &c->fpu_ctxt,
    3.63 -           sizeof(p->thread.i387));
    3.64 -    memcpy(p->thread.traps,
    3.65 -           &c->trap_ctxt,
    3.66 -           sizeof(p->thread.traps));
    3.67 -#ifdef ARCH_HAS_FAST_TRAP
    3.68 -    SET_DEFAULT_FAST_TRAP(&p->thread);
    3.69 -    (void)set_fast_trap(p, c->fast_trap_idx);
    3.70 -#endif
    3.71 -    p->mm.ldt_base = c->ldt_base;
    3.72 -    p->mm.ldt_ents = c->ldt_ents;
    3.73 -    SET_GDT_ENTRIES(p, DEFAULT_GDT_ENTRIES);
    3.74 -    SET_GDT_ADDRESS(p, DEFAULT_GDT_ADDRESS);
    3.75 -    if ( c->gdt_ents != 0 )
    3.76 -        (void)set_gdt(p,
    3.77 -                      c->gdt_frames,
    3.78 -                      c->gdt_ents);
    3.79 -    p->thread.guestos_ss = c->guestos_ss;
    3.80 -    p->thread.guestos_sp = c->guestos_esp;
    3.81 -    for ( i = 0; i < 8; i++ )
    3.82 -        (void)set_debugreg(p, i, c->debugreg[i]);
    3.83 -    p->event_selector    = c->event_callback_cs;
    3.84 -    p->event_address     = c->event_callback_eip;
    3.85 -    p->failsafe_selector = c->failsafe_callback_cs;
    3.86 -    p->failsafe_address  = c->failsafe_callback_eip;
    3.87 -    
    3.88 -    phys_basetab = c->pt_base;
    3.89 -    p->mm.pagetable = mk_pagetable(phys_basetab);
    3.90 -    get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], p, 
    3.91 -                      PGT_base_page_table);
    3.92 +    arch_final_setup_guestos(p,c);
    3.93  
    3.94      /* Set up the shared info structure. */
    3.95      update_dom_time(p->shared_info);
     4.1 --- a/xen/include/xen/mm.h	Tue Jul 06 20:42:40 2004 +0000
     4.2 +++ b/xen/include/xen/mm.h	Tue Jul 06 23:52:24 2004 +0000
     4.3 @@ -3,6 +3,9 @@
     4.4  #define __XEN_MM_H__
     4.5  
     4.6  #include <xen/config.h>
     4.7 +#ifdef LINUX_2_6
     4.8 +#include <xen/gfp.h>
     4.9 +#endif
    4.10  #include <xen/list.h>
    4.11  #include <xen/spinlock.h>
    4.12  #include <xen/perfc.h>
     5.1 --- a/xen/include/xen/sched.h	Tue Jul 06 20:42:40 2004 +0000
     5.2 +++ b/xen/include/xen/sched.h	Tue Jul 06 23:52:24 2004 +0000
     5.3 @@ -4,6 +4,9 @@
     5.4  #include <xen/config.h>
     5.5  #include <xen/types.h>
     5.6  #include <xen/spinlock.h>
     5.7 +#ifdef LINUX_2_6
     5.8 +#include <linux/thread_info.h>
     5.9 +#endif
    5.10  #include <asm/ptrace.h>
    5.11  #include <xen/smp.h>
    5.12  #include <asm/page.h>
    5.13 @@ -149,17 +152,6 @@ struct domain
    5.14  
    5.15  #include <asm/uaccess.h> /* for KERNEL_DS */
    5.16  
    5.17 -#define IDLE0_TASK(_t)           \
    5.18 -{                                \
    5.19 -    processor:   0,              \
    5.20 -    domain:      IDLE_DOMAIN_ID, \
    5.21 -    mm:          IDLE0_MM,       \
    5.22 -    addr_limit:  KERNEL_DS,      \
    5.23 -    thread:      INIT_THREAD,    \
    5.24 -    flags:       1<<DF_IDLETASK, \
    5.25 -    refcnt:      ATOMIC_INIT(1)  \
    5.26 -}
    5.27 -
    5.28  extern struct domain idle0_task;
    5.29  
    5.30  extern struct domain *idle_task[NR_CPUS];