Fix ARM Generic Timer interrupt parsing
cover Fix ARM Generic Timer interrupt parsing
From: Andrei Cherechesu <[email protected]>
This 2-patch series fixes the parsing of the ARM Generic Timer interrupts from the device tree.
If the generic timer interrupts order in the DT was different than the expected order in Xen code, these interrupts would no longer be correctly parsed and registered by Xen, and would result in boot failure.
This method with using "interrupt-names" for the generic timer interrupts instead of having them hardcoded in the DTB in a specific order is the newer approach already implemented in Linux. Xen did not have the necessary code for this approach, and it has been implemented by the means of this patch series.
Functionality should remain the same if "interrupt-names" is not present in the Generic Timer DTB node of the platform, but the interrupts should then still be present in the expected "sec-phys", "phys", "virt", "hyp-phys", "hyp-virt" order. If "interrupt-names" is present, now it is also correctly handled.
Andrei Cherechesu (2):
arch/arm: irq: Add platform_get_irq_byname() implementation arch/arm: time: Add support for parsing interrupts by names
xen/arch/arm/include/asm/irq.h | 2 ++ xen/arch/arm/include/asm/time.h | 3 ++- xen/arch/arm/irq.c | 14 +++++++++++ xen/arch/arm/time.c | 26 +++++++++++++++++--- xen/drivers/passthrough/arm/smmu-v3.c | 35 +++++---------------------- 5 files changed, 46 insertions(+), 34 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/2 arch/arm: irq: Add platform_get_irq_byname() implementation
From: Andrei Cherechesu <[email protected]>
Moved implementation for the function which parses the IRQs of a DT node by the "interrupt-names" property from the SMMU-v3 driver to the IRQ core code and made it non-static to be used as helper.
Also changed it to receive a "struct dt_device_node*" as parameter, like its counterpart, platform_get_irq(). Updated its usage inside the SMMU-v3 driver accordingly.
--- xen/arch/arm/include/asm/irq.h | 2 ++ xen/arch/arm/irq.c | 14 +++++++++++ xen/drivers/passthrough/arm/smmu-v3.c | 35 +++++---------------------- 3 files changed, 22 insertions(+), 29 deletions(-)
xen/arch/arm/include/asm/irq.h +2 -0
@@ -89,6 +89,8 @@ int irq_set_type(unsigned int irq, unsigned int type);int platform_get_irq (const struct dt_device_node *device,int index); +int platform_get_irq_byname (struct dt_device_node *np,const char *name); +void irq_set_affinity (struct irq_desc *desc,const cpumask_t *cpu_mask);/*
xen/arch/arm/irq.c +14 -0
@@ -718,6 +718,20 @@ int platform_get_irq(const struct dt_device_node *device, int index)return irq; } +int platform_get_irq_byname (struct dt_device_node *np,const char *name) +{ +int index; + +if (unlikely (!name) ) +return -EINVAL ; + + index =dt_property_match_string (np,"interrupt-names" , name); +if ( index <0 ) +return index; + +return platform_get_irq (np, index); +} +/* * Local variables: * mode: C
xen/drivers/passthrough/arm/smmu-v3.c +6 -29
@@ -200,30 +200,6 @@ static inline void dev_iommu_priv_set(struct device *dev, void *priv) fwspec->iommu_priv = priv; } -static int platform_get_irq_byname_optional (struct device *dev, -const char *name) -{ -int index, ret; -struct dt_device_node *np =dev_to_dt (dev); - -if (unlikely (!name)) -return -EINVAL ; - - index =dt_property_match_string (np,"interrupt-names" , name); -if (index <0 ) { -dev_info (dev,"IRQ %s not found\n" , name); -return index; - } - - ret =platform_get_irq (np, index); -if (ret <0 ) { -dev_err (dev,"failed to get irq index %d\n" , index); -return -ENODEV ; - } - -return ret; -} -/* Start of Linux SMMUv3 code */ static bool disable_bypass =1 ;
@@ -2434,6 +2410,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)int irq, ret;paddr_t ioaddr, iosize;struct arm_smmu_device *smmu; +struct dt_device_node *np =dev_to_dt (pdev); smmu = xzalloc(struct arm_smmu_device);if (!smmu)
@@ -2451,7 +2428,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) }/* Base address */ - ret =dt_device_get_address (dev_to_dt (pdev),0 , &ioaddr, &iosize); + ret =dt_device_get_address (np,0 , &ioaddr, &iosize);if (ret) goto out_free_smmu;
@@ -2484,19 +2461,19 @@ static int arm_smmu_device_probe(struct platform_device *pdev)/* Interrupt lines */ - irq =platform_get_irq_byname_optional (pdev,"combined" ); + irq =platform_get_irq_byname (np,"combined" );if (irq >0 ) smmu->combined_irq = irq;else { - irq =platform_get_irq_byname_optional (pdev,"eventq" ); + irq =platform_get_irq_byname (np,"eventq" );if (irq >0 ) smmu->evtq.q.irq = irq; - irq =platform_get_irq_byname_optional (pdev,"priq" ); + irq =platform_get_irq_byname (np,"priq" );if (irq >0 ) smmu->priq.q.irq = irq; - irq =platform_get_irq_byname_optional (pdev,"gerror" ); + irq =platform_get_irq_byname (np,"gerror" );if (irq >0 ) smmu->gerr_irq = irq; }
Signature · 1 line
2.35.1
Re: [PATCH v1 1/2] arch/arm: irq: Add platform_get_irq_byname() implementation
Hi Andrei,
Quoted 8 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Moved implementation for the function which parses the IRQs of a DT node by the "interrupt-names" property from the SMMU-v3 driver to the IRQ core code and made it non-static to be used as helper.
Quoted 5 lines
Also changed it to receive a "struct dt_device_node*" as parameter, like its counterpart,
platform_get_irq(). Updated its usage inside the SMMU-v3 driver accordingly.Signed-off-by Andrei Cherechesu <[email protected]>
Cheers
Bertrand
Quoted 124 lines
---
xen/arch/arm/include/asm/irq.h | 2 ++ xen/arch/arm/irq.c | 14 +++++++++++ xen/drivers/passthrough/arm/smmu-v3.c | 35 +++++---------------------- 3 files changed, 22 insertions(+), 29 deletions(-)xen/arch/arm/include/asm/irq.h +2
-0@@ -89,6 +89,8 @@ int irq_set_type(unsigned int irq, unsigned int type);int platform_get_irq (const struct dt_device_node *device,int index); +int platform_get_irq_byname (struct dt_device_node *np,const char *name); +void irq_set_affinity (struct irq_desc *desc,const cpumask_t *cpu_mask);/* xen/arch/arm/irq.c +14
-0@@ -718,6 +718,20 @@ int platform_get_irq(const struct dt_device_node *device, int index)return irq; } +int platform_get_irq_byname (struct dt_device_node *np,const char *name) +{ +int index; + +if (unlikely (!name) ) +return -EINVAL ; + + index =dt_property_match_string (np,"interrupt-names" , name); +if ( index <0 ) +return index; + +return platform_get_irq (np, index); +} +/* * Local variables: * mode: C xen/drivers/passthrough/arm/smmu-v3.c +6
-29@@ -200,30 +200,6 @@ static inline void dev_iommu_priv_set(struct device *dev, void *priv) fwspec->iommu_priv = priv; } -static int platform_get_irq_byname_optional (struct device *dev, -const char *name) -{ -int index, ret; -struct dt_device_node *np =dev_to_dt (dev); - -if (unlikely (!name)) -return -EINVAL ; - - index =dt_property_match_string (np,"interrupt-names" , name); -if (index <0 ) { -dev_info (dev,"IRQ %s not found\n" , name); -return index; - } - - ret =platform_get_irq (np, index); -if (ret <0 ) { -dev_err (dev,"failed to get irq index %d\n" , index); -return -ENODEV ; - } - -return ret; -} -/* Start of Linux SMMUv3 code */ static bool disable_bypass =1 ;@@ -2434,6 +2410,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)int irq, ret;paddr_t ioaddr, iosize;struct arm_smmu_device *smmu; +struct dt_device_node *np =dev_to_dt (pdev); smmu = xzalloc(struct arm_smmu_device);if (!smmu)@@ -2451,7 +2428,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) }/* Base address */ - ret =dt_device_get_address (dev_to_dt (pdev),0 , &ioaddr, &iosize); + ret =dt_device_get_address (np,0 , &ioaddr, &iosize);if (ret) goto out_free_smmu;@@ -2484,19 +2461,19 @@ static int arm_smmu_device_probe(struct platform_device *pdev)/* Interrupt lines */ - irq =platform_get_irq_byname_optional (pdev,"combined" ); + irq =platform_get_irq_byname (np,"combined" );if (irq >0 ) smmu->combined_irq = irq;else { - irq =platform_get_irq_byname_optional (pdev,"eventq" ); + irq =platform_get_irq_byname (np,"eventq" );if (irq >0 ) smmu->evtq.q.irq = irq; - irq =platform_get_irq_byname_optional (pdev,"priq" ); + irq =platform_get_irq_byname (np,"priq" );if (irq >0 ) smmu->priq.q.irq = irq; - irq =platform_get_irq_byname_optional (pdev,"gerror" ); + irq =platform_get_irq_byname (np,"gerror" );if (irq >0 ) smmu->gerr_irq = irq; }Signature · 1 line
2.35.1
PATCH 2/2 arch/arm: time: Add support for parsing interrupts by names
In reply to Andrei Cherechesu (OSS)From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
--- xen/arch/arm/include/asm/time.h | 3 ++- xen/arch/arm/time.c | 26 ++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-)
xen/arch/arm/include/asm/time.h +2 -1
@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/*
xen/arch/arm/time.c +22 -4
@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );
@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ ) { - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 ) + timer_irq[i] = res; +/* Do not panic if "hyp-virt" PPI is not found, since it's not +* currently used. +*/ +else if ( i !=TIMER_HYP_VIRT_PPI )panic ("Timer: Unable to retrieve IRQ %u from the device tree\n" , i); - timer_irq[i] = res; } }
Signature · 1 line
2.35.1
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Hi Andrei,
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;
xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +
I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )
xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )
The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.
@stefano, julien any idea here ? should just keep the old behaviour ?
xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 176
Quoted 4 lines
xen/arch/arm/time.c +4
-0+ timer_irq[i] = res; +/* Do not panic if "hyp-virt" PPI is not found, since it's not +* currently used. +*/
Please respect the standard for comments and keep the first line empty:
/*
* comment
*/
xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 180
Quoted 5 lines
xen/arch/arm/time.c +1
-1+else if ( i !=TIMER_HYP_VIRT_PPI )panic ("Timer: Unable to retrieve IRQ %u from the device tree\n" , i); - timer_irq[i] = res; } }
Cheers
Bertrand
Quoted 5 lines
Signature · 2 lines
-- 2.35.1
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Quoted 44 lines · Bertrand Marquis
Hi Andrei,
Quoted 42 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;static unsigned int timer_irq[MAX_TIMER_PPI ];
Quoted 10 lines
xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 8 lines
xen/arch/arm/time.c +8
-0+static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Hi Bertrand,
This implementation follows the one in Linux [0]. The parsing order for the IRQs remains the same whether or not the "interrupt-names" property is available, since the driver in both Linux and Xen expects them in a specific order (defined by enum arch_timer_ppi_nr in Linux, for example) which, most of the time, does not correspond to how they are mapped onto the SoC. But now it can discover them correctly regardless of their order in the "interrupts" property in the DT node.
Only the "hyp-virt" IRQ is not required to be present, which is also the last one parsed.
Quoted 28 lines
Quoted 14 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Quoted 8 lines
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
You're right, I didn't take the dummy fake interrupts case into consideration. I also think we should keep the old behaviour then, and let 0 go through too, as you mentioned.
Quoted 10 lines
xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 176
Quoted 4 lines
xen/arch/arm/time.c +4
-0+ timer_irq[i] = res; +/* Do not panic if "hyp-virt" PPI is not found, since it's not +* currently used. +*/ Please respect the standard for comments and keep the first line empty:
/*
* comment
*/
Will update in v2.
Quoted 9 lines
xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 180
Quoted 5 lines
xen/arch/arm/time.c +1
-1+else if ( i !=TIMER_HYP_VIRT_PPI )panic ("Timer: Unable to retrieve IRQ %u from the device tree\n" , i); - timer_irq[i] = res; } }Cheers
Bertrand
Thanks for the review.
Regards,
Andrei
Quoted 6 lines
Quoted 5 lines
Signature · 2 lines
-- 2.35.1
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
In reply to Bertrand MarquisQuoted 80 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Quoted 7 lines
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
platform_get_irq returns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Hi Stefano,
Quoted 89 lines · Stefano Stabellini
Quoted 86 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.
Quoted 5 lines
Quoted 1 line
@stefano, julien any idea here ? should just keep the old behaviour ?
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.
Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
So I think we need to keep the current behaviour, might be ok to put a debug print.
What I would think is feasible would be to panic for interrupt numbers we need only.
Cheers
Bertrand
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Quoted 95 lines · Bertrand Marquis
Hi Stefano,
Quoted 91 lines · Stefano Stabellini
Quoted 87 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
Quoted 7 lines
Quoted 3 lines
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)
- EL1 phys (always)
- EL1 virt (always)
- NS EL2 phys (if EL2 is there)
therefore, if we get 0 for one of those, it means that something went wrong and we shall consider it as an error.
~Michal
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Hi Michal,
Quoted 104 lines · Michal Orzel
Quoted 99 lines · Bertrand Marquis
Hi Stefano,
Quoted 94 lines · Stefano Stabellini
Quoted 80 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Quoted 7 lines
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.
Quoted 6 lines
Quoted 3 lines
Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)
This might be needed by EL3 but not by Xen.
Quoted 3 lines
- EL1 phys (always)
- EL1 virt (always)
- NS EL2 phys (if EL2 is there)
Agree
Quoted 3 lines
therefore, if we get 0 for one of those, it means that something went wrong and we shall consider it as an error.
Agree except for the EL3 one :-)
Cheers
Bertrand
Quoted 2 lines
~Michal
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Quoted 108 lines · Bertrand Marquis
Hi Michal,
Quoted 104 lines · Michal Orzel
Quoted 99 lines · Bertrand Marquis
Hi Stefano,
Quoted 94 lines · Stefano Stabellini
Quoted 80 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Quoted 7 lines
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)This might be needed by EL3 but not by Xen.
Xen requires system with EL3 and if there is EL3, both Arm spec and dt bindings requires sec-phys timer to be there. So it would be very strange to see a fake interrupt with IRQ being 0. But if we relly want to only care about what Xen needs, then we could live with that (although it is difficult for me to find justification for 0 there). Device trees are created per system and if system has EL3, then why forcing 0 to be listed for sec-phys timer?
~Michal
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Hi Michal,
Quoted 120 lines · Michal Orzel
Quoted 115 lines · Bertrand Marquis
Hi Michal,
Quoted 110 lines · Michal Orzel
Quoted 95 lines · Bertrand Marquis
Hi Stefano,
Quoted 91 lines · Stefano Stabellini
Quoted 87 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
Quoted 7 lines
Quoted 3 lines
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)
Quoted 6 lines
Quoted 1 line
This might be needed by EL3 but not by Xen.
Xen requires system with EL3 and if there is EL3, both Arm spec and dt bindings requires sec-phys timer to be there. So it would be very strange to see a fake interrupt with IRQ being 0. But if we relly want to only care about what Xen needs, then we could live with that (although it is difficult for me to find justification for 0 there). Device trees are created per system and if system has EL3, then why forcing 0 to be listed for sec-phys timer?
Let's see that on the other angle: why should Xen check stuff that it does not need ?
Bertrand
Quoted 1 line
~Michal
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Hi Bertrand,
Quoted 124 lines · Bertrand Marquis
Hi Michal,
Quoted 120 lines · Michal Orzel
Quoted 115 lines · Bertrand Marquis
Hi Michal,
Quoted 110 lines · Michal Orzel
Quoted 95 lines · Bertrand Marquis
Hi Stefano,
Quoted 91 lines · Stefano Stabellini
Quoted 87 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
Quoted 7 lines
Quoted 3 lines
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This might be needed by EL3 but not by Xen.
Xen requires system with EL3 and if there is EL3, both Arm spec and dt bindings requires sec-phys timer to be there. So it would be very strange to see a fake interrupt with IRQ being 0. But if we relly want to only care about what Xen needs, then we could live with that (although it is difficult for me to find justification for 0 there). Device trees are created per system and if system has EL3, then why forcing 0 to be listed for sec-phys timer?
Let's see that on the other angle: why should Xen check stuff that it does not need ?
Because apart from what it needs or not, there is a matter of a failure in Xen.
Xen exposes timer IRQs to dom0 as they were taken from dtb and allowing 0 for any of the timer IRQ would result in a Xen failure when reserving such IRQ. Xen presets SGI IRQs, meaning bits 0:15 in allocated_irqs bitmap are set. This is why when calling vgic_reserve_virq and passing SGI always results in calling a BUG().
So we have two options:
- panic earlier with a meaningful message when IRQ is 0
- let Xen continue and reach BUG which would be not that obvious for people using but not knowing Xen
I think first option is always better.
~Michal
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Hi Michal,
Quoted 137 lines · Michal Orzel
Hi Bertrand,
Quoted 124 lines · Bertrand Marquis
Hi Michal,
Quoted 120 lines · Michal Orzel
Quoted 115 lines · Bertrand Marquis
Hi Michal,
Quoted 110 lines · Michal Orzel
Quoted 95 lines · Bertrand Marquis
Hi Stefano,
Quoted 91 lines · Stefano Stabellini
Quoted 87 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
Quoted 7 lines
Quoted 3 lines
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This might be needed by EL3 but not by Xen.
Xen requires system with EL3 and if there is EL3, both Arm spec and dt bindings requires sec-phys timer to be there. So it would be very strange to see a fake interrupt with IRQ being 0. But if we relly want to only care about what Xen needs, then we could live with that (although it is difficult for me to find justification for 0 there). Device trees are created per system and if system has EL3, then why forcing 0 to be listed for sec-phys timer?
Let's see that on the other angle: why should Xen check stuff that it does not need ?
Quoted 8 lines
Because apart from what it needs or not, there is a matter of a failure in Xen.
Xen exposes timer IRQs to dom0 as they were taken from dtb and allowing 0 for any of the timer IRQ would result in a Xen failure when reserving such IRQ. Xen presets SGI IRQs, meaning bits 0:15 inallocated_irqsbitmap are set. This is why when callingvgic_reserve_virqand passing SGI always results in calling aBUG().So we have two options:
- panic earlier with a meaningful message when IRQ is 0
- let Xen continue and reach BUG which would be not that obvious for people using but not knowing Xen
So you are saying that in the current state 0 would be ignored during scan and create a bug later.
If this is the case than definitely we should panic earlier with a proper message I agree.
Regards
Bertrand
Quoted 4 lines
I think first option is always better.
~Michal
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Quoted 146 lines · Bertrand Marquis
Hi Michal,
Quoted 142 lines · Michal Orzel
Hi Bertrand,
Quoted 124 lines · Bertrand Marquis
Hi Michal,
Quoted 120 lines · Michal Orzel
Quoted 115 lines · Bertrand Marquis
Hi Michal,
Quoted 110 lines · Michal Orzel
Quoted 95 lines · Bertrand Marquis
Hi Stefano,
Quoted 91 lines · Stefano Stabellini
Quoted 87 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
Quoted 7 lines
Quoted 3 lines
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This might be needed by EL3 but not by Xen.
Xen requires system with EL3 and if there is EL3, both Arm spec and dt bindings requires sec-phys timer to be there. So it would be very strange to see a fake interrupt with IRQ being 0. But if we relly want to only care about what Xen needs, then we could live with that (although it is difficult for me to find justification for 0 there). Device trees are created per system and if system has EL3, then why forcing 0 to be listed for sec-phys timer?
Let's see that on the other angle: why should Xen check stuff that it does not need ?
Because apart from what it needs or not, there is a matter of a failure in Xen.
Xen exposes timer IRQs to dom0 as they were taken from dtb and allowing 0 for any of the timer IRQ would result in a Xen failure when reserving such IRQ. Xen presets SGI IRQs, meaning bits 0:15 inallocated_irqsbitmap are set. This is why when callingvgic_reserve_virqand passing SGI always results in calling aBUG().
Quoted 5 lines
Quoted 3 lines
So we have two options:
- panic earlier with a meaningful message when IRQ is 0
- let Xen continue and reach BUG which would be not that obvious for people using but not knowing XenSo you are saying that in the current state 0 would be ignored during scan and create a bug later.
Yes, provided platform_get_irq() returns 0. This is however only theory because IMO it is impossible at the moment. Both GICs, do not allow specifying SGIs in dt bindings and require at least 3 cells where 1st one specifies type. So if we have a fake IRQ 0 as PPI, platform_get_irq will return 16 and for SPI - 32.
Therefore I cannot see how it would return 0.
~Michal
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Quoted 153 lines · Michal Orzel
Quoted 150 lines · Bertrand Marquis
Hi Michal,
Quoted 145 lines · Michal Orzel
Hi Bertrand,
Quoted 124 lines · Bertrand Marquis
Hi Michal,
Quoted 120 lines · Michal Orzel
Quoted 115 lines · Bertrand Marquis
Hi Michal,
Quoted 110 lines · Michal Orzel
Quoted 95 lines · Bertrand Marquis
Hi Stefano,
Quoted 91 lines · Stefano Stabellini
Quoted 87 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
Quoted 7 lines
Quoted 3 lines
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This might be needed by EL3 but not by Xen.
Xen requires system with EL3 and if there is EL3, both Arm spec and dt bindings requires sec-phys timer to be there. So it would be very strange to see a fake interrupt with IRQ being 0. But if we relly want to only care about what Xen needs, then we could live with that (although it is difficult for me to find justification for 0 there). Device trees are created per system and if system has EL3, then why forcing 0 to be listed for sec-phys timer?
Let's see that on the other angle: why should Xen check stuff that it does not need ?
Because apart from what it needs or not, there is a matter of a failure in Xen.
Xen exposes timer IRQs to dom0 as they were taken from dtb and allowing 0 for any of the timer IRQ would result in a Xen failure when reserving such IRQ. Xen presets SGI IRQs, meaning bits 0:15 inallocated_irqsbitmap are set. This is why when callingvgic_reserve_virqand passing SGI always results in calling aBUG().So we have two options:
- panic earlier with a meaningful message when IRQ is 0
- let Xen continue and reach BUG which would be not that obvious for people using but not knowing Xen
Quoted 8 lines
Quoted 1 line
So you are saying that in the current state 0 would be ignored during scan and create a bug later.
Yes, provided
platform_get_irq()returns 0. This is however only theory because IMO it is impossible at the moment. Both GICs, do not allow specifying SGIs in dt bindings and require at least 3 cells where 1st one specifies type. So if we have a fake IRQ 0 as PPI,platform_get_irqwill return 16 and for SPI - 32.
Therefore I cannot see how it would return 0.~Michal
This was my original thought process as well when I initially implemented this fix. Thus, I figured 0 should also be an error case.
Extending this, all SGI possible return values (0 to 15) should be errors here, right? But I'm not sure if we should also treat those extra cases here (1 to 15).
So, to make sure we all aligned, the only change to be made in a v2 for this patch is the coding style for the added comment? Or do you also think a more specific check for valid PPI IDs returned (16 <= id <= 31) would be beneficial?
Regards,
Andrei
Re: [PATCH v1 2/2] arch/arm: time: Add support for parsing interrupts by names
Hi,
Quoted 171 lines · Andrei Cherechesu
Quoted 153 lines · Michal Orzel
Quoted 150 lines · Bertrand Marquis
Hi Michal,
Quoted 145 lines · Michal Orzel
Hi Bertrand,
Quoted 124 lines · Bertrand Marquis
Hi Michal,
Quoted 120 lines · Michal Orzel
Quoted 115 lines · Bertrand Marquis
Hi Michal,
Quoted 110 lines · Michal Orzel
Quoted 95 lines · Bertrand Marquis
Hi Stefano,
Quoted 91 lines · Stefano Stabellini
Quoted 87 lines · Bertrand Marquis
Quoted 40 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
Added support for parsing the ARM generic timer interrupts DT node by the "interrupt-names" property, if it is available.
If not available, the usual parsing based on the expected IRQ order is performed.
Also added the "hyp-virt" PPI to the timer PPI list, even though it's currently not in use. If the "hyp-virt" PPI is not found, the hypervisor won't panic.
Signed-off-by Andrei Cherechesu <[email protected]>---
xen/arch/arm/include/asm/time.h| 3 ++-xen/arch/arm/time.c| 26 ++++++++++++++++++++++----2 files changed, 24 insertions(+), 5 deletions(-)xen/arch/arm/include/asm/time.h +2
-1@@ -82,7 +82,8 @@ enum timer_ppiTIMER_PHYS_NONSECURE_PPI =1 ,TIMER_VIRT_PPI =2 ,TIMER_HYP_PPI =3 , - MAX_TIMER_PPI = 4, +TIMER_HYP_VIRT_PPI =4 , + MAX_TIMER_PPI = 5, };/* xen/arch/arm/time.c +0
-0@@ -38,6 +38,14 @@ uint32_t __read_mostly timer_dt_clock_frequency;xen/arch/arm/time.c uint32_t __read_mostly timer_dt_clock_frequency; · line 48
Quoted 10 lines
xen/arch/arm/time.c +8
-0static unsigned int timer_irq[MAX_TIMER_PPI ]; +static const char *timer_irq_names[MAX_TIMER_PPI ] = { + [TIMER_PHYS_SECURE_PPI ] ="sec-phys" , + [TIMER_PHYS_NONSECURE_PPI ] ="phys" , + [TIMER_VIRT_PPI ] ="virt" , + [TIMER_HYP_PPI ] ="hyp-phys" , + [TIMER_HYP_VIRT_PPI ] ="hyp-virt" , +}; +I would need some reference or a pointer to some doc to check those.
Quoted 13 lines
xen/arch/arm/time.c +3
-0unsigned int timer_get_irq (enum timer_ppi ppi) {ASSERT (ppi >=TIMER_PHYS_SECURE_PPI && ppi <MAX_TIMER_PPI );@@ -149,15 +157,25 @@ static void __init init_dt_xen_time(void) {int res;unsigned int i; +bool has_names; + + has_names =dt_property_read_bool (timer,"interrupt-names" );/* Retrieve all IRQs for the timer */ for ( i =TIMER_PHYS_SECURE_PPI ; i <MAX_TIMER_PPI ; i++ )xen/arch/arm/time.c static void __init init_dt_xen_time(void) · line 172
Quoted 10 lines
xen/arch/arm/time.c +6
-3{ - res =platform_get_irq (timer, i); - -if ( res <0 ) +if ( has_names ) + res =platform_get_irq_byname (timer, timer_irq_names[i]); +else + res =platform_get_irq (timer, i); + +if ( res >0 )The behaviour of the code is changed here compared to the current version as res = 0 will now generate a panic.
Some device tree might not specify an interrupt number and just put 0 and Xen will now panic on those systems.
As I have no idea if such systems exists and the behaviour is modified you should justify this and mention it in the commit message or keep the old behaviour and let 0 go through without a panic.@stefano, julien any idea here ? should just keep the old behaviour ?
Quoted 7 lines
Quoted 3 lines
platform_get_irqreturns 0 if the irq is 0. The irq cannot be 0 because 0 is reserved for SGIs, not PPIs. So I think it is OK to consider 0 an error.Problem here is that a DTB might not specify all interrupts and just put 0 for the one not used (or not available for example if you have no secure world).
Xen requires presence of EL3,EL2 and on such system, at least the following timers needs to be there according to Arm ARM:
- EL3 phys (if EL3 is there)Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This might be needed by EL3 but not by Xen.
Xen requires system with EL3 and if there is EL3, both Arm spec and dt bindings requires sec-phys timer to be there. So it would be very strange to see a fake interrupt with IRQ being 0. But if we relly want to only care about what Xen needs, then we could live with that (although it is difficult for me to find justification for 0 there). Device trees are created per system and if system has EL3, then why forcing 0 to be listed for sec-phys timer?
Let's see that on the other angle: why should Xen check stuff that it does not need ?
Because apart from what it needs or not, there is a matter of a failure in Xen.
Xen exposes timer IRQs to dom0 as they were taken from dtb and allowing 0 for any of the timer IRQ would result in a Xen failure when reserving such IRQ. Xen presets SGI IRQs, meaning bits 0:15 inallocated_irqsbitmap are set. This is why when callingvgic_reserve_virqand passing SGI always results in calling aBUG().So we have two options:
- panic earlier with a meaningful message when IRQ is 0
- let Xen continue and reach BUG which would be not that obvious for people using but not knowing XenQuoted 8 lines
Quoted 1 line
So you are saying that in the current state 0 would be ignored during scan and create a bug later.
Yes, provided
platform_get_irq()returns 0. This is however only theory because IMO it is impossible at the moment. Both GICs, do not allow specifying SGIs in dt bindings and require at least 3 cells where 1st one specifies type. So if we have a fake IRQ 0 as PPI,platform_get_irqwill return 16 and for SPI - 32.
Therefore I cannot see how it would return 0.~Michal
This was my original thought process as well when I initially implemented this fix. Thus, I figured 0 should also be an error case.
Quoted 9 lines
Extending this, all SGI possible return values (0 to 15) should be errors here, right? But I'm not sure if we should also treat those extra cases here (1 to 15).
So, to make sure we all aligned, the only change to be made in a v2 for this patch is the coding style for the added comment? Or do you also think a more specific check for valid PPI IDs returned (16 <= id <= 31) would be beneficial?
No i think we should not check more.
Just add something in the commit message to mention this change and why it is ok.
Cheers
Bertrand
Quoted 2 lines
Regards,
Andrei
Hi Andrei,
When submitting patches, please use the add_maintainer.pl script so that maintainers of the code modified are added in CC.
Quoted 7 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
This 2-patch series fixes the parsing of the ARM Generic Timer interrupts from the device tree.
Quoted 8 lines
If the generic timer interrupts order in the DT was different than the expected order in Xen code, these interrupts would no longer be correctly parsed and registered by Xen, and would result in boot failure.
This method with using "interrupt-names" for the generic timer interrupts instead of having them hardcoded in the DTB in a specific order is the newer approach already implemented in Linux. Xen did not have the necessary code for this approach, and it has been implemented by the means of this patch series.
Would mind giving a link to an example or the Linux documentation if there is one ?
Cheers
Bertrand
Quoted 21 lines
Functionality should remain the same if "interrupt-names" is not present in the Generic Timer DTB node of the platform, but the interrupts should then still be present in the expected "sec-phys", "phys", "virt", "hyp-phys", "hyp-virt" order. If "interrupt-names" is present, now it is also correctly handled.
Andrei Cherechesu (2):
arch/arm: irq: Addplatform_get_irq_byname()implementationarch/arm: time: Add support for parsing interrupts by namesxen/arch/arm/include/asm/irq.h | 2 ++ xen/arch/arm/include/asm/time.h | 3 ++- xen/arch/arm/irq.c | 14 +++++++++++ xen/arch/arm/time.c | 26 +++++++++++++++++--- xen/drivers/passthrough/arm/smmu-v3.c | 35 +++++---------------------- 5 files changed, 46 insertions(+), 34 deletions(-)Signature · 1 line
2.35.1
Quoted 4 lines · Bertrand Marquis
Hi Andrei,
When submitting patches, please use the add_maintainer.pl script so that maintainers of the code modified are added in CC.
Hi Bertrand,
Thank you for reviewing the patches. I apologize for not adding the maintainers in CC. I added them now.
Quoted 12 lines
Quoted 12 lines · Andrei Cherechesu (OSS)
From: Andrei Cherechesu <[email protected]>
This 2-patch series fixes the parsing of the ARM Generic Timer interrupts from the device tree.
If the generic timer interrupts order in the DT was different than the expected order in Xen code, these interrupts would no longer be correctly parsed and registered by Xen, and would result in boot failure.
Quoted 7 lines
Quoted 4 lines
This method with using "interrupt-names" for the generic timer interrupts instead of having them hardcoded in the DTB in a specific order is the newer approach already implemented in Linux. Xen did not have the necessary code for this approach, and it has been implemented by the means of this patch series.
Would mind giving a link to an example or the Linux documentation if there is one ?
The bindings [0] for the ARM Generic Timer DT node were changed around Linux 5.13, when the interrupt-names property was added, along with the implementation for handling it [1].
[0]
https://elixir.bootlin.com/linux/v6.3-rc1/source/Documentation/devicetree/bindings/timer/arm,arch_timer.yaml#L44
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/clocksource/arm_arch_timer.c?id=86332e9e3477af8f31c9d5f3e81e57e0fd2118e7
Regards,
Andrei
Quoted 25 lines
Cheers
BertrandQuoted 21 lines
Functionality should remain the same if "interrupt-names" is not present in the Generic Timer DTB node of the platform, but the interrupts should then still be present in the expected "sec-phys", "phys", "virt", "hyp-phys", "hyp-virt" order. If "interrupt-names" is present, now it is also correctly handled.
Andrei Cherechesu (2):
arch/arm: irq: Addplatform_get_irq_byname()implementationarch/arm: time: Add support for parsing interrupts by namesxen/arch/arm/include/asm/irq.h | 2 ++ xen/arch/arm/include/asm/time.h | 3 ++- xen/arch/arm/irq.c | 14 +++++++++++ xen/arch/arm/time.c | 26 +++++++++++++++++--- xen/drivers/passthrough/arm/smmu-v3.c | 35 +++++---------------------- 5 files changed, 46 insertions(+), 34 deletions(-)Signature · 1 line
2.35.1