2021-11-17 16:38:20

by Paolo Bonzini

[permalink] [raw]
Subject: [PATCH 1/4] selftests: sev_migrate_tests: free all VMs

Ensure that the ASID are freed promptly, which becomes more important
when more tests are added to this file.

Cc: Peter Gonda <[email protected]>
Cc: Sean Christopherson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
---
tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c b/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
index 5ba325cd64bf..4a5d3728412b 100644
--- a/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
+++ b/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
@@ -162,7 +162,6 @@ static void test_sev_migrate_parameters(void)
sev_ioctl(sev_es_vm_no_vmsa->fd, KVM_SEV_ES_INIT, NULL);
vm_vcpu_add(sev_es_vm_no_vmsa, 1);

-
ret = __sev_migrate_from(sev_vm->fd, sev_es_vm->fd);
TEST_ASSERT(
ret == -1 && errno == EINVAL,
@@ -191,6 +190,12 @@ static void test_sev_migrate_parameters(void)
TEST_ASSERT(ret == -1 && errno == EINVAL,
"Migrations require SEV enabled. ret %d, errno: %d\n", ret,
errno);
+
+ kvm_vm_free(sev_vm);
+ kvm_vm_free(sev_es_vm);
+ kvm_vm_free(sev_es_vm_no_vmsa);
+ kvm_vm_free(vm_no_vcpu);
+ kvm_vm_free(vm_no_sev);
}

int main(int argc, char *argv[])
--
2.27.0




2021-11-17 16:52:55

by Peter Gonda

[permalink] [raw]
Subject: Re: [PATCH 1/4] selftests: sev_migrate_tests: free all VMs

I think we are still missing the kvm_vm_free() from
test_sev_migrate_locking(). Should we have this at the end?

for (i = 0; i < NR_LOCK_TESTING_THREADS; ++i)
kvm_vm_free(input[i].vm);


On Wed, Nov 17, 2021 at 9:38 AM Paolo Bonzini <[email protected]> wrote:
>
> Ensure that the ASID are freed promptly, which becomes more important
> when more tests are added to this file.
>
> Cc: Peter Gonda <[email protected]>
> Cc: Sean Christopherson <[email protected]>
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---
> tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c b/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
> index 5ba325cd64bf..4a5d3728412b 100644
> --- a/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
> +++ b/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
> @@ -162,7 +162,6 @@ static void test_sev_migrate_parameters(void)
> sev_ioctl(sev_es_vm_no_vmsa->fd, KVM_SEV_ES_INIT, NULL);
> vm_vcpu_add(sev_es_vm_no_vmsa, 1);
>
> -
> ret = __sev_migrate_from(sev_vm->fd, sev_es_vm->fd);
> TEST_ASSERT(
> ret == -1 && errno == EINVAL,
> @@ -191,6 +190,12 @@ static void test_sev_migrate_parameters(void)
> TEST_ASSERT(ret == -1 && errno == EINVAL,
> "Migrations require SEV enabled. ret %d, errno: %d\n", ret,
> errno);
> +
> + kvm_vm_free(sev_vm);
> + kvm_vm_free(sev_es_vm);
> + kvm_vm_free(sev_es_vm_no_vmsa);
> + kvm_vm_free(vm_no_vcpu);
> + kvm_vm_free(vm_no_sev);
> }
>
> int main(int argc, char *argv[])
> --
> 2.27.0
>
>

2021-11-17 18:25:14

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 1/4] selftests: sev_migrate_tests: free all VMs

On 11/17/21 17:52, Peter Gonda wrote:
> I think we are still missing the kvm_vm_free() from
> test_sev_migrate_locking(). Should we have this at the end?
>
> for (i = 0; i < NR_LOCK_TESTING_THREADS; ++i)
> kvm_vm_free(input[i].vm);

Yes, we should. Thanks!

Paolo