Skip to contentSkip to conversation

KVM: selftests: Compile code with warnings enabled

PATCH Applied Thomas Huth 5 participants 8 messages May 17, 2019 – May 23, 2019

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

PATCH v2 1/1 KVM: selftests: Compile code with warnings enabled

So far the KVM selftests are compiled without any compiler warnings enabled. That's quite bad, since we miss a lot of possible bugs this way. Let's enable at least "-Wall" and some other useful warning flags now, and fix at least the trivial problems in the code (like unused variables).

Signed-off-by Thomas Huth <thuth at redhat.com>

---
v2:
- Rebased to kvm/queue
- Fix warnings in state_test.c and evmcs_test.c, too

 tools/testing/selftests/kvm/Makefile                       | 4 +++-
 tools/testing/selftests/kvm/dirty_log_test.c               | 6 +++++-
 tools/testing/selftests/kvm/lib/kvm_util.c                 | 3 ---
 tools/testing/selftests/kvm/lib/x86_64/processor.c         | 4 +---
 tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c   | 1 +
 tools/testing/selftests/kvm/x86_64/evmcs_test.c            | 7 +------
 tools/testing/selftests/kvm/x86_64/platform_info_test.c    | 1 -
 tools/testing/selftests/kvm/x86_64/smm_test.c              | 3 +--
 tools/testing/selftests/kvm/x86_64/state_test.c            | 7 +------
 .../selftests/kvm/x86_64/vmx_close_while_nested_test.c     | 5 +----
 tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c   | 5 ++---
 11 files changed, 16 insertions(+), 30 deletions(-)
tools/testing/selftests/kvm/Makefile +3 -1
index 79c524395ebe..d113eaf2d570 100644
@@ -34,7 +34,9 @@ LIBKVM += $(LIBKVM_$(UNAME_M))
 INSTALL_HDR_PATH = $(top_srcdir)/usr
 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
-CFLAGS += -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
+CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
+	-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
+	-I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
 
 no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
         $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
