File 19801-x86-p2m-2mb-hap-only.patch of Package xen
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1245397378 -3600
# Node ID c3a94ac4c03172d31eab8899013f9253592fe20f
# Parent 78962f85c56279118b96f64f4042b591f5b85e26
P2M: check whether hap mode is enabled before using 2mb pages
This small patch checks whether hap mode is enabled when guest is
trying to allocate 2MB pages inside P2M. This prevents potential
errors when hap is disabled.
Cc: Chris Lalancette <clalance@redhat.com>
Cc: Sarathy, Bhavna <Bhavna.Sarathy@amd.com>
Signed-off-by: Wei Huang <wei.huang2@amd.com>
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -541,7 +541,11 @@ int set_p2m_entry(struct domain *d, unsi
while ( todo )
{
- order = (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0;
+ if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled )
+ order = (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ?
+ 9 : 0;
+ else
+ order = 0;
rc = d->arch.p2m->set_entry(d, gfn, mfn, order, p2mt);
gfn += 1ul << order;
if ( mfn_x(mfn) != INVALID_MFN )