euleros inclusion category: feature bugzilla: NA CVE: NA
Add the interface kvm_vm_ioctl_clear_dirty_log for clearing the log of dirty pages in a slot. In addition, config KVM_GENERIC_DIRTYLOG_READ_PROTECT is added in defconfig.
Link: https://gitee.com/openeuler/kernel/issues/I1SWY2 Signed-off-by: Yifei Jiang jiangyifei@huawei.com Signed-off-by: Yipeng Yin yinyipeng1@huawei.com --- arch/riscv/configs/defconfig | 1 + arch/riscv/kvm/Kconfig | 1 + arch/riscv/kvm/vm.c | 16 ++++++++++++++++ 3 files changed, 18 insertions(+)
diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 1b8375b63..1bffcedb6 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -18,6 +18,7 @@ CONFIG_SOC_SIFIVE=y CONFIG_SMP=y CONFIG_VIRTUALIZATION=y CONFIG_KVM=y +CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y CONFIG_HOTPLUG_CPU=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y diff --git a/arch/riscv/kvm/Kconfig b/arch/riscv/kvm/Kconfig index 95d85d893..2fb5867de 100644 --- a/arch/riscv/kvm/Kconfig +++ b/arch/riscv/kvm/Kconfig @@ -28,6 +28,7 @@ config KVM select HAVE_KVM_VCPU_ASYNC_IOCTL select SRCU select HAVE_KVM_EVENTFD + select KVM_GENERIC_DIRTYLOG_READ_PROTECT help Support hosting virtualized guest machines.
diff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c index 26c228577..e95d3dd3e 100644 --- a/arch/riscv/kvm/vm.c +++ b/arch/riscv/kvm/vm.c @@ -47,6 +47,22 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) return r; }
+int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm, struct kvm_clear_dirty_log *log) +{ + bool flush = false; + int r; + + mutex_lock(&kvm->slots_lock); + + r = kvm_clear_dirty_log_protect(kvm, log, &flush); + + if (flush) + kvm_flush_remote_tlbs(kvm); + + mutex_unlock(&kvm->slots_lock); + return r; +} + int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) { int r;