tools/testing/selftests/kvm/dirty_log_test.c +5 -1
index a29d1119ccb3..ff20950aee05 100644
@@ -131,6 +131,7 @@ static void *vcpu_worker(void *data)
 	while (!READ_ONCE(host_quit)) {
 		/* Let the guest dirty the random pages */
 		ret = _vcpu_run(vm, VCPU_ID);
+		TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret);
 		if (get_ucall(vm, VCPU_ID, &uc) == UCALL_SYNC) {
 			pages_count += TEST_PAGES_PER_LOOP;
 			generate_random_array(guest_array, TEST_PAGES_PER_LOOP);
@@ -423,8 +424,11 @@ int main(int argc, char *argv[])
 	unsigned long interval = TEST_HOST_LOOP_INTERVAL;
 	bool mode_selected = false;
 	uint64_t phys_offset = 0;
-	unsigned int mode, host_ipa_limit;
+	unsigned int mode;
 	int opt, i;
+#ifdef __aarch64__
+	unsigned int host_ipa_limit;
+#endif
 
 #ifdef USE_CLEAR_DIRTY_LOG
 	if (!kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2)) {
tools/testing/selftests/kvm/lib/kvm_util.c +0 -3
index e9113857f44e..cf62de377310 100644
@@ -135,7 +135,6 @@ struct kvm_vm *_vm_create(enum vm_guest_mode mode, uint64_t phy_pages,
 			  int perm, unsigned long type)
 {
 	struct kvm_vm *vm;
-	int kvm_fd;
 
 	vm = calloc(1, sizeof(*vm));
 	TEST_ASSERT(vm != NULL, "Insufficient Memory");
@@ -556,7 +555,6 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
 	uint32_t flags)
 {
 	int ret;
-	unsigned long pmem_size = 0;
 	struct userspace_mem_region *region;
 	size_t huge_page_size = KVM_UTIL_PGS_PER_HUGEPG * vm->page_size;
 
@@ -1334,7 +1332,6 @@ void vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_sregs *sregs)
 int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_sregs *sregs)
 {
 	struct vcpu *vcpu = vcpu_find(vm, vcpuid);
-	int ret;
 
 	TEST_ASSERT(vcpu != NULL, "vcpu not found, vcpuid: %u", vcpuid);
 
tools/testing/selftests/kvm/lib/x86_64/processor.c +1 -3
index dc7fae9fa424..21f3040d90cb 100644
@@ -229,8 +229,6 @@ void sregs_dump(FILE *stream, struct kvm_sregs *sregs,
 
 void virt_pgd_alloc(struct kvm_vm *vm, uint32_t pgd_memslot)
 {
-	int rc;
-
 	TEST_ASSERT(vm->mode == VM_MODE_P52V48_4K, "Attempt to use "
 		"unknown or unsupported guest mode, mode: 0x%x", vm->mode);
 
@@ -549,7 +547,6 @@ vm_paddr_t addr_gva2gpa(struct kvm_vm *vm, vm_vaddr_t gva)
 	struct pageDirectoryPointerEntry *pdpe;
 	struct pageDirectoryEntry *pde;
 	struct pageTableEntry *pte;
-	void *hva;
 
 	TEST_ASSERT(vm->mode == VM_MODE_P52V48_4K, "Attempt to use "
 		"unknown or unsupported guest mode, mode: 0x%x", vm->mode);
@@ -582,6 +579,7 @@ vm_paddr_t addr_gva2gpa(struct kvm_vm *vm, vm_vaddr_t gva)
 unmapped_gva:
 	TEST_ASSERT(false, "No mapping for vm virtual address, "
 		    "gva: 0x%lx", gva);
+	exit(EXIT_FAILURE);
 }
 
 static void kvm_setup_gdt(struct kvm_vm *vm, struct kvm_dtable *dt, int gdt_memslot,
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c +1 -0
index 7c2c4d4055a8..63cc9c3f5ab6 100644
@@ -87,6 +87,7 @@ int main(int argc, char *argv[])
 	while (1) {
 		rc = _vcpu_run(vm, VCPU_ID);
 
+		TEST_ASSERT(rc == 0, "vcpu_run failed: %d\n", rc);
 		TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
 			    "Unexpected exit reason: %u (%s),\n",
 			    run->exit_reason,
tools/testing/selftests/kvm/x86_64/evmcs_test.c +1 -6
index 36669684eca5..b38260e29775 100644
@@ -19,8 +19,6 @@
 
 #define VCPU_ID		5
 
-static bool have_nested_state;
-
 void l2_guest_code(void)
 {
 	GUEST_SYNC(6);
@@ -73,7 +71,6 @@ void guest_code(struct vmx_pages *vmx_pages)
 
 int main(int argc, char *argv[])
 {
-	struct vmx_pages *vmx_pages = NULL;
 	vm_vaddr_t vmx_pages_gva = 0;
 
 	struct kvm_regs regs1, regs2;
@@ -88,8 +85,6 @@ int main(int argc, char *argv[])
 		 .args[0] = (unsigned long)&evmcs_ver
 	};
 
-	struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
-
 	/* Create VM */
 	vm = vm_create_default(VCPU_ID, 0, guest_code);
 
@@ -113,7 +108,7 @@ int main(int argc, char *argv[])
 
 	vcpu_regs_get(vm, VCPU_ID, &regs1);
 
-	vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva);
+	vcpu_alloc_vmx(vm, &vmx_pages_gva);
 	vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
 
 	for (stage = 1;; stage++) {
tools/testing/selftests/kvm/x86_64/platform_info_test.c +0 -1
index eb3e7a838cb4..40050e44ec0a 100644
@@ -81,7 +81,6 @@ static void test_msr_platform_info_disabled(struct kvm_vm *vm)
 int main(int argc, char *argv[])
 {
 	struct kvm_vm *vm;
-	struct kvm_run *state;
 	int rv;
 	uint64_t msr_platform_info;
 
tools/testing/selftests/kvm/x86_64/smm_test.c +1 -2
index fb8086964d83..4daf520bada1 100644
@@ -87,7 +87,6 @@ void guest_code(struct vmx_pages *vmx_pages)
 
 int main(int argc, char *argv[])
 {
-	struct vmx_pages *vmx_pages = NULL;
 	vm_vaddr_t vmx_pages_gva = 0;
 
 	struct kvm_regs regs;
@@ -115,7 +114,7 @@ int main(int argc, char *argv[])
 	vcpu_set_msr(vm, VCPU_ID, MSR_IA32_SMBASE, SMRAM_GPA);
 
 	if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
-		vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva);
+		vcpu_alloc_vmx(vm, &vmx_pages_gva);
 		vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
 	} else {
 		printf("will skip SMM test with VMX enabled\n");
tools/testing/selftests/kvm/x86_64/state_test.c +1 -6
index e0a3c0204b7c..2a4121f4de01 100644
@@ -22,8 +22,6 @@
 
 #define VCPU_ID		5
 
-static bool have_nested_state;
-
 void l2_guest_code(void)
 {
 	GUEST_SYNC(6);
@@ -122,7 +120,6 @@ void guest_code(struct vmx_pages *vmx_pages)
 
 int main(int argc, char *argv[])
 {
-	struct vmx_pages *vmx_pages = NULL;
 	vm_vaddr_t vmx_pages_gva = 0;
 
 	struct kvm_regs regs1, regs2;
@@ -132,8 +129,6 @@ int main(int argc, char *argv[])
 	struct ucall uc;
 	int stage;
 
-	struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
-
 	/* Create VM */
 	vm = vm_create_default(VCPU_ID, 0, guest_code);
 	vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
@@ -142,7 +137,7 @@ int main(int argc, char *argv[])
 	vcpu_regs_get(vm, VCPU_ID, &regs1);
 
 	if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
-		vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva);
+		vcpu_alloc_vmx(vm, &vmx_pages_gva);
 		vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
 	} else {
 		printf("will skip nested state checks\n");
tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c +1 -4
index 6edec6fd790b..97182b47b10c 100644
@@ -39,8 +39,6 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
 {
 #define L2_GUEST_STACK_SIZE 64
 	unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
-	uint32_t control;
-	uintptr_t save_cr3;
 
 	GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
 	GUEST_ASSERT(load_vmcs(vmx_pages));
@@ -55,7 +53,6 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
 
 int main(int argc, char *argv[])
 {
-	struct vmx_pages *vmx_pages;
 	vm_vaddr_t vmx_pages_gva;
 	struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
 
@@ -68,7 +65,7 @@ int main(int argc, char *argv[])
 	vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
 
 	/* Allocate VMX pages and shared descriptors (vmx_pages). */
-	vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva);
+	vcpu_alloc_vmx(vm, &vmx_pages_gva);
 	vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
 
 	for (;;) {
tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c +2 -3
index 18fa64db0d7a..6d37a3173956 100644
@@ -121,7 +121,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
 	GUEST_DONE();
 }
 
-void report(int64_t val)
+static void report(int64_t val)
 {
 	printf("IA32_TSC_ADJUST is %ld (%lld * TSC_ADJUST_VALUE + %lld).\n",
 	       val, val / TSC_ADJUST_VALUE, val % TSC_ADJUST_VALUE);
@@ -129,7 +129,6 @@ void report(int64_t val)
 
 int main(int argc, char *argv[])
 {
-	struct vmx_pages *vmx_pages;
 	vm_vaddr_t vmx_pages_gva;
 	struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
 
@@ -142,7 +141,7 @@ int main(int argc, char *argv[])
 	vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
 
 	/* Allocate VMX pages and shared descriptors (vmx_pages). */
-	vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva);
+	vcpu_alloc_vmx(vm, &vmx_pages_gva);
 	vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
 
 	for (;;) {
Signature · 1 line
2.21.0
#1 lore raw
Quoted 11 lines · Thomas Huth

So far the KVM selftests are compiled without any compiler warnings enabled. That's quite bad, since we miss a lot of possible bugs this way. Let's enable at least "-Wall" and some other useful warning flags now, and fix at least the trivial problems in the code (like unused variables).

Signed-off-by Thomas Huth <thuth at redhat.com>

---
v2:
- Rebased to kvm/queue
- Fix warnings in state_test.c and evmcs_test.c, too

I still see these warnings (probably because the hyperv_cpuid.c is a new test):

In file included from x86_64/hyperv_cpuid.c:18:
x86_64/hyperv_cpuid.c: In function ‘test_hv_cpuid’:
x86_64/hyperv_cpuid.c:61:33: warning: suggest parentheses around comparison in operand of ‘==’ [-Wparentheses]
TEST_ASSERT(entry->padding[0] == entry->padding[1]

               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
include/test_util.h:32:15: note: in definition of macro ‘TEST_ASSERT’
  test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
               ^
x86_64/hyperv_cpuid.c:62:8: warning: suggest parentheses around comparison in operand of ‘==’ [-Wparentheses]
   TEST_ASSERT(entry->padding[0] == entry->padding[1]
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        == entry->padding[2] == 0,
        ^~~~~~~~~~~~~~~~~~~~
include/test_util.h:32:15: note: in definition of macro ‘TEST_ASSERT’
  test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
               ^
x86_64/hyperv_cpuid.c: In function ‘kvm_get_supported_hv_cpuid’:
x86_64/hyperv_cpuid.c:93:6: warning: unused variable ‘ret’ [-Wunused-variable]
  int ret;
      ^~~

The first two seem to be real bugs in the test code, and the 3rd one might need a cleanup too.

Thanks,

Signature · 1 line
Peter Xu
#2 lore raw
Quoted 29 lines · Peter Xu
Quoted 11 lines · Thomas Huth

So far the KVM selftests are compiled without any compiler warnings enabled. That's quite bad, since we miss a lot of possible bugs this way. Let's enable at least "-Wall" and some other useful warning flags now, and fix at least the trivial problems in the code (like unused variables).

Signed-off-by Thomas Huth <thuth at redhat.com>

---
v2:
- Rebased to kvm/queue
- Fix warnings in state_test.c and evmcs_test.c, too

I still see these warnings (probably because the hyperv_cpuid.c is a new test):

In file included from x86_64/hyperv_cpuid.c:18:
x86_64/hyperv_cpuid.c: In function ‘test_hv_cpuid’:
x86_64/hyperv_cpuid.c:61:33: warning: suggest parentheses around comparison in operand of ‘==’ [-Wparentheses]
TEST_ASSERT(entry->padding[0] == entry->padding[1]

               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
include/test_util.h:32:15: note: in definition of macro ‘TEST_ASSERT’
  test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
               ^
x86_64/hyperv_cpuid.c:62:8: warning: suggest parentheses around comparison in operand of ‘==’ [-Wparentheses]
   TEST_ASSERT(entry->padding[0] == entry->padding[1]
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        == entry->padding[2] == 0,
        ^~~~~~~~~~~~~~~~~~~~
Quoted 2 lines

include/test_util.h:32:15: note: in definition of macro ‘TEST_ASSERT’
test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)

There's a fix from Dan Carpenter on the list:
https://marc.info/?l=kernel-janitors&m=155783012012532&w=2

Quoted 8 lines
               ^
x86_64/hyperv_cpuid.c: In function ‘kvm_get_supported_hv_cpuid’:
x86_64/hyperv_cpuid.c:93:6: warning: unused variable ‘ret’ [-Wunused-variable]
  int ret;
      ^~~

The first two seem to be real bugs in the test code, and the 3rd one might need a cleanup too.

Signature · 1 line
Vitaly
#3 lore raw
Quoted 34 lines · Vitaly Kuznetsov
Quoted 29 lines · Peter Xu
Quoted 11 lines · Thomas Huth

So far the KVM selftests are compiled without any compiler warnings enabled. That's quite bad, since we miss a lot of possible bugs this way. Let's enable at least "-Wall" and some other useful warning flags now, and fix at least the trivial problems in the code (like unused variables).

Signed-off-by Thomas Huth <thuth at redhat.com>

---
v2:
- Rebased to kvm/queue
- Fix warnings in state_test.c and evmcs_test.c, too

I still see these warnings (probably because the hyperv_cpuid.c is a new test):

In file included from x86_64/hyperv_cpuid.c:18:
x86_64/hyperv_cpuid.c: In function ‘test_hv_cpuid’:
x86_64/hyperv_cpuid.c:61:33: warning: suggest parentheses around comparison in operand of ‘==’ [-Wparentheses]
TEST_ASSERT(entry->padding[0] == entry->padding[1]

               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
include/test_util.h:32:15: note: in definition of macro ‘TEST_ASSERT’
  test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
               ^
x86_64/hyperv_cpuid.c:62:8: warning: suggest parentheses around comparison in operand of ‘==’ [-Wparentheses]
   TEST_ASSERT(entry->padding[0] == entry->padding[1]
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        == entry->padding[2] == 0,
        ^~~~~~~~~~~~~~~~~~~~
Quoted 2 lines

include/test_util.h:32:15: note: in definition of macro ‘TEST_ASSERT’
test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)

Quoted 2 lines

There's a fix from Dan Carpenter on the list:
https://marc.info/?l=kernel-janitors&m=155783012012532&w=2

Right, that fix should preferably be committed first.

Quoted 4 lines
Quoted 4 lines

x86_64/hyperv_cpuid.c: In function ‘kvm_get_supported_hv_cpuid’:
x86_64/hyperv_cpuid.c:93:6: warning: unused variable ‘ret’ [-Wunused-variable]

  int ret;
      ^~~

... but I obviously missed this one here again :-/

There are also these compiler warnings left:

lib/ucall.c: In function ‘get_ucall’:
lib/ucall.c:145:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
gva = *(vm_vaddr_t *)run->mmio.data;

x86_64/vmx_set_nested_state_test.c: In function ‘set_revision_id_for_vmcs12’:
x86_64/vmx_set_nested_state_test.c:78:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(u32 *)(state->data) = vmcs12_revision;

... how do we want to handle such spots in the kvm selftest code? Compile with -fno-strict-aliasing? Or fix it with type-punning through unions?

Thomas

#4 lore raw
Quoted 10 lines · Thomas Huth

x86_64/vmx_set_nested_state_test.c: In function ‘set_revision_id_for_vmcs12’:
x86_64/vmx_set_nested_state_test.c:78:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(u32 *)(state->data) = vmcs12_revision;

... how do we want to handle such spots in the kvm selftest code? Compile with -fno-strict-aliasing? Or fix it with type-punning through unions?

These are tests, let's keep code simple. Casting my vote for the former option)

Signature · 1 line
Vitaly
maintainer
#5 lore raw
In reply to Thomas Huth
Quoted 12 lines · Thomas Huth

lib/ucall.c: In function ‘get_ucall’:
lib/ucall.c:145:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
gva = *(vm_vaddr_t *)run->mmio.data;

x86_64/vmx_set_nested_state_test.c: In function ‘set_revision_id_for_vmcs12’:
x86_64/vmx_set_nested_state_test.c:78:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(u32 *)(state->data) = vmcs12_revision;

Quoted 3 lines

... how do we want to handle such spots in the kvm selftest code? Compile with -fno-strict-aliasing? Or fix it with type-punning through unions?

I would use memcpy. I'll send a patch shortly.

Paolo

maintainer Applied
#6 lore raw
In reply to Thomas Huth
Quoted 12 lines · Thomas Huth

So far the KVM selftests are compiled without any compiler warnings enabled. That's quite bad, since we miss a lot of possible bugs this way. Let's enable at least "-Wall" and some other useful warning flags now, and fix at least the trivial problems in the code (like unused variables).

Signed-off-by Thomas Huth <thuth at redhat.com>

---
v2:
- Rebased to kvm/queue
- Fix warnings in state_test.c and evmcs_test.c, too

Quoted 12 lines
 tools/testing/selftests/kvm/Makefile                       | 4 +++-
 tools/testing/selftests/kvm/dirty_log_test.c               | 6 +++++-
 tools/testing/selftests/kvm/lib/kvm_util.c                 | 3 ---
 tools/testing/selftests/kvm/lib/x86_64/processor.c         | 4 +---
 tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c   | 1 +
 tools/testing/selftests/kvm/x86_64/evmcs_test.c            | 7 +------
 tools/testing/selftests/kvm/x86_64/platform_info_test.c    | 1 -
 tools/testing/selftests/kvm/x86_64/smm_test.c              | 3 +--
 tools/testing/selftests/kvm/x86_64/state_test.c            | 7 +------
 .../selftests/kvm/x86_64/vmx_close_while_nested_test.c     | 5 +----
 tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c   | 5 ++---
 11 files changed, 16 insertions(+), 30 deletions(-)

Queued, with a squashed fix to kvm_get_supported_hv_cpuid.

Paolo

#7 lore raw
Quoted 26 lines · Paolo Bonzini
Quoted 12 lines · Thomas Huth

So far the KVM selftests are compiled without any compiler warnings enabled. That's quite bad, since we miss a lot of possible bugs this way. Let's enable at least "-Wall" and some other useful warning flags now, and fix at least the trivial problems in the code (like unused variables).

Signed-off-by Thomas Huth <thuth at redhat.com>

---
v2:
- Rebased to kvm/queue
- Fix warnings in state_test.c and evmcs_test.c, too

Quoted 12 lines
 tools/testing/selftests/kvm/Makefile                       | 4 +++-
 tools/testing/selftests/kvm/dirty_log_test.c               | 6 +++++-
 tools/testing/selftests/kvm/lib/kvm_util.c                 | 3 ---
 tools/testing/selftests/kvm/lib/x86_64/processor.c         | 4 +---
 tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c   | 1 +
 tools/testing/selftests/kvm/x86_64/evmcs_test.c            | 7 +------
 tools/testing/selftests/kvm/x86_64/platform_info_test.c    | 1 -
 tools/testing/selftests/kvm/x86_64/smm_test.c              | 3 +--
 tools/testing/selftests/kvm/x86_64/state_test.c            | 7 +------
 .../selftests/kvm/x86_64/vmx_close_while_nested_test.c     | 5 +----
 tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c   | 5 ++---
 11 files changed, 16 insertions(+), 30 deletions(-)
Quoted 2 lines

Queued, with a squashed fix to kvm_get_supported_hv_cpuid.

I've done the fixups needed to keep aarch64 compiling and will send the patch shortly.

drew