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

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


  • To: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Mon, 22 Sep 2025 17:55:33 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=epam.com 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=k+HtFtnHizkVwm3iHtIBny6Q4Lf+QYAEmQX1AOlj1jE=; b=hmo1Q3Ax+s0vrQLLTUxc2BDJ/1byBSiejORl9O3JVLpiYlVSGjFKjEaNJsgzuwC9JaAcDaOWJLlsw0+IM+0N/DPEW+z/itNV2ze4jM4olnZsG2M7v4szQ6CesHoAV2JQZZ8CzAMZtrL0nK+1S4jtQ0gJyFelpkqa+1srqt4L/Etb5j0N2gDvwFqiBBXMctFT3rcoEh/ufUql2KMZRCxn+U7LynVhb8Cv4FMx59jF3VTrHz7fZHl7uNom5yatB/WIQzlMBlmPU38ROLWDaYusAomX5+g9BWfu1V+d9jrATF0ODNCrphBurlHLAE+itN+tE/Hry2B2xD/NKp9InKC+BA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AONnWHxOaGCryV3CkYDXCKXjRiqerQvkqDFdBzF4YjrCSpd3A1XvmPZOsTDbWB4A7X4oM8q4YdTiOUl/Qy5QaoLbafyDoA8NDjZkcG72bFxcu6GnSXuUqA7xQYUjEoHyrMgOOnq/uerUcR4MZAgXXxS54N8lsz+DggTx6sm3ye6biCc53eq1G+oA2309OX7iBXo9eHYkJ/C8Tgs/lSdr7V5ylCtG299I8ijC8Yljz5sUF4QQ/SxDo/D4mKlgjWODoNftGZOiFDbpkR5xize+mM00ebQaO9g2/dQ6VVHjGnLNE0sW5mekCpDsJ91TYLJz56OE8wtaB3vWhpRMGdI2RQ==
  • Cc: 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: Mon, 22 Sep 2025 16:55:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 16/09/2025 11:55, Grygorii Strashko wrote:
Hi Ayan,
Hi Grygorii,

On 12.09.25 20:00, Ayan Kumar Halder wrote:
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
+

I'd like to ask, if possible, to minimize mixing selftest and functional code.
Like add gic-v3-selftest.c.

I can try that. However, the self test needs to be invoked from functional code.

Also, your suggestion gave me an idea. I can do :-

+static bool __initdata opt_gicv3_selftest = false;
+
+#ifdef CONFIG_GICV3_SELFTEST
+opt_gicv3_selftest = true;
+#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

if (gic_selftest_run)
And then instead of ifdef, I can enclose the below under "if (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");

       gic_selftest_done = true;

+        break;
+    default:
+        panic("Unknown SGI triggered\n");
+        break;
+    }

Potentially GIC selftest code can be guarded by some "gic_selftest_run/done" vars
if xen boot is expected to proceed further after testing.

Ah no, Xen will terminate after running the self test.

- Ayan




 


Rackspace

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