From: Eric Auger <eauger@redhat.com>
To: Oliver Upton <oliver.upton@linux.dev>, 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>,
Zhou Wang <wangzhou1@hisilicon.com>
Subject: Re: [PATCH v4 5/6] KVM: arm64: selftests: Add test for nASSGIcap attribute
Date: Mon, 14 Jul 2025 17:03:09 +0200 [thread overview]
Message-ID: <a072d0c9-1831-4381-ae4d-2f5ce9960a43@redhat.com> (raw)
In-Reply-To: <20250709211417.2074487-6-oliver.upton@linux.dev>
Hi,
On 7/9/25 11:14 PM, Oliver Upton wrote:
> 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>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> tools/testing/selftests/kvm/arm64/vgic_init.c | 42 ++++++++++++++++++-
> 1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/arm64/vgic_init.c b/tools/testing/selftests/kvm/arm64/vgic_init.c
> index b3b5fb0ff0a9..743351aa998e 100644
> --- a/tools/testing/selftests/kvm/arm64/vgic_init.c
> +++ b/tools/testing/selftests/kvm/arm64/vgic_init.c
> @@ -13,13 +13,12 @@
> #include "kvm_util.h"
> #include "processor.h"
> #include "vgic.h"
> +#include "gic_v3.h"
>
> #define NR_VCPUS 4
>
> #define REG_OFFSET(vcpu, offset) (((uint64_t)vcpu << 32) | offset)
>
> -#define GICR_TYPER 0x8
> -
> #define VGIC_DEV_IS_V2(_d) ((_d) == KVM_DEV_TYPE_ARM_VGIC_V2)
> #define VGIC_DEV_IS_V3(_d) ((_d) == KVM_DEV_TYPE_ARM_VGIC_V3)
>
> @@ -675,6 +674,44 @@ static void test_v3_its_region(void)
> vm_gic_destroy(&v);
> }
>
> +static void test_v3_nassgicap(void)
> +{
> + struct kvm_vcpu *vcpus[NR_VCPUS];
> + bool has_nassgicap;
> + struct vm_gic vm;
> + u32 typer2;
> + int ret;
> +
> + vm = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS, vcpus);
> + kvm_device_attr_get(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS,
> + GICD_TYPER2, &typer2);
> + has_nassgicap = typer2 & GICD_TYPER2_nASSGIcap;
> +
> + typer2 |= GICD_TYPER2_nASSGIcap;
> + ret = __kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS,
> + GICD_TYPER2, &typer2);
> + if (has_nassgicap)
> + TEST_ASSERT(!ret, KVM_IOCTL_ERROR(KVM_DEVICE_ATTR_SET, ret));
> + else
> + TEST_ASSERT(ret && errno == EINVAL,
> + "Enabled nASSGIcap even though it's unavailable");
> +
> + typer2 &= ~GICD_TYPER2_nASSGIcap;
> + kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS,
> + GICD_TYPER2, &typer2);
> +
> + kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
> + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL);
> +
> + typer2 ^= GICD_TYPER2_nASSGIcap;
> + ret = __kvm_device_attr_set(vm.gic_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS,
> + GICD_TYPER2, &typer2);
> + TEST_ASSERT(ret && errno == EBUSY,
> + "Changed 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 +767,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();
> }
> }
>
next prev parent reply other threads:[~2025-07-14 15:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 21:14 [PATCH v4 0/6] KVM: arm64: Allow userspace to write GICD_TYPER2.nASSGIcap Oliver Upton
2025-07-09 21:14 ` [PATCH v4 1/6] KVM: arm64: Disambiguate support for vSGIs v. vLPIs Oliver Upton
2025-07-10 8:59 ` Ben Horgan
2025-07-10 16:22 ` Oliver Upton
2025-07-14 10:20 ` Eric Auger
2025-07-22 21:36 ` Oliver Upton
2025-07-09 21:14 ` [PATCH v4 2/6] KVM: arm64: vgic-v3: Consolidate MAINT_IRQ handling Oliver Upton
2025-07-14 12:52 ` Eric Auger
2025-07-14 12:59 ` Eric Auger
2025-07-22 21:42 ` Oliver Upton
2025-07-09 21:14 ` [PATCH v4 3/6] KVM: arm64: vgic-v3: Allow access to GICD_IIDR prior to initialization Oliver Upton
2025-07-14 14:41 ` Eric Auger
2025-07-22 21:47 ` Oliver Upton
2025-08-21 10:55 ` Zhou Wang
2025-08-21 18:43 ` Oliver Upton
2025-08-22 1:54 ` Zhou Wang
2025-07-09 21:14 ` [PATCH v4 4/6] KVM: arm64: vgic-v3: Allow userspace to write GICD_TYPER2.nASSGIcap Oliver Upton
2025-07-14 14:58 ` Eric Auger
2025-07-09 21:14 ` [PATCH v4 5/6] KVM: arm64: selftests: Add test for nASSGIcap attribute Oliver Upton
2025-07-14 15:03 ` Eric Auger [this message]
2025-07-09 21:14 ` [PATCH v4 6/6] Documentation: KVM: arm64: Describe VGICv3 registers writable pre-init Oliver Upton
2025-07-14 15:06 ` Eric Auger
2025-07-22 21:50 ` Oliver Upton
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=a072d0c9-1831-4381-ae4d-2f5ce9960a43@redhat.com \
--to=eauger@redhat.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=rananta@google.com \
--cc=suzuki.poulose@arm.com \
--cc=wangzhou1@hisilicon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox