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

KVM: arm/arm64: Enable Dirty Page logging for ARMv8

This patch enables ARMv8 ditry page logging support. Plugs ARMv8 into generic
layer through Kconfig symbol, and drops earlier ARM64 constraints to enable
logging at architecture layer.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Mario Smarduch <m.smarduch@samsung.com>

authored by

Mario Smarduch and committed by
Christoffer Dall
7276030a 9836c6b9

+13 -24
-12
arch/arm/include/asm/kvm_host.h
··· 221 221 kvm_call_hyp((void*)hyp_stack_ptr, vector_ptr, pgd_ptr); 222 222 } 223 223 224 - /** 225 - * kvm_flush_remote_tlbs() - flush all VM TLB entries 226 - * @kvm: pointer to kvm structure. 227 - * 228 - * Interface to HYP function to flush all VM TLB entries without address 229 - * parameter. 230 - */ 231 - static inline void kvm_flush_remote_tlbs(struct kvm *kvm) 232 - { 233 - kvm_call_hyp(__kvm_tlb_flush_vmid, kvm); 234 - } 235 - 236 224 static inline int kvm_arch_dev_ioctl_check_extension(long ext) 237 225 { 238 226 return 0;
-4
arch/arm/kvm/arm.c
··· 808 808 */ 809 809 int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) 810 810 { 811 - #ifdef CONFIG_ARM 812 811 bool is_dirty = false; 813 812 int r; 814 813 ··· 820 821 821 822 mutex_unlock(&kvm->slots_lock); 822 823 return r; 823 - #else /* arm64 */ 824 - return -EINVAL; 825 - #endif 826 824 } 827 825 828 826 static int kvm_vm_ioctl_set_device_addr(struct kvm *kvm,
+11 -8
arch/arm/kvm/mmu.c
··· 52 52 53 53 static bool memslot_is_logging(struct kvm_memory_slot *memslot) 54 54 { 55 - #ifdef CONFIG_ARM 56 55 return memslot->dirty_bitmap && !(memslot->flags & KVM_MEM_READONLY); 57 - #else 58 - return false; 59 - #endif 56 + } 57 + 58 + /** 59 + * kvm_flush_remote_tlbs() - flush all VM TLB entries for v7/8 60 + * @kvm: pointer to kvm structure. 61 + * 62 + * Interface to HYP function to flush all VM TLB entries 63 + */ 64 + void kvm_flush_remote_tlbs(struct kvm *kvm) 65 + { 66 + kvm_call_hyp(__kvm_tlb_flush_vmid, kvm); 60 67 } 61 68 62 69 static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) ··· 957 950 return !pfn_valid(pfn); 958 951 } 959 952 960 - #ifdef CONFIG_ARM 961 953 /** 962 954 * stage2_wp_ptes - write protect PMD range 963 955 * @pmd: pointer to pmd entry ··· 1101 1095 1102 1096 stage2_wp_range(kvm, start, end); 1103 1097 } 1104 - #endif 1105 1098 1106 1099 static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, 1107 1100 struct kvm_memory_slot *memslot, unsigned long hva, ··· 1516 1511 const struct kvm_memory_slot *old, 1517 1512 enum kvm_mr_change change) 1518 1513 { 1519 - #ifdef CONFIG_ARM 1520 1514 /* 1521 1515 * At this point memslot has been committed and there is an 1522 1516 * allocated dirty_bitmap[], dirty pages will be be tracked while the ··· 1523 1519 */ 1524 1520 if (change != KVM_MR_DELETE && mem->flags & KVM_MEM_LOG_DIRTY_PAGES) 1525 1521 kvm_mmu_wp_memory_region(kvm, mem->slot); 1526 - #endif 1527 1522 } 1528 1523 1529 1524 int kvm_arch_prepare_memory_region(struct kvm *kvm,
+2
arch/arm64/kvm/Kconfig
··· 22 22 select PREEMPT_NOTIFIERS 23 23 select ANON_INODES 24 24 select HAVE_KVM_CPU_RELAX_INTERCEPT 25 + select HAVE_KVM_ARCH_TLB_FLUSH_ALL 25 26 select KVM_MMIO 26 27 select KVM_ARM_HOST 27 28 select KVM_ARM_VGIC 28 29 select KVM_ARM_TIMER 30 + select KVM_GENERIC_DIRTYLOG_READ_PROTECT 29 31 ---help--- 30 32 Support hosting virtualized guest machines. 31 33