[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH] xen/arm: Introduce GICV3 Self Tests


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Fri, 12 Sep 2025 18:00:55 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=27DHt0J20Pg2g97L+tvBsc3Z3ZrT3sGO/+bEzgDSuu0=; b=BXCMxPegprTnkbJbnijbQuUQLElrFdI+7vyzjCqgbq4AjDu5cv0H6duG0tGDs9x+F3sg8sJwwpAVHTPw7Kz/cjJ8p7R3QTQuD95LhHF2wT59quT7PJk8QZirc2zPjuTL4DbmVY+9bL6TJ9wcfHhEr7AyKYYxWCnpfR2x5emHrKwqNjrJxzSM4trL2uhUs41Vfz2VPREHGjMDpyAY7AyZTjYoFkcbw0ishHpqkqDtQOhaE6YoNMObxjl2l6gDKuiYM9LydDJv0rW5WspoDAJ+4rQ61utP++6xcohXT3gmzbs0Mp6QuhOPAxp7+J4FySU03/m4xMlflx8Md31zBZQHJg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=czQP1mDVyw//DwTw0gsdKPcX/M8VueT06XAsl58hWm/ccwnNczArLR9fIhE+AI/HoZ4hls/q5Rzz2TfGfXR+8NZ6G/mRAhu8HElatXMQORPw7emA5USN7pmeJNsYU1KtkNjI/4ye4nBwFkso/fljeRYo3t/8usuSEsZiWbbEKh8FqZ94N9d2LUwqRtClU6RvL4HXTra4Mnh9KO+I4G+VDysIhDYLSlsVgHVIp2jKOEmfdA6c4poomALbfjqCqvS1sJHlwhglchXvnKeeC0h06VvvyDFCtuwjwTa/YoFmK03ePoctIO9q2KVyrcdVS2o9Skwtb5vo/TKrEhQocxiBow==
  • Cc: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 12 Sep 2025 17:01:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce CONFIG_GICV3_SELFTEST to enclose tests for GICv3 driver.
Test that Xen is able to generate SGIs.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
One of the aim of functional safety is to test hw/sw interface. This means that
Xen is able to configure the hardware correctly for the desired functionalities.

Normally this is tested from the VMs. For eg if a VM is able to receive irq, 
this
implies that Xen has configured the GICv3 interface 'correctly'. However this is
a high level (or integration) test which uses not only the GICv3 interface
between Xen and VM, but the interrupt injection code for Xen to VMs.

We want to have some kind of unit tests to check that Xen is able to receive
various interrupts, set priorities, etc. Here, we have written unit tests for
software generated interrupts (SGIs) as example.

These tests are expected to be triggered as Xen boots (right after Xen has
initialised the GICv3 interface ie gicv3_init(). The aim of this test is to
check whether Xen can trigger SGIs after gicv3_init() is invoked. If so, we can
claim that gicv3_init() was done properly to be able to trigger SGIs. Likewise
we will have tests to check for priorities, SPIs, etc.

A script will parse the logs and claim that Xen is able to trigger SGIs.

 xen/arch/arm/Kconfig  |  8 ++++++++
 xen/arch/arm/gic-v3.c |  7 +++++++
 xen/arch/arm/gic.c    | 21 +++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 950e4452c1..739f99eaa9 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -73,6 +73,14 @@ config GICV3
          Driver for the ARM Generic Interrupt Controller v3.
          If unsure, use the default setting.
 
+config GICV3_SELFTEST
+    bool "GICv3 driver self test"
+    default n
+    depends on GICV3
+    ---help---
+
+      Self tests to validate GICV3 driver.
+
 config HAS_ITS
         bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED
         depends on GICV3 && !NEW_VGIC && !ARM_32
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 4e6c98bada..eb0c05231c 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1818,6 +1818,13 @@ static int __init gicv3_init(void)
 
     gicv3_hyp_init();
 
+#ifdef CONFIG_GICV3_SELFTEST
+    send_SGI_self(GIC_SGI_EVENT_CHECK);
+    send_SGI_self(GIC_SGI_DUMP_STATE);
+    send_SGI_self(GIC_SGI_CALL_FUNCTION);
+    send_SGI_self(GIC_SGI_MAX);
+#endif
+
 out:
     spin_unlock(&gicv3.lock);
 
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index d922ea67aa..5cb58cdb92 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -346,6 +346,26 @@ static void do_sgi(struct cpu_user_regs *regs, enum 
gic_sgi sgi)
      */
     smp_rmb();
 
+#ifdef CONFIG_GICV3_SELFTEST
+    switch (sgi)
+    {
+    case GIC_SGI_EVENT_CHECK:
+        printk("GIC_SGI_EVENT_CHECK received\n");
+        break;
+    case GIC_SGI_DUMP_STATE:
+        printk("GIC_SGI_DUMP_STATE received\n");
+        break;
+    case GIC_SGI_CALL_FUNCTION:
+        printk("GIC_SGI_CALL_FUNCTION received\n");
+        break;
+    case GIC_SGI_MAX:
+        printk("GIC_SGI_MAX received\n");
+        break;
+    default:
+        panic("Unknown SGI triggered\n");
+        break;
+    }
+#else
     switch (sgi)
     {
     case GIC_SGI_EVENT_CHECK:
@@ -361,6 +381,7 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi 
sgi)
         panic("Unhandled SGI %d on CPU%d\n", sgi, smp_processor_id());
         break;
     }
+#endif
 
     /* Deactivate */
     gic_hw_ops->deactivate_irq(desc);
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.