ia64/xen-unstable

changeset 19051:40d9d9ff435a

x86 p2m: Apply correct 4GB NPT limit check in two places.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 15 12:54:31 2009 +0000 (2009-01-15)
parents d84504432e61
children 71e0b8adeb1f
files xen/arch/x86/mm/p2m.c
line diff
     1.1 --- a/xen/arch/x86/mm/p2m.c	Thu Jan 15 12:41:44 2009 +0000
     1.2 +++ b/xen/arch/x86/mm/p2m.c	Thu Jan 15 12:54:31 2009 +0000
     1.3 @@ -1890,6 +1890,30 @@ guest_physmap_remove_page(struct domain 
     1.4      p2m_unlock(d->arch.p2m);
     1.5  }
     1.6  
     1.7 +#if CONFIG_PAGING_LEVELS == 3
     1.8 +static int gfn_check_limit(
     1.9 +    struct domain *d, unsigned long gfn, unsigned int order)
    1.10 +{
    1.11 +    /*
    1.12 +     * 32bit AMD nested paging does not support over 4GB guest due to 
    1.13 +     * hardware translation limit. This limitation is checked by comparing
    1.14 +     * gfn with 0xfffffUL.
    1.15 +     */
    1.16 +    if ( !paging_mode_hap(d) || ((gfn + (1ul << order)) <= 0x100000UL) ||
    1.17 +         (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) )
    1.18 +        return 0;
    1.19 +
    1.20 +    if ( !test_and_set_bool(d->arch.hvm_domain.svm.npt_4gb_warning) )
    1.21 +        dprintk(XENLOG_WARNING, "Dom%d failed to populate memory beyond"
    1.22 +                " 4GB: specify 'hap=0' domain config option.\n",
    1.23 +                d->domain_id);
    1.24 +
    1.25 +    return -EINVAL;
    1.26 +}
    1.27 +#else
    1.28 +#define gfn_check_limit(d, g, o) 0
    1.29 +#endif
    1.30 +
    1.31  int
    1.32  guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn,
    1.33                                        unsigned int order)
    1.34 @@ -1903,21 +1927,9 @@ guest_physmap_mark_populate_on_demand(st
    1.35  
    1.36      BUG_ON(!paging_mode_translate(d));
    1.37  
    1.38 -#if CONFIG_PAGING_LEVELS == 3
    1.39 -    /*
    1.40 -     * 32bit PAE nested paging does not support over 4GB guest due to 
    1.41 -     * hardware translation limit. This limitation is checked by comparing
    1.42 -     * gfn with 0xfffffUL.
    1.43 -     */
    1.44 -    if ( paging_mode_hap(d) && (gfn > 0xfffffUL) )
    1.45 -    {
    1.46 -        if ( !test_and_set_bool(d->arch.hvm_domain.svm.npt_4gb_warning) )
    1.47 -            dprintk(XENLOG_WARNING, "Dom%d failed to populate memory beyond"
    1.48 -                    " 4GB: specify 'hap=0' domain config option.\n",
    1.49 -                    d->domain_id);
    1.50 -        return -EINVAL;
    1.51 -    }
    1.52 -#endif
    1.53 +    rc = gfn_check_limit(d, gfn, order);
    1.54 +    if ( rc != 0 )
    1.55 +        return rc;
    1.56  
    1.57      p2m_lock(p2md);
    1.58      audit_p2m(d);
    1.59 @@ -1987,22 +1999,9 @@ guest_physmap_add_entry(struct domain *d
    1.60          return 0;
    1.61      }
    1.62  
    1.63 -#if CONFIG_PAGING_LEVELS == 3
    1.64 -    /*
    1.65 -     * 32bit AMD nested paging does not support over 4GB guest due to 
    1.66 -     * hardware translation limit. This limitation is checked by comparing
    1.67 -     * gfn with 0xfffffUL.
    1.68 -     */
    1.69 -    if ( paging_mode_hap(d) && (gfn > 0xfffffUL) &&
    1.70 -         (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) )
    1.71 -    {
    1.72 -        if ( !test_and_set_bool(d->arch.hvm_domain.svm.npt_4gb_warning) )
    1.73 -            dprintk(XENLOG_WARNING, "Dom%d failed to populate memory beyond"
    1.74 -                    " 4GB: specify 'hap=0' domain config option.\n",
    1.75 -                    d->domain_id);
    1.76 -        return -EINVAL;
    1.77 -    }
    1.78 -#endif
    1.79 +    rc = gfn_check_limit(d, gfn, order);
    1.80 +    if ( rc != 0 )
    1.81 +        return rc;
    1.82  
    1.83      p2m_lock(d->arch.p2m);
    1.84      audit_p2m(d);