ARM: arch_timers: enable the use of the virtual timer

At the moment, the arch_timer driver only uses the physical timer,
which can cause problem if PL2 hasn't enabled PL1 access in CNTHCTL,
which is likely in a virtualized environment. Instead, the virtual
timer is always available.

This patch enables the use of the virtual timer, unless no
interrupt is provided in the DT for it, in which case it falls
back to the physical timer.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
ARM: arch_timers: register a time/cycle counter

Some subsystems (KVM for example) need access to a cycle counter.
In the KVM case, this is used to measure the time delta between
host and guest in order to accurately generate timer events for
the guest.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
ARM: arch_timers: switch to physical timers if HYP mode is available

If we're booted in HYP mode, it is possible that we'll run some
kind of virtualized environment. In this case, it is a better to
switch to the physical timers, and leave the virtual timers to
guests.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
ARM: KVM: arch_timers: Add minimal infrastructure

Add some very minimal architected timer related infrastructure.
For the moment, we just provide empty structures, and enable/disable
access to the physical timer across world switch.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
ARM: KVM: arch_timers: Add guest timer core support

We can inject a timer interrupt into the guest as a result of
three possible events:
- The virtual timer interrupt has fired while we were still
  executing the guest
- The timer interrupt hasn't fired, but it expired while we
  were doing the world switch
- A hrtimer we programmed earlier has fired

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
ARM: KVM: arch_timers: Add timer world switch

Do the necessary save/restore dance for the timers in the world
switch code. In the process, allow the guest to read the physical
counter, which is useful for its own clock_event_device.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
ARM: KVM: arch_timers: Wire the init code and config option

It is now possible to select CONFIG_KVM_ARM_TIMER to enable the
KVM architected timer support.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
KVM: ARM: Cleanup _kvm_va_t_pa

Co-written with Marc Zyngier (in pair - yeah!) this is just better.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Use stage2 page table format for change_pte

When mmu notifiers merges a page, make sure the new guest page table
entry uses the stage2 format.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
fixup! KVM: ARM: Cleanup _kvm_va_t_pa

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
Revert "fixup! KVM: ARM: Cleanup _kvm_va_t_pa"

Turns out we need to change almost all the CP15 registers anyhow.

This reverts commit d6e6d9372fffe2eb53727a063ce164e31c9b5467.
Revert "KVM: ARM: Cleanup _kvm_va_t_pa"

This reverts commit 128220941c2b2e5d1161cdf15076e834f16925db.
KVM: ARM: Allow non hsr.isv mmio to go through vgic

When the guest uses mmio operations that do not have decode information
in the HSR, we decode these instructions manually, but the instruction
may be used to access the vgic distributor interface emulated inside the
kernel so we have to go through that path for both values of HSR.ISV.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
fixup! KVM: ARM: Allow non hsr.isv mmio to go through vgic

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
Merge remote-tracking branch 'marc/kvm-arm-v3.6-rc3-timer' into kvm-arm-master
fixup! ARM: KVM: arch_timers: Wire the init code and config option

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Wrap pte access in pte_val

Make sure this compiles under debug options.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
KVM: ARM: Don't pin guest pages

We need to put the extra reference from get_user_pages, as we are
notified through MMU notifiers required by KVM/ARM.

Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>