mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: seanjc@google.com, michael.roth@amd.com, aik@amd.com,
	isaku.yamahata@intel.com
Subject: [PATCH 11/10] selftests: kvm: switch sev_migrate_tests to KVM_SEV_INIT2
Date: Fri,  9 Feb 2024 13:37:43 -0500	[thread overview]
Message-ID: <20240209183743.22030-12-pbonzini@redhat.com> (raw)
In-Reply-To: <20240209183743.22030-1-pbonzini@redhat.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 .../selftests/kvm/x86_64/sev_migrate_tests.c  | 45 ++++++++++---------
 1 file changed, 23 insertions(+), 22 deletions(-)

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 c7ef97561038..301f7083cad0 100644
--- a/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
+++ b/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
@@ -50,11 +50,12 @@ static void sev_ioctl(int vm_fd, int cmd_id, void *data)
 static struct kvm_vm *sev_vm_create(bool es)
 {
 	struct kvm_vm *vm;
+	struct kvm_sev_init init = { 0 };
 	struct kvm_sev_launch_start start = { 0 };
 	int i;
 
-	vm = vm_create_barebones();
-	sev_ioctl(vm->fd, es ? KVM_SEV_ES_INIT : KVM_SEV_INIT, NULL);
+	vm = vm_create_barebones_type(es ? KVM_X86_SEV_ES_VM : KVM_X86_SEV_VM);
+	sev_ioctl(vm->fd, KVM_SEV_INIT2, &init);
 	for (i = 0; i < NR_MIGRATE_TEST_VCPUS; ++i)
 		__vm_vcpu_add(vm, i);
 	if (es)
@@ -65,12 +66,12 @@ static struct kvm_vm *sev_vm_create(bool es)
 	return vm;
 }
 
