ia64/xen-unstable

changeset 8684:f658587fdaac

Make SMP guests work in shadow translate mode.

Signed-off-by: Steven Smith, sos22@cam.ac.uk
author sos22@douglas.cl.cam.ac.uk
date Thu Jan 26 18:00:40 2006 +0100 (2006-01-26)
parents 0d95066795de
children edf1fab86618
files tools/libxc/xc_linux_build.c xen/arch/x86/domain.c xen/arch/x86/mm.c
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Thu Jan 26 14:39:12 2006 +0100
     1.2 +++ b/tools/libxc/xc_linux_build.c	Thu Jan 26 18:00:40 2006 +0100
     1.3 @@ -98,7 +98,10 @@ static int setup_pg_tables(int xc_handle
     1.4      ppt_alloc = (vpt_start - dsi_v_start) >> PAGE_SHIFT;
     1.5      alloc_pt(l2tab, vl2tab, pl2tab);
     1.6      vl2e = &vl2tab[l2_table_offset(dsi_v_start)];
     1.7 -    ctxt->ctrlreg[3] = l2tab;
     1.8 +    if (shadow_mode_enabled)
     1.9 +        ctxt->ctrlreg[3] = pl2tab;
    1.10 +    else
    1.11 +        ctxt->ctrlreg[3] = l2tab;
    1.12  
    1.13      for ( count = 0; count < ((v_end - dsi_v_start) >> PAGE_SHIFT); count++ )
    1.14      {
    1.15 @@ -166,7 +169,10 @@ static int setup_pg_tables_pae(int xc_ha
    1.16  
    1.17      alloc_pt(l3tab, vl3tab, pl3tab);
    1.18      vl3e = &vl3tab[l3_table_offset_pae(dsi_v_start)];
    1.19 -    ctxt->ctrlreg[3] = l3tab;
    1.20 +    if (shadow_mode_enabled)
    1.21 +        ctxt->ctrlreg[3] = pl3tab;
    1.22 +    else
    1.23 +        ctxt->ctrlreg[3] = l3tab;
    1.24  
    1.25      for ( count = 0; count < ((v_end - dsi_v_start) >> PAGE_SHIFT); count++)
    1.26      {
    1.27 @@ -246,7 +252,10 @@ static int setup_pg_tables_64(int xc_han
    1.28      ppt_alloc = (vpt_start - dsi_v_start) >> PAGE_SHIFT;
    1.29      alloc_pt(l4tab, vl4tab);
    1.30      vl4e = &vl4tab[l4_table_offset(dsi_v_start)];
    1.31 -    ctxt->ctrlreg[3] = l4tab;
    1.32 +    if (shadow_mode_enabled)
    1.33 +        ctxt->ctrlreg[3] = pl4tab;
    1.34 +    else
    1.35 +        ctxt->ctrlreg[3] = l4tab;
    1.36      
    1.37      for ( count = 0; count < ((v_end-dsi_v_start)>>PAGE_SHIFT); count++)
    1.38      {
     2.1 --- a/xen/arch/x86/domain.c	Thu Jan 26 14:39:12 2006 +0100
     2.2 +++ b/xen/arch/x86/domain.c	Thu Jan 26 18:00:40 2006 +0100
     2.3 @@ -348,6 +348,7 @@ int arch_set_info_guest(
     2.4      struct domain *d = v->domain;
     2.5      unsigned long phys_basetab;
     2.6      int i, rc;
     2.7 +    unsigned got_basetab_type;
     2.8  
     2.9      /*
    2.10       * This is sufficient! If the descriptor DPL differs from CS RPL then we'll
    2.11 @@ -401,23 +402,32 @@ int arch_set_info_guest(
    2.12          d->vm_assist = c->vm_assist;
    2.13  
    2.14      phys_basetab = c->ctrlreg[3];
    2.15 +    phys_basetab =
    2.16 +        (__gpfn_to_mfn(d, phys_basetab >> PAGE_SHIFT) << PAGE_SHIFT) |
    2.17 +        (phys_basetab & ~PAGE_MASK);
    2.18 +
    2.19      v->arch.guest_table = mk_pagetable(phys_basetab);
    2.20  
    2.21      if ( shadow_mode_refcounts(d) )
    2.22      {
    2.23          if ( !get_page(pfn_to_page(phys_basetab>>PAGE_SHIFT), d) )
    2.24              return -EINVAL;
    2.25 +        got_basetab_type = 0;
    2.26      }
    2.27      else if ( !(c->flags & VGCF_VMX_GUEST) )
    2.28      {
    2.29          if ( !get_page_and_type(pfn_to_page(phys_basetab>>PAGE_SHIFT), d,
    2.30                                  PGT_base_page_table) )
    2.31              return -EINVAL;
    2.32 +        got_basetab_type = 1;
    2.33      }
    2.34  
    2.35      if ( (rc = (int)set_gdt(v, c->gdt_frames, c->gdt_ents)) != 0 )
    2.36      {
    2.37 -        put_page_and_type(pfn_to_page(phys_basetab>>PAGE_SHIFT));
    2.38 +        if (got_basetab_type)
    2.39 +            put_page_and_type(pfn_to_page(phys_basetab>>PAGE_SHIFT));
    2.40 +        else
    2.41 +            put_page(pfn_to_page(phys_basetab>>PAGE_SHIFT));
    2.42          return rc;
    2.43      }
    2.44  
     3.1 --- a/xen/arch/x86/mm.c	Thu Jan 26 14:39:12 2006 +0100
     3.2 +++ b/xen/arch/x86/mm.c	Thu Jan 26 18:00:40 2006 +0100
     3.3 @@ -2153,9 +2153,7 @@ int do_mmu_update(
     3.4          case MMU_MACHPHYS_UPDATE:
     3.5  
     3.6              if (shadow_mode_translate(FOREIGNDOM)) {
     3.7 -                /* We don't allow translate mode guests to have their
     3.8 -                   M2P tables mutated while they're running. */
     3.9 -                okay = 0;
    3.10 +                MEM_LOG("can't mutate m2p table of translate mode guest");
    3.11                  break;
    3.12              }
    3.13  
    3.14 @@ -2637,7 +2635,7 @@ long set_gdt(struct vcpu *v,
    3.15  
    3.16      /* Check the pages in the new GDT. */
    3.17      for ( i = 0; i < nr_pages; i++ ) {
    3.18 -        pfn = frames[i];
    3.19 +        pfn = frames[i] = __gpfn_to_mfn(d, frames[i]);
    3.20          if ((pfn >= max_page) ||
    3.21              !get_page_and_type(pfn_to_page(pfn), d, PGT_gdt_page) )
    3.22              goto fail;
    3.23 @@ -2669,7 +2667,6 @@ long do_set_gdt(unsigned long *frame_lis
    3.24      int nr_pages = (entries + 511) / 512;
    3.25      unsigned long frames[16];
    3.26      long ret;
    3.27 -    int x;
    3.28  
    3.29      /* Rechecked in set_gdt, but ensures a sane limit for copy_from_user(). */
    3.30      if ( entries > FIRST_RESERVED_GDT_ENTRY )
    3.31 @@ -2678,11 +2675,6 @@ long do_set_gdt(unsigned long *frame_lis
    3.32      if ( copy_from_user(frames, frame_list, nr_pages * sizeof(unsigned long)) )
    3.33          return -EFAULT;
    3.34  
    3.35 -    if (shadow_mode_translate(current->domain)) {
    3.36 -        for (x = 0; x < nr_pages; x++)
    3.37 -            frames[x] = __gpfn_to_mfn(current->domain, frames[x]);
    3.38 -    }
    3.39 -
    3.40      LOCK_BIGLOCK(current->domain);
    3.41  
    3.42      if ( (ret = set_gdt(current, frames, entries)) == 0 )