From: Mukesh Rathor Date: Wed, 4 Jun 2014 09:27:50 +0000 (+0200) Subject: x86/PVH: avoid call to handle_mmio X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4905 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7c4870915c2d50acbc66347a532e33b452f64f17;p=xen.git x86/PVH: avoid call to handle_mmio handle_mmio() is currently unsafe for pvh guests. A call to it would result in call to vioapic_range that will crash xen since the vioapic ptr in struct hvm_domain is not initialized for pvh guests. However, one path exists for such a call. If a pvh guest, dom0 or domU, unintentionally touches non-existing memory, an EPT violation would occur. This would result in unconditional call to hvm_hap_nested_page_fault. In that function, because get_gfn_type_access returns p2m_mmio_dm for non existing mfns by default, handle_mmio() will get called. This would result in xen crash instead of the guest crash. This patch addresses that. Signed-off-by: Mukesh Rathor --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 163e62a589..4f993f4bd1 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2743,6 +2743,11 @@ int hvm_hap_nested_page_fault(paddr_t gpa, (access_w && (p2mt == p2m_ram_ro)) ) { put_gfn(p2m->domain, gfn); + + rc = 0; + if ( unlikely(is_pvh_vcpu(v)) ) + goto out; + if ( !handle_mmio() ) hvm_inject_hw_exception(TRAP_gp_fault, 0); rc = 1; diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index a8fe0aa29c..b2b7b2736c 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -84,6 +84,8 @@ int handle_mmio(void) struct hvm_vcpu_io *vio = &curr->arch.hvm_vcpu.hvm_io; int rc; + ASSERT(!is_pvh_vcpu(curr)); + hvm_emulate_prepare(&ctxt, guest_cpu_user_regs()); rc = hvm_emulate_one(&ctxt);