From 0a1e25103aebfb48abb1f904ccc4ebf8c9a82c3c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 20 Apr 2012 09:33:35 +0100 Subject: [PATCH] Clean up convoluted hvm_inject_exception() logic. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/hvm.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index e353acfb2e..42d545ba40 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1203,30 +1203,19 @@ void hvm_triple_fault(void) 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; - } + struct vcpu *curr = current; - if ( nhvm_vmcx_guest_intercepts_trap(v, trapnr, errcode) ) + if ( nestedhvm_enabled(curr->domain) && + !nestedhvm_vmswitch_in_progress(curr) && + nestedhvm_vcpu_in_guestmode(curr) && + nhvm_vmcx_guest_intercepts_trap(curr, trapnr, errcode) ) { enum nestedhvm_vmexits nsret; - nsret = nhvm_vcpu_vmexit_trap(v, trapnr, errcode, cr2); + nsret = nhvm_vcpu_vmexit_trap(curr, trapnr, errcode, cr2); - switch (nsret) { + switch ( nsret ) + { case NESTEDHVM_VMEXIT_DONE: case NESTEDHVM_VMEXIT_ERROR: /* L1 guest will crash L2 guest */ return; -- 2.39.5