diff options
author | Andre Przywara <andre.przywara@arm.com> | 2018-07-06 04:11:50 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2019-02-19 16:05:22 -0500 |
commit | ee7930490a8f84570e96268f5736e99570b58307 (patch) | |
tree | a517617fdf0cf02dcea998a8347b5dc93a5f14f6 | |
parent | 49a57857aeea06ca831043acbb0fa5e0f50602fd (diff) |
clocksource/arm_arch_timer: Store physical timer IRQ number for KVM on VHE
A host running in VHE mode gets the EL2 physical timer as its time
source (accessed using the EL1 sysreg accessors, which get re-directed
to the EL2 sysregs by VHE).
The EL1 physical timer remains unused by the host kernel, allowing us to
pass that on directly to a KVM guest and saves us from emulating this
timer for the guest on VHE systems.
Store the EL1 Physical Timer's IRQ number in
struct arch_timer_kvm_info on VHE systems to allow KVM to use it.
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
-rw-r--r-- | drivers/clocksource/arm_arch_timer.c | 11 | ||||
-rw-r--r-- | include/clocksource/arm_arch_timer.h | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 9a7d4dc00b6e..b9243e2328b4 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c | |||
@@ -1206,6 +1206,13 @@ static enum arch_timer_ppi_nr __init arch_timer_select_ppi(void) | |||
1206 | return ARCH_TIMER_PHYS_SECURE_PPI; | 1206 | return ARCH_TIMER_PHYS_SECURE_PPI; |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | static void __init arch_timer_populate_kvm_info(void) | ||
1210 | { | ||
1211 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; | ||
1212 | if (is_kernel_in_hyp_mode()) | ||
1213 | arch_timer_kvm_info.physical_irq = arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI]; | ||
1214 | } | ||
1215 | |||
1209 | static int __init arch_timer_of_init(struct device_node *np) | 1216 | static int __init arch_timer_of_init(struct device_node *np) |
1210 | { | 1217 | { |
1211 | int i, ret; | 1218 | int i, ret; |
@@ -1220,7 +1227,7 @@ static int __init arch_timer_of_init(struct device_node *np) | |||
1220 | for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) | 1227 | for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) |
1221 | arch_timer_ppi[i] = irq_of_parse_and_map(np, i); | 1228 | arch_timer_ppi[i] = irq_of_parse_and_map(np, i); |
1222 | 1229 | ||
1223 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; | 1230 | arch_timer_populate_kvm_info(); |
1224 | 1231 | ||
1225 | rate = arch_timer_get_cntfrq(); | 1232 | rate = arch_timer_get_cntfrq(); |
1226 | arch_timer_of_configure_rate(rate, np); | 1233 | arch_timer_of_configure_rate(rate, np); |
@@ -1550,7 +1557,7 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table) | |||
1550 | arch_timer_ppi[ARCH_TIMER_HYP_PPI] = | 1557 | arch_timer_ppi[ARCH_TIMER_HYP_PPI] = |
1551 | acpi_gtdt_map_ppi(ARCH_TIMER_HYP_PPI); | 1558 | acpi_gtdt_map_ppi(ARCH_TIMER_HYP_PPI); |
1552 | 1559 | ||
1553 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; | 1560 | arch_timer_populate_kvm_info(); |
1554 | 1561 | ||
1555 | /* | 1562 | /* |
1556 | * When probing via ACPI, we have no mechanism to override the sysreg | 1563 | * When probing via ACPI, we have no mechanism to override the sysreg |
diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 349e5957c949..702967d996bb 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h | |||
@@ -74,6 +74,7 @@ enum arch_timer_spi_nr { | |||
74 | struct arch_timer_kvm_info { | 74 | struct arch_timer_kvm_info { |
75 | struct timecounter timecounter; | 75 | struct timecounter timecounter; |
76 | int virtual_irq; | 76 | int virtual_irq; |
77 | int physical_irq; | ||
77 | }; | 78 | }; |
78 | 79 | ||
79 | struct arch_timer_mem_frame { | 80 | struct arch_timer_mem_frame { |