diff mbox

[kvm-unit-tests,v2] x86: emulator: Fix h_mem usage in tests_smsw

Message ID 1417621455-22031-1-git-send-email-chris.j.arges@canonical.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chris J Arges Dec. 3, 2014, 3:44 p.m. UTC
In emulator.c/tests_smsw, smsw (3) fails because h_mem isn't being set correctly
before smsw is called. By using the + constraint modifier for memory we can
ensure the compiler no longer optimizes out the assignment before smsw.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
---
 x86/emulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini Dec. 3, 2014, 3:46 p.m. UTC | #1
On 03/12/2014 16:44, Chris J Arges wrote:
> In emulator.c/tests_smsw, smsw (3) fails because h_mem isn't being set correctly
> before smsw is called. By using the + constraint modifier for memory we can
> ensure the compiler no longer optimizes out the assignment before smsw.
> 
> Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
> ---
>  x86/emulator.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/x86/emulator.c b/x86/emulator.c
> index 5aa4dbf..1e05574 100644
> --- a/x86/emulator.c
> +++ b/x86/emulator.c
> @@ -359,7 +359,7 @@ void test_smsw(uint64_t *h_mem)
>  
>  	/* Trigger exit on smsw */
>  	*h_mem = 0x12345678abcdeful;
> -	asm volatile("smsw %0" : "=m"(*h_mem));
> +	asm volatile("smsw %0" : "+m"(*h_mem));
>  	report("smsw (3)", msw == (unsigned short)*h_mem &&
>  		(*h_mem & ~0xfffful) == 0x12345678ab0000ul);
>  }
> 

Applied, thanks.

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/emulator.c b/x86/emulator.c
index 5aa4dbf..1e05574 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -359,7 +359,7 @@  void test_smsw(uint64_t *h_mem)
 
 	/* Trigger exit on smsw */
 	*h_mem = 0x12345678abcdeful;
-	asm volatile("smsw %0" : "=m"(*h_mem));
+	asm volatile("smsw %0" : "+m"(*h_mem));
 	report("smsw (3)", msw == (unsigned short)*h_mem &&
 		(*h_mem & ~0xfffful) == 0x12345678ab0000ul);
 }