Skip to contentSkip to conversation

selftests: kvm/x86: Fix the warning in lib/x86_64/processor.c

PATCH In review Jinrong Liang 2 participants 2 messages Jan 19, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: kvm/x86: Fix the warning in lib/x86_64/processor.c

From: Jinrong Liang <[email protected]>

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")

---
 tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/lib/x86_64/processor.c +1 -1
index 59dcfe1967cc..4a4c7945cf3e 100644
@@ -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;
 
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 29 lines · Jinrong Liang

From: Jinrong Liang <[email protected]>

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")

---
  tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/lib/x86_64/processor.c +0 -0
index 59dcfe1967cc..4a4c7945cf3e 100644

tools/testing/selftests/kvm/lib/x86_64/processor.c unsigned long vm_compute_max_gfn(struct kvm_vm *vm) · line 1526

Quoted 8 lines
tools/testing/selftests/kvm/lib/x86_64/processor.c +1 -1
@@ -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