text: Q:
  
  How kvm guest access Virtual timer in ARM
  
  ARMv7 architectures with hardware virtualization support also include virtualization support for timers and the interrupt controller. 
  I would like to know how guest access virtual timer in this Virtualized environment?
  Is it like when guest trying to access virtual timer it(Guest KVM) would Inject virtual interrupt(kvm_vgic_inject_irq) to vgic code?
  Could any one please provide the details on Guest access Virtual timer in ARM?
  EDIT
  I am trying to understand source flow from the point Guest access the Virtual timer. As per my understanding 
  When KVM Guest trying to access(read VTimer tick/count) , it would inject virtual interrupt to vgic code via ach_timer.c
                      kvm_timer_inject_irq()
                               |
                               |
                       kvm_vgic_inject_irq()
                               |                                 
                               |
                         kvm_vcpu_kick()  
                               | 
                               | 
                         timer_handler()
                               |
                               |
                        arch_timer_reg_read()
                               |
                               |
                      arch_timer_reg_read_cp15()    
  
  Also,reading Vtimer count from guest would not generate any trap as can't find any vmexit or vmentry in code flow, right?
  
  A:
  
  I will divide the answer into two parts:
  1. Accessing Virtual Timer registers:
  The guest OS will be accessing a Virtual timer. KVM will keep a copy of the Virtual Timer registers in VM context for each VM in the system. This (timer) context will be switching IN/OUT during VM switching. In addition to this, Virtual timer's counter can be adjusted by Host Kernel using the Timer Offset register. (The adjustment is done to account for lost ticks when other Guest VMs were executing). These two mechanisms allows KVM to switch between VM's and virtualize the timer registers.
  2. Routing of Virtual timer interrupts
  All interrupts in the system are routed through KVM. KVM decides based on the interrupt number (and other paramater) as to which Guest should be getting the interrupt. Once a decision is made to deliver the interrupt, KVM will ask the VCPU interface of VGIC to fire an interrupt for the particual VM. Essentially the Virtual timer interrupt is routed to Guest VM just like any other Interrupt in the system
  The call trace you have pasted in your question, shows how an interrupt is generally handled. The 'timer_handler' was called, because in this particular instance the timer interrupt fired, the top half of the trace would remain pretty much same for any interrupt.
  
  