* [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 14:52 ` Mark Brown
0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 14:52 UTC (permalink / raw)
To: Marc Zyngier, Shuah Khan
Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, kvmarm,
linux-kselftest, linux-arm-kernel, Mark Brown
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>
---
v3:
- Use custom print_skip() helper.
- Use internal version of _kvm_create_device.
v2:
- The test for being able to create the GIC doesn't actually
instantiate it, add a call doing so in that case.
tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
3 files changed, 13 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..b08d30bf71c5 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) {
+ print_skip("Failed to create vgic-v3");
+ 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..7eca97799917 100644
--- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
+++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
@@ -761,6 +761,10 @@ 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) {
+ print_skip("Failed to create vgic-v3, skipping");
+ 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..f5cd0c536d85 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);
+ if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
+ false, &gic_fd) != 0)
+ return -1;
kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
0, &nr_irqs, true);
--
2.30.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 14:52 ` Mark Brown
0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 14:52 UTC (permalink / raw)
To: Marc Zyngier, Shuah Khan
Cc: Mark Brown, linux-kselftest, kvmarm, linux-arm-kernel
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>
---
v3:
- Use custom print_skip() helper.
- Use internal version of _kvm_create_device.
v2:
- The test for being able to create the GIC doesn't actually
instantiate it, add a call doing so in that case.
tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
3 files changed, 13 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..b08d30bf71c5 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) {
+ print_skip("Failed to create vgic-v3");
+ 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..7eca97799917 100644
--- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
+++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
@@ -761,6 +761,10 @@ 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) {
+ print_skip("Failed to create vgic-v3, skipping");
+ 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..f5cd0c536d85 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);
+ if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
+ false, &gic_fd) != 0)
+ 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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 14:52 ` Mark Brown
0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 14:52 UTC (permalink / raw)
To: Marc Zyngier, Shuah Khan
Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, kvmarm,
linux-kselftest, linux-arm-kernel, Mark Brown
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>
---
v3:
- Use custom print_skip() helper.
- Use internal version of _kvm_create_device.
v2:
- The test for being able to create the GIC doesn't actually
instantiate it, add a call doing so in that case.
tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
3 files changed, 13 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..b08d30bf71c5 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) {
+ print_skip("Failed to create vgic-v3");
+ 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..7eca97799917 100644
--- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
+++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
@@ -761,6 +761,10 @@ 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) {
+ print_skip("Failed to create vgic-v3, skipping");
+ 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..f5cd0c536d85 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);
+ if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
+ false, &gic_fd) != 0)
+ return -1;
kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
0, &nr_irqs, true);
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
2022-01-26 14:52 ` Mark Brown
(?)
@ 2022-01-26 15:12 ` Andrew Jones
-1 siblings, 0 replies; 24+ messages in thread
From: Andrew Jones @ 2022-01-26 15:12 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, linux-kselftest, kvmarm, linux-arm-kernel
On Wed, Jan 26, 2022 at 02:52:42PM +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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 insertions(+), 2 deletions(-)
>
Reviewed-by: Andrew Jones <drjones@redhat.com>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 15:12 ` Andrew Jones
0 siblings, 0 replies; 24+ messages in thread
From: Andrew Jones @ 2022-01-26 15:12 UTC (permalink / raw)
To: Mark Brown
Cc: linux-arm-kernel, Marc Zyngier, Shuah Khan, kvmarm, linux-kselftest
On Wed, Jan 26, 2022 at 02:52:42PM +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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 insertions(+), 2 deletions(-)
>
Reviewed-by: Andrew Jones <drjones@redhat.com>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 15:12 ` Andrew Jones
0 siblings, 0 replies; 24+ messages in thread
From: Andrew Jones @ 2022-01-26 15:12 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, linux-kselftest, kvmarm, linux-arm-kernel
On Wed, Jan 26, 2022 at 02:52:42PM +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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 insertions(+), 2 deletions(-)
>
Reviewed-by: Andrew Jones <drjones@redhat.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
2022-01-26 14:52 ` Mark Brown
(?)
@ 2022-01-26 19:22 ` Shuah Khan
-1 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 19:22 UTC (permalink / raw)
To: Mark Brown, Marc Zyngier, Shuah Khan
Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, kvmarm,
linux-kselftest, linux-arm-kernel, Shuah Khan
On 1/26/22 7:52 AM, 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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 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..b08d30bf71c5 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) {
> + print_skip("Failed to create vgic-v3");
Printing the negative error code returned by vgic_v3_setup will be useful.
> + 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..7eca97799917 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,10 @@ 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) {
> + print_skip("Failed to create vgic-v3, skipping");
Same here.
> + 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..f5cd0c536d85 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);
> + if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
> + false, &gic_fd) != 0)
> + return -1;
>
> kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
> 0, &nr_irqs, true);
>
With these fixed:
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 19:22 ` Shuah Khan
0 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 19:22 UTC (permalink / raw)
To: Mark Brown, Marc Zyngier, Shuah Khan
Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, kvmarm,
linux-kselftest, linux-arm-kernel, Shuah Khan
On 1/26/22 7:52 AM, 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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 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..b08d30bf71c5 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) {
> + print_skip("Failed to create vgic-v3");
Printing the negative error code returned by vgic_v3_setup will be useful.
> + 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..7eca97799917 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,10 @@ 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) {
> + print_skip("Failed to create vgic-v3, skipping");
Same here.
> + 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..f5cd0c536d85 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);
> + if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
> + false, &gic_fd) != 0)
> + return -1;
>
> kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
> 0, &nr_irqs, true);
>
With these fixed:
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 19:22 ` Shuah Khan
0 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 19:22 UTC (permalink / raw)
To: Mark Brown, Marc Zyngier, Shuah Khan
Cc: linux-kselftest, Shuah Khan, kvmarm, linux-arm-kernel
On 1/26/22 7:52 AM, 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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 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..b08d30bf71c5 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) {
> + print_skip("Failed to create vgic-v3");
Printing the negative error code returned by vgic_v3_setup will be useful.
> + 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..7eca97799917 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,10 @@ 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) {
> + print_skip("Failed to create vgic-v3, skipping");
Same here.
> + 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..f5cd0c536d85 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);
> + if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
> + false, &gic_fd) != 0)
> + return -1;
>
> kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
> 0, &nr_irqs, true);
>
With these fixed:
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
2022-01-26 19:22 ` Shuah Khan
(?)
@ 2022-01-26 19:52 ` Mark Brown
-1 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 19:52 UTC (permalink / raw)
To: Shuah Khan
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 439 bytes --]
On Wed, Jan 26, 2022 at 12:22:41PM -0700, Shuah Khan wrote:
> On 1/26/22 7:52 AM, Mark Brown wrote:
> > + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> > + if (ret < 0) {
> > + print_skip("Failed to create vgic-v3");
> Printing the negative error code returned by vgic_v3_setup will be useful.
If the function fails for any reason other than the system not
supporting vgic-v3 it will abort rather than return.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 19:52 ` Mark Brown
0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 19:52 UTC (permalink / raw)
To: Shuah Khan
Cc: Marc Zyngier, linux-kselftest, Shuah Khan, kvmarm, linux-arm-kernel
[-- Attachment #1.1: Type: text/plain, Size: 439 bytes --]
On Wed, Jan 26, 2022 at 12:22:41PM -0700, Shuah Khan wrote:
> On 1/26/22 7:52 AM, Mark Brown wrote:
> > + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> > + if (ret < 0) {
> > + print_skip("Failed to create vgic-v3");
> Printing the negative error code returned by vgic_v3_setup will be useful.
If the function fails for any reason other than the system not
supporting vgic-v3 it will abort rather than return.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 151 bytes --]
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 19:52 ` Mark Brown
0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 19:52 UTC (permalink / raw)
To: Shuah Khan
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel
[-- Attachment #1.1: Type: text/plain, Size: 439 bytes --]
On Wed, Jan 26, 2022 at 12:22:41PM -0700, Shuah Khan wrote:
> On 1/26/22 7:52 AM, Mark Brown wrote:
> > + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
> > + if (ret < 0) {
> > + print_skip("Failed to create vgic-v3");
> Printing the negative error code returned by vgic_v3_setup will be useful.
If the function fails for any reason other than the system not
supporting vgic-v3 it will abort rather than return.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
2022-01-26 19:52 ` Mark Brown
(?)
@ 2022-01-26 20:03 ` Shuah Khan
-1 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 20:03 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel,
Shuah Khan
On 1/26/22 12:52 PM, Mark Brown wrote:
> On Wed, Jan 26, 2022 at 12:22:41PM -0700, Shuah Khan wrote:
>> On 1/26/22 7:52 AM, Mark Brown wrote:
>
>>> + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
>>> + if (ret < 0) {
>>> + print_skip("Failed to create vgic-v3");
>
>> Printing the negative error code returned by vgic_v3_setup will be useful.
>
> If the function fails for any reason other than the system not
> supporting vgic-v3 it will abort rather than return.
>
Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
Return: GIC file-descriptor or negative error code upon failure
I don't follow the abort part.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 20:03 ` Shuah Khan
0 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 20:03 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel,
Shuah Khan
On 1/26/22 12:52 PM, Mark Brown wrote:
> On Wed, Jan 26, 2022 at 12:22:41PM -0700, Shuah Khan wrote:
>> On 1/26/22 7:52 AM, Mark Brown wrote:
>
>>> + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
>>> + if (ret < 0) {
>>> + print_skip("Failed to create vgic-v3");
>
>> Printing the negative error code returned by vgic_v3_setup will be useful.
>
> If the function fails for any reason other than the system not
> supporting vgic-v3 it will abort rather than return.
>
Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
Return: GIC file-descriptor or negative error code upon failure
I don't follow the abort part.
thanks,
-- Shuah
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 20:03 ` Shuah Khan
0 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 20:03 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, linux-kselftest, Shuah Khan, Shuah Khan, kvmarm,
linux-arm-kernel
On 1/26/22 12:52 PM, Mark Brown wrote:
> On Wed, Jan 26, 2022 at 12:22:41PM -0700, Shuah Khan wrote:
>> On 1/26/22 7:52 AM, Mark Brown wrote:
>
>>> + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
>>> + if (ret < 0) {
>>> + print_skip("Failed to create vgic-v3");
>
>> Printing the negative error code returned by vgic_v3_setup will be useful.
>
> If the function fails for any reason other than the system not
> supporting vgic-v3 it will abort rather than return.
>
Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
Return: GIC file-descriptor or negative error code upon failure
I don't follow the abort part.
thanks,
-- Shuah
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
2022-01-26 20:03 ` Shuah Khan
(?)
@ 2022-01-26 20:13 ` Mark Brown
-1 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 20:13 UTC (permalink / raw)
To: Shuah Khan
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 768 bytes --]
On Wed, Jan 26, 2022 at 01:03:44PM -0700, Shuah Khan wrote:
> On 1/26/22 12:52 PM, Mark Brown wrote:
> > If the function fails for any reason other than the system not
> > supporting vgic-v3 it will abort rather than return.
> Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
> Return: GIC file-descriptor or negative error code upon failure
Yes, but in reality the only return other than a valid file descriptor
is just -1 rather than a useful error code.
> I don't follow the abort part.
All the TEST_ASSERTS() in the code (including those in the functions
called) are calls to test_assert() in assert.c which if the test
asserted isn't true will print some diagnostics and call exit(), the
general idiom is to give up immediately on error.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 20:13 ` Mark Brown
0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 20:13 UTC (permalink / raw)
To: Shuah Khan
Cc: Marc Zyngier, linux-kselftest, Shuah Khan, kvmarm, linux-arm-kernel
[-- Attachment #1.1: Type: text/plain, Size: 768 bytes --]
On Wed, Jan 26, 2022 at 01:03:44PM -0700, Shuah Khan wrote:
> On 1/26/22 12:52 PM, Mark Brown wrote:
> > If the function fails for any reason other than the system not
> > supporting vgic-v3 it will abort rather than return.
> Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
> Return: GIC file-descriptor or negative error code upon failure
Yes, but in reality the only return other than a valid file descriptor
is just -1 rather than a useful error code.
> I don't follow the abort part.
All the TEST_ASSERTS() in the code (including those in the functions
called) are calls to test_assert() in assert.c which if the test
asserted isn't true will print some diagnostics and call exit(), the
general idiom is to give up immediately on error.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 151 bytes --]
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 20:13 ` Mark Brown
0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2022-01-26 20:13 UTC (permalink / raw)
To: Shuah Khan
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel
[-- Attachment #1.1: Type: text/plain, Size: 768 bytes --]
On Wed, Jan 26, 2022 at 01:03:44PM -0700, Shuah Khan wrote:
> On 1/26/22 12:52 PM, Mark Brown wrote:
> > If the function fails for any reason other than the system not
> > supporting vgic-v3 it will abort rather than return.
> Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
> Return: GIC file-descriptor or negative error code upon failure
Yes, but in reality the only return other than a valid file descriptor
is just -1 rather than a useful error code.
> I don't follow the abort part.
All the TEST_ASSERTS() in the code (including those in the functions
called) are calls to test_assert() in assert.c which if the test
asserted isn't true will print some diagnostics and call exit(), the
general idiom is to give up immediately on error.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
2022-01-26 20:13 ` Mark Brown
(?)
@ 2022-01-26 20:50 ` Shuah Khan
-1 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 20:50 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel,
Shuah Khan
On 1/26/22 1:13 PM, Mark Brown wrote:
> On Wed, Jan 26, 2022 at 01:03:44PM -0700, Shuah Khan wrote:
>> On 1/26/22 12:52 PM, Mark Brown wrote:
>
>>> If the function fails for any reason other than the system not
>>> supporting vgic-v3 it will abort rather than return.
>
>> Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
>> Return: GIC file-descriptor or negative error code upon failure
>
> Yes, but in reality the only return other than a valid file descriptor
> is just -1 rather than a useful error code.
>
The interface document gives the impression that it will return
error - Oh well. In which case, no point in printing that. Agree.
>> I don't follow the abort part.
>
> All the TEST_ASSERTS() in the code (including those in the functions
> called) are calls to test_assert() in assert.c which if the test
> asserted isn't true will print some diagnostics and call exit(), the
> general idiom is to give up immediately on error.
>
Ah right. Makes sense.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 20:50 ` Shuah Khan
0 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 20:50 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, James Morse, Alexandru Elisei,
Suzuki K Poulose, kvmarm, linux-kselftest, linux-arm-kernel,
Shuah Khan
On 1/26/22 1:13 PM, Mark Brown wrote:
> On Wed, Jan 26, 2022 at 01:03:44PM -0700, Shuah Khan wrote:
>> On 1/26/22 12:52 PM, Mark Brown wrote:
>
>>> If the function fails for any reason other than the system not
>>> supporting vgic-v3 it will abort rather than return.
>
>> Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
>> Return: GIC file-descriptor or negative error code upon failure
>
> Yes, but in reality the only return other than a valid file descriptor
> is just -1 rather than a useful error code.
>
The interface document gives the impression that it will return
error - Oh well. In which case, no point in printing that. Agree.
>> I don't follow the abort part.
>
> All the TEST_ASSERTS() in the code (including those in the functions
> called) are calls to test_assert() in assert.c which if the test
> asserted isn't true will print some diagnostics and call exit(), the
> general idiom is to give up immediately on error.
>
Ah right. Makes sense.
thanks,
-- Shuah
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-26 20:50 ` Shuah Khan
0 siblings, 0 replies; 24+ messages in thread
From: Shuah Khan @ 2022-01-26 20:50 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, linux-kselftest, Shuah Khan, Shuah Khan, kvmarm,
linux-arm-kernel
On 1/26/22 1:13 PM, Mark Brown wrote:
> On Wed, Jan 26, 2022 at 01:03:44PM -0700, Shuah Khan wrote:
>> On 1/26/22 12:52 PM, Mark Brown wrote:
>
>>> If the function fails for any reason other than the system not
>>> supporting vgic-v3 it will abort rather than return.
>
>> Hmm. vgic_v3_setup() return gic_fd looks like and the interface says
>> Return: GIC file-descriptor or negative error code upon failure
>
> Yes, but in reality the only return other than a valid file descriptor
> is just -1 rather than a useful error code.
>
The interface document gives the impression that it will return
error - Oh well. In which case, no point in printing that. Agree.
>> I don't follow the abort part.
>
> All the TEST_ASSERTS() in the code (including those in the functions
> called) are calls to test_assert() in assert.c which if the test
> asserted isn't true will print some diagnostics and call exit(), the
> general idiom is to give up immediately on error.
>
Ah right. Makes sense.
thanks,
-- Shuah
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
2022-01-26 14:52 ` Mark Brown
(?)
@ 2022-01-27 4:16 ` Ricardo Koller
-1 siblings, 0 replies; 24+ messages in thread
From: Ricardo Koller @ 2022-01-27 4:16 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, linux-kselftest, kvmarm, linux-arm-kernel
On Wed, Jan 26, 2022 at 02:52:42PM +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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 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..b08d30bf71c5 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) {
> + print_skip("Failed to create vgic-v3");
> + 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..7eca97799917 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,10 @@ 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) {
> + print_skip("Failed to create vgic-v3, skipping");
> + 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..f5cd0c536d85 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);
> + if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
> + false, &gic_fd) != 0)
> + 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
Tried both gicv2 and v3 and the change works as expected.
Tested-by: Ricardo Koller <ricarkol@google.com>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-27 4:16 ` Ricardo Koller
0 siblings, 0 replies; 24+ messages in thread
From: Ricardo Koller @ 2022-01-27 4:16 UTC (permalink / raw)
To: Mark Brown
Cc: linux-arm-kernel, Marc Zyngier, Shuah Khan, kvmarm, linux-kselftest
On Wed, Jan 26, 2022 at 02:52:42PM +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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 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..b08d30bf71c5 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) {
> + print_skip("Failed to create vgic-v3");
> + 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..7eca97799917 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,10 @@ 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) {
> + print_skip("Failed to create vgic-v3, skipping");
> + 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..f5cd0c536d85 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);
> + if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
> + false, &gic_fd) != 0)
> + 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
Tried both gicv2 and v3 and the change works as expected.
Tested-by: Ricardo Koller <ricarkol@google.com>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3
@ 2022-01-27 4:16 ` Ricardo Koller
0 siblings, 0 replies; 24+ messages in thread
From: Ricardo Koller @ 2022-01-27 4:16 UTC (permalink / raw)
To: Mark Brown
Cc: Marc Zyngier, Shuah Khan, linux-kselftest, kvmarm, linux-arm-kernel
On Wed, Jan 26, 2022 at 02:52:42PM +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>
> ---
>
> v3:
> - Use custom print_skip() helper.
> - Use internal version of _kvm_create_device.
> v2:
> - The test for being able to create the GIC doesn't actually
> instantiate it, add a call doing so in that case.
>
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
> tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
> tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
> 3 files changed, 13 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..b08d30bf71c5 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) {
> + print_skip("Failed to create vgic-v3");
> + 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..7eca97799917 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
> @@ -761,6 +761,10 @@ 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) {
> + print_skip("Failed to create vgic-v3, skipping");
> + 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..f5cd0c536d85 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);
> + if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
> + false, &gic_fd) != 0)
> + 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
Tried both gicv2 and v3 and the change works as expected.
Tested-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
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2022-01-27 15:52 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 14:52 [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 Mark Brown
2022-01-26 14:52 ` Mark Brown
2022-01-26 14:52 ` Mark Brown
2022-01-26 15:12 ` Andrew Jones
2022-01-26 15:12 ` Andrew Jones
2022-01-26 15:12 ` Andrew Jones
2022-01-26 19:22 ` Shuah Khan
2022-01-26 19:22 ` Shuah Khan
2022-01-26 19:22 ` Shuah Khan
2022-01-26 19:52 ` Mark Brown
2022-01-26 19:52 ` Mark Brown
2022-01-26 19:52 ` Mark Brown
2022-01-26 20:03 ` Shuah Khan
2022-01-26 20:03 ` Shuah Khan
2022-01-26 20:03 ` Shuah Khan
2022-01-26 20:13 ` Mark Brown
2022-01-26 20:13 ` Mark Brown
2022-01-26 20:13 ` Mark Brown
2022-01-26 20:50 ` Shuah Khan
2022-01-26 20:50 ` Shuah Khan
2022-01-26 20:50 ` Shuah Khan
2022-01-27 4:16 ` Ricardo Koller
2022-01-27 4:16 ` Ricardo Koller
2022-01-27 4:16 ` Ricardo Koller
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.