public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Lilit Janpoladyan <lilitj@amazon.com>
To: <kvm@vger.kernel.org>, <maz@kernel.org>, <oliver.upton@linux.dev>,
	<james.morse@arm.com>, <suzuki.poulose@arm.com>,
	<yuzenghui@huawei.com>, <nh-open-source@amazon.com>,
	<lilitj@amazon.com>
Subject: [PATCH 6/8] KVM: arm64: flush dirty logging data
Date: Wed, 18 Sep 2024 15:28:05 +0000	[thread overview]
Message-ID: <20240918152807.25135-7-lilitj@amazon.com> (raw)
In-Reply-To: <20240918152807.25135-1-lilitj@amazon.com>

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(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 139d7e929266..5ed049accb3e 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -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;
 }
 
-- 
2.40.1


  parent reply	other threads:[~2024-09-18 15:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18 15:27 [PATCH 0/8] *** RFC: ARM KVM dirty tracking device *** Lilit Janpoladyan
2024-09-18 15:28 ` [PATCH 1/8] arm64: add an interface for stage-2 page tracking Lilit Janpoladyan
2024-09-18 15:28 ` [PATCH 2/8] KVM: arm64: add page tracking device as a capability Lilit Janpoladyan
2024-09-18 15:28 ` [PATCH 3/8] KVM: arm64: use page tracking interface to enable dirty logging Lilit Janpoladyan
2024-09-22  7:31   ` Sean Christopherson
2024-09-18 15:28 ` [PATCH 4/8] KVM: return value from kvm_arch_sync_dirty_log Lilit Janpoladyan
2024-09-19  1:50   ` kernel test robot
2024-09-19  2:32   ` kernel test robot
2024-09-18 15:28 ` [PATCH 5/8] KVM: arm64: get dirty pages from the page tracking device Lilit Janpoladyan
2024-09-18 15:28 ` Lilit Janpoladyan [this message]
2024-09-18 15:28 ` [PATCH 7/8] KVM: arm64: enable hardware dirty state management for stage-2 Lilit Janpoladyan
2024-09-18 15:28 ` [PATCH 8/8] KVM: arm64: make hardware manage dirty state after write faults Lilit Janpoladyan
2024-09-19  9:11 ` [PATCH 0/8] *** RFC: ARM KVM dirty tracking device *** Oliver Upton
2024-09-20 10:12   ` Janpoladyan, Lilit
2024-09-26 10:00   ` David Woodhouse
2024-09-30 17:33     ` Oliver Upton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240918152807.25135-7-lilitj@amazon.com \
    --to=lilitj@amazon.com \
    --cc=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=nh-open-source@amazon.com \
    --cc=oliver.upton@linux.dev \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox