From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
broonie@kernel.org, maz@kernel.org, kvmarm@lists.linux.dev,
kvm@vger.kernel.org, joey.gouly@arm.com, oliver.upton@linux.dev,
shuah@kernel.org, pbonzini@redhat.com
Subject: [PATCH 3/3] KVM: selftests: Handle dead VM in vgic_init test
Date: Thu, 7 Nov 2024 10:38:50 +0100 [thread overview]
Message-ID: <20241107094000.70705-4-eric.auger@redhat.com> (raw)
In-Reply-To: <20241107094000.70705-1-eric.auger@redhat.com>
Commit df5fd75ee305 ("KVM: arm64: Don't eagerly teardown the vgic on init
error") changed the way the error is handled in case of incomplete
vgic setup. Now a KVM_REQ_VM_DEAD request is sent causing subsequent
KVM ioctl to fail. This now triggers a test assertion failure in
kvm_vm_free() which calls KVM_SET_USER_MEMORY_REGION2 ioctl.
Update the test so that it checks that after the partial vgic setup
the KVM_REQ_VM_DEAD has been sent and use the new kvm_vm_dead_free()
helper to free the resources.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/all/3f0918bf-0265-4714-9660-89b75da49859@sirena.org.uk/
---
.../testing/selftests/kvm/aarch64/vgic_init.c | 41 +++++++++++--------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/kvm/aarch64/vgic_init.c b/tools/testing/selftests/kvm/aarch64/vgic_init.c
index b3b5fb0ff0a9..845108afce5e 100644
--- a/tools/testing/selftests/kvm/aarch64/vgic_init.c
+++ b/tools/testing/selftests/kvm/aarch64/vgic_init.c
@@ -101,6 +101,12 @@ static void vm_gic_destroy(struct vm_gic *v)
kvm_vm_free(v->vm);
}
+static void vm_dead_gic_destroy(struct vm_gic *v)
+{
+ close(v->gic_fd);
+ kvm_vm_dead_free(v->vm);
+}
+
struct vgic_region_attr {
uint64_t attr;
uint64_t size;
@@ -335,7 +341,7 @@ static void test_vgic_then_vcpus(uint32_t gic_dev_type)
{
struct kvm_vcpu *vcpus[NR_VCPUS];
struct vm_gic v;
- int ret, i;
+ int i;
v = vm_gic_create_with_vcpus(gic_dev_type, 1, vcpus);
@@ -345,10 +351,10 @@ static void test_vgic_then_vcpus(uint32_t gic_dev_type)
for (i = 1; i < NR_VCPUS; ++i)
vcpus[i] = vm_vcpu_add(v.vm, i, guest_code);
- ret = run_vcpu(vcpus[3]);
- TEST_ASSERT(ret == -EINVAL, "dist/rdist overlap detected on 1st vcpu run");
+ run_vcpu(vcpus[3]);
+ TEST_ASSERT(vm_dead(v.vm), "dist/rdist overlap detected on 1st vcpu run");
- vm_gic_destroy(&v);
+ vm_dead_gic_destroy(&v);
}
/* All the VCPUs are created before the VGIC KVM device gets initialized */
@@ -356,16 +362,15 @@ static void test_vcpus_then_vgic(uint32_t gic_dev_type)
{
struct kvm_vcpu *vcpus[NR_VCPUS];
struct vm_gic v;
- int ret;
v = vm_gic_create_with_vcpus(gic_dev_type, NR_VCPUS, vcpus);
subtest_dist_rdist(&v);
- ret = run_vcpu(vcpus[3]);
- TEST_ASSERT(ret == -EINVAL, "dist/rdist overlap detected on 1st vcpu run");
+ run_vcpu(vcpus[3]);
+ TEST_ASSERT(vm_dead(v.vm), "dist/rdist overlap detected on 1st vcpu run");
- vm_gic_destroy(&v);
+ vm_dead_gic_destroy(&v);
}
#define KVM_VGIC_V2_ATTR(offset, cpu) \
@@ -415,9 +420,9 @@ static void test_v3_new_redist_regions(void)
kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL);
- ret = run_vcpu(vcpus[3]);
- TEST_ASSERT(ret == -ENXIO, "running without sufficient number of rdists");
- vm_gic_destroy(&v);
+ run_vcpu(vcpus[3]);
+ TEST_ASSERT(vm_dead(v.vm), "running without sufficient number of rdists");
+ vm_dead_gic_destroy(&v);
/* step2 */
@@ -428,10 +433,10 @@ static void test_v3_new_redist_regions(void)
kvm_device_attr_set(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_ADDR,
KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION, &addr);
- ret = run_vcpu(vcpus[3]);
- TEST_ASSERT(ret == -EBUSY, "running without vgic explicit init");
+ run_vcpu(vcpus[3]);
+ TEST_ASSERT(vm_dead(v.vm), "running without vgic explicit init");
- vm_gic_destroy(&v);
+ vm_dead_gic_destroy(&v);
/* step 3 */
@@ -604,8 +609,8 @@ static void test_v3_redist_ipa_range_check_at_vcpu_run(void)
{
struct kvm_vcpu *vcpus[NR_VCPUS];
struct vm_gic v;
- int ret, i;
uint64_t addr;
+ int i;
v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, 1, vcpus);
@@ -626,11 +631,11 @@ static void test_v3_redist_ipa_range_check_at_vcpu_run(void)
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL);
/* Attempt to run a vcpu without enough redist space. */
- ret = run_vcpu(vcpus[2]);
- TEST_ASSERT(ret && errno == EINVAL,
+ run_vcpu(vcpus[2]);
+ TEST_ASSERT(vm_dead(v.vm),
"redist base+size above PA range detected on 1st vcpu run");
- vm_gic_destroy(&v);
+ vm_dead_gic_destroy(&v);
}
static void test_v3_its_region(void)
--
2.41.0
prev parent reply other threads:[~2024-11-07 9:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 9:38 [PATCH 0/3] KVM: arm64: Handle KVM_REQ_VM_DEAD in vgic_init test Eric Auger
2024-11-07 9:38 ` [PATCH 1/3] KVM: selftests: Introduce vm_dead() Eric Auger
2024-11-07 9:38 ` [PATCH 2/3] KVM: selftests: Introduce kvm_vm_dead_free Eric Auger
2024-11-07 17:55 ` Sean Christopherson
2024-11-07 18:17 ` Mark Brown
2024-11-07 19:08 ` Oliver Upton
2024-11-07 19:56 ` Sean Christopherson
2024-11-07 20:12 ` Oliver Upton
2024-11-07 20:26 ` Sean Christopherson
2024-11-11 19:46 ` Oliver Upton
2024-11-08 8:55 ` Eric Auger
2024-11-08 9:00 ` Eric Auger
2024-11-08 17:18 ` Oliver Upton
2024-11-07 9:38 ` Eric Auger [this message]
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=20241107094000.70705-4-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=broonie@kernel.org \
--cc=eric.auger.pro@gmail.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.