xen/arm: vtimer: Don't read/use the secure physical timer interrupt for ACPI
PATCH 1/1 xen/arm: vtimer: Don't read/use the secure physical timer interrupt for ACPI
From: Julien Grall <[email protected]>
Per ACPI 6.5 section 5.2.25 ("Generic Timer Description Table (GTDT)"), the fields "Secure EL1 Timer GSIV/Flags" are optional and an OS running in non-secure world is meant to ignore the values.
However, Xen is trying to reserve the value. When booting on Graviton 2 metal instances, this would result to crash a boot because the value is 0 which is already reserved (I haven't checked for which device). While nothing prevent a PPI to be shared, the field should have been ignored by Xen.
For the Device-Tree case, I couldn't find a statement suggesting that the secure physical timer interrupt is ignored. In fact, I have found some code in Linux using it as a fallback. That said, it should never be used.
As I am not aware of any issue when booting using Device-Tree, the physical timer interrupt is only ignored for ACPI.
----
This has not been tested on Graviton 2 because I can't seem to get the serial console working properly. @Dan would you be able to try it?
It would also be good to understand why 0 why already reserved. This may be a sign for other issues in the ACPI code.
--- xen/arch/arm/time.c | 4 ---- xen/arch/arm/vtimer.c | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-)
xen/arch/arm/time.c +0 -4
@@ -78,10 +78,6 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *header)irq_set_type (gtdt->non_secure_el1_interrupt, irq_type); timer_irq[TIMER_PHYS_NONSECURE_PPI ] = gtdt->non_secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->secure_el1_flags); -irq_set_type (gtdt->secure_el1_interrupt, irq_type); - timer_irq[TIMER_PHYS_SECURE_PPI ] = gtdt->secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->virtual_timer_flags);irq_set_type (gtdt->virtual_timer_interrupt, irq_type); timer_irq[TIMER_VIRT_PPI ] = gtdt->virtual_timer_interrupt;
xen/arch/arm/vtimer.c +15 -2
@@ -8,6 +8,7 @@* Copyright (c) 2011 Citrix Systems. */ +#include <xen/acpi.h> #include <xen/lib.h> #include <xen/perfc.h> #include <xen/sched.h>
@@ -61,10 +62,22 @@ int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) config->clock_frequency = timer_dt_clock_frequency; -/* At this stage vgic_reserve_virq can't fail */ +/* +* Per the ACPI specification, providing a secure EL1 timer +* interrupt is optional and will be ignored by non-secure OS. +* Therefore don't reserve the interrupt number for the HW domain +* and ACPI. +* +* Note that we should still reserve it when using the Device-Tree +* because the interrupt is not optional. That said, we are not +* expecting any OS to use it when running on top of Xen. +* +* At this stage vgic_reserve_virq() is not meant to fail. +*/ if (is_hardware_domain (d) ) { -if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_SECURE_PPI )) ) +if ( acpi_disabled && + !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_SECURE_PPI )) )BUG ();if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_NONSECURE_PPI )) )
Signature · 1 line
2.40.1
Hi Julien,
Quoted 11 lines · Julien Grall
From: Julien Grall <[email protected]>
Per ACPI 6.5 section 5.2.25 ("Generic Timer Description Table (GTDT)"), the fields "Secure EL1 Timer GSIV/Flags" are optional and an OS running in non-secure world is meant to ignore the values.
However, Xen is trying to reserve the value. When booting on Graviton 2 metal instances, this would result to crash a boot because the value is 0 which is already reserved (I haven't checked for which device).
Per my understanding it is not reserved by any device.
0 means SGI and for SGIs we pre-reserve the bits in allocated_irqs at the very start.
~Michal
Quoted 1 line · Michal Orzel
Hi Julien,
Hi Michal,
Quoted 9 lines · Julien Grall
Quoted 8 lines
From: Julien Grall <[email protected]>
Per ACPI 6.5 section 5.2.25 ("Generic Timer Description Table (GTDT)"), the fields "Secure EL1 Timer GSIV/Flags" are optional and an OS running in non-secure world is meant to ignore the values.
Quoted 5 lines
Quoted 3 lines
However, Xen is trying to reserve the value. When booting on Graviton 2 metal instances, this would result to crash a boot because the value is 0 which is already reserved (I haven't checked for which device).
Per my understanding it is not reserved by any device.
0 means SGI and for SGIs we pre-reserve the bits inallocated_irqsat the very start.
Ah yes good point. Somehow, I had in mind that PPI was starting at 0 '^^. How about replacing the paragraph with:
"However, Xen is trying to reserve the value. The ACPI tables for Graviton 2 metal instances will provide the value 0 which is not a correct PPI (PPIs start at 16) and would have in fact been already reserved by Xen as this is an SGI. Xen will hit the BUG() and panic()".
Cheers,
Signature · 1 line
Julien Grall
Michal Orzel
Reviewed-byHi Julien,
Quoted 22 lines · Julien Grall
Quoted 1 line · Michal Orzel
Hi Julien,
Hi Michal,
Quoted 9 lines · Julien Grall
Quoted 8 lines
From: Julien Grall <[email protected]>
Per ACPI 6.5 section 5.2.25 ("Generic Timer Description Table (GTDT)"), the fields "Secure EL1 Timer GSIV/Flags" are optional and an OS running in non-secure world is meant to ignore the values.
Quoted 5 lines
Quoted 3 lines
However, Xen is trying to reserve the value. When booting on Graviton 2 metal instances, this would result to crash a boot because the value is 0 which is already reserved (I haven't checked for which device).
Per my understanding it is not reserved by any device.
0 means SGI and for SGIs we pre-reserve the bits inallocated_irqsat the very start.
Quoted 7 lines
Ah yes good point. Somehow, I had in mind that PPI was starting at 0 '^^. How about replacing the paragraph with:
"However, Xen is trying to reserve the value. The ACPI tables for Graviton 2 metal instances will provide the value 0 which is not a correct PPI (PPIs start at 16) and would have in fact been already reserved by Xen as this is an SGI. Xen will hit the
BUG()andpanic()".
Yes, this sounds better. With that:
~Michal
Quoted 68 lines · Julien Grall
From: Julien Grall <[email protected]>
Per ACPI 6.5 section 5.2.25 ("Generic Timer Description Table (GTDT)"), the fields "Secure EL1 Timer GSIV/Flags" are optional and an OS running in non-secure world is meant to ignore the values.
However, Xen is trying to reserve the value. When booting on Graviton 2 metal instances, this would result to crash a boot because the value is 0 which is already reserved (I haven't checked for which device). While nothing prevent a PPI to be shared, the field should have been ignored by Xen.
For the Device-Tree case, I couldn't find a statement suggesting that the secure physical timer interrupt is ignored. In fact, I have found some code in Linux using it as a fallback. That said, it should never be used.
As I am not aware of any issue when booting using Device-Tree, the physical timer interrupt is only ignored for ACPI.
Signed-off-by Julien Grall <[email protected]>----
This has not been tested on Graviton 2 because I can't seem to get the serial console working properly. @Dan would you be able to try it?
It would also be good to understand why 0 why already reserved. This may be a sign for other issues in the ACPI code.
--- xen/arch/arm/time.c | 4 ---- xen/arch/arm/vtimer.c | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-)xen/arch/arm/time.c +0
-4@@ -78,10 +78,6 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *header)irq_set_type (gtdt->non_secure_el1_interrupt, irq_type); timer_irq[TIMER_PHYS_NONSECURE_PPI ] = gtdt->non_secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->secure_el1_flags); -irq_set_type (gtdt->secure_el1_interrupt, irq_type); - timer_irq[TIMER_PHYS_SECURE_PPI ] = gtdt->secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->virtual_timer_flags);irq_set_type (gtdt->virtual_timer_interrupt, irq_type); timer_irq[TIMER_VIRT_PPI ] = gtdt->virtual_timer_interrupt;xen/arch/arm/vtimer.c +3
-1@@ -8,6 +8,7 @@* Copyright (c) 2011 Citrix Systems. */ +#include <xen/acpi.h> #include <xen/lib.h> #include <xen/perfc.h> #include <xen/sched.h> @@ -61,10 +62,22 @@ int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) config->clock_frequency = timer_dt_clock_frequency; -/* At this stage vgic_reserve_virq can't fail */ +/* +* Per the ACPI specification, providing a secure EL1 timer
xen/arch/arm/vtimer.c int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) · line 76
Quoted 10 lines
xen/arch/arm/vtimer.c +10
-0+* interrupt is optional and will be ignored by non-secure OS. +* Therefore don't reserve the interrupt number for the HW domain +* and ACPI. +* +* Note that we should still reserve it when using the Device-Tree +* because the interrupt is not optional. That said, we are not +* expecting any OS to use it when running on top of Xen. +* +* At this stage vgic_reserve_virq() is not meant to fail. +*/
NIT: minor code style issue that can be solved on commit
Assuming it passes Dan's test:
Quoted 11 lines
xen/arch/arm/vtimer.c +2
-1if (is_hardware_domain (d) ) { -if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_SECURE_PPI )) ) +if ( acpi_disabled && + !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_SECURE_PPI )) )BUG ();if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_NONSECURE_PPI )) )Signature · 1 line
2.40.1
Hi,
Quoted 84 lines · Stefano Stabellini
Quoted 68 lines · Julien Grall
From: Julien Grall <[email protected]>
Per ACPI 6.5 section 5.2.25 ("Generic Timer Description Table (GTDT)"), the fields "Secure EL1 Timer GSIV/Flags" are optional and an OS running in non-secure world is meant to ignore the values.
However, Xen is trying to reserve the value. When booting on Graviton 2 metal instances, this would result to crash a boot because the value is 0 which is already reserved (I haven't checked for which device). While nothing prevent a PPI to be shared, the field should have been ignored by Xen.
For the Device-Tree case, I couldn't find a statement suggesting that the secure physical timer interrupt is ignored. In fact, I have found some code in Linux using it as a fallback. That said, it should never be used.
As I am not aware of any issue when booting using Device-Tree, the physical timer interrupt is only ignored for ACPI.
Signed-off-by Julien Grall <[email protected]>----
This has not been tested on Graviton 2 because I can't seem to get the serial console working properly. @Dan would you be able to try it?
It would also be good to understand why 0 why already reserved. This may be a sign for other issues in the ACPI code.
---xen/arch/arm/time.c| 4 ----xen/arch/arm/vtimer.c| 17 +++++++++++++++--2 files changed, 15 insertions(+), 6 deletions(-)xen/arch/arm/time.c +0
-4@@ -78,10 +78,6 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *header)irq_set_type (gtdt->non_secure_el1_interrupt, irq_type); timer_irq[TIMER_PHYS_NONSECURE_PPI ] = gtdt->non_secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->secure_el1_flags); -irq_set_type (gtdt->secure_el1_interrupt, irq_type); - timer_irq[TIMER_PHYS_SECURE_PPI ] = gtdt->secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->virtual_timer_flags);irq_set_type (gtdt->virtual_timer_interrupt, irq_type); timer_irq[TIMER_VIRT_PPI ] = gtdt->virtual_timer_interrupt;xen/arch/arm/vtimer.c +3
-1@@ -8,6 +8,7 @@* Copyright (c) 2011 Citrix Systems. */ +#include <xen/acpi.h> #include <xen/lib.h> #include <xen/perfc.h> #include <xen/sched.h> @@ -61,10 +62,22 @@ int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) config->clock_frequency = timer_dt_clock_frequency; -/* At this stage vgic_reserve_virq can't fail */ +/* +* Per the ACPI specification, providing a secure EL1 timer xen/arch/arm/vtimer.c int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) · line 76
Quoted 10 lines
xen/arch/arm/vtimer.c +10
-0+* interrupt is optional and will be ignored by non-secure OS. +* Therefore don't reserve the interrupt number for the HW domain +* and ACPI. +* +* Note that we should still reserve it when using the Device-Tree +* because the interrupt is not optional. That said, we are not +* expecting any OS to use it when running on top of Xen. +* +* At this stage vgic_reserve_virq() is not meant to fail. +*/ NIT: minor code style issue that can be solved on commit
Quoted 3 lines
Assuming it passes Dan's test:
Reviewed-by Stefano Stabellini <[email protected]>
Kind regards,
Henry
Quoted 13 lines
Quoted 13 lines
xen/arch/arm/vtimer.c +2
-1if (is_hardware_domain (d) ) { -if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_SECURE_PPI )) ) +if ( acpi_disabled && + !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_SECURE_PPI )) )BUG ();if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_NONSECURE_PPI )) )Signature · 1 line
2.40.1
Julien,
Verified this patch works on Graviton 2... so looks good from this perspective.
Thanks,
Dan
Quoted 103 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: Thursday, October 5, 2023 11:55 AM
To: [email protected]
Cc: [email protected]; Driscoll, Dan (DI SW CAS ES TO) <[email protected]>; Raghuraman, Arvind (DI SW CAS ES) <[email protected]>; [email protected]; Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; Julien Grall <[email protected]>; Bertrand Marquis <[email protected]>; Volodymyr Babchuk <[email protected]>
Subject: [PATCH] xen/arm: vtimer: Don't read/use the secure physical timer interrupt for ACPIFrom: Julien Grall <[email protected]>
Per ACPI 6.5 section 5.2.25 ("Generic Timer Description Table (GTDT)"), the fields "Secure EL1 Timer GSIV/Flags" are optional and an OS running in non-secure world is meant to ignore the values.
However, Xen is trying to reserve the value. When booting on Graviton 2 metal instances, this would result to crash a boot because the value is 0 which is already reserved (I haven't checked for which device).
While nothing prevent a PPI to be shared, the field should have been ignored by Xen.For the Device-Tree case, I couldn't find a statement suggesting that the secure physical timer interrupt is ignored. In fact, I have found some code in Linux using it as a fallback. That said, it should never be used.
As I am not aware of any issue when booting using Device-Tree, the physical timer interrupt is only ignored for ACPI.
Signed-off-by Julien Grall <[email protected]>----
This has not been tested on Graviton 2 because I can't seem to get the serial console working properly. @Dan would you be able to try it?
It would also be good to understand why 0 why already reserved. This may be a sign for other issues in the ACPI code.
--- xen/arch/arm/time.c | 4 ---- xen/arch/arm/vtimer.c | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-)xen/arch/arm/time.c index renamed from xen/arch/arm/time.c +0
-0
3535bd8ac7c7..8fc14cd3ff62100644xen/arch/arm/time.c +0
-4@@ -78,10 +78,6 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *header) irq_set_type(gtdt->non_secure_el1_interrupt, irq_type); timer_irq[TIMER_PHYS_NONSECURE_PPI ] = gtdt->non_secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->secure_el1_flags); -irq_set_type (gtdt->secure_el1_interrupt, irq_type); - timer_irq[TIMER_PHYS_SECURE_PPI ] = gtdt->secure_el1_interrupt; - irq_type =acpi_get_timer_irq_type (gtdt->virtual_timer_flags);irq_set_type (gtdt->virtual_timer_interrupt, irq_type);timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt; diff --git
a/xen/arch/arm/vtimer.cb/xen/arch/arm/vtimer.cindexc54360e20266..e73ae33c1b58100644xen/arch/arm/vtimer.c +16
-3@@ -8,6 +8,7 @@* Copyright (c) 2011 Citrix Systems. */ +#include <xen/acpi.h> #include <xen/lib.h> #include <xen/perfc.h> #include <xen/sched.h> @@ -61,10 +62,22 @@ int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) config->clock_frequency = timer_dt_clock_frequency; -/* At this stage vgic_reserve_virq can't fail */ +/* +* Per the ACPI specification, providing a secure EL1 timer +* interrupt is optional and will be ignored by non-secure OS. +* Therefore don't reserve the interrupt number for the HW domain +* and ACPI. +* +* Note that we should still reserve it when using the Device-Tree +* because the interrupt is not optional. That said, we are not +* expecting any OS to use it when running on top of Xen. +* +* At this stage vgic_reserve_virq() is not meant to fail. +*/ if (is_hardware_domain (d) ) { -if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_SECURE_PPI )) ) +if ( acpi_disabled && + !vgic_reserve_virq (d, +timer_get_irq (TIMER_PHYS_SECURE_PPI )) )BUG ();if ( !vgic_reserve_virq (d,timer_get_irq (TIMER_PHYS_NONSECURE_PPI )) ) --2.40.1
Hi Dan,
Quoted 3 lines · Dan
Julien,
Verified this patch works on Graviton 2... so looks good from this perspective.
Thanks for testing. I will commit the patch then to staging so it will be included in the next release (4.18.0).
Cheers,
Signature · 1 line
Julien Grall