From: Oliver Upton <oliver.upton@linux.dev>
To: kvmarm@lists.linux.dev
Cc: Marc Zyngier <maz@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Raghavendra Rao Ananta <rananta@google.com>,
Ben Horgan <ben.horgan@arm.com>,
Oliver Upton <oliver.upton@linux.dev>
Subject: [PATCH v2 4/4] KVM: arm64: selftests: Add test for nASSGIcap attribute
Date: Fri, 30 May 2025 18:25:45 -0700 [thread overview]
Message-ID: <20250531012545.709887-5-oliver.upton@linux.dev> (raw)
In-Reply-To: <20250531012545.709887-1-oliver.upton@linux.dev>
From: Raghavendra Rao Ananta <rananta@google.com>
Extend vgic_init to test the nASSGIcap attribute, asserting that it is
configurable (within reason) prior to initializing the VGIC.
Additionally, check that userspace cannot set the attribute after the
VGIC has been initialized.
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
tools/testing/selftests/kvm/arm64/vgic_init.c | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/tools/testing/selftests/kvm/arm64/vgic_init.c b/tools/testing/selftests/kvm/arm64/vgic_init.c
index b3b5fb0ff0a9..aaecba432dbc 100644
--- a/tools/testing/selftests/kvm/arm64/vgic_init.c
+++ b/tools/testing/selftests/kvm/arm64/vgic_init.c
@@ -675,6 +675,46 @@ static void test_v3_its_region(void)
vm_gic_destroy(&v);
}
+static void test_v3_nassgicap(void)
+{
+ struct kvm_vcpu *vcpus[NR_VCPUS];
+ struct vm_gic vm;
+ __u8 nassgicap;
+ int ret;
+
+ vm = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus);
+ TEST_REQUIRE(!__kvm_has_device_attr(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_FEATURES,
+ KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap));
+
+ kvm_device_attr_get(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_FEATURES,
+ KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap, &nassgicap);
+ if (!nassgicap) {
+ nassgicap = true;
+ ret = __kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_FEATURES,
+ KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap, &nassgicap);
+ TEST_ASSERT(ret && errno == EINVAL,
+ "Enabled nASSGIcap even though it's unavailable");
+ } else {
+ nassgicap = false;
+ kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_FEATURES,
+ KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap, &nassgicap);
+
+ nassgicap = true;
+ kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_FEATURES,
+ KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap, &nassgicap);
+ }
+
+ kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
+ KVM_DEV_ARM_VGIC_CTRL_INIT, NULL);
+
+ ret = __kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_FEATURES,
+ KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap, &nassgicap);
+ TEST_ASSERT(ret && errno == EBUSY,
+ "Configured nASSGIcap after initializing the VGIC");
+
+ vm_gic_destroy(&vm);
+}
+
/*
* Returns 0 if it's possible to create GIC device of a given type (V2 or V3).
*/
@@ -730,6 +770,7 @@ void run_tests(uint32_t gic_dev_type)
test_v3_last_bit_single_rdist();
test_v3_redist_ipa_range_check_at_vcpu_run();
test_v3_its_region();
+ test_v3_nassgicap();
}
}
--
2.39.5
next prev parent reply other threads:[~2025-05-31 1:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-31 1:25 [PATCH v2 0/4] KVM: arm64: Add attribute to control GICD_TYPER2.nASSGIcap Oliver Upton
2025-05-31 1:25 ` [PATCH v2 1/4] KVM: arm64: Disambiguate support for vSGIs v. vLPIs Oliver Upton
2025-05-31 1:25 ` [PATCH v2 2/4] KVM: arm64: vgic-v3: Consolidate MAINT_IRQ handling Oliver Upton
2025-05-31 1:25 ` [PATCH v2 3/4] KVM: arm64: Introduce attribute to control GICD_TYPER2.nASSGIcap Oliver Upton
2025-06-03 18:33 ` Raghavendra Rao Ananta
2025-06-03 19:03 ` Oliver Upton
2025-05-31 1:25 ` Oliver Upton [this message]
2025-06-03 18:42 ` [PATCH v2 4/4] KVM: arm64: selftests: Add test for nASSGIcap attribute Raghavendra Rao Ananta
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=20250531012545.709887-5-oliver.upton@linux.dev \
--to=oliver.upton@linux.dev \
--cc=ben.horgan@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=rananta@google.com \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.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 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.