@@ -1877,17 +1877,21 @@ int kvm_arch_disable_dirty_logging(struct kvm *kvm, const struct kvm_memory_slot
r = page_tracking_disable(kvm->arch.page_tracking_ctx, -1);
- if (r == -EBUSY) {
- r = 0;
- } else {
- page_tracking_release(kvm->arch.page_tracking_ctx);
- kvm->arch.page_tracking_ctx = NULL;
+ if (r == -EBUSY)
+ return 0;
- if (kvm->arch.page_tracking_pg) {
- free_page((unsigned long)kvm->arch.page_tracking_pg);
- kvm->arch.page_tracking_pg = NULL;
- }
+ /* Flush only when dirty tracking is disabled */
+ if (!r)
+ r = page_tracking_flush(kvm->arch.page_tracking_ctx);
+
+ /* But release resources anyway */
+ page_tracking_release(kvm->arch.page_tracking_ctx);
+ kvm->arch.page_tracking_ctx = NULL;
+ if (kvm->arch.page_tracking_pg) {
+ free_page((unsigned long)kvm->arch.page_tracking_pg);
+ kvm->arch.page_tracking_pg = NULL;
}
+
return r;
}
Make sure we do not miss last dirty pages and flush the data after disabling dirty logging. Flush only when dirty logging is actually disabled i.e. when page_tracking_disable returns 0. Signed-off-by: Lilit Janpoladyan <lilitj@amazon.com> --- arch/arm64/kvm/arm.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)