Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6498e1da authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini
Browse files

kvm: selftests: dirty_log_test: always use -t



There's no reason not to always test the topmost physical
addresses, and if the user wants to try lower addresses
then '-p' (used to be '-o before this patch) can be used.
Let's remove the '-t' option and just always do what it did.

Signed-off-by: default avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent d4df5a15
Loading
Loading
Loading
Loading
+17 −19
Original line number Original line Diff line number Diff line
@@ -51,10 +51,16 @@ static uint64_t random_array[TEST_PAGES_PER_LOOP];
static uint64_t iteration;
static uint64_t iteration;


/*
/*
 * GPA offset of the testing memory slot. Must be bigger than
 * Guest physical memory offset of the testing memory slot.
 * DEFAULT_GUEST_PHY_PAGES * PAGE_SIZE.
 * This will be set to the topmost valid physical address minus
 * the test memory size.
 */
static uint64_t guest_test_phys_mem;

/*
 * Guest virtual memory offset of the testing memory slot.
 * Must not conflict with identity mapped test code.
 */
 */
static uint64_t guest_test_phys_mem = DEFAULT_GUEST_TEST_MEM;
static uint64_t guest_test_virt_mem = DEFAULT_GUEST_TEST_MEM;
static uint64_t guest_test_virt_mem = DEFAULT_GUEST_TEST_MEM;


/*
/*
@@ -225,7 +231,7 @@ static struct kvm_vm *create_vm(enum vm_guest_mode mode, uint32_t vcpuid,
}
}


static void run_test(enum vm_guest_mode mode, unsigned long iterations,
static void run_test(enum vm_guest_mode mode, unsigned long iterations,
		     unsigned long interval, bool top_offset)
		     unsigned long interval)
{
{
	unsigned int guest_pa_bits, guest_page_shift;
	unsigned int guest_pa_bits, guest_page_shift;
	pthread_t vcpu_thread;
	pthread_t vcpu_thread;
@@ -273,7 +279,7 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
	host_num_pages = (guest_num_pages * guest_page_size) / host_page_size +
	host_num_pages = (guest_num_pages * guest_page_size) / host_page_size +
			 !!((guest_num_pages * guest_page_size) % host_page_size);
			 !!((guest_num_pages * guest_page_size) % host_page_size);


	if (top_offset) {
	if (!guest_test_phys_mem) {
		guest_test_phys_mem = (max_gfn - guest_num_pages) * guest_page_size;
		guest_test_phys_mem = (max_gfn - guest_num_pages) * guest_page_size;
		guest_test_phys_mem &= ~(host_page_size - 1);
		guest_test_phys_mem &= ~(host_page_size - 1);
	}
	}
@@ -381,16 +387,14 @@ static void help(char *name)


	puts("");
	puts("");
	printf("usage: %s [-h] [-i iterations] [-I interval] "
	printf("usage: %s [-h] [-i iterations] [-I interval] "
	       "[-o offset] [-t] [-m mode]\n", name);
	       "[-p offset] [-m mode]\n", name);
	puts("");
	puts("");
	printf(" -i: specify iteration counts (default: %"PRIu64")\n",
	printf(" -i: specify iteration counts (default: %"PRIu64")\n",
	       TEST_HOST_LOOP_N);
	       TEST_HOST_LOOP_N);
	printf(" -I: specify interval in ms (default: %"PRIu64" ms)\n",
	printf(" -I: specify interval in ms (default: %"PRIu64" ms)\n",
	       TEST_HOST_LOOP_INTERVAL);
	       TEST_HOST_LOOP_INTERVAL);
	printf(" -o: guest test memory offset (default: 0x%lx)\n",
	printf(" -p: specify guest physical test memory offset\n"
	       DEFAULT_GUEST_TEST_MEM);
	       "     Warning: a low offset can conflict with the loaded test code.\n");
	printf(" -t: map guest test memory at the top of the allowed "
	       "physical address range\n");
	printf(" -m: specify the guest mode ID to test "
	printf(" -m: specify the guest mode ID to test "
	       "(default: test all supported modes)\n"
	       "(default: test all supported modes)\n"
	       "     This option may be used multiple times.\n"
	       "     This option may be used multiple times.\n"
@@ -410,7 +414,6 @@ int main(int argc, char *argv[])
	unsigned long iterations = TEST_HOST_LOOP_N;
	unsigned long iterations = TEST_HOST_LOOP_N;
	unsigned long interval = TEST_HOST_LOOP_INTERVAL;
	unsigned long interval = TEST_HOST_LOOP_INTERVAL;
	bool mode_selected = false;
	bool mode_selected = false;
	bool top_offset = false;
	unsigned int mode;
	unsigned int mode;
	int opt, i;
	int opt, i;


@@ -421,7 +424,7 @@ int main(int argc, char *argv[])
	}
	}
#endif
#endif


	while ((opt = getopt(argc, argv, "hi:I:o:tm:")) != -1) {
	while ((opt = getopt(argc, argv, "hi:I:p:m:")) != -1) {
		switch (opt) {
		switch (opt) {
		case 'i':
		case 'i':
			iterations = strtol(optarg, NULL, 10);
			iterations = strtol(optarg, NULL, 10);
@@ -429,12 +432,9 @@ int main(int argc, char *argv[])
		case 'I':
		case 'I':
			interval = strtol(optarg, NULL, 10);
			interval = strtol(optarg, NULL, 10);
			break;
			break;
		case 'o':
		case 'p':
			guest_test_phys_mem = strtoull(optarg, NULL, 0);
			guest_test_phys_mem = strtoull(optarg, NULL, 0);
			break;
			break;
		case 't':
			top_offset = true;
			break;
		case 'm':
		case 'm':
			if (!mode_selected) {
			if (!mode_selected) {
				for (i = 0; i < NUM_VM_MODES; ++i)
				for (i = 0; i < NUM_VM_MODES; ++i)
@@ -455,8 +455,6 @@ int main(int argc, char *argv[])


	TEST_ASSERT(iterations > 2, "Iterations must be greater than two");
	TEST_ASSERT(iterations > 2, "Iterations must be greater than two");
	TEST_ASSERT(interval > 0, "Interval must be greater than zero");
	TEST_ASSERT(interval > 0, "Interval must be greater than zero");
	TEST_ASSERT(!top_offset || guest_test_phys_mem == DEFAULT_GUEST_TEST_MEM,
		    "Cannot use both -o [offset] and -t at the same time");


	DEBUG("Test iterations: %"PRIu64", interval: %"PRIu64" (ms)\n",
	DEBUG("Test iterations: %"PRIu64", interval: %"PRIu64" (ms)\n",
	      iterations, interval);
	      iterations, interval);
@@ -470,7 +468,7 @@ int main(int argc, char *argv[])
			    "Guest mode ID %d (%s) not supported.",
			    "Guest mode ID %d (%s) not supported.",
			    vm_guest_modes[i].mode,
			    vm_guest_modes[i].mode,
			    vm_guest_mode_string(vm_guest_modes[i].mode));
			    vm_guest_mode_string(vm_guest_modes[i].mode));
		run_test(vm_guest_modes[i].mode, iterations, interval, top_offset);
		run_test(vm_guest_modes[i].mode, iterations, interval);
	}
	}


	return 0;
	return 0;