From 2dc1902e6756163ceb1f079bede9c047725a7097 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 11 Jan 2019 02:50:20 -0700 Subject: [PATCH] nested-vmx: exceptions take priority over VMFail* The way the instruction invocations are coded, it is compiler version dependent whether things work: With old gcc, fail_{,in}valid will not get touched and hence remain at their initial values, while with newer gcc evaluation of the status flags occurs outside of the asm(), i.e. also when an exception was received (in which case EFLAGS didn't change from its value before the faulting instruction). Since it is more logical anyway to check for a possible exception first, do so uniformly instead of trying to fiddle with the asm() in some way. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- tests/nested-vmx/util.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/nested-vmx/util.c b/tests/nested-vmx/util.c index e44ae73..61611ab 100644 --- a/tests/nested-vmx/util.c +++ b/tests/nested-vmx/util.c @@ -90,12 +90,14 @@ exinfo_t stub_vmxon(uint64_t paddr) : [paddr] "m" (paddr), "X" (ex_record_fault_edi)); - if ( fail_invalid ) + if ( ex ) + return ex; + else if ( fail_invalid ) return VMERR_INVALID; else if ( fail_valid ) return get_vmx_insn_err(); else - return ex; + return VMERR_SUCCESS; } exinfo_t stub_vmptrld(uint64_t paddr) @@ -114,12 +116,14 @@ exinfo_t stub_vmptrld(uint64_t paddr) : [paddr] "m" (paddr), "X" (ex_record_fault_edi)); - if ( fail_invalid ) + if ( ex ) + return ex; + else if ( fail_invalid ) return VMERR_INVALID; else if ( fail_valid ) return get_vmx_insn_err(); else - return ex; + return VMERR_SUCCESS; } exinfo_t __user_text stub_vmxon_user(uint64_t paddr) @@ -138,12 +142,14 @@ exinfo_t __user_text stub_vmxon_user(uint64_t paddr) : [paddr] "m" (paddr), "X" (ex_record_fault_edi)); - if ( fail_invalid ) + if ( ex ) + return ex; + else if ( fail_invalid ) return VMERR_INVALID; else if ( fail_valid ) return get_vmx_insn_err(); else - return ex; + return VMERR_SUCCESS; } /* -- 2.39.5