diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index a8f5a19da9..d75dc2b9ed 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "private.h" @@ -405,8 +406,13 @@ static mfn_t hap_make_monitor_table(struct vcpu *v) return m4mfn; oom: - printk(XENLOG_G_ERR "out of memory building monitor pagetable\n"); - domain_crash(d); + if ( !d->is_dying && + (!d->is_shutting_down || d->shutdown_code != SHUTDOWN_crash) ) + { + printk(XENLOG_G_ERR "%pd: out of memory building monitor pagetable\n", + d); + domain_crash(d); + } return INVALID_MFN; } @@ -766,6 +772,9 @@ static void hap_update_paging_modes(struct vcpu *v) if ( pagetable_is_null(v->arch.hvm.monitor_table) ) { mfn_t mmfn = hap_make_monitor_table(v); + + if ( mfn_eq(mmfn, INVALID_MFN) ) + goto unlock; v->arch.hvm.monitor_table = pagetable_from_mfn(mmfn); make_cr3(v, mmfn); hvm_update_host_cr3(v); @@ -774,6 +783,7 @@ static void hap_update_paging_modes(struct vcpu *v) /* CR3 is effectively updated by a mode change. Flush ASIDs, etc. */ hap_update_cr3(v, 0, false); + unlock: paging_unlock(d); put_gfn(d, cr3_gfn); }