ia64/xen-unstable

changeset 3651:393483ae9f62

bitkeeper revision 1.1159.1.543 (4203cc52-IjyDkH9JipqJcJq995IaQ)

Merge tempest.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xeno.bk
into tempest.cl.cam.ac.uk:/local/scratch/smh22/xen-unstable.bk
author smh22@tempest.cl.cam.ac.uk
date Fri Feb 04 19:26:10 2005 +0000 (2005-02-04)
parents bbe8541361dd 8c6281ec8860
children 88957a238191
files xen/arch/x86/boot/x86_64.S xen/arch/x86/domain.c xen/arch/x86/setup.c xen/arch/x86/traps.c xen/arch/x86/x86_32/domain_build.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/domain_build.c xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/mm.c xen/arch/x86/x86_64/traps.c xen/include/asm-x86/x86_64/asm_defns.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h
line diff
     1.1 --- a/xen/arch/x86/boot/x86_64.S	Fri Feb 04 14:44:18 2005 +0000
     1.2 +++ b/xen/arch/x86/boot/x86_64.S	Fri Feb 04 19:26:10 2005 +0000
     1.3 @@ -189,7 +189,7 @@ 1:      jmp     1b
     1.4  ENTRY(gdt_table)
     1.5          .fill FIRST_RESERVED_GDT_ENTRY,8,0
     1.6          .quad 0x0000000000000000     /* unused */
     1.7 -        .quad 0x00cf9a000000ffff     /* 0x0808 ring 0 code, compatability */
     1.8 +        .quad 0x00cf9a000000ffff     /* 0x0808 ring 0 code, compatibility */
     1.9          .quad 0x00af9a000000ffff     /* 0x0810 ring 0 code, 64-bit mode   */
    1.10          .quad 0x00cf92000000ffff     /* 0x0818 ring 0 data                */
    1.11          .quad 0x00cffa000000ffff     /* 0x0823 ring 3 code, compatibility */
     2.1 --- a/xen/arch/x86/domain.c	Fri Feb 04 14:44:18 2005 +0000
     2.2 +++ b/xen/arch/x86/domain.c	Fri Feb 04 19:26:10 2005 +0000
     2.3 @@ -491,13 +491,14 @@ void new_thread(struct exec_domain *d,
     2.4  
     2.5      /*
     2.6       * Initial register values:
     2.7 -     *  DS,ES,FS,GS = FLAT_RING1_DS
     2.8 -     *       CS:EIP = FLAT_RING1_CS:start_pc
     2.9 -     *       SS:ESP = FLAT_RING1_DS:start_stack
    2.10 +     *  DS,ES,FS,GS = FLAT_GUESTOS_DS
    2.11 +     *       CS:EIP = FLAT_GUESTOS_CS:start_pc
    2.12 +     *       SS:ESP = FLAT_GUESTOS_SS:start_stack
    2.13       *          ESI = start_info
    2.14       *  [EAX,EBX,ECX,EDX,EDI,EBP are zero]
    2.15       */
    2.16 -    ec->ds = ec->es = ec->fs = ec->gs = ec->ss = FLAT_GUESTOS_DS;
    2.17 +    ec->ds = ec->es = ec->fs = ec->gs = FLAT_GUESTOS_DS;
    2.18 +    ec->ss = FLAT_GUESTOS_SS;
    2.19      ec->cs = FLAT_GUESTOS_CS;
    2.20      ec->eip = start_pc;
    2.21      ec->esp = start_stack;
     3.1 --- a/xen/arch/x86/setup.c	Fri Feb 04 14:44:18 2005 +0000
     3.2 +++ b/xen/arch/x86/setup.c	Fri Feb 04 19:26:10 2005 +0000
     3.3 @@ -298,6 +298,7 @@ void __init identify_cpu(struct cpuinfo_
     3.4  unsigned long cpu_initialized;
     3.5  void __init cpu_init(void)
     3.6  {
     3.7 +    extern void percpu_traps_init(void);
     3.8      int nr = smp_processor_id();
     3.9      struct tss_struct *t = &init_tss[nr];
    3.10  
    3.11 @@ -335,6 +336,8 @@ void __init cpu_init(void)
    3.12      CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7);
    3.13  #undef CD
    3.14  
    3.15 +    percpu_traps_init();
    3.16 +
    3.17      /* Install correct page table. */
    3.18      write_ptbase(&current->mm);
    3.19  
     4.1 --- a/xen/arch/x86/traps.c	Fri Feb 04 14:44:18 2005 +0000
     4.2 +++ b/xen/arch/x86/traps.c	Fri Feb 04 19:26:10 2005 +0000
     4.3 @@ -470,7 +470,7 @@ asmlinkage int do_general_protection(str
     4.4      unsigned long fixup;
     4.5  
     4.6      DEBUGGER_trap_entry(TRAP_gp_fault, regs);
     4.7 -    
     4.8 +
     4.9      if ( regs->error_code & 1 )
    4.10          goto hardware_gp;
    4.11  
    4.12 @@ -732,8 +732,6 @@ void __init trap_init(void)
    4.13  
    4.14  #if defined(__i386__)
    4.15      _set_gate(idt_table+HYPERCALL_VECTOR, 14, 1, &hypercall);
    4.16 -#elif defined(__x86_64__)
    4.17 -    _set_gate(idt_table+HYPERCALL_VECTOR, 14, 3, &hypercall);
    4.18  #endif
    4.19  
    4.20      /* CPU0 uses the master IDT. */
     5.1 --- a/xen/arch/x86/x86_32/domain_build.c	Fri Feb 04 14:44:18 2005 +0000
     5.2 +++ b/xen/arch/x86/x86_32/domain_build.c	Fri Feb 04 19:26:10 2005 +0000
     5.3 @@ -218,7 +218,7 @@ int construct_dom0(struct domain *d,
     5.4       */
     5.5      ed->thread.failsafe_selector = FLAT_GUESTOS_CS;
     5.6      ed->thread.event_selector    = FLAT_GUESTOS_CS;
     5.7 -    ed->thread.guestos_ss = FLAT_GUESTOS_DS;
     5.8 +    ed->thread.guestos_ss = FLAT_GUESTOS_SS;
     5.9      for ( i = 0; i < 256; i++ ) 
    5.10          ed->thread.traps[i].cs = FLAT_GUESTOS_CS;
    5.11  
    5.12 @@ -257,7 +257,6 @@ int construct_dom0(struct domain *d,
    5.13      l2tab = l2start + l2_table_offset(vpt_start);
    5.14      l1start = l1tab = (l1_pgentry_t *)l2_pgentry_to_phys(*l2tab);
    5.15      l1tab += l1_table_offset(vpt_start);
    5.16 -    l2tab++;
    5.17      for ( count = 0; count < nr_pt_pages; count++ ) 
    5.18      {
    5.19          *l1tab = mk_l1_pgentry(l1_pgentry_val(*l1tab) & ~_PAGE_RW);
    5.20 @@ -294,9 +293,8 @@ int construct_dom0(struct domain *d,
    5.21               */
    5.22              get_page(page, d); /* an extra ref because of readable mapping */
    5.23          }
    5.24 -        l1tab++;
    5.25 -        if( !((unsigned long)l1tab & (PAGE_SIZE - 1)) )
    5.26 -            l1start = l1tab = (l1_pgentry_t *)l2_pgentry_to_phys(*l2tab);
    5.27 +        if ( !((unsigned long)++l1tab & (PAGE_SIZE - 1)) )
    5.28 +            l1start = l1tab = (l1_pgentry_t *)l2_pgentry_to_phys(*++l2tab);
    5.29      }
    5.30  
    5.31      /* Set up shared-info area. */
     6.1 --- a/xen/arch/x86/x86_32/traps.c	Fri Feb 04 14:44:18 2005 +0000
     6.2 +++ b/xen/arch/x86/x86_32/traps.c	Fri Feb 04 19:26:10 2005 +0000
     6.3 @@ -196,6 +196,10 @@ void __init doublefault_init(void)
     6.4      set_task_gate(TRAP_double_fault, __DOUBLEFAULT_TSS_ENTRY<<3);
     6.5  }
     6.6  
     6.7 +void __init percpu_traps_init(void)
     6.8 +{
     6.9 +}
    6.10 +
    6.11  long set_fast_trap(struct exec_domain *p, int idx)
    6.12  {
    6.13      trap_info_t *ti;
     7.1 --- a/xen/arch/x86/x86_64/domain_build.c	Fri Feb 04 14:44:18 2005 +0000
     7.2 +++ b/xen/arch/x86/x86_64/domain_build.c	Fri Feb 04 19:26:10 2005 +0000
     7.3 @@ -42,7 +42,9 @@ int construct_dom0(struct domain *d,
     7.4      unsigned long nr_pages = (alloc_end - alloc_start) >> PAGE_SHIFT;
     7.5      unsigned long nr_pt_pages;
     7.6      unsigned long count;
     7.7 -    l2_pgentry_t *l2tab, *l2start;
     7.8 +    l4_pgentry_t *l4tab = NULL, *l4start = NULL;
     7.9 +    l3_pgentry_t *l3tab = NULL, *l3start = NULL;
    7.10 +    l2_pgentry_t *l2tab = NULL, *l2start = NULL;
    7.11      l1_pgentry_t *l1tab = NULL, *l1start = NULL;
    7.12      struct pfn_info *page = NULL;
    7.13      start_info_t *si;
    7.14 @@ -128,8 +130,14 @@ int construct_dom0(struct domain *d,
    7.15          v_end            = (vstack_end + (1UL<<22)-1) & ~((1UL<<22)-1);
    7.16          if ( (v_end - vstack_end) < (512UL << 10) )
    7.17              v_end += 1UL << 22; /* Add extra 4MB to get >= 512kB padding. */
    7.18 -        if ( (((v_end - dsi.v_start + ((1UL<<L2_PAGETABLE_SHIFT)-1)) >> 
    7.19 -               L2_PAGETABLE_SHIFT) + 1) <= nr_pt_pages )
    7.20 +#define NR(_l,_h,_s) \
    7.21 +    (((((_h) + ((1UL<<(_s))-1)) & ~((1UL<<(_s))-1)) - \
    7.22 +       ((_l) & ~((1UL<<(_s))-1))) >> (_s))
    7.23 +        if ( (1 + /* # L4 */
    7.24 +              NR(dsi.v_start, v_end, L4_PAGETABLE_SHIFT) + /* # L3 */
    7.25 +              NR(dsi.v_start, v_end, L3_PAGETABLE_SHIFT) + /* # L2 */
    7.26 +              NR(dsi.v_start, v_end, L2_PAGETABLE_SHIFT))  /* # L1 */
    7.27 +             <= nr_pt_pages )
    7.28              break;
    7.29      }
    7.30  
    7.31 @@ -195,8 +203,8 @@ int construct_dom0(struct domain *d,
    7.32      printk("done.\n");
    7.33  
    7.34      /* Construct a frame-allocation list for the initial domain. */
    7.35 -    for ( mfn = (alloc_start>>PAGE_SHIFT); 
    7.36 -          mfn < (alloc_end>>PAGE_SHIFT); 
    7.37 +    for ( mfn = (alloc_start>>PAGE_SHIFT);
    7.38 +          mfn < (alloc_end>>PAGE_SHIFT);
    7.39            mfn++ )
    7.40      {
    7.41          page = &frame_table[mfn];
    7.42 @@ -218,85 +226,97 @@ int construct_dom0(struct domain *d,
    7.43       */
    7.44      ed->thread.failsafe_selector = FLAT_GUESTOS_CS;
    7.45      ed->thread.event_selector    = FLAT_GUESTOS_CS;
    7.46 -    ed->thread.guestos_ss = FLAT_GUESTOS_DS;
    7.47 +    ed->thread.guestos_ss = FLAT_GUESTOS_SS;
    7.48      for ( i = 0; i < 256; i++ ) 
    7.49          ed->thread.traps[i].cs = FLAT_GUESTOS_CS;
    7.50  
    7.51      /* WARNING: The new domain must have its 'processor' field filled in! */
    7.52 -    l2start = l2tab = (l2_pgentry_t *)mpt_alloc; mpt_alloc += PAGE_SIZE;
    7.53 -    memcpy(l2tab, &idle_pg_table[0], PAGE_SIZE);
    7.54 -    l2tab[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =
    7.55 -        mk_l2_pgentry((unsigned long)l2start | __PAGE_HYPERVISOR);
    7.56 -    l2tab[PERDOMAIN_VIRT_START >> L2_PAGETABLE_SHIFT] =
    7.57 -        mk_l2_pgentry(__pa(d->mm_perdomain_pt) | __PAGE_HYPERVISOR);
    7.58 -    ed->mm.pagetable = mk_pagetable((unsigned long)l2start);
    7.59 +    phys_to_page(mpt_alloc)->u.inuse.type_info = PGT_l4_page_table;
    7.60 +    l4start = l4tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE;
    7.61 +    memcpy(l4tab, &idle_pg_table[0], PAGE_SIZE);
    7.62 +    l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] =
    7.63 +        mk_l4_pgentry(__pa(l4start) | __PAGE_HYPERVISOR);
    7.64 +    l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =
    7.65 +        mk_l4_pgentry(__pa(d->mm_perdomain_pt) | __PAGE_HYPERVISOR);
    7.66 +    ed->mm.pagetable = mk_pagetable(__pa(l4start));
    7.67  
    7.68 -    l2tab += l2_table_offset(dsi.v_start);
    7.69 +    l4tab += l4_table_offset(dsi.v_start);
    7.70      mfn = alloc_start >> PAGE_SHIFT;
    7.71      for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ )
    7.72      {
    7.73          if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
    7.74          {
    7.75 -            l1start = l1tab = (l1_pgentry_t *)mpt_alloc; 
    7.76 -            mpt_alloc += PAGE_SIZE;
    7.77 -            *l2tab++ = mk_l2_pgentry((unsigned long)l1start | L2_PROT);
    7.78 +            phys_to_page(mpt_alloc)->u.inuse.type_info = PGT_l1_page_table;
    7.79 +            l1start = l1tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE;
    7.80              clear_page(l1tab);
    7.81              if ( count == 0 )
    7.82                  l1tab += l1_table_offset(dsi.v_start);
    7.83 +            if ( !((unsigned long)l2tab & (PAGE_SIZE-1)) )
    7.84 +            {
    7.85 +                phys_to_page(mpt_alloc)->u.inuse.type_info = PGT_l2_page_table;
    7.86 +                l2start = l2tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE;
    7.87 +                clear_page(l2tab);
    7.88 +                if ( count == 0 )
    7.89 +                    l2tab += l2_table_offset(dsi.v_start);
    7.90 +                if ( !((unsigned long)l3tab & (PAGE_SIZE-1)) )
    7.91 +                {
    7.92 +                    phys_to_page(mpt_alloc)->u.inuse.type_info =
    7.93 +                        PGT_l3_page_table;
    7.94 +                    l3start = l3tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE;
    7.95 +                    clear_page(l3tab);
    7.96 +                    if ( count == 0 )
    7.97 +                        l3tab += l3_table_offset(dsi.v_start);
    7.98 +                    *l4tab++ = mk_l4_pgentry(__pa(l3start) | L4_PROT);
    7.99 +                }
   7.100 +                *l3tab++ = mk_l3_pgentry(__pa(l2start) | L3_PROT);
   7.101 +            }
   7.102 +            *l2tab++ = mk_l2_pgentry(__pa(l1start) | L2_PROT);
   7.103          }
   7.104          *l1tab++ = mk_l1_pgentry((mfn << PAGE_SHIFT) | L1_PROT);
   7.105 -        
   7.106 +
   7.107          page = &frame_table[mfn];
   7.108 -        if ( !get_page_and_type(page, d, PGT_writable_page) )
   7.109 +        if ( (page->u.inuse.type_info == 0) &&
   7.110 +             !get_page_and_type(page, d, PGT_writable_page) )
   7.111              BUG();
   7.112  
   7.113          mfn++;
   7.114      }
   7.115  
   7.116      /* Pages that are part of page tables must be read only. */
   7.117 -    l2tab = l2start + l2_table_offset(vpt_start);
   7.118 -    l1start = l1tab = (l1_pgentry_t *)l2_pgentry_to_phys(*l2tab);
   7.119 +    l4tab = l4start + l4_table_offset(vpt_start);
   7.120 +    l3start = l3tab = l4_pgentry_to_l3(*l4tab);
   7.121 +    l3tab += l3_table_offset(vpt_start);
   7.122 +    l2start = l2tab = l3_pgentry_to_l2(*l3tab);
   7.123 +    l2tab += l2_table_offset(vpt_start);
   7.124 +    l1start = l1tab = l2_pgentry_to_l1(*l2tab);
   7.125      l1tab += l1_table_offset(vpt_start);
   7.126 -    l2tab++;
   7.127      for ( count = 0; count < nr_pt_pages; count++ ) 
   7.128      {
   7.129          *l1tab = mk_l1_pgentry(l1_pgentry_val(*l1tab) & ~_PAGE_RW);
   7.130          page = &frame_table[l1_pgentry_to_pagenr(*l1tab)];
   7.131 -        if ( count == 0 )
   7.132 -        {
   7.133 -            page->u.inuse.type_info &= ~PGT_type_mask;
   7.134 -            page->u.inuse.type_info |= PGT_l2_page_table;
   7.135 +
   7.136 +        /* Read-only mapping + PGC_allocated + page-table page. */
   7.137 +        page->count_info         = PGC_allocated | 3;
   7.138 +        page->u.inuse.type_info |= PGT_validated | 1;
   7.139  
   7.140 -            /*
   7.141 -             * No longer writable: decrement the type_count.
   7.142 -             * Installed as CR3: increment both the ref_count and type_count.
   7.143 -             * Net: just increment the ref_count.
   7.144 -             */
   7.145 -            get_page(page, d); /* an extra ref because of readable mapping */
   7.146 -
   7.147 -            /* Get another ref to L2 page so that it can be pinned. */
   7.148 -            if ( !get_page_and_type(page, d, PGT_l2_page_table) )
   7.149 -                BUG();
   7.150 -            set_bit(_PGT_pinned, &page->u.inuse.type_info);
   7.151 +        /* Top-level p.t. is pinned. */
   7.152 +        if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l4_page_table )
   7.153 +        {
   7.154 +            page->count_info        += 1;
   7.155 +            page->u.inuse.type_info += 1 | PGT_pinned;
   7.156          }
   7.157 -        else
   7.158 +
   7.159 +        /* Iterate. */
   7.160 +        if ( !((unsigned long)++l1tab & (PAGE_SIZE - 1)) )
   7.161          {
   7.162 -            page->u.inuse.type_info &= ~PGT_type_mask;
   7.163 -            page->u.inuse.type_info |= PGT_l1_page_table;
   7.164 -	    page->u.inuse.type_info |= 
   7.165 -		((dsi.v_start>>L2_PAGETABLE_SHIFT)+(count-1))<<PGT_va_shift;
   7.166 -
   7.167 -            /*
   7.168 -             * No longer writable: decrement the type_count.
   7.169 -             * This is an L1 page, installed in a validated L2 page:
   7.170 -             * increment both the ref_count and type_count.
   7.171 -             * Net: just increment the ref_count.
   7.172 -             */
   7.173 -            get_page(page, d); /* an extra ref because of readable mapping */
   7.174 +            if ( !((unsigned long)++l2tab & (PAGE_SIZE - 1)) )
   7.175 +            {
   7.176 +                if ( !((unsigned long)++l3tab & (PAGE_SIZE - 1)) )
   7.177 +                    l3start = l3tab = l4_pgentry_to_l3(*++l4tab); 
   7.178 +                l2start = l2tab = l3_pgentry_to_l2(*l3tab);
   7.179 +            }
   7.180 +            l1start = l1tab = l2_pgentry_to_l1(*l2tab);
   7.181          }
   7.182 -        l1tab++;
   7.183 -        if( !((unsigned long)l1tab & (PAGE_SIZE - 1)) )
   7.184 -            l1start = l1tab = (l1_pgentry_t *)l2_pgentry_to_phys(*l2tab);
   7.185      }
   7.186  
   7.187      /* Set up shared-info area. */
   7.188 @@ -365,12 +385,6 @@ int construct_dom0(struct domain *d,
   7.189      write_ptbase(&current->mm);
   7.190      __sti();
   7.191  
   7.192 -    /* Destroy low mappings - they were only for our convenience. */
   7.193 -    for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
   7.194 -        if ( l2_pgentry_val(l2start[i]) & _PAGE_PSE )
   7.195 -            l2start[i] = mk_l2_pgentry(0);
   7.196 -    zap_low_mappings(); /* Do the same for the idle page tables. */
   7.197 -    
   7.198      /* DOM0 gets access to everything. */
   7.199      physdev_init_dom0(d);
   7.200  
   7.201 @@ -378,12 +392,6 @@ int construct_dom0(struct domain *d,
   7.202  
   7.203      new_thread(ed, dsi.v_kernentry, vstack_end, vstartinfo_start);
   7.204  
   7.205 -#if 0 /* XXXXX DO NOT CHECK IN ENABLED !!! (but useful for testing so leave) */
   7.206 -    shadow_lock(&d->mm);
   7.207 -    shadow_mode_enable(p, SHM_test); 
   7.208 -    shadow_unlock(&d->mm);
   7.209 -#endif
   7.210 -
   7.211      return 0;
   7.212  }
   7.213  
     8.1 --- a/xen/arch/x86/x86_64/entry.S	Fri Feb 04 14:44:18 2005 +0000
     8.2 +++ b/xen/arch/x86/x86_64/entry.S	Fri Feb 04 19:26:10 2005 +0000
     8.3 @@ -12,25 +12,27 @@
     8.4  #include <public/xen.h>
     8.5  
     8.6  ENTRY(hypercall)
     8.7 -        iret
     8.8 -
     8.9 +        movl  $0x0833,8(%rsp)
    8.10 +        pushq %r11
    8.11 +        pushq $0x082b
    8.12 +        pushq %rcx
    8.13 +        pushq $0
    8.14 +        SAVE_ALL
    8.15 +	andq  $(NR_hypercalls-1),%rax
    8.16 +        leaq  SYMBOL_NAME(exception_table)(%rip),%rcx
    8.17 +        callq *(%rcx,%rax,8)
    8.18 +        RESTORE_ALL
    8.19 +        addq  $8,%rsp
    8.20 +        popq  %rcx
    8.21 +        addq  $8,%rsp
    8.22 +        popq  %r11
    8.23 +        cli
    8.24 +        popq  %rsp
    8.25 +        sysretq
    8.26 +        
    8.27  ENTRY(ret_from_intr)
    8.28  restore_all_xen:
    8.29 -        popq  %r15
    8.30 -        popq  %r14
    8.31 -        popq  %r13
    8.32 -        popq  %r12
    8.33 -        popq  %rbp
    8.34 -        popq  %rbx
    8.35 -        popq  %r11
    8.36 -        popq  %r10
    8.37 -        popq  %r9
    8.38 -        popq  %r8
    8.39 -        popq  %rax
    8.40 -        popq  %rcx
    8.41 -        popq  %rdx
    8.42 -        popq  %rsi
    8.43 -        popq  %rdi
    8.44 +        RESTORE_ALL
    8.45          addq  $8,%rsp
    8.46          iretq
    8.47  
    8.48 @@ -156,3 +158,33 @@ ENTRY(exception_table)
    8.49          .quad SYMBOL_NAME(do_alignment_check)
    8.50          .quad SYMBOL_NAME(do_machine_check)
    8.51          .quad SYMBOL_NAME(do_simd_coprocessor_error)
    8.52 +
    8.53 +ENTRY(hypercall_table)
    8.54 +        .quad SYMBOL_NAME(do_set_trap_table)     /*  0 */
    8.55 +        .quad SYMBOL_NAME(do_mmu_update)
    8.56 +        .quad SYMBOL_NAME(do_set_gdt)
    8.57 +        .quad SYMBOL_NAME(do_stack_switch)
    8.58 +        .quad SYMBOL_NAME(do_set_callbacks)
    8.59 +        .quad SYMBOL_NAME(do_fpu_taskswitch)     /*  5 */
    8.60 +        .quad SYMBOL_NAME(do_sched_op)
    8.61 +        .quad SYMBOL_NAME(do_dom0_op)
    8.62 +        .quad SYMBOL_NAME(do_set_debugreg)
    8.63 +        .quad SYMBOL_NAME(do_get_debugreg)
    8.64 +        .quad SYMBOL_NAME(do_update_descriptor)  /* 10 */
    8.65 +        .quad SYMBOL_NAME(do_ni_hypercall) # do_set_fast_trap
    8.66 +        .quad SYMBOL_NAME(do_dom_mem_op)
    8.67 +        .quad SYMBOL_NAME(do_multicall)
    8.68 +        .quad SYMBOL_NAME(do_update_va_mapping)
    8.69 +        .quad SYMBOL_NAME(do_set_timer_op)       /* 15 */
    8.70 +        .quad SYMBOL_NAME(do_event_channel_op)
    8.71 +        .quad SYMBOL_NAME(do_xen_version)
    8.72 +        .quad SYMBOL_NAME(do_console_io)
    8.73 +        .quad SYMBOL_NAME(do_physdev_op)
    8.74 +        .quad SYMBOL_NAME(do_grant_table_op)     /* 20 */
    8.75 +        .quad SYMBOL_NAME(do_vm_assist)
    8.76 +        .quad SYMBOL_NAME(do_update_va_mapping_otherdomain)
    8.77 +        .quad SYMBOL_NAME(do_ni_hypercall) # do_switch_vm86
    8.78 +        .quad SYMBOL_NAME(do_boot_vcpu)
    8.79 +        .rept NR_hypercalls-((.-hypercall_table)/4)
    8.80 +        .quad SYMBOL_NAME(do_ni_hypercall)
    8.81 +        .endr
     9.1 --- a/xen/arch/x86/x86_64/mm.c	Fri Feb 04 14:44:18 2005 +0000
     9.2 +++ b/xen/arch/x86/x86_64/mm.c	Fri Feb 04 19:26:10 2005 +0000
     9.3 @@ -118,8 +118,8 @@ void __init paging_init(void)
     9.4      unsigned long i, p, max;
     9.5  
     9.6      /* Map all of physical memory. */
     9.7 -    max = (max_page + (1UL << L2_PAGETABLE_SHIFT) - 1UL) &
     9.8 -        ~((1UL << L2_PAGETABLE_SHIFT) - 1UL);
     9.9 +    max = ((max_page + ENTRIES_PER_L1_PAGETABLE - 1) & 
    9.10 +           ~(ENTRIES_PER_L1_PAGETABLE - 1)) << PAGE_SHIFT;
    9.11      map_pages(idle_pg_table, PAGE_OFFSET, 0, max, PAGE_HYPERVISOR);
    9.12  
    9.13      /*
    10.1 --- a/xen/arch/x86/x86_64/traps.c	Fri Feb 04 14:44:18 2005 +0000
    10.2 +++ b/xen/arch/x86/x86_64/traps.c	Fri Feb 04 19:26:10 2005 +0000
    10.3 @@ -7,6 +7,8 @@
    10.4  #include <xen/mm.h>
    10.5  #include <xen/irq.h>
    10.6  #include <xen/console.h>
    10.7 +#include <xen/sched.h>
    10.8 +#include <asm/msr.h>
    10.9  
   10.10  static int kstack_depth_to_print = 8*20;
   10.11  
   10.12 @@ -176,6 +178,33 @@ void __init doublefault_init(void)
   10.13      idt_table[TRAP_double_fault].a |= 1UL << 32; /* IST1 */
   10.14  }
   10.15  
   10.16 +asmlinkage void hypercall(void);
   10.17 +void __init percpu_traps_init(void)
   10.18 +{
   10.19 +    char *stack_top = (char *)get_stack_top();
   10.20 +    char *stack     = (char *)((unsigned long)stack_top & ~(STACK_SIZE - 1));
   10.21 +
   10.22 +    /* movq %rsp, saversp(%rip) */
   10.23 +    stack[0] = 0x48;
   10.24 +    stack[1] = 0x89;
   10.25 +    stack[2] = 0x25;
   10.26 +    *(u32 *)&stack[3] = (stack_top - &stack[7]) - 16;
   10.27 +
   10.28 +    /* leaq saversp(%rip), %rsp */
   10.29 +    stack[7] = 0x48;
   10.30 +    stack[8] = 0x8d;
   10.31 +    stack[9] = 0x25;
   10.32 +    *(u32 *)&stack[10] = (stack_top - &stack[14]) - 16;
   10.33 +
   10.34 +    /* jmp hypercall */
   10.35 +    stack[14] = 0xe9;
   10.36 +    *(u32 *)&stack[15] = (char *)hypercall - &stack[19];
   10.37 +
   10.38 +    wrmsr(MSR_STAR,  0, (FLAT_RING3_CS64<<16) | __HYPERVISOR_CS); 
   10.39 +    wrmsr(MSR_LSTAR, (unsigned long)stack, ((unsigned long)stack>>32)); 
   10.40 +    wrmsr(MSR_SYSCALL_MASK, 0xFFFFFFFFU, 0U);
   10.41 +}
   10.42 +
   10.43  void *decode_reg(struct xen_regs *regs, u8 b)
   10.44  {
   10.45      switch ( b )
    11.1 --- a/xen/include/asm-x86/x86_64/asm_defns.h	Fri Feb 04 14:44:18 2005 +0000
    11.2 +++ b/xen/include/asm-x86/x86_64/asm_defns.h	Fri Feb 04 19:26:10 2005 +0000
    11.3 @@ -22,6 +22,23 @@
    11.4          "pushq %r14;" \
    11.5          "pushq %r15;"
    11.6  
    11.7 +#define RESTORE_ALL \
    11.8 +        "popq  %r15;" \
    11.9 +        "popq  %r14;" \
   11.10 +        "popq  %r13;" \
   11.11 +        "popq  %r12;" \
   11.12 +        "popq  %rbp;" \
   11.13 +        "popq  %rbx;" \
   11.14 +        "popq  %r11;" \
   11.15 +        "popq  %r10;" \
   11.16 +        "popq  %r9;" \
   11.17 +        "popq  %r8;" \
   11.18 +        "popq  %rax;" \
   11.19 +        "popq  %rcx;" \
   11.20 +        "popq  %rdx;" \
   11.21 +        "popq  %rsi;" \
   11.22 +        "popq  %rdi;"
   11.23 +
   11.24  #else
   11.25  
   11.26  #define SAVE_ALL \
   11.27 @@ -42,6 +59,23 @@
   11.28          pushq %r14; \
   11.29          pushq %r15;
   11.30  
   11.31 +#define RESTORE_ALL \
   11.32 +        popq  %r15; \
   11.33 +        popq  %r14; \
   11.34 +        popq  %r13; \
   11.35 +        popq  %r12; \
   11.36 +        popq  %rbp; \
   11.37 +        popq  %rbx; \
   11.38 +        popq  %r11; \
   11.39 +        popq  %r10; \
   11.40 +        popq  %r9; \
   11.41 +        popq  %r8; \
   11.42 +        popq  %rax; \
   11.43 +        popq  %rcx; \
   11.44 +        popq  %rdx; \
   11.45 +        popq  %rsi; \
   11.46 +        popq  %rdi;
   11.47 +
   11.48  #endif
   11.49  
   11.50  #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
    12.1 --- a/xen/include/public/arch-x86_32.h	Fri Feb 04 14:44:18 2005 +0000
    12.2 +++ b/xen/include/public/arch-x86_32.h	Fri Feb 04 19:26:10 2005 +0000
    12.3 @@ -49,13 +49,17 @@
    12.4   */
    12.5  #define FLAT_RING1_CS 0x0819    /* GDT index 259 */
    12.6  #define FLAT_RING1_DS 0x0821    /* GDT index 260 */
    12.7 +#define FLAT_RING1_SS 0x0821    /* GDT index 260 */
    12.8  #define FLAT_RING3_CS 0x082b    /* GDT index 261 */
    12.9  #define FLAT_RING3_DS 0x0833    /* GDT index 262 */
   12.10 +#define FLAT_RING3_SS 0x0833    /* GDT index 262 */
   12.11  
   12.12  #define FLAT_GUESTOS_CS FLAT_RING1_CS
   12.13  #define FLAT_GUESTOS_DS FLAT_RING1_DS
   12.14 +#define FLAT_GUESTOS_SS FLAT_RING1_SS
   12.15  #define FLAT_USER_CS    FLAT_RING3_CS
   12.16  #define FLAT_USER_DS    FLAT_RING3_DS
   12.17 +#define FLAT_USER_SS    FLAT_RING3_SS
   12.18  
   12.19  /* And the trap vector is... */
   12.20  #define TRAP_INSTR "int $0x82"
    13.1 --- a/xen/include/public/arch-x86_64.h	Fri Feb 04 14:44:18 2005 +0000
    13.2 +++ b/xen/include/public/arch-x86_64.h	Fri Feb 04 19:26:10 2005 +0000
    13.3 @@ -45,7 +45,9 @@
    13.4  #define FLAT_RING3_CS32 0x0823  /* GDT index 260 */
    13.5  #define FLAT_RING3_CS64 0x082b  /* GDT index 261 */
    13.6  #define FLAT_RING3_DS32 0x0833  /* GDT index 262 */
    13.7 -#define FLAT_RING3_DS64 0x0000
    13.8 +#define FLAT_RING3_DS64 0x0000  /* NULL selector */
    13.9 +#define FLAT_RING3_SS32 0x0833  /* GDT index 262 */
   13.10 +#define FLAT_RING3_SS64 0x0833  /* GDT index 262 */
   13.11  
   13.12  #define FLAT_GUESTOS_DS64 FLAT_RING3_DS64
   13.13  #define FLAT_GUESTOS_DS32 FLAT_RING3_DS32
   13.14 @@ -53,6 +55,9 @@
   13.15  #define FLAT_GUESTOS_CS64 FLAT_RING3_CS64
   13.16  #define FLAT_GUESTOS_CS32 FLAT_RING3_CS32
   13.17  #define FLAT_GUESTOS_CS   FLAT_GUESTOS_CS64
   13.18 +#define FLAT_GUESTOS_SS64 FLAT_RING3_SS64
   13.19 +#define FLAT_GUESTOS_SS32 FLAT_RING3_SS32
   13.20 +#define FLAT_GUESTOS_SS   FLAT_GUESTOS_SS64
   13.21  
   13.22  #define FLAT_USER_DS64 FLAT_RING3_DS64
   13.23  #define FLAT_USER_DS32 FLAT_RING3_DS32
   13.24 @@ -60,13 +65,21 @@
   13.25  #define FLAT_USER_CS64 FLAT_RING3_CS64
   13.26  #define FLAT_USER_CS32 FLAT_RING3_CS32
   13.27  #define FLAT_USER_CS   FLAT_USER_CS64
   13.28 +#define FLAT_USER_SS64 FLAT_RING3_SS64
   13.29 +#define FLAT_USER_SS32 FLAT_RING3_SS32
   13.30 +#define FLAT_USER_SS   FLAT_USER_SS64
   13.31  
   13.32  /* And the trap vector is... */
   13.33  #define TRAP_INSTR "syscall"
   13.34  
   13.35 +#ifndef HYPERVISOR_VIRT_START
   13.36 +#define HYPERVISOR_VIRT_START (0xFFFF800000000000UL)
   13.37 +#define HYPERVISOR_VIRT_END   (0xFFFF880000000000UL)
   13.38 +#endif
   13.39 +
   13.40  /* The machine->physical mapping table starts at this address, read-only. */
   13.41  #ifndef machine_to_phys_mapping
   13.42 -#define machine_to_phys_mapping ((unsigned long *)0xffff810000000000ULL)
   13.43 +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
   13.44  #endif
   13.45  
   13.46  #ifndef __ASSEMBLY__