Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andre Przywara and committed by
Marc Zyngier
ee793049 49a57857

+10 -2
+9 -2
drivers/clocksource/arm_arch_timer.c
··· 1206 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 1216 static int __init arch_timer_of_init(struct device_node *np) 1210 1217 { 1211 1218 int i, ret; ··· 1227 1220 for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) 1228 1221 arch_timer_ppi[i] = irq_of_parse_and_map(np, i); 1229 1222 1230 - arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; 1223 + arch_timer_populate_kvm_info(); 1231 1224 1232 1225 rate = arch_timer_get_cntfrq(); 1233 1226 arch_timer_of_configure_rate(rate, np); ··· 1557 1550 arch_timer_ppi[ARCH_TIMER_HYP_PPI] = 1558 1551 acpi_gtdt_map_ppi(ARCH_TIMER_HYP_PPI); 1559 1552 1560 - arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; 1553 + arch_timer_populate_kvm_info(); 1561 1554 1562 1555 /* 1563 1556 * When probing via ACPI, we have no mechanism to override the sysreg
+1
include/clocksource/arm_arch_timer.h
··· 74 74 struct arch_timer_kvm_info { 75 75 struct timecounter timecounter; 76 76 int virtual_irq; 77 + int physical_irq; 77 78 }; 78 79 79 80 struct arch_timer_mem_frame {