* [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs
@ 2024-03-15 14:35 Maxim Levitsky
2024-04-02 14:05 ` Maxim Levitsky
2024-04-09 2:01 ` Sean Christopherson
0 siblings, 2 replies; 4+ messages in thread
From: Maxim Levitsky @ 2024-03-15 14:35 UTC (permalink / raw)
To: kvm
Cc: linux-kernel, Sean Christopherson, Paolo Bonzini, linux-kselftest,
Shuah Khan, Maxim Levitsky
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 <mlevitsk@redhat.com>
---
.../testing/selftests/kvm/max_guest_memory_test.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/kvm/max_guest_memory_test.c b/tools/testing/selftests/kvm/max_guest_memory_test.c
index 6628dc4dda89f3c..1a6da7389bf1f5b 100644
--- a/tools/testing/selftests/kvm/max_guest_memory_test.c
+++ b/tools/testing/selftests/kvm/max_guest_memory_test.c
@@ -22,10 +22,11 @@ static void guest_code(uint64_t start_gpa, uint64_t end_gpa, uint64_t stride)
{
uint64_t gpa;
- for (gpa = start_gpa; gpa < end_gpa; gpa += stride)
- *((volatile uint64_t *)gpa) = gpa;
-
- GUEST_DONE();
+ for (;;) {
+ for (gpa = start_gpa; gpa < end_gpa; gpa += stride)
+ *((volatile uint64_t *)gpa) = gpa;
+ GUEST_SYNC(0);
+ }
}
struct vcpu_info {
@@ -55,7 +56,7 @@ static void rendezvous_with_boss(void)
static void run_vcpu(struct kvm_vcpu *vcpu)
{
vcpu_run(vcpu);
- TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_DONE);
+ TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_SYNC);
}
static void *vcpu_worker(void *data)
@@ -64,17 +65,13 @@ static void *vcpu_worker(void *data)
struct kvm_vcpu *vcpu = info->vcpu;
struct kvm_vm *vm = vcpu->vm;
struct kvm_sregs sregs;
- struct kvm_regs regs;
vcpu_args_set(vcpu, 3, info->start_gpa, info->end_gpa, vm->page_size);
- /* Snapshot regs before the first run. */
- vcpu_regs_get(vcpu, ®s);
rendezvous_with_boss();
run_vcpu(vcpu);
rendezvous_with_boss();
- vcpu_regs_set(vcpu, ®s);
vcpu_sregs_get(vcpu, &sregs);
#ifdef __x86_64__
/* Toggle CR0.WP to trigger a MMU context reset. */
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs
2024-03-15 14:35 [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs Maxim Levitsky
@ 2024-04-02 14:05 ` Maxim Levitsky
2024-04-02 23:06 ` Sean Christopherson
2024-04-09 2:01 ` Sean Christopherson
1 sibling, 1 reply; 4+ messages in thread
From: Maxim Levitsky @ 2024-04-02 14:05 UTC (permalink / raw)
To: kvm
Cc: linux-kernel, Sean Christopherson, Paolo Bonzini, linux-kselftest,
Shuah Khan
On Fri, 2024-03-15 at 10:35 -0400, Maxim Levitsky wrote:
> 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 <mlevitsk@redhat.com>
> ---
> .../testing/selftests/kvm/max_guest_memory_test.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/max_guest_memory_test.c b/tools/testing/selftests/kvm/max_guest_memory_test.c
> index 6628dc4dda89f3c..1a6da7389bf1f5b 100644
> --- a/tools/testing/selftests/kvm/max_guest_memory_test.c
> +++ b/tools/testing/selftests/kvm/max_guest_memory_test.c
> @@ -22,10 +22,11 @@ static void guest_code(uint64_t start_gpa, uint64_t end_gpa, uint64_t stride)
> {
> uint64_t gpa;
>
> - for (gpa = start_gpa; gpa < end_gpa; gpa += stride)
> - *((volatile uint64_t *)gpa) = gpa;
> -
> - GUEST_DONE();
> + for (;;) {
> + for (gpa = start_gpa; gpa < end_gpa; gpa += stride)
> + *((volatile uint64_t *)gpa) = gpa;
> + GUEST_SYNC(0);
> + }
> }
>
> struct vcpu_info {
> @@ -55,7 +56,7 @@ static void rendezvous_with_boss(void)
> static void run_vcpu(struct kvm_vcpu *vcpu)
> {
> vcpu_run(vcpu);
> - TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_DONE);
> + TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_SYNC);
> }
>
> static void *vcpu_worker(void *data)
> @@ -64,17 +65,13 @@ static void *vcpu_worker(void *data)
> struct kvm_vcpu *vcpu = info->vcpu;
> struct kvm_vm *vm = vcpu->vm;
> struct kvm_sregs sregs;
> - struct kvm_regs regs;
>
> vcpu_args_set(vcpu, 3, info->start_gpa, info->end_gpa, vm->page_size);
>
> - /* Snapshot regs before the first run. */
> - vcpu_regs_get(vcpu, ®s);
> rendezvous_with_boss();
>
> run_vcpu(vcpu);
> rendezvous_with_boss();
> - vcpu_regs_set(vcpu, ®s);
> vcpu_sregs_get(vcpu, &sregs);
> #ifdef __x86_64__
> /* Toggle CR0.WP to trigger a MMU context reset. */
Kind ping on this patch.
Best regards,
Maxim Levitsky
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs
2024-04-02 14:05 ` Maxim Levitsky
@ 2024-04-02 23:06 ` Sean Christopherson
0 siblings, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2024-04-02 23:06 UTC (permalink / raw)
To: Maxim Levitsky
Cc: kvm, linux-kernel, Paolo Bonzini, linux-kselftest, Shuah Khan
On Tue, Apr 02, 2024, Maxim Levitsky wrote:
> Kind ping on this patch.
It (and patches from other folks that are getting pinged) is on my list of things
to grab, I'm still digging myself out of my mailbox and time sensitive things that
cropped up while I was offline. I expect to start applying stuff this week,
especially for fixes like this.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs
2024-03-15 14:35 [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs Maxim Levitsky
2024-04-02 14:05 ` Maxim Levitsky
@ 2024-04-09 2:01 ` Sean Christopherson
1 sibling, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2024-04-09 2:01 UTC (permalink / raw)
To: Sean Christopherson, kvm, Maxim Levitsky
Cc: linux-kernel, Paolo Bonzini, linux-kselftest, Shuah Khan
On Fri, 15 Mar 2024 10:35:07 -0400, Maxim Levitsky wrote:
> 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.
>
> [...]
Applied to kvm-x86 fixes, thanks!
[1/1] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs
https://github.com/kvm-x86/linux/commit/0ef2dd1f4144
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-09 2:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-15 14:35 [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs Maxim Levitsky
2024-04-02 14:05 ` Maxim Levitsky
2024-04-02 23:06 ` Sean Christopherson
2024-04-09 2:01 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox