Skip to content

Commit 0ef2dd1

Browse files
Maxim Levitskysean-jc
authored andcommitted
KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs
max_guest_memory_test uses ucalls to sync with the host, but it also resets the guest RIP back to its initial value in between tests stages. This makes the guest never reach the code which frees the ucall struct and since a fixed pool of 512 ucall structs is used, the test starts to fail when more that 256 vCPUs are used. Fix that by replacing the manual register reset with a loop in the guest code. Signed-off-by: Maxim Levitsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 08a8282 commit 0ef2dd1

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tools/testing/selftests/kvm/max_guest_memory_test.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ static void guest_code(uint64_t start_gpa, uint64_t end_gpa, uint64_t stride)
2222
{
2323
uint64_t gpa;
2424

25-
for (gpa = start_gpa; gpa < end_gpa; gpa += stride)
26-
*((volatile uint64_t *)gpa) = gpa;
27-
28-
GUEST_DONE();
25+
for (;;) {
26+
for (gpa = start_gpa; gpa < end_gpa; gpa += stride)
27+
*((volatile uint64_t *)gpa) = gpa;
28+
GUEST_SYNC(0);
29+
}
2930
}
3031

3132
struct vcpu_info {
@@ -55,7 +56,7 @@ static void rendezvous_with_boss(void)
5556
static void run_vcpu(struct kvm_vcpu *vcpu)
5657
{
5758
vcpu_run(vcpu);
58-
TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_DONE);
59+
TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_SYNC);
5960
}
6061

6162
static void *vcpu_worker(void *data)
@@ -64,17 +65,13 @@ static void *vcpu_worker(void *data)
6465
struct kvm_vcpu *vcpu = info->vcpu;
6566
struct kvm_vm *vm = vcpu->vm;
6667
struct kvm_sregs sregs;
67-
struct kvm_regs regs;
6868

6969
vcpu_args_set(vcpu, 3, info->start_gpa, info->end_gpa, vm->page_size);
7070

71-
/* Snapshot regs before the first run. */
72-
vcpu_regs_get(vcpu, &regs);
7371
rendezvous_with_boss();
7472

7573
run_vcpu(vcpu);
7674
rendezvous_with_boss();
77-
vcpu_regs_set(vcpu, &regs);
7875
vcpu_sregs_get(vcpu, &sregs);
7976
#ifdef __x86_64__
8077
/* Toggle CR0.WP to trigger a MMU context reset. */

0 commit comments

Comments
 (0)