diff mbox series

[v2,4/6] selftests: kvm: s390: Add ucontrol gis routing test

Message ID 20241216092140.329196-5-schlameuss@linux.ibm.com (mailing list archive)
State New
Headers show
Series selftests: kvm: s390: Reject invalid ioctls on ucontrol VMs | expand

Commit Message

Christoph Schlameuss Dec. 16, 2024, 9:21 a.m. UTC
Add a selftests for the interrupt routing configuration when using
ucontrol VMs.

Calling the test may trigger a null pointer dereferences on kernels not
containing the fixes in this patch series.

Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
---
 .../selftests/kvm/s390x/ucontrol_test.c       | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Hariharan Mari Dec. 18, 2024, 3:08 p.m. UTC | #1
On 2024-12-16 10:21, Christoph Schlameuss wrote:
> Add a selftests for the interrupt routing configuration when using
> ucontrol VMs.
> 
> Calling the test may trigger a null pointer dereferences on kernels not
> containing the fixes in this patch series.
> 
> Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>

Tested-by: Hariharan Mari <hari55@linux.ibm.com>
> ---
>  .../selftests/kvm/s390x/ucontrol_test.c       | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> b/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> index b003abda8495..8f306395696e 100644
> --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> @@ -783,4 +783,23 @@ TEST_F(uc_kvm, uc_flic_attrs)
>  	close(cd.fd);
>  }
> 
> +TEST_F(uc_kvm, uc_set_gsi_routing)
> +{
> +	struct kvm_irq_routing *routing = kvm_gsi_routing_create();
> +	struct kvm_irq_routing_entry ue = {
> +		.type = KVM_IRQ_ROUTING_S390_ADAPTER,
> +		.gsi = 1,
> +		.u.adapter = (struct kvm_irq_routing_s390_adapter) {
> +			.ind_addr = 0,
> +		},
> +	};
> +	int rc;
> +
> +	routing->entries[0] = ue;
> +	routing->nr = 1;
> +	rc = ioctl(self->vm_fd, KVM_SET_GSI_ROUTING, routing);
> +	ASSERT_EQ(-1, rc) TH_LOG("err %s (%i)", strerror(errno), errno);
> +	ASSERT_EQ(EINVAL, errno) TH_LOG("err %s (%i)", strerror(errno), 
> errno);
> +}
> +
>  TEST_HARNESS_MAIN
Hariharan Mari Dec. 19, 2024, 3:54 p.m. UTC | #2
On 2024-12-16 10:21, Christoph Schlameuss wrote:
> Add a selftests for the interrupt routing configuration when using
> ucontrol VMs.
> 
> Calling the test may trigger a null pointer dereferences on kernels not
> containing the fixes in this patch series.
> 
> Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>

Reviewed-by: Hariharan Mari <hari55@linux.ibm.com>
> ---
>  .../selftests/kvm/s390x/ucontrol_test.c       | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> b/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> index b003abda8495..8f306395696e 100644
> --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c
> @@ -783,4 +783,23 @@ TEST_F(uc_kvm, uc_flic_attrs)
>  	close(cd.fd);
>  }
> 
> +TEST_F(uc_kvm, uc_set_gsi_routing)
> +{
> +	struct kvm_irq_routing *routing = kvm_gsi_routing_create();
> +	struct kvm_irq_routing_entry ue = {
> +		.type = KVM_IRQ_ROUTING_S390_ADAPTER,
> +		.gsi = 1,
> +		.u.adapter = (struct kvm_irq_routing_s390_adapter) {
> +			.ind_addr = 0,
> +		},
> +	};
> +	int rc;
> +
> +	routing->entries[0] = ue;
> +	routing->nr = 1;
> +	rc = ioctl(self->vm_fd, KVM_SET_GSI_ROUTING, routing);
> +	ASSERT_EQ(-1, rc) TH_LOG("err %s (%i)", strerror(errno), errno);
> +	ASSERT_EQ(EINVAL, errno) TH_LOG("err %s (%i)", strerror(errno), 
> errno);
> +}
> +
>  TEST_HARNESS_MAIN
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c
index b003abda8495..8f306395696e 100644
--- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c
+++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c
@@ -783,4 +783,23 @@  TEST_F(uc_kvm, uc_flic_attrs)
 	close(cd.fd);
 }
 
+TEST_F(uc_kvm, uc_set_gsi_routing)
+{
+	struct kvm_irq_routing *routing = kvm_gsi_routing_create();
+	struct kvm_irq_routing_entry ue = {
+		.type = KVM_IRQ_ROUTING_S390_ADAPTER,
+		.gsi = 1,
+		.u.adapter = (struct kvm_irq_routing_s390_adapter) {
+			.ind_addr = 0,
+		},
+	};
+	int rc;
+
+	routing->entries[0] = ue;
+	routing->nr = 1;
+	rc = ioctl(self->vm_fd, KVM_SET_GSI_ROUTING, routing);
+	ASSERT_EQ(-1, rc) TH_LOG("err %s (%i)", strerror(errno), errno);
+	ASSERT_EQ(EINVAL, errno) TH_LOG("err %s (%i)", strerror(errno), errno);
+}
+
 TEST_HARNESS_MAIN