lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <207d6598c8b74161efc38bd18b476ca8626786b1.camel@redhat.com>
Date: Tue, 02 Apr 2024 10:05:24 -0400
From: Maxim Levitsky <mlevitsk@...hat.com>
To: kvm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Sean Christopherson <seanjc@...gle.com>, 
 Paolo Bonzini <pbonzini@...hat.com>, linux-kselftest@...r.kernel.org, Shuah
 Khan <shuah@...nel.org>
Subject: Re: [PATCH] KVM: selftests: fix max_guest_memory_test with more
 that 256 vCPUs

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@...hat.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, &regs);
>  	rendezvous_with_boss();
>  
>  	run_vcpu(vcpu);
>  	rendezvous_with_boss();
> -	vcpu_regs_set(vcpu, &regs);
>  	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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