lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210210230625.550939-15-seanjc@google.com>
Date:   Wed, 10 Feb 2021 15:06:24 -0800
From:   Sean Christopherson <seanjc@...gle.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Sean Christopherson <seanjc@...gle.com>,
        Ben Gardon <bgardon@...gle.com>,
        Yanan Wang <wangyanan55@...wei.com>,
        Andrew Jones <drjones@...hat.com>,
        Peter Xu <peterx@...hat.com>,
        Aaron Lewis <aaronlewis@...gle.com>
Subject: [PATCH 14/15] KVM: selftests: Track size of per-VM memslot in perf_test_args

Capture the final size of the dedicated memslot created by perf_test_args
so that tests don't have to try and guesstimate the final result.  This
will be used by the memslots modification test to remove some truly
mind-boggling code.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@...gle.com>
---
 tools/testing/selftests/kvm/include/perf_test_util.h | 1 +
 tools/testing/selftests/kvm/lib/perf_test_util.c     | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h
index 330e528f206f..4da2d2dbf4c2 100644
--- a/tools/testing/selftests/kvm/include/perf_test_util.h
+++ b/tools/testing/selftests/kvm/include/perf_test_util.h
@@ -30,6 +30,7 @@ struct perf_test_args {
 	struct kvm_vm *vm;
 	uint64_t gpa;
 	uint64_t guest_page_size;
+	uint64_t nr_bytes;
 	int wr_fract;
 
 	struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS];
diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c
index 6f41fe2685cb..00953d15388f 100644
--- a/tools/testing/selftests/kvm/lib/perf_test_util.c
+++ b/tools/testing/selftests/kvm/lib/perf_test_util.c
@@ -80,8 +80,6 @@ static void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus,
 	}
 }
 
-
-
 struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
 				   uint64_t vcpu_memory_bytes,
 				   enum vm_mem_backing_src_type backing_src,
@@ -104,7 +102,11 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
 
 	guest_num_pages = vm_adjust_num_guest_pages(mode,
 				(vcpus * vcpu_memory_bytes) / pta->guest_page_size);
-	vcpu_memory_bytes = (guest_num_pages * pta->guest_page_size) / vcpus;
+	pta->nr_bytes = guest_num_pages * pta->guest_page_size;
+
+	TEST_ASSERT(pta->nr_bytes % vcpus == 0,
+		    "Guest pages adjustment yielded a weird number of pages.");
+	vcpu_memory_bytes = pta->nr_bytes / vcpus;
 
 	TEST_ASSERT(vcpu_memory_bytes % getpagesize() == 0,
 		    "Guest memory size is not host page size aligned.");
-- 
2.30.0.478.g8a0d178c01-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