All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests: kvm/x86: Fix the warning in lib/x86_64/processor.c
@ 2022-01-19 14:03 Jinrong Liang
  2022-01-19 18:37 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Jinrong Liang @ 2022-01-19 14:03 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Wanpeng Li, Sean Christopherson, Jim Mattson, Vitaly Kuznetsov,
	Joerg Roedel, Jinrong Liang, kvm, linux-kernel

From: Jinrong Liang <cloudliang@tencent.com>

The following warning appears when executing
make -C tools/testing/selftests/kvm

In file included from lib/x86_64/processor.c:11:
lib/x86_64/processor.c: In function ':
include/x86_64/processor.h:290:2: warning: 'ecx' may be used uninitialized in this
function [-Wmaybe-uninitialized]
  asm volatile("cpuid"
  ^~~
lib/x86_64/processor.c:1523:21: note: 'ecx' was declared here
  uint32_t eax, ebx, ecx, edx, max_ext_leaf;

Just initialize ecx to remove this warning.

Fixes: c8cc43c1eae2 ("selftests: KVM: avoid failures due to reserved
HyperTransport region")

Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
---
 tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
index 59dcfe1967cc..4a4c7945cf3e 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
@@ -1520,7 +1520,7 @@ unsigned long vm_compute_max_gfn(struct kvm_vm *vm)
 {
 	const unsigned long num_ht_pages = 12 << (30 - vm->page_shift); /* 12 GiB */
 	unsigned long ht_gfn, max_gfn, max_pfn;
-	uint32_t eax, ebx, ecx, edx, max_ext_leaf;
+	uint32_t eax, ebx, ecx = 0, edx, max_ext_leaf;
 
 	max_gfn = (1ULL << (vm->pa_bits - vm->page_shift)) - 1;
 
-- 
2.27.0


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

* Re: [PATCH] selftests: kvm/x86: Fix the warning in lib/x86_64/processor.c
  2022-01-19 14:03 [PATCH] selftests: kvm/x86: Fix the warning in lib/x86_64/processor.c Jinrong Liang
@ 2022-01-19 18:37 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2022-01-19 18:37 UTC (permalink / raw)
  To: Jinrong Liang
  Cc: Wanpeng Li, Sean Christopherson, Jim Mattson, Vitaly Kuznetsov,
	Joerg Roedel, Jinrong Liang, kvm, linux-kernel

On 1/19/22 15:03, Jinrong Liang wrote:
> From: Jinrong Liang <cloudliang@tencent.com>
> 
> The following warning appears when executing
> make -C tools/testing/selftests/kvm
> 
> In file included from lib/x86_64/processor.c:11:
> lib/x86_64/processor.c: In function ':
> include/x86_64/processor.h:290:2: warning: 'ecx' may be used uninitialized in this
> function [-Wmaybe-uninitialized]
>    asm volatile("cpuid"
>    ^~~
> lib/x86_64/processor.c:1523:21: note: 'ecx' was declared here
>    uint32_t eax, ebx, ecx, edx, max_ext_leaf;
> 
> Just initialize ecx to remove this warning.
> 
> Fixes: c8cc43c1eae2 ("selftests: KVM: avoid failures due to reserved
> HyperTransport region")
> 
> Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
> ---
>   tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> index 59dcfe1967cc..4a4c7945cf3e 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> @@ -1520,7 +1520,7 @@ unsigned long vm_compute_max_gfn(struct kvm_vm *vm)
>   {
>   	const unsigned long num_ht_pages = 12 << (30 - vm->page_shift); /* 12 GiB */
>   	unsigned long ht_gfn, max_gfn, max_pfn;
> -	uint32_t eax, ebx, ecx, edx, max_ext_leaf;
> +	uint32_t eax, ebx, ecx = 0, edx, max_ext_leaf;
>   
>   	max_gfn = (1ULL << (vm->pa_bits - vm->page_shift)) - 1;
>   

A separate assignment of "ecx = 0" is slightly more conforming to the 
coding standards.  Queued nevertheless, thanks.

Paolo


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

end of thread, other threads:[~2022-01-19 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 14:03 [PATCH] selftests: kvm/x86: Fix the warning in lib/x86_64/processor.c Jinrong Liang
2022-01-19 18:37 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.