diff mbox

[kvm-unit-tests,2/4] x86: vmx: fix vm{launch,resume} early exit logic

Message ID e37de36e717fea8312ea6cfc18fbc99154120301.1458340713.git.pfeiner@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Feiner March 18, 2016, 10:39 p.m. UTC
If vmlaunch or vmresume returns immediately, there's definitely been
an error -- rflags only needs to be consulted to determine what
error occurred. By setting fail=1 unconditionally, the test framework
will now detect problems with rflags *not* being set properly.

Signed-off-by: Peter Feiner <pfeiner@google.com>
---
 x86/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini March 19, 2016, 9:18 a.m. UTC | #1
On 18/03/2016 23:39, Peter Feiner wrote:
> If vmlaunch or vmresume returns immediately, there's definitely been
> an error -- rflags only needs to be consulted to determine what
> error occurred. By setting fail=1 unconditionally, the test framework
> will now detect problems with rflags *not* being set properly.

You should still do the setbe, and follow it with orl $2, %0.  Then if
fail==2 there is a problem.

Paolo

> Signed-off-by: Peter Feiner <pfeiner@google.com>
> ---
>  x86/vmx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/x86/vmx.c b/x86/vmx.c
> index b2e015f..27e85eb 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -911,6 +911,7 @@ static int vmx_run()
>  	u32 ret = 0, fail = 0;
>  
>  	while (1) {
> +
>  		asm volatile (
>  			"mov %%rsp, %%rsi\n\t"
>  			"mov %2, %%rdi\n\t"
> @@ -926,7 +927,7 @@ static int vmx_run()
>  			"vmresume\n\t"
>  			"2: "
>  			SAVE_GPR_C
> -			"setbe %0\n\t"
> +			"movl $1, %0\n\t"
>  			"jmp 3f\n\t"
>  			"vmx_return:\n\t"
>  			SAVE_GPR_C
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini March 19, 2016, 9:20 a.m. UTC | #2
On 19/03/2016 10:18, Paolo Bonzini wrote:
> 
> 
> On 18/03/2016 23:39, Peter Feiner wrote:
>> If vmlaunch or vmresume returns immediately, there's definitely been
>> an error -- rflags only needs to be consulted to determine what
>> error occurred. By setting fail=1 unconditionally, the test framework
>> will now detect problems with rflags *not* being set properly.
> 
> You should still do the setbe, and follow it with orl $2, %0.  Then if
> fail==2 there is a problem.

Nevermind, this is checked already below.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/x86/vmx.c b/x86/vmx.c
index b2e015f..27e85eb 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -911,6 +911,7 @@  static int vmx_run()
 	u32 ret = 0, fail = 0;
 
 	while (1) {
+
 		asm volatile (
 			"mov %%rsp, %%rsi\n\t"
 			"mov %2, %%rdi\n\t"
@@ -926,7 +927,7 @@  static int vmx_run()
 			"vmresume\n\t"
 			"2: "
 			SAVE_GPR_C
-			"setbe %0\n\t"
+			"movl $1, %0\n\t"
 			"jmp 3f\n\t"
 			"vmx_return:\n\t"
 			SAVE_GPR_C