xen/arm: Introduce GICV3 Self Tests
RFC PATCH 1/1 xen/arm: Introduce GICV3 Self Tests
Introduce CONFIG_GICV3_SELFTEST to enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.
---
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(+)
xen/arch/arm/Kconfig +8 -0
@@ -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
xen/arch/arm/gic-v3.c +7 -0
@@ -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);
xen/arch/arm/gic.c +21 -0
@@ -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);
Signature · 1 line
2.25.1
Hi Ayan,
Quoted 13 lines · Ayan Kumar Halder
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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.
Quoted 8 lines
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_init()was done properly to be able to trigger SGIs.
To clarify, this only guarantees that the boot CPU can send SGIs to self. Secondary CPUs are brought up later and will need their own setup to enable SGIs.
Quoted 34 lines
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(+)xen/arch/arm/Kconfig +8
-0@@ -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_32xen/arch/arm/gic-v3.c +0
-0
xen/arch/arm/gic-v3.c static int __init gicv3_init(void) · line 1826
Quoted 9 lines
xen/arch/arm/gic-v3.c +6
-0@@ -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
Looking a the code below, it seems like Xen will not be functional after running the selftests? Is this intended? If so, we need to stop Xen as soon as possible.
Also, looking at start_xen(), we call local_irq_enable() a little after gicv3_init() is called. So I am a little bit surprised this is working?
Cheers,
Signature · 1 line
Julien Grall
Quoted 1 line · Julien Grall
Hi Ayan,
Hi Julien,
Quoted 19 lines · Ayan Kumar Halder
Quoted 17 lines
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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.
Quoted 6 lines
Quoted 4 lines
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_init()was done properly to be able to trigger SGIs.To clarify, this only guarantees that the boot CPU can send SGIs to self.
Yes, this is the idea.
Quoted 1 line
Secondary CPUs are brought up later and will need their own setup to enable SGIs.
Yes, we will have separate tests for them.
Quoted 35 lines
Quoted 35 lines
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(+)xen/arch/arm/Kconfig +0
-0@@ -73,6 +73,14 @@ config GICV3Driver 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---xen/arch/arm/Kconfig +3
-0+ + Self tests to validate GICV3 driver. +config
HAS_ITS
bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED depends on GICV3 && !NEW_VGIC && !ARM_32xen/arch/arm/gic-v3.c +0
-0@@ -1818,6 +1818,13 @@ static int __init gicv3_init(void) gicv3_hyp_init();
Quoted 8 lines
Quoted 6 lines
+#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);
+#endifLooking a the code below, it seems like Xen will not be functional after running the selftests? Is this intended? If so, we need to stop Xen as soon as possible.
Tbh, I didnot realize this with the current test. However you are correct that for some of these tests, Xen will not be usable. We can put a while(1) after it completes the tests.
Or, I can invoke machine_halt() .
The important bit here is CONFIG_GICV3_SELFTEST cannot be enabled for normal usage of Xen. IOW, user should not expect Xen to run domains when this configuration is enabled.
They are used to run baremetal tests.
Quoted 2 lines
Also, looking at
start_xen(), we calllocal_irq_enable()a little aftergicv3_init()is called. So I am a little bit surprised this is working?
This is working i.e. we are getting interrupts. However, I can put the test after local_irq_enable() as Xen is expected to terminate after running the tests.
- Ayan
Quoted 3 lines
Cheers,
Hi Ayan,
Quoted 76 lines · Ayan Kumar Halder
Quoted 1 line · Julien Grall
Hi Ayan,
Hi Julien,
Quoted 19 lines · Ayan Kumar Halder
Quoted 17 lines
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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.
Quoted 6 lines
Quoted 4 lines
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_init()was done properly to be able to trigger SGIs.To clarify, this only guarantees that the boot CPU can send SGIs to self.
Yes, this is the idea.
Quoted 1 line
Secondary CPUs are brought up later and will need their own setup to enable SGIs.
Yes, we will have separate tests for them.
Quoted 35 lines
Quoted 35 lines
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(+)xen/arch/arm/Kconfig +0
-0@@ -73,6 +73,14 @@ config GICV3Driver 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---xen/arch/arm/Kconfig +3
-0+ + Self tests to validate GICV3 driver. +config
HAS_ITS
bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED depends on GICV3 && !NEW_VGIC && !ARM_32xen/arch/arm/gic-v3.c +0
-0@@ -1818,6 +1818,13 @@ static int __init gicv3_init(void) gicv3_hyp_init();Quoted 8 lines
Quoted 6 lines
+#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);
+#endifLooking a the code below, it seems like Xen will not be functional after running the selftests? Is this intended? If so, we need to stop Xen as soon as possible.
Quoted 3 lines
Tbh, I didnot realize this with the current test. However you are correct that for some of these tests, Xen will not be usable. We can put a while(1) after it completes the tests.
Or, I can invoke
machine_halt().
I think it would be better to use machine_halt(). This would tell QEMU to stop and hopefully we don't wait until it timeouts.
Quoted 9 lines
The important bit here is CONFIG_GICV3_SELFTEST cannot be enabled for normal usage of Xen. IOW, user should not expect Xen to run domains when this configuration is enabled.
They are used to run baremetal tests.
Quoted 2 lines
Also, looking at
start_xen(), we calllocal_irq_enable()a little aftergicv3_init()is called. So I am a little bit surprised this is working?This is working i.e. we are getting interrupts. However, I can put the test after
local_irq_enable()as Xen is expected to terminate after running the tests.
I don't understand how this is working. Can you check whether the interrupts are unmasked? If yes, it would be good to know who unmasked them because it is not meant to be safe to enable them until the call of local_irq_enable() in start_xen().
Cheers,
Signature · 1 line
Julien Grall
Quoted 1 line · Julien Grall
Hi Ayan,
Hi Julien,
Quoted 78 lines · Ayan Kumar Halder
Quoted 76 lines · Julien Grall
Quoted 1 line
Hi Ayan,
Hi Julien,
Quoted 19 lines · Ayan Kumar Halder
Quoted 17 lines
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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.
Quoted 6 lines
Quoted 4 lines
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_init()was done properly to be able to trigger SGIs.To clarify, this only guarantees that the boot CPU can send SGIs to self.
Yes, this is the idea.
Quoted 1 line
Secondary CPUs are brought up later and will need their own setup to enable SGIs.
Yes, we will have separate tests for them.
Quoted 43 lines
Quoted 35 lines
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(+)xen/arch/arm/Kconfig +0
-0@@ -73,6 +73,14 @@ config GICV3Driver 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---xen/arch/arm/Kconfig +3
-0+ + Self tests to validate GICV3 driver. +config
HAS_ITS
bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED depends on GICV3 && !NEW_VGIC && !ARM_32xen/arch/arm/gic-v3.c +0
-0@@ -1818,6 +1818,13 @@ static int __init gicv3_init(void) gicv3_hyp_init();Quoted 6 lines
+#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);
+#endifLooking a the code below, it seems like Xen will not be functional after running the selftests? Is this intended? If so, we need to stop Xen as soon as possible.
Quoted 5 lines
Quoted 3 lines
Tbh, I didnot realize this with the current test. However you are correct that for some of these tests, Xen will not be usable. We can put a while(1) after it completes the tests.
Or, I can invoke
machine_halt().I think it would be better to use
machine_halt(). This would tell QEMU to stop and hopefully we don't wait until it timeouts.
Ack. I agree.
Quoted 4 lines
Quoted 4 lines
The important bit here is CONFIG_GICV3_SELFTEST cannot be enabled for normal usage of Xen. IOW, user should not expect Xen to run domains when this configuration is enabled.
Quoted 8 lines
Quoted 6 lines
They are used to run baremetal tests.
Quoted 2 lines
Also, looking at
start_xen(), we calllocal_irq_enable()a little aftergicv3_init()is called. So I am a little bit surprised this is working?This is working i.e. we are getting interrupts. However, I can put the test after
local_irq_enable()as Xen is expected to terminate after running the tests.I don't understand how this is working. Can you check whether the interrupts are unmasked? If yes, it would be good to know who unmasked them because it is not meant to be safe to enable them until the call of
local_irq_enable()instart_xen().
Yes, you are correct.
I put a while(1) after local_irq_enable() and then I could see the interrupts. Before that, we do not get the SGIs.
This means we should be doing this.
local_irq_enable();
+
+ mdelay(1); /* to allow some time for interrupts to be received */ + machine_halt();
I will think of something to avoid ifdef in common code. May be write a wrapper for local_irq_enable() which will invoke the GICv3 self tests.
- Ayan
Quoted 3 lines
Cheers,
Hi Ayan,
Quoted 54 lines · Ayan Kumar Halder
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_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(+)xen/arch/arm/Kconfig +8
-0@@ -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_32xen/arch/arm/gic-v3.c +0
-0
xen/arch/arm/gic-v3.c static int __init gicv3_init(void) · line 1827
Quoted 10 lines
xen/arch/arm/gic-v3.c +7
-0@@ -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.
xen/arch/arm/gic.c static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi) · line 349
Quoted 12 lines
xen/arch/arm/gic-v3.c +0
-0out:spin_unlock (&gicv3.lock);xen/arch/arm/gic.c +1
-0@@ -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)
xen/arch/arm/gic.c static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi) · line 362
Quoted 13 lines
xen/arch/arm/gic.c +13
-0+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;
xen/arch/arm/gic.c static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi) · line 367
Quoted 5 lines
xen/arch/arm/gic.c +5
-0+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.
Quoted 12 lines
xen/arch/arm/gic.c +2
-0+#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);
Signature · 2 lines
Best regards, -grygorii
Quoted 1 line · Grygorii Strashko
Hi Ayan,
Hi Grygorii,
Quoted 58 lines · Ayan Kumar Halder
Quoted 56 lines
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_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(+)xen/arch/arm/Kconfig +0
-0@@ -73,6 +73,14 @@ config GICV3Driver 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---xen/arch/arm/Kconfig +3
-0+ + Self tests to validate GICV3 driver. +config
HAS_ITS
bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED depends on GICV3 && !NEW_VGIC && !ARM_32xen/arch/arm/gic-v3.c +0
-0@@ -1818,6 +1818,13 @@ static int __init gicv3_init(void) gicv3_hyp_init();+#ifdef
CONFIG_GICV3_SELFTEST
+send_SGI_self(GIC_SGI_EVENT_CHECK);
Quoted 8 lines
xen/arch/arm/gic-v3.c static int __init gicv3_init(void) · line 1827
Quoted 5 lines
+
send_SGI_self(GIC_SGI_DUMP_STATE);
+send_SGI_self(GIC_SGI_CALL_FUNCTION);
+send_SGI_self(GIC_SGI_MAX);xen/arch/arm/gic-v3.c +2
-0+#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
Quoted 14 lines
Quoted 11 lines
out:
spin_unlock(&gicv3.lock);
diff --gita/xen/arch/arm/gic.cb/xen/arch/arm/gic.cindexd922ea67aa..5cb58cdb92100644xen/arch/arm/gic.c +0
-0@@ -346,6 +346,26 @@ static void do_sgi(struct cpu_user_regs *regs,enum gic_sgi sgi) */ smp_rmb();Quoted 1 line
+#ifdef
CONFIG_GICV3_SELFTESTif (
gic_selftest_run)
And then instead of ifdef, I can enclose the below under "if (gicv3_selftest)" .
Quoted 17 lines
Quoted 14 lines
+ switch (sgi)
+ {
+ caseGIC_SGI_EVENT_CHECK:
+printk("GIC_SGI_EVENT_CHECK received\n"); + break;
+ caseGIC_SGI_DUMP_STATE:
+printk("GIC_SGI_DUMP_STATE received\n"); + break;
+ caseGIC_SGI_CALL_FUNCTION:
+printk("GIC_SGI_CALL_FUNCTION received\n"); + break;
+ caseGIC_SGI_MAX:
+printk("GIC_SGI_MAX received\n");
gic_selftest_done= true;
Quoted 8 lines
Quoted 5 lines
+ 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
Hi Ayan,
Quoted 75 lines · Ayan Kumar Halder
Quoted 1 line · Grygorii Strashko
Hi Ayan,
Hi Grygorii,
Quoted 58 lines · Ayan Kumar Halder
Quoted 56 lines
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_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(+)xen/arch/arm/Kconfig +0
-0@@ -73,6 +73,14 @@ config GICV3Driver 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---xen/arch/arm/Kconfig +3
-0+ + Self tests to validate GICV3 driver. +config
HAS_ITS
bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED depends on GICV3 && !NEW_VGIC && !ARM_32xen/arch/arm/gic-v3.c +0
-0@@ -1818,6 +1818,13 @@ static int __init gicv3_init(void) gicv3_hyp_init();+#ifdef
CONFIG_GICV3_SELFTEST
+send_SGI_self(GIC_SGI_EVENT_CHECK);Quoted 8 lines
xen/arch/arm/gic-v3.c static int __init gicv3_init(void) · line 1827
Quoted 5 lines
+
send_SGI_self(GIC_SGI_DUMP_STATE);
+send_SGI_self(GIC_SGI_CALL_FUNCTION);
+send_SGI_self(GIC_SGI_MAX);xen/arch/arm/gic-v3.c +2
-0+#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 :-
Review
Quoted 5 lines
(quoted diff) +5
-0+static bool __initdata opt_gicv3_selftest = false; + +#ifdef CONFIG_GICV3_SELFTEST +opt_gicv3_selftest = true; +#endif
I'd like to propose to consider other approach according to the following assumptions:
1) the goal is "Test that Xen is able to generate SGIs.". According to the goal and your code
- for this test, it doesn't matter which one (SGI) is tested. Any way you don't call real handlers for GIC_SGI_x.
2) there are 16 SGIs available, only 3 are statistically defined (enum gic_sgi) and It's possible to reserve one more for testing purposes,
like GIC_SGI_SELFTEST
Then, gic SGI selftest might work without breaking Xen boot (probably for gicv2 also)
gic.c:
do_static_sgi()
{
...
#ifdef CONFIG_GIC_SELFTEST
case GIC_SGI_SELFTEST:
gic_sgi_selftest();
break;#endif
git-selftest.c
gic_sgi_selftest()
{
// process test SGI, like count number of triggers
} void [__init __constructor?] test_gic_sgi_selftest() {
setup test 1 send_SGI_self(GIC_SGI_SELFTEST)
setup test 2 send_SGI_allbutself(GIC_SGI_SELFTEST) setup test 2
send_SGI_mask(cpu_mask, GIC_SGI_SELFTEST)
}
Quoted 45 lines
Quoted 14 lines
Quoted 11 lines
out:
spin_unlock(&gicv3.lock);
diff --gita/xen/arch/arm/gic.cb/xen/arch/arm/gic.cindexd922ea67aa..5cb58cdb92100644xen/arch/arm/gic.c +0
-0@@ -346,6 +346,26 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)*/ smp_rmb();Quoted 1 line
+#ifdef
CONFIG_GICV3_SELFTESTif (
gic_selftest_run)And then instead of ifdef, I can enclose the below under "if (
gicv3_selftest)" .Quoted 17 lines
Quoted 14 lines
+ switch (sgi)
+ {
+ caseGIC_SGI_EVENT_CHECK:
+printk("GIC_SGI_EVENT_CHECK received\n"); + break;
+ caseGIC_SGI_DUMP_STATE:
+printk("GIC_SGI_DUMP_STATE received\n"); + break;
+ caseGIC_SGI_CALL_FUNCTION:
+printk("GIC_SGI_CALL_FUNCTION received\n"); + break;
+ caseGIC_SGI_MAX:
+printk("GIC_SGI_MAX received\n");
gic_selftest_done= true;Quoted 8 lines
Quoted 5 lines
+ 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
Signature · 2 lines
Best regards, -grygorii
Quoted 1 line · Grygorii Strashko
Hi Ayan,
Hi Grygorii,
Quoted 89 lines · Ayan Kumar Halder
Quoted 75 lines · Grygorii Strashko
Quoted 1 line
Hi Ayan,
Hi Grygorii,
Quoted 58 lines · Ayan Kumar Halder
Quoted 56 lines
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_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(+)xen/arch/arm/Kconfig +0
-0@@ -73,6 +73,14 @@ config GICV3Driver 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---xen/arch/arm/Kconfig +3
-0+ + Self tests to validate GICV3 driver. +config
HAS_ITS
bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORTED depends on GICV3 && !NEW_VGIC && !ARM_32xen/arch/arm/gic-v3.c +0
-0@@ -1818,6 +1818,13 @@ static int __init gicv3_init(void) gicv3_hyp_init();+#ifdef
CONFIG_GICV3_SELFTEST
+send_SGI_self(GIC_SGI_EVENT_CHECK);Quoted 8 lines
xen/arch/arm/gic-v3.c static int __init gicv3_init(void) · line 1827
Quoted 5 lines
+
send_SGI_self(GIC_SGI_DUMP_STATE);
+send_SGI_self(GIC_SGI_CALL_FUNCTION);
+send_SGI_self(GIC_SGI_MAX);xen/arch/arm/gic-v3.c +2
-0+#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 :-
Review
Quoted 5 lines
(quoted diff) +5
-0+static bool __initdata opt_gicv3_selftest = false; + +#ifdef CONFIG_GICV3_SELFTEST +opt_gicv3_selftest = true; +#endifI'd like to propose to consider other approach according to the following assumptions:
1) the goal is "Test that Xen is able to generate SGIs.". According to the goal and your code
- for this test, it doesn't matter which one (SGI) is tested. Any way
you don't call real handlers for
GIC_SGI_x.
Quoted 3 lines
2) there are 16 SGIs available, only 3 are statistically defined (enum
gic_sgi) and It's possible to reserve one more for testing purposes,
likeGIC_SGI_SELFTEST
I do like this approach. The only mild concern is that the test introduces a new SGI. IOW, it is not testing the existing SGIs which are used by Xen.
I need to think a bit more on this.
Quoted 2 lines
Then, gic SGI selftest might work without breaking Xen boot (probably for gicv2 also)
The goal of these kind of self tests are to validate Xen drivers (or rather Xen's configuration of the HW component). We will not be running Xen with any domains. Also, we don't intend to have the self tests run during regular boot of Xen as it adds a significant amount of code to be executed during boot time.
These tests will help to isolate issues when there is a potential misconfiguration of Xen for the hardware component or the hardware component does not work correctly with Xen.
Quoted 18 lines
gic.c:
do_static_sgi()
{
...
#ifdefCONFIG_GIC_SELFTEST
caseGIC_SGI_SELFTEST:
gic_sgi_selftest();
break;
#endif
git-selftest.c
gic_sgi_selftest()
{
// process test SGI, like count number of triggers }
Quoted 11 lines
void [
__init__constructor?]test_gic_sgi_selftest(){
setup test 1send_SGI_self(GIC_SGI_SELFTEST)
setup test 2send_SGI_allbutself(GIC_SGI_SELFTEST)setup test 2
send_SGI_mask(cpu_mask,GIC_SGI_SELFTEST) }
I do like the coding suggestion.
- Ayan
Quoted 17 lines · Ayan Kumar Halder
Introduce
CONFIG_GICV3_SELFTESTto enclose tests for GICv3 driver. Test that Xen is able to generate SGIs.Signed-off-by Ayan Kumar Halder <[email protected]>---
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.
Quoted 7 lines
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 aftergicv3_init()is invoked. If so, we can claim thatgicv3_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.
I like this approach and I think it is OK if Xen is not functional after some of the SELFTESTS because it is not the goal to run those in a working system.
My only suggestion is to separate the SELFTESTS in a separate __init function, keeping them isolated from the rest of the code, for simplicy and also ease of understanding.
See for example stub_selftest.
Quoted 84 lines
xen/arch/arm/Kconfig | 8 ++++++++ xen/arch/arm/gic-v3.c | 7 +++++++ xen/arch/arm/gic.c | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+)xen/arch/arm/Kconfig +8
-0@@ -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_32xen/arch/arm/gic-v3.c +7
-0@@ -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);xen/arch/arm/gic.c +21
-0@@ -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);Signature · 1 line
2.25.1