Skip to content

Commit 5a2acbb

Browse files
author
Marc Zyngier
committed
Merge branch kvm/selftests/memslot into kvmarm-master/next
* kvm/selftests/memslot: : . : Enable KVM memslot selftests on arm64, making them less : x86 specific. : . KVM: selftests: Build the memslot tests for arm64 KVM: selftests: Make memslot_perf_test arch independent Signed-off-by: Marc Zyngier <[email protected]>
2 parents be08c3c + 358928f commit 5a2acbb

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

tools/testing/selftests/kvm/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ TEST_GEN_PROGS_aarch64 += dirty_log_test
9696
TEST_GEN_PROGS_aarch64 += dirty_log_perf_test
9797
TEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus
9898
TEST_GEN_PROGS_aarch64 += kvm_page_table_test
99+
TEST_GEN_PROGS_aarch64 += memslot_modification_stress_test
100+
TEST_GEN_PROGS_aarch64 += memslot_perf_test
99101
TEST_GEN_PROGS_aarch64 += rseq_test
100102
TEST_GEN_PROGS_aarch64 += set_memory_region_test
101103
TEST_GEN_PROGS_aarch64 += steal_time

tools/testing/selftests/kvm/memslot_perf_test.c

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,43 +127,54 @@ static bool verbose;
127127
pr_info(__VA_ARGS__); \
128128
} while (0)
129129

130+
static void check_mmio_access(struct vm_data *vm, struct kvm_run *run)
131+
{
132+
TEST_ASSERT(vm->mmio_ok, "Unexpected mmio exit");
133+
TEST_ASSERT(run->mmio.is_write, "Unexpected mmio read");
134+
TEST_ASSERT(run->mmio.len == 8,
135+
"Unexpected exit mmio size = %u", run->mmio.len);
136+
TEST_ASSERT(run->mmio.phys_addr >= vm->mmio_gpa_min &&
137+
run->mmio.phys_addr <= vm->mmio_gpa_max,
138+
"Unexpected exit mmio address = 0x%llx",
139+
run->mmio.phys_addr);
140+
}
141+
130142
static void *vcpu_worker(void *data)
131143
{
132144
struct vm_data *vm = data;
133145
struct kvm_run *run;
134146
struct ucall uc;
135-
uint64_t cmd;
136147

137148
run = vcpu_state(vm->vm, VCPU_ID);
138149
while (1) {
139150
vcpu_run(vm->vm, VCPU_ID);
140151

141-
if (run->exit_reason == KVM_EXIT_IO) {
142-
cmd = get_ucall(vm->vm, VCPU_ID, &uc);
143-
if (cmd != UCALL_SYNC)
144-
break;
145-
152+
switch (get_ucall(vm->vm, VCPU_ID, &uc)) {
153+
case UCALL_SYNC:
154+
TEST_ASSERT(uc.args[1] == 0,
155+
"Unexpected sync ucall, got %lx",
156+
(ulong)uc.args[1]);
146157
sem_post(&vcpu_ready);
147158
continue;
148-
}
149-
150-
if (run->exit_reason != KVM_EXIT_MMIO)
159+
case UCALL_NONE:
160+
if (run->exit_reason == KVM_EXIT_MMIO)
161+
check_mmio_access(vm, run);
162+
else
163+
goto done;
151164
break;
152-
153-
TEST_ASSERT(vm->mmio_ok, "Unexpected mmio exit");
154-
TEST_ASSERT(run->mmio.is_write, "Unexpected mmio read");
155-
TEST_ASSERT(run->mmio.len == 8,
156-
"Unexpected exit mmio size = %u", run->mmio.len);
157-
TEST_ASSERT(run->mmio.phys_addr >= vm->mmio_gpa_min &&
158-
run->mmio.phys_addr <= vm->mmio_gpa_max,
159-
"Unexpected exit mmio address = 0x%llx",
160-
run->mmio.phys_addr);
165+
case UCALL_ABORT:
166+
TEST_FAIL("%s at %s:%ld, val = %lu",
167+
(const char *)uc.args[0],
168+
__FILE__, uc.args[1], uc.args[2]);
169+
break;
170+
case UCALL_DONE:
171+
goto done;
172+
default:
173+
TEST_FAIL("Unknown ucall %lu", uc.cmd);
174+
}
161175
}
162176

163-
if (run->exit_reason == KVM_EXIT_IO && cmd == UCALL_ABORT)
164-
TEST_FAIL("%s at %s:%ld, val = %lu", (const char *)uc.args[0],
165-
__FILE__, uc.args[1], uc.args[2]);
166-
177+
done:
167178
return NULL;
168179
}
169180

@@ -268,6 +279,7 @@ static bool prepare_vm(struct vm_data *data, int nslots, uint64_t *maxslots,
268279
TEST_ASSERT(data->hva_slots, "malloc() fail");
269280

270281
data->vm = vm_create_default(VCPU_ID, mempages, guest_code);
282+
ucall_init(data->vm, NULL);
271283

272284
pr_info_v("Adding slots 1..%i, each slot with %"PRIu64" pages + %"PRIu64" extra pages last\n",
273285
max_mem_slots - 1, data->pages_per_slot, rempages);

0 commit comments

Comments
 (0)