kernel-ark/arch/arm/kvm
Catalin Marinas 0648505324 kvm: arm64: Enable hardware updates of the Access Flag for Stage 2 page tables
The ARMv8.1 architecture extensions introduce support for hardware
updates of the access and dirty information in page table entries. With
VTCR_EL2.HA enabled (bit 21), when the CPU accesses an IPA with the
PTE_AF bit cleared in the stage 2 page table, instead of raising an
Access Flag fault to EL2 the CPU sets the actual page table entry bit
(10). To ensure that kernel modifications to the page table do not
inadvertently revert a bit set by hardware updates, certain Stage 2
software pte/pmd operations must be performed atomically.

The main user of the AF bit is the kvm_age_hva() mechanism. The
kvm_age_hva_handler() function performs a "test and clear young" action
on the pte/pmd. This needs to be atomic in respect of automatic hardware
updates of the AF bit. Since the AF bit is in the same position for both
Stage 1 and Stage 2, the patch reuses the existing
ptep_test_and_clear_young() functionality if
__HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG is defined. Otherwise, the
existing pte_young/pte_mkold mechanism is preserved.

The kvm_set_s2pte_readonly() (and the corresponding pmd equivalent) have
to perform atomic modifications in order to avoid a race with updates of
the AF bit. The arm64 implementation has been re-written using
exclusives.

Currently, kvm_set_s2pte_writable() (and pmd equivalent) take a pointer
argument and modify the pte/pmd in place. However, these functions are
only used on local variables rather than actual page table entries, so
it makes more sense to follow the pte_mkwrite() approach for stage 1
attributes. The change to kvm_s2pte_mkwrite() makes it clear that these
functions do not modify the actual page table entries.

The (pte|pmd)_mkyoung() uses on Stage 2 entries (setting the AF bit
explicitly) do not need to be modified since hardware updates of the
dirty status are not supported by KVM, so there is no possibility of
losing such information.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
2016-05-09 22:23:08 +02:00
..
hyp ARM: KVM: Use common version of timer-sr.c 2016-02-29 18:34:19 +00:00
arm.c kvm-arm: Cleanup stage2 pgd handling 2016-04-21 14:58:23 +02:00
coproc_a7.c arm/arm64: KVM: Use set/way op trapping to track the state of the caches 2015-01-29 23:24:56 +01:00
coproc_a15.c arm/arm64: KVM: Use set/way op trapping to track the state of the caches 2015-01-29 23:24:56 +01:00
coproc.c ARM: KVM: Switch the CP reg search to be a binary search 2016-02-29 18:34:22 +00:00
coproc.h ARM: KVM: Rename struct coproc_reg::is_64 to is_64bit 2016-02-29 18:34:22 +00:00
emulate.c ARM: KVM: Move GP registers into the CPU context structure 2016-02-29 18:34:12 +00:00
guest.c One of the largest releases for KVM... Hardly any generic improvement, 2016-03-16 09:55:35 -07:00
handle_exit.c ARM: KVM: Remove handling of ARM_EXCEPTION_DATA/PREF_ABORT 2016-02-29 18:34:15 +00:00
init.S ARM: KVM: Switch to C-based stage2 init 2016-02-29 18:34:14 +00:00
interrupts.S ARM: KVM: Remove the old world switch 2016-02-29 18:34:14 +00:00
Kconfig arm/arm64: KVM : Enable vhost device selection under KVM config menu 2015-10-22 23:01:45 +02:00
Makefile ARM: KVM: Add TLB invalidation code 2016-02-29 18:34:13 +00:00
mmio.c arm/arm64: KVM: Feed initialized memory to MMIO accesses 2016-02-24 11:53:09 +00:00
mmu.c kvm: arm64: Enable hardware updates of the Access Flag for Stage 2 page tables 2016-05-09 22:23:08 +02:00
perf.c ARM: KVM: add support for minimal host vs guest profiling 2013-04-28 21:44:01 -07:00
psci.c KVM: Use simple waitqueue for vcpu->wq 2016-02-25 11:27:16 +01:00
reset.c ARM: KVM: Move GP registers into the CPU context structure 2016-02-29 18:34:12 +00:00
trace.h arm/arm64: KVM: Improve kvm_exit tracepoint 2015-10-22 23:01:47 +02:00