mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
KVM: selftests: Precisely limit the number of guest loops in mmu_stress_test
Run the exact number of guest loops required in mmu_stress_test instead of looping indefinitely in anticipation of adding more stages that run different code (e.g. reads instead of writes). Reviewed-by: James Houghton <jthoughton@google.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20241128005547.4077116-12-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
3a04225264
commit
82b542e118
|
|
@ -20,12 +20,15 @@
|
|||
static void guest_code(uint64_t start_gpa, uint64_t end_gpa, uint64_t stride)
|
||||
{
|
||||
uint64_t gpa;
|
||||
int i;
|
||||
|
||||
for (;;) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (gpa = start_gpa; gpa < end_gpa; gpa += stride)
|
||||
vcpu_arch_put_guest(*((volatile uint64_t *)gpa), gpa);
|
||||
GUEST_SYNC(0);
|
||||
GUEST_SYNC(i);
|
||||
}
|
||||
|
||||
GUEST_ASSERT(0);
|
||||
}
|
||||
|
||||
struct vcpu_info {
|
||||
|
|
@ -52,10 +55,18 @@ static void rendezvous_with_boss(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void run_vcpu(struct kvm_vcpu *vcpu)
|
||||
static void assert_sync_stage(struct kvm_vcpu *vcpu, int stage)
|
||||
{
|
||||
struct ucall uc;
|
||||
|
||||
TEST_ASSERT_EQ(get_ucall(vcpu, &uc), UCALL_SYNC);
|
||||
TEST_ASSERT_EQ(uc.args[1], stage);
|
||||
}
|
||||
|
||||
static void run_vcpu(struct kvm_vcpu *vcpu, int stage)
|
||||
{
|
||||
vcpu_run(vcpu);
|
||||
TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_SYNC);
|
||||
assert_sync_stage(vcpu, stage);
|
||||
}
|
||||
|
||||
static void *vcpu_worker(void *data)
|
||||
|
|
@ -69,7 +80,8 @@ static void *vcpu_worker(void *data)
|
|||
|
||||
rendezvous_with_boss();
|
||||
|
||||
run_vcpu(vcpu);
|
||||
/* Stage 0, write all of guest memory. */
|
||||
run_vcpu(vcpu, 0);
|
||||
rendezvous_with_boss();
|
||||
#ifdef __x86_64__
|
||||
vcpu_sregs_get(vcpu, &sregs);
|
||||
|
|
@ -79,7 +91,8 @@ static void *vcpu_worker(void *data)
|
|||
#endif
|
||||
rendezvous_with_boss();
|
||||
|
||||
run_vcpu(vcpu);
|
||||
/* Stage 1, re-write all of guest memory. */
|
||||
run_vcpu(vcpu, 1);
|
||||
rendezvous_with_boss();
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user