# HG changeset patch
# User Tim Deegan <tim@xxxxxxx>
# Date 1319452148 -3600
# Node ID ffe861c1d5dfa8f4485052e5600e06124105033f
# Parent a7ccbc79fc17862c21e34c2f145a5a053711f917
nestedhvm: handle l2 guest MMIO access
Hyper-V starts a root domain which effectively an l2 guest.
Hyper-V passes its devices through to the root domain and
let it do the MMIO accesses. The emulation is done by
Xen (host) and Hyper-V forwards the interrupts to the l2 guest.
Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
Acked-by: Tim Deegan <tim@xxxxxxx>
Committed-by: Tim Deegan <tim@xxxxxxx>
---
diff -r a7ccbc79fc17 -r ffe861c1d5df xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c Fri Oct 21 09:45:24 2011 +0200
+++ b/xen/arch/x86/hvm/hvm.c Mon Oct 24 11:29:08 2011 +0100
@@ -1208,6 +1208,10 @@
return 0;
case NESTEDHVM_PAGEFAULT_INJECT:
return -1;
+ case NESTEDHVM_PAGEFAULT_MMIO:
+ if ( !handle_mmio() )
+ hvm_inject_exception(TRAP_gp_fault, 0, 0);
+ return 1;
}
}
diff -r a7ccbc79fc17 -r ffe861c1d5df xen/arch/x86/hvm/svm/nestedsvm.c
--- a/xen/arch/x86/hvm/svm/nestedsvm.c Fri Oct 21 09:45:24 2011 +0200
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c Mon Oct 24 11:29:08 2011 +0100
@@ -1161,6 +1161,15 @@
if ( svm->ns_hostflags.fields.vintrmask )
if ( !svm->ns_hostflags.fields.rflagsif )
return hvm_intblk_rflags_ie;
+
+ /* when l1 guest passes its devices through to the l2 guest
+ * and l2 guest does an MMIO access then we may want to
+ * inject an VMEXIT(#INTR) exitcode into the l1 guest.
+ * Delay the injection because this would result in delivering
+ * an interrupt *within* the execution of an instruction.
+ */
+ if ( v->arch.hvm_vcpu.io_state != HVMIO_none )
+ return hvm_intblk_shadow;
}
if ( nv->nv_vmexit_pending ) {
diff -r a7ccbc79fc17 -r ffe861c1d5df xen/arch/x86/mm/hap/nested_hap.c
--- a/xen/arch/x86/mm/hap/nested_hap.c Fri Oct 21 09:45:24 2011 +0200
+++ b/xen/arch/x86/mm/hap/nested_hap.c Mon Oct 24 11:29:08 2011 +0100
@@ -151,6 +151,9 @@
mfn = gfn_to_mfn_type_p2m(p2m, L1_gpa >> PAGE_SHIFT, &p2mt, &p2ma,
p2m_query, page_order);
+ if ( p2m_is_mmio(p2mt) )
+ return NESTEDHVM_PAGEFAULT_MMIO;
+
if ( p2m_is_paging(p2mt) || p2m_is_shared(p2mt) || !p2m_is_ram(p2mt) )
return NESTEDHVM_PAGEFAULT_ERROR;
@@ -228,6 +231,8 @@
return rv;
case NESTEDHVM_PAGEFAULT_DONE:
break;
+ case NESTEDHVM_PAGEFAULT_MMIO:
+ return rv;
default:
BUG();
break;
diff -r a7ccbc79fc17 -r ffe861c1d5df xen/include/asm-x86/hvm/nestedhvm.h
--- a/xen/include/asm-x86/hvm/nestedhvm.h Fri Oct 21 09:45:24 2011 +0200
+++ b/xen/include/asm-x86/hvm/nestedhvm.h Mon Oct 24 11:29:08 2011 +0100
@@ -50,6 +50,7 @@
#define NESTEDHVM_PAGEFAULT_DONE 0
#define NESTEDHVM_PAGEFAULT_INJECT 1
#define NESTEDHVM_PAGEFAULT_ERROR 2
+#define NESTEDHVM_PAGEFAULT_MMIO 3
int nestedhvm_hap_nested_page_fault(struct vcpu *v, paddr_t L2_gpa);
/* IO permission map */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|