-static struct kvm_vm *aux_vm_create(bool with_vcpus)
+static struct kvm_vm *aux_vm_create(bool es, bool with_vcpus)
 {
 	struct kvm_vm *vm;
 	int i;
 
-	vm = vm_create_barebones();
+	vm = vm_create_barebones_type(es ? KVM_X86_SEV_ES_VM : KVM_X86_SEV_VM);
 	if (!with_vcpus)
 		return vm;
 
@@ -102,7 +103,7 @@ static void test_sev_migrate_from(bool es)
 
 	src_vm = sev_vm_create(es);
 	for (i = 0; i < NR_MIGRATE_TEST_VMS; ++i)
-		dst_vms[i] = aux_vm_create(true);
+		dst_vms[i] = aux_vm_create(es, true);
 
 	/* Initial migration from the src to the first dst. */
 	sev_migrate_from(dst_vms[0], src_vm);
@@ -164,16 +165,17 @@ static void test_sev_migrate_locking(void)
 
 static void test_sev_migrate_parameters(void)
 {
-	struct kvm_vm *sev_vm, *sev_es_vm, *vm_no_vcpu, *vm_no_sev,
+	struct kvm_vm *sev_vm, *sev_es_vm, *vm_no_vcpu,
 		*sev_es_vm_no_vmsa;
 	int ret;
 
 	vm_no_vcpu = vm_create_barebones();
-	vm_no_sev = aux_vm_create(true);
-	ret = __sev_migrate_from(vm_no_vcpu, vm_no_sev);
+	sev_vm = aux_vm_create(false, true);
+	ret = __sev_migrate_from(vm_no_vcpu, sev_vm);
 	TEST_ASSERT(ret == -1 && errno == EINVAL,
 		    "Migrations require SEV enabled. ret %d, errno: %d\n", ret,
 		    errno);
+	kvm_vm_free(sev_vm);
 
 	if (!have_sev_es)
 		goto out;
@@ -213,7 +215,6 @@ static void test_sev_migrate_parameters(void)
 	kvm_vm_free(sev_es_vm_no_vmsa);
 out:
 	kvm_vm_free(vm_no_vcpu);
-	kvm_vm_free(vm_no_sev);
 }
 
 static int __sev_mirror_create(struct kvm_vm *dst, struct kvm_vm *src)
@@ -272,7 +273,7 @@ static void test_sev_mirror(bool es)
 	int i;
 
 	src_vm = sev_vm_create(es);
-	dst_vm = aux_vm_create(false);
+	dst_vm = aux_vm_create(es, false);
 
 	sev_mirror_create(dst_vm, src_vm);
 
@@ -295,8 +296,8 @@ static void test_sev_mirror_parameters(void)
 	int ret;
 
 	sev_vm = sev_vm_create(/* es= */ false);
-	vm_with_vcpu = aux_vm_create(true);
-	vm_no_vcpu = aux_vm_create(false);
+	vm_with_vcpu = aux_vm_create(false, true);
+	vm_no_vcpu = aux_vm_create(false, false);
 
 	ret = __sev_mirror_create(sev_vm, sev_vm);
 	TEST_ASSERT(
@@ -345,13 +346,13 @@ static void test_sev_move_copy(void)
 		      *dst_mirror_vm, *dst2_mirror_vm, *dst3_mirror_vm;
 
 	sev_vm = sev_vm_create(/* es= */ false);
-	dst_vm = aux_vm_create(true);
-	dst2_vm = aux_vm_create(true);
-	dst3_vm = aux_vm_create(true);
-	mirror_vm = aux_vm_create(false);
-	dst_mirror_vm = aux_vm_create(false);
-	dst2_mirror_vm = aux_vm_create(false);
-	dst3_mirror_vm = aux_vm_create(false);
+	dst_vm = aux_vm_create(false, true);
+	dst2_vm = aux_vm_create(false, true);
+	dst3_vm = aux_vm_create(false, true);
+	mirror_vm = aux_vm_create(false, false);
+	dst_mirror_vm = aux_vm_create(false, false);
+	dst2_mirror_vm = aux_vm_create(false, false);
+	dst3_mirror_vm = aux_vm_create(false, false);
 
 	sev_mirror_create(mirror_vm, sev_vm);
 
@@ -378,9 +379,9 @@ static void test_sev_move_copy(void)
 	 * destruction is done safely.
 	 */
 	sev_vm = sev_vm_create(/* es= */ false);
-	dst_vm = aux_vm_create(true);
-	mirror_vm = aux_vm_create(false);
-	dst_mirror_vm = aux_vm_create(false);
+	dst_vm = aux_vm_create(false, true);
+	mirror_vm = aux_vm_create(false, false);
+	dst_mirror_vm = aux_vm_create(false, false);
 
 	sev_mirror_create(mirror_vm, sev_vm);
 
-- 
2.39.0


  parent reply	other threads:[~2024-02-09 18:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 18:37 [PATCH 00/10] KVM: SEV: allow customizing VMSA features Paolo Bonzini
2024-02-09 18:37 ` [PATCH 01/10] KVM: SEV: fix compat ABI for KVM_MEMORY_ENCRYPT_OP Paolo Bonzini
2024-02-14 22:50   ` Michael Roth
2024-02-09 18:37 ` [PATCH 02/10] KVM: introduce new vendor op for KVM_GET_DEVICE_ATTR Paolo Bonzini
2024-02-14 22:57   ` Michael Roth
2024-02-09 18:37 ` [PATCH 03/10] Documentation: kvm/sev: separate description of firmware Paolo Bonzini
2024-02-14 23:23   ` Michael Roth
2024-02-09 18:37 ` [PATCH 04/10] KVM: SEV: publish supported VMSA features Paolo Bonzini
2024-02-14 23:49   ` Michael Roth
2024-02-09 18:37 ` [PATCH 05/10] KVM: SEV: store VMSA features in kvm_sev_info Paolo Bonzini
2024-02-15  0:03   ` Michael Roth
2024-02-09 18:37 ` [PATCH 06/10] KVM: x86: define standard behavior for bits 0/1 of VM type Paolo Bonzini
2024-02-09 18:37 ` [PATCH 07/10] KVM: x86: Add is_vm_type_supported callback Paolo Bonzini
2024-02-15  0:33   ` Michael Roth
2024-02-15 13:35     ` Paolo Bonzini
2024-02-09 18:37 ` [PATCH 08/10] KVM: SEV: define VM types for SEV and SEV-ES Paolo Bonzini
2024-02-15  1:19   ` Michael Roth
2024-02-15 13:40     ` Paolo Bonzini
2024-02-09 18:37 ` [PATCH 09/10] KVM: SEV: introduce KVM_SEV_INIT2 operation Paolo Bonzini
2024-02-15  1:34   ` Michael Roth
2024-02-15 13:44     ` Paolo Bonzini
2024-02-15 14:44       ` Michael Roth
2024-02-15 17:28         ` Paolo Bonzini
2024-02-15 17:54           ` Michael Roth
2024-02-15 18:08             ` Paolo Bonzini
2024-02-15 20:44               ` Michael Roth
2024-02-15 11:07   ` Alexey Kardashevskiy
2024-02-15 21:14   ` Tom Lendacky
2024-02-09 18:37 ` [PATCH 10/10] selftests: kvm: add tests for KVM_SEV_INIT2 Paolo Bonzini
2024-02-09 18:37 ` Paolo Bonzini [this message]
2024-02-09 19:40 ` [PATCH 00/10] KVM: SEV: allow customizing VMSA features Sean Christopherson
2024-02-09 22:40   ` Paolo Bonzini
2024-02-13  2:46     ` Sean Christopherson
2024-02-13 14:44       ` Paolo Bonzini
2024-02-17  1:40         ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240209183743.22030-12-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aik@amd.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®