public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm-unit-test: fix cpuid test
@ 2013-11-04 14:04 Gleb Natapov
  2013-11-04 14:06 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2013-11-04 14:04 UTC (permalink / raw)
  To: kvm; +Cc: pbonzini

If cpuid is called with function value greater than max supported one
max supported value is used instead and index parameter is honored. That
is why we need to initialize index to same value in the test to get
same result from both cpuid invocations.

diff --git a/x86/realmode.c b/x86/realmode.c
index c57e033..0e1cd37 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1375,6 +1375,7 @@ static void test_cpuid(void)
     unsigned eax, ebx, ecx, edx;
 
     inregs.eax = eax = function;
+    inregs.ecx = ecx = 0;
     asm("cpuid" : "+a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx));
     exec_in_big_real_mode(&insn_cpuid);
     report("cpuid", R_AX|R_BX|R_CX|R_DX,
--
			Gleb.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kvm-unit-test: fix cpuid test
  2013-11-04 14:04 [PATCH] kvm-unit-test: fix cpuid test Gleb Natapov
@ 2013-11-04 14:06 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2013-11-04 14:06 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm

Il 04/11/2013 15:04, Gleb Natapov ha scritto:
> If cpuid is called with function value greater than max supported one
> max supported value is used instead and index parameter is honored. That
> is why we need to initialize index to same value in the test to get
> same result from both cpuid invocations.
> 
> diff --git a/x86/realmode.c b/x86/realmode.c
> index c57e033..0e1cd37 100644
> --- a/x86/realmode.c
> +++ b/x86/realmode.c
> @@ -1375,6 +1375,7 @@ static void test_cpuid(void)
>      unsigned eax, ebx, ecx, edx;
>  
>      inregs.eax = eax = function;
> +    inregs.ecx = ecx = 0;
>      asm("cpuid" : "+a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx));
>      exec_in_big_real_mode(&insn_cpuid);
>      report("cpuid", R_AX|R_BX|R_CX|R_DX,
> --
> 			Gleb.
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-04 14:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-04 14:04 [PATCH] kvm-unit-test: fix cpuid test Gleb Natapov
2013-11-04 14:06 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox