From: cegger Date: Mon, 28 Feb 2011 11:21:52 +0000 (+0100) Subject: When injecting an exception into L2 guest, X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10535 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b3677ee4e0ad7700eb61e9924e0fb21eed5c9c8c;p=xen.git When injecting an exception into L2 guest, inject a #VMEXIT if L1 guest intercepts the exception Signed-off-by: Christoph Egger Acked-by: Eddie Dong Acked-by: Tim Deegan Committed-by: Tim Deegan --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index d52b4f8659..b1fe14bdae 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1117,6 +1117,47 @@ void hvm_triple_fault(void) domain_shutdown(v->domain, SHUTDOWN_reboot); } +void hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2) +{ + struct vcpu *v = current; + + if ( !nestedhvm_enabled(v->domain) ) { + hvm_funcs.inject_exception(trapnr, errcode, cr2); + return; + } + + if ( nestedhvm_vmswitch_in_progress(v) ) { + hvm_funcs.inject_exception(trapnr, errcode, cr2); + return; + } + + if ( !nestedhvm_vcpu_in_guestmode(v) ) { + hvm_funcs.inject_exception(trapnr, errcode, cr2); + return; + } + + if ( nhvm_vmcx_guest_intercepts_trap(v, trapnr) ) + { + enum nestedhvm_vmexits nsret; + + nsret = nhvm_vcpu_vmexit_trap(v, trapnr, errcode, cr2); + + switch (nsret) { + case NESTEDHVM_VMEXIT_DONE: + case NESTEDHVM_VMEXIT_ERROR: /* L1 guest will crash L2 guest */ + return; + case NESTEDHVM_VMEXIT_HOST: + case NESTEDHVM_VMEXIT_CONTINUE: + case NESTEDHVM_VMEXIT_FATALERROR: + default: + gdprintk(XENLOG_ERR, "unexpected nestedhvm error %i\n", nsret); + return; + } + } + + hvm_funcs.inject_exception(trapnr, errcode, cr2); +} + bool_t hvm_hap_nested_page_fault(unsigned long gpa, bool_t gla_valid, unsigned long gla, diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index a01849af87..bf06790389 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -278,11 +278,7 @@ void hvm_migrate_timers(struct vcpu *v); void hvm_do_resume(struct vcpu *v); void hvm_migrate_pirqs(struct vcpu *v); -static inline void -hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2) -{ - hvm_funcs.inject_exception(trapnr, errcode, cr2); -} +void hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2); static inline int hvm_event_pending(struct vcpu *v) {