diff mbox

[04/13] VMX: Fix return label in fault-triggering handlers

Message ID 59793077f3173bfa9f211c38617d288611f3a11f.1388858359.git.jan.kiszka@web.de (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka Jan. 4, 2014, 5:59 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Some compiler versions (seen with gcc 4.8.1) move the resume label after
the return statement which, of course, causes sever problems.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 x86/vmx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini Jan. 22, 2014, 3 p.m. UTC | #1
Il 04/01/2014 18:59, Jan Kiszka ha scritto:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Some compiler versions (seen with gcc 4.8.1) move the resume label after
> the return statement which, of course, causes sever problems.

Can you include the assembly output?  Do you mean after the "ret" 
instruction?

The return should not be needed except for the rule that a label must be 
followed by a statement.  But I would not except any difference between 
a ";" and a barrier in this case.

Paolo

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  x86/vmx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/x86/vmx.c b/x86/vmx.c
> index a475aec..f9d5493 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -563,7 +563,7 @@ static void do_vmxon_off(void)
>  	vmx_on();
>  	vmx_off();
>  resume:
> -	return;
> +	barrier();
>  }
>
>  static void do_write_feature_control(void)
> @@ -572,7 +572,7 @@ static void do_write_feature_control(void)
>  	barrier();
>  	wrmsr(MSR_IA32_FEATURE_CONTROL, 0);
>  resume:
> -	return;
> +	barrier();
>  }
>
>  static int test_vmx_feature_control(void)
>

--
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 Jan. 22, 2014, 5:21 p.m. UTC | #2
Il 22/01/2014 16:00, Paolo Bonzini ha scritto:
> Il 04/01/2014 18:59, Jan Kiszka ha scritto:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> Some compiler versions (seen with gcc 4.8.1) move the resume label after
>> the return statement which, of course, causes sever problems.
>
> Can you include the assembly output?  Do you mean after the "ret"
> instruction?

Reproduced now, I think it's a compiler bug... with -O2 it's even weird, 
&&resume points to the *first* instruction in the function.

I'll report it to GCC.


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 a475aec..f9d5493 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -563,7 +563,7 @@  static void do_vmxon_off(void)
 	vmx_on();
 	vmx_off();
 resume:
-	return;
+	barrier();
 }
 
 static void do_write_feature_control(void)
@@ -572,7 +572,7 @@  static void do_write_feature_control(void)
 	barrier();
 	wrmsr(MSR_IA32_FEATURE_CONTROL, 0);
 resume:
-	return;
+	barrier();
 }
 
 static int test_vmx_feature_control(void)