From: Ricardo Koller <ricarkol@google.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
Marc Zyngier <maz@kernel.org>, Shuah Khan <shuah@kernel.org>,
kvmarm@lists.cs.columbia.edu, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
Date: Tue, 25 Jan 2022 17:23:00 -0800 [thread overview]
Message-ID: <YfCidIboLDMb/Hy3@google.com> (raw)
In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org>
On Tue, Jan 25, 2022 at 07:28:51PM +0000, Mark Brown wrote:
> The arch_timer and vgic_irq kselftests assume that they can create a
> vgic-v3, using the library function vgic_v3_setup() which aborts with a
> test failure if it is not possible to do so. Since vgic-v3 can only be
> instantiated on systems where the host has GICv3 this leads to false
> positives on older systems where that is not the case.
>
> Fix this by changing vgic_v3_setup() to return an error if the vgic can't
> be instantiated and have the callers skip if this happens. We could also
> exit flagging a skip in vgic_v3_setup() but this would prevent future test
> cases conditionally deciding which GIC to use or generally doing more
> complex output.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 5 +++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> index 9ad38bd360a4..791d38404652 100644
> --- a/tools/testing/selftests/kvm/aarch64/arch_timer.c
> +++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> @@ -366,6 +366,7 @@ static struct kvm_vm *test_vm_create(void)
> {
> struct kvm_vm *vm;
> unsigned int i;
> + int ret;
> int nr_vcpus = test_args.nr_vcpus;
>
> vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
> @@ -382,7 +383,11 @@ static struct kvm_vm *test_vm_create(void)
>
> ucall_init(vm, NULL);
> test_init_timer_irq(vm);
> - vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> + if (ret < 0) {
> + pr_info("Failed to create vgic-v3, skipping\n");
> + exit(KSFT_SKIP);
> + }
>
> /* Make all the test's cmdline args visible to the guest */
> sync_global_to_guest(vm, test_args);
> diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> index e6c7d7f8fbd1..8c6b61b8e6aa 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,11 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
>
> gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
> GICD_BASE_GPA, GICR_BASE_GPA);
> + if (gic_fd < 0) {
> + pr_info("Failed to create vgic-v3, skipping\n");
> + exit(KSFT_SKIP);
> + }
> +
>
> vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT,
> guest_irq_handlers[args.eoi_split][args.level_sensitive]);
> diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> index b3a0fca0d780..647c18733e1b 100644
> --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> @@ -52,7 +52,9 @@ int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs,
> nr_vcpus, nr_vcpus_created);
>
> /* Distributor setup */
> - gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false);
> + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, true);
> + if (gic_fd == -1)
> + return -1;
>
> kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
> 0, &nr_irqs, true);
> --
> 2.30.2
>
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Reviewed-by: Ricardo Koller <ricarkol@google.com>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
WARNING: multiple messages have this Message-ID (diff)
From: Ricardo Koller <ricarkol@google.com>
To: Mark Brown <broonie@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
Date: Tue, 25 Jan 2022 17:23:00 -0800 [thread overview]
Message-ID: <YfCidIboLDMb/Hy3@google.com> (raw)
In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org>
On Tue, Jan 25, 2022 at 07:28:51PM +0000, Mark Brown wrote:
> The arch_timer and vgic_irq kselftests assume that they can create a
> vgic-v3, using the library function vgic_v3_setup() which aborts with a
> test failure if it is not possible to do so. Since vgic-v3 can only be
> instantiated on systems where the host has GICv3 this leads to false
> positives on older systems where that is not the case.
>
> Fix this by changing vgic_v3_setup() to return an error if the vgic can't
> be instantiated and have the callers skip if this happens. We could also
> exit flagging a skip in vgic_v3_setup() but this would prevent future test
> cases conditionally deciding which GIC to use or generally doing more
> complex output.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 5 +++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> index 9ad38bd360a4..791d38404652 100644
> --- a/tools/testing/selftests/kvm/aarch64/arch_timer.c
> +++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> @@ -366,6 +366,7 @@ static struct kvm_vm *test_vm_create(void)
> {
> struct kvm_vm *vm;
> unsigned int i;
> + int ret;
> int nr_vcpus = test_args.nr_vcpus;
>
> vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
> @@ -382,7 +383,11 @@ static struct kvm_vm *test_vm_create(void)
>
> ucall_init(vm, NULL);
> test_init_timer_irq(vm);
> - vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> + if (ret < 0) {
> + pr_info("Failed to create vgic-v3, skipping\n");
> + exit(KSFT_SKIP);
> + }
>
> /* Make all the test's cmdline args visible to the guest */
> sync_global_to_guest(vm, test_args);
> diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> index e6c7d7f8fbd1..8c6b61b8e6aa 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,11 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
>
> gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
> GICD_BASE_GPA, GICR_BASE_GPA);
> + if (gic_fd < 0) {
> + pr_info("Failed to create vgic-v3, skipping\n");
> + exit(KSFT_SKIP);
> + }
> +
>
> vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT,
> guest_irq_handlers[args.eoi_split][args.level_sensitive]);
> diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> index b3a0fca0d780..647c18733e1b 100644
> --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> @@ -52,7 +52,9 @@ int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs,
> nr_vcpus, nr_vcpus_created);
>
> /* Distributor setup */
> - gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false);
> + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, true);
> + if (gic_fd == -1)
> + return -1;
>
> kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
> 0, &nr_irqs, true);
> --
> 2.30.2
>
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Reviewed-by: Ricardo Koller <ricarkol@google.com>
WARNING: multiple messages have this Message-ID (diff)
From: Ricardo Koller <ricarkol@google.com>
To: Mark Brown <broonie@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
Date: Tue, 25 Jan 2022 17:23:00 -0800 [thread overview]
Message-ID: <YfCidIboLDMb/Hy3@google.com> (raw)
In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org>
On Tue, Jan 25, 2022 at 07:28:51PM +0000, Mark Brown wrote:
> The arch_timer and vgic_irq kselftests assume that they can create a
> vgic-v3, using the library function vgic_v3_setup() which aborts with a
> test failure if it is not possible to do so. Since vgic-v3 can only be
> instantiated on systems where the host has GICv3 this leads to false
> positives on older systems where that is not the case.
>
> Fix this by changing vgic_v3_setup() to return an error if the vgic can't
> be instantiated and have the callers skip if this happens. We could also
> exit flagging a skip in vgic_v3_setup() but this would prevent future test
> cases conditionally deciding which GIC to use or generally doing more
> complex output.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 5 +++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> index 9ad38bd360a4..791d38404652 100644
> --- a/tools/testing/selftests/kvm/aarch64/arch_timer.c
> +++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> @@ -366,6 +366,7 @@ static struct kvm_vm *test_vm_create(void)
> {
> struct kvm_vm *vm;
> unsigned int i;
> + int ret;
> int nr_vcpus = test_args.nr_vcpus;
>
> vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
> @@ -382,7 +383,11 @@ static struct kvm_vm *test_vm_create(void)
>
> ucall_init(vm, NULL);
> test_init_timer_irq(vm);
> - vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> + if (ret < 0) {
> + pr_info("Failed to create vgic-v3, skipping\n");
> + exit(KSFT_SKIP);
> + }
>
> /* Make all the test's cmdline args visible to the guest */
> sync_global_to_guest(vm, test_args);
> diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> index e6c7d7f8fbd1..8c6b61b8e6aa 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,11 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
>
> gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
> GICD_BASE_GPA, GICR_BASE_GPA);
> + if (gic_fd < 0) {
> + pr_info("Failed to create vgic-v3, skipping\n");
> + exit(KSFT_SKIP);
> + }
> +
>
> vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT,
> guest_irq_handlers[args.eoi_split][args.level_sensitive]);
> diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> index b3a0fca0d780..647c18733e1b 100644
> --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
> @@ -52,7 +52,9 @@ int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs,
> nr_vcpus, nr_vcpus_created);
>
> /* Distributor setup */
> - gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false);
> + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, true);
> + if (gic_fd == -1)
> + return -1;
>
> kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
> 0, &nr_irqs, true);
> --
> 2.30.2
>
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Reviewed-by: Ricardo Koller <ricarkol@google.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-01-26 1:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 19:28 [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 Mark Brown
2022-01-25 19:28 ` Mark Brown
2022-01-25 19:28 ` Mark Brown
2022-01-25 19:48 ` Shuah Khan
2022-01-25 19:48 ` Shuah Khan
2022-01-25 19:48 ` Shuah Khan
2022-01-26 1:23 ` Ricardo Koller [this message]
2022-01-26 1:23 ` Ricardo Koller
2022-01-26 1:23 ` Ricardo Koller
2022-01-26 9:07 ` Marc Zyngier
2022-01-26 9:07 ` Marc Zyngier
2022-01-26 9:07 ` Marc Zyngier
2022-01-26 12:52 ` Mark Brown
2022-01-26 12:52 ` Mark Brown
2022-01-26 12:52 ` Mark Brown
2022-01-26 13:05 ` Marc Zyngier
2022-01-26 13:05 ` Marc Zyngier
2022-01-26 13:05 ` Marc Zyngier
2022-01-26 13:21 ` Mark Brown
2022-01-26 13:21 ` Mark Brown
2022-01-26 13:21 ` Mark Brown
2022-01-26 13:32 ` Marc Zyngier
2022-01-26 13:32 ` Marc Zyngier
2022-01-26 13:32 ` Marc Zyngier
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=YfCidIboLDMb/Hy3@google.com \
--to=ricarkol@google.com \
--cc=broonie@kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maz@kernel.org \
--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.