Skip to contentSkip to conversation

KVM: selftests: fix hyperv_clock test

PATCH Superseded Maxim Levitsky 2 participants 3 messages Aug 4, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: selftests: fix hyperv_clock test

The test was mistakenly using addr_gpa2hva on a gva and that happened to work accidentally.

commit 106a2e766eae ("KVM: selftests:
Lower the min virtual address for misc page allocations") revealed this bug.

Fixes 106a2e766eae ("KVM: selftests: Lower the min virtual address for misc page allocations")
---
 tools/testing/selftests/kvm/x86_64/hyperv_clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/x86_64/hyperv_clock.c +1 -1
index bab10ae787b6..e0b2bb1339b1 100644
@@ -215,7 +215,7 @@ int main(void)
 	vcpu_set_hv_cpuid(vm, VCPU_ID);
 
 	tsc_page_gva = vm_vaddr_alloc_page(vm);
-	memset(addr_gpa2hva(vm, tsc_page_gva), 0x0, getpagesize());
+	memset(addr_gva2hva(vm, tsc_page_gva), 0x0, getpagesize());
 	TEST_ASSERT((addr_gva2gpa(vm, tsc_page_gva) & (getpagesize() - 1)) == 0,
 		"TSC page has to be page aligned\n");
 	vcpu_args_set(vm, VCPU_ID, 2, tsc_page_gva, addr_gva2gpa(vm, tsc_page_gva));
Signature · 1 line
2.26.3
maintainer
#1 lore raw
Quoted 8 lines · Maxim Levitsky

The test was mistakenly using addr_gpa2hva on a gva and that happened to work accidentally.

commit 106a2e766eae ("KVM: selftests:
Lower the min virtual address for misc page allocations") revealed this bug.

Fixes 106a2e766eae ("KVM: selftests: Lower the min virtual address for misc page allocations")

The right "Fixes" is 2c7f76b4c42b ("selftests: kvm: Add basic Hyper-V clocksources tests", 2021-03-18).

Paolo

Quoted 19 lines
---
  tools/testing/selftests/kvm/x86_64/hyperv_clock.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/x86_64/hyperv_clock.c +1 -1
index bab10ae787b6..e0b2bb1339b1 100644
@@ -215,7 +215,7 @@ int main(void)
  	vcpu_set_hv_cpuid(vm, VCPU_ID);
 
  	tsc_page_gva = vm_vaddr_alloc_page(vm);
-	memset(addr_gpa2hva(vm, tsc_page_gva), 0x0, getpagesize());
+	memset(addr_gva2hva(vm, tsc_page_gva), 0x0, getpagesize());
  	TEST_ASSERT((addr_gva2gpa(vm, tsc_page_gva) & (getpagesize() - 1)) == 0,
  		"TSC page has to be page aligned\n");
  	vcpu_args_set(vm, VCPU_ID, 2, tsc_page_gva, addr_gva2gpa(vm, tsc_page_gva));
#2 lore raw
Quoted 4 lines · Paolo Bonzini
Quoted 3 lines · Maxim Levitsky

The test was mistakenly using addr_gpa2hva on a gva and that happened to work accidentally.

Quoted 8 lines
Quoted 5 lines

commit 106a2e766eae ("KVM: selftests:
Lower the min virtual address for misc page allocations") revealed this bug.

Fixes 106a2e766eae ("KVM: selftests: Lower the min virtual address for misc page allocations")

The right "Fixes" is 2c7f76b4c42b ("selftests: kvm: Add basic Hyper-V clocksources tests", 2021-03-18).

Makes sense. I wasn't sure about which commit to blame here. I'll resend the patch.

Best regards,
Maxim Levitsky

Quoted 22 lines

Paolo

Quoted 19 lines
---
  tools/testing/selftests/kvm/x86_64/hyperv_clock.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/x86_64/hyperv_clock.c +1 -1
index bab10ae787b6..e0b2bb1339b1 100644
@@ -215,7 +215,7 @@ int main(void)
  	vcpu_set_hv_cpuid(vm, VCPU_ID);
 
  	tsc_page_gva = vm_vaddr_alloc_page(vm);
-	memset(addr_gpa2hva(vm, tsc_page_gva), 0x0, getpagesize());
+	memset(addr_gva2hva(vm, tsc_page_gva), 0x0, getpagesize());
  	TEST_ASSERT((addr_gva2gpa(vm, tsc_page_gva) & (getpagesize() - 1)) == 0,
  		"TSC page has to be page aligned\n");
  	vcpu_args_set(vm, VCPU_ID, 2, tsc_page_gva, addr_gva2gpa(vm, tsc_page_gva));