ia64/xen-unstable

changeset 13481:e5f585514b16

[XEN] Simplify CR3 switching code (remove slow path that allows old
page tables to be writable in new page tables -- shadow mode cannot
handle the failure case and it is easy to work around this in the
guest anyway). Also remove broken shadow-refcount compat-mode case.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Wed Jan 17 22:27:56 2007 +0000 (2007-01-17)
parents 05c1db1b8cb9
children 8e79d8d87ecd
files xen/arch/x86/mm.c
line diff
     1.1 --- a/xen/arch/x86/mm.c	Wed Jan 17 21:07:43 2007 +0000
     1.2 +++ b/xen/arch/x86/mm.c	Wed Jan 17 22:27:56 2007 +0000
     1.3 @@ -1768,25 +1768,14 @@ int new_guest_cr3(unsigned long mfn)
     1.4      int okay;
     1.5      unsigned long old_base_mfn;
     1.6  
     1.7 -    if ( is_hvm_domain(d) && !hvm_paging_enabled(v) )
     1.8 -        return 0;
     1.9 -
    1.10  #ifdef CONFIG_COMPAT
    1.11      if ( IS_COMPAT(d) )
    1.12      {
    1.13 -        l4_pgentry_t l4e = l4e_from_pfn(
    1.14 -            mfn, _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED);
    1.15 -
    1.16 -        if ( shadow_mode_refcounts(d) )
    1.17 -        {
    1.18 -            okay = get_page_from_pagenr(mfn, d);
    1.19 -            old_base_mfn = l4e_get_pfn(l4e);
    1.20 -            if ( okay && old_base_mfn )
    1.21 -                put_page(mfn_to_page(old_base_mfn));
    1.22 -        }
    1.23 -        else
    1.24 -            okay = mod_l4_entry(__va(pagetable_get_paddr(v->arch.guest_table)),
    1.25 -                                l4e, 0);
    1.26 +        okay = shadow_mode_refcounts(d)
    1.27 +            ? 0 /* Old code was broken, but what should it be? */
    1.28 +            : mod_l4_entry(__va(pagetable_get_paddr(v->arch.guest_table)),
    1.29 +                           l4e_from_pfn(mfn, (_PAGE_PRESENT|_PAGE_RW|
    1.30 +                                              _PAGE_USER|_PAGE_ACCESSED)), 0);
    1.31          if ( unlikely(!okay) )
    1.32          {
    1.33              MEM_LOG("Error while installing new compat baseptr %lx", mfn);
    1.34 @@ -1799,39 +1788,13 @@ int new_guest_cr3(unsigned long mfn)
    1.35          return 1;
    1.36      }
    1.37  #endif
    1.38 -    if ( shadow_mode_refcounts(d) )
    1.39 -    {
    1.40 -        okay = get_page_from_pagenr(mfn, d);
    1.41 -        if ( unlikely(!okay) )
    1.42 -        {
    1.43 -            MEM_LOG("Error while installing new baseptr %lx", mfn);
    1.44 -            return 0;
    1.45 -        }
    1.46 -    }
    1.47 -    else
    1.48 +    okay = shadow_mode_refcounts(d)
    1.49 +        ? get_page_from_pagenr(mfn, d)
    1.50 +        : get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d);
    1.51 +    if ( unlikely(!okay) )
    1.52      {
    1.53 -        okay = get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d);
    1.54 -        if ( unlikely(!okay) )
    1.55 -        {
    1.56 -            /* Switch to idle pagetable: this VCPU has no active p.t. now. */
    1.57 -            MEM_LOG("New baseptr %lx: slow path via idle pagetables", mfn);
    1.58 -            old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
    1.59 -            v->arch.guest_table = pagetable_null();
    1.60 -            update_cr3(v);
    1.61 -            write_cr3(__pa(idle_pg_table));
    1.62 -            if ( old_base_mfn != 0 )
    1.63 -                put_page_and_type(mfn_to_page(old_base_mfn));
    1.64 -
    1.65 -            /* Retry the validation with no active p.t. for this VCPU. */
    1.66 -            okay = get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d);
    1.67 -            if ( !okay )
    1.68 -            {
    1.69 -                /* Failure here is unrecoverable: the VCPU has no pagetable! */
    1.70 -                MEM_LOG("Fatal error while installing new baseptr %lx", mfn);
    1.71 -                domain_crash(d);
    1.72 -                return 0;
    1.73 -            }
    1.74 -        }
    1.75 +        MEM_LOG("Error while installing new baseptr %lx", mfn);
    1.76 +        return 0;
    1.77      }
    1.78  
    1.79      invalidate_shadow_ldt(v);
    1.80 @@ -1839,7 +1802,7 @@ int new_guest_cr3(unsigned long mfn)
    1.81      old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
    1.82  
    1.83      v->arch.guest_table = pagetable_from_pfn(mfn);
    1.84 -    update_cr3(v); /* update shadow_table and cr3 fields of vcpu struct */
    1.85 +    update_cr3(v);
    1.86  
    1.87      write_ptbase(v);
    1.88