* [PATCH v2 0/2] KVM: arm64: Dirty logging fixes/cleanups
@ 2026-10-29 17:52 Wei-Lin Chang
2026-10-29 17:52 ` [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode Wei-Lin Chang
2026-10-29 17:52 ` [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment Wei-Lin Chang
0 siblings, 2 replies; 8+ messages in thread
From: Wei-Lin Chang @ 2026-10-29 17:52 UTC (permalink / raw)
To: linux-arm-kernel, kvmarm, linux-kernel
Cc: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden,
Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon,
Mark Rutland, Gavin Shan, Leonardo Bras, Wei-Lin Chang
Hi,
These are two fixes/cleanups I found when reading the code. It fixes
dirty logging detection in ring-only mode and updates a stale comment.
Please view the patches for more detail.
* Changes from v1 ([1]):
- Keep memslot_is_logging() and use kvm_slot_dirty_track_enabled() in
it. This preserves the RO memslot check.
- Change patch 2 to updating the stale comment only, the original
change is obsolete now.
- Collect Reviewed-by and Tested-by tags from Fuad (thanks!).
Thanks!
[1]: https://lore.kernel.org/kvmarm/20260605153248.2412064-1-weilin.chang@arm.com/
Wei-Lin Chang (2):
KVM: arm64: Fix dirty logging detection in ring-only mode
KVM: arm64: Remove stale remark on canonical IPA alignment
arch/arm64/kvm/mmu.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode 2026-10-29 17:52 [PATCH v2 0/2] KVM: arm64: Dirty logging fixes/cleanups Wei-Lin Chang @ 2026-10-29 17:52 ` Wei-Lin Chang 2026-10-30 5:11 ` Gavin Shan 2026-10-30 11:42 ` Leonardo Bras 2026-10-29 17:52 ` [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment Wei-Lin Chang 1 sibling, 2 replies; 8+ messages in thread From: Wei-Lin Chang @ 2026-10-29 17:52 UTC (permalink / raw) To: linux-arm-kernel, kvmarm, linux-kernel Cc: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon, Mark Rutland, Gavin Shan, Leonardo Bras, Wei-Lin Chang, stable When checking whether a memslot has dirty logging enabled, the KVM_MEM_LOG_DIRTY_PAGES flag is the source of truth. Previously in memslot_is_logging() we were testing the dirty bitmap only and did not consider dirty ring. With the ring and no bitmap, a logged memslot can still get block mappings, so guest writes to most of a block are never logged and a migration can copy stale memory. Fix this by using kvm_slot_dirty_track_enabled() instead which checks KVM_MEM_LOG_DIRTY_PAGES, within memslot_is_logging(). Fixes: 9cb1096f8590 ("KVM: arm64: Enable ring-based dirty memory tracking") Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Tested-by: Fuad Tabba <fuad.tabba@linux.dev> Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com> Cc: stable@vger.kernel.org --- arch/arm64/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 705f6d84770e..c7df646af79f 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -176,7 +176,7 @@ static int kvm_mmu_split_huge_pages(struct kvm *kvm, phys_addr_t addr, static bool memslot_is_logging(struct kvm_memory_slot *memslot) { - return memslot->dirty_bitmap && !(memslot->flags & KVM_MEM_READONLY); + return kvm_slot_dirty_track_enabled(memslot) && !(memslot->flags & KVM_MEM_READONLY); } static int pkvm_flush_remote_tlbs(struct kvm *kvm) -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode 2026-10-29 17:52 ` [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode Wei-Lin Chang @ 2026-10-30 5:11 ` Gavin Shan 2026-10-30 11:42 ` Leonardo Bras 1 sibling, 0 replies; 8+ messages in thread From: Gavin Shan @ 2026-10-30 5:11 UTC (permalink / raw) To: Wei-Lin Chang, linux-arm-kernel, kvmarm, linux-kernel Cc: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon, Mark Rutland, Leonardo Bras, stable On 10/30/26 3:52 AM, Wei-Lin Chang wrote: > When checking whether a memslot has dirty logging enabled, the > KVM_MEM_LOG_DIRTY_PAGES flag is the source of truth. Previously in > memslot_is_logging() we were testing the dirty bitmap only and did not > consider dirty ring. > > With the ring and no bitmap, a logged memslot can still get block > mappings, so guest writes to most of a block are never logged and a > migration can copy stale memory. > > Fix this by using kvm_slot_dirty_track_enabled() instead which checks > KVM_MEM_LOG_DIRTY_PAGES, within memslot_is_logging(). > > Fixes: 9cb1096f8590 ("KVM: arm64: Enable ring-based dirty memory tracking") > Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> > Tested-by: Fuad Tabba <fuad.tabba@linux.dev> > Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com> > Cc: stable@vger.kernel.org > --- > arch/arm64/kvm/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Reviewed-by: Gavin Shan <gshan@redhat.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode 2026-10-29 17:52 ` [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode Wei-Lin Chang 2026-10-30 5:11 ` Gavin Shan @ 2026-10-30 11:42 ` Leonardo Bras 1 sibling, 0 replies; 8+ messages in thread From: Leonardo Bras @ 2026-10-30 11:42 UTC (permalink / raw) To: Wei-Lin Chang Cc: Leonardo Bras, linux-arm-kernel, kvmarm, linux-kernel, Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon, Mark Rutland, Gavin Shan, stable On Thu, Oct 29, 2026 at 05:52:37PM +0000, Wei-Lin Chang wrote: > When checking whether a memslot has dirty logging enabled, the > KVM_MEM_LOG_DIRTY_PAGES flag is the source of truth. Previously in > memslot_is_logging() we were testing the dirty bitmap only and did not > consider dirty ring. > > With the ring and no bitmap, a logged memslot can still get block > mappings, so guest writes to most of a block are never logged and a > migration can copy stale memory. > > Fix this by using kvm_slot_dirty_track_enabled() instead which checks > KVM_MEM_LOG_DIRTY_PAGES, within memslot_is_logging(). > > Fixes: 9cb1096f8590 ("KVM: arm64: Enable ring-based dirty memory tracking") > Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> > Tested-by: Fuad Tabba <fuad.tabba@linux.dev> > Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com> > Cc: stable@vger.kernel.org > --- > arch/arm64/kvm/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 705f6d84770e..c7df646af79f 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -176,7 +176,7 @@ static int kvm_mmu_split_huge_pages(struct kvm *kvm, phys_addr_t addr, > > static bool memslot_is_logging(struct kvm_memory_slot *memslot) > { > - return memslot->dirty_bitmap && !(memslot->flags & KVM_MEM_READONLY); > + return kvm_slot_dirty_track_enabled(memslot) && !(memslot->flags & KVM_MEM_READONLY); > } > > static int pkvm_flush_remote_tlbs(struct kvm *kvm) > -- > 2.43.0 > Reviewed-by: Leonardo Bras <leo.bras@arm.com> Awesome, thanks for taking the suggestion! Leo ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment 2026-10-29 17:52 [PATCH v2 0/2] KVM: arm64: Dirty logging fixes/cleanups Wei-Lin Chang 2026-10-29 17:52 ` [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode Wei-Lin Chang @ 2026-10-29 17:52 ` Wei-Lin Chang 2026-10-29 18:39 ` Fuad Tabba ` (2 more replies) 1 sibling, 3 replies; 8+ messages in thread From: Wei-Lin Chang @ 2026-10-29 17:52 UTC (permalink / raw) To: linux-arm-kernel, kvmarm, linux-kernel Cc: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon, Mark Rutland, Gavin Shan, Leonardo Bras, Wei-Lin Chang Commit 3b8ce2b5132ae ("KVM: arm64: Use a variable for the canonical IPA in kvm_s2_fault_map()") created a variable to store the canonical IPA, instead of calculating it when needed. It moved the aligning just before mark_page_dirty_in_slot() to an earlier place but did not update the comment. Remove the stale part of the comment. Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com> --- arch/arm64/kvm/mmu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index c7df646af79f..695c6229a216 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -2232,11 +2232,7 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, kvm_fault_unlock(kvm); kfree(mapping); - /* - * Mark the page dirty only if the fault is handled successfully, - * making sure we adjust the canonical IPA if the mapping size has - * been updated (via a THP upgrade, for example). - */ + /* Mark the page dirty only if the fault is handled successfully. */ if (writable && !ret) mark_page_dirty_in_slot(kvm, s2fd->memslot, gpa_to_gfn(canonical_ipa)); -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment 2026-10-29 17:52 ` [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment Wei-Lin Chang @ 2026-10-29 18:39 ` Fuad Tabba 2026-10-30 5:12 ` Gavin Shan 2026-10-30 11:50 ` Leonardo Bras 2 siblings, 0 replies; 8+ messages in thread From: Fuad Tabba @ 2026-10-29 18:39 UTC (permalink / raw) To: Wei-Lin Chang Cc: linux-arm-kernel, kvmarm, linux-kernel, Marc Zyngier, Oliver Upton, Joey Gouly, Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon, Mark Rutland, Gavin Shan, Leonardo Bras On Thu, 29 Oct 2026 at 17:53, Wei-Lin Chang <weilin.chang@arm.com> wrote: > > Commit 3b8ce2b5132ae ("KVM: arm64: Use a variable for the canonical IPA > in kvm_s2_fault_map()") created a variable to store the canonical IPA, > instead of calculating it when needed. It moved the aligning just before > mark_page_dirty_in_slot() to an earlier place but did not update the > comment. > > Remove the stale part of the comment. > > Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com> Reviewed-by: Fuad Tabba <fuad.tabba@linux.dev> Cheers, /fuad ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment 2026-10-29 17:52 ` [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment Wei-Lin Chang 2026-10-29 18:39 ` Fuad Tabba @ 2026-10-30 5:12 ` Gavin Shan 2026-10-30 11:50 ` Leonardo Bras 2 siblings, 0 replies; 8+ messages in thread From: Gavin Shan @ 2026-10-30 5:12 UTC (permalink / raw) To: Wei-Lin Chang, linux-arm-kernel, kvmarm, linux-kernel Cc: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon, Mark Rutland, Leonardo Bras On 10/30/26 3:52 AM, Wei-Lin Chang wrote: > Commit 3b8ce2b5132ae ("KVM: arm64: Use a variable for the canonical IPA > in kvm_s2_fault_map()") created a variable to store the canonical IPA, > instead of calculating it when needed. It moved the aligning just before > mark_page_dirty_in_slot() to an earlier place but did not update the > comment. > > Remove the stale part of the comment. > > Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com> > --- > arch/arm64/kvm/mmu.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > Reviewed-by: Gavin Shan <gshan@redhat.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment 2026-10-29 17:52 ` [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment Wei-Lin Chang 2026-10-29 18:39 ` Fuad Tabba 2026-10-30 5:12 ` Gavin Shan @ 2026-10-30 11:50 ` Leonardo Bras 2 siblings, 0 replies; 8+ messages in thread From: Leonardo Bras @ 2026-10-30 11:50 UTC (permalink / raw) To: Wei-Lin Chang Cc: Leonardo Bras, linux-arm-kernel, kvmarm, linux-kernel, Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon, Mark Rutland, Gavin Shan On Thu, Oct 29, 2026 at 05:52:38PM +0000, Wei-Lin Chang wrote: > Commit 3b8ce2b5132ae ("KVM: arm64: Use a variable for the canonical IPA > in kvm_s2_fault_map()") created a variable to store the canonical IPA, > instead of calculating it when needed. It moved the aligning just before > mark_page_dirty_in_slot() to an earlier place but did not update the > comment. > > Remove the stale part of the comment. > > Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com> > --- > arch/arm64/kvm/mmu.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index c7df646af79f..695c6229a216 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -2232,11 +2232,7 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, > kvm_fault_unlock(kvm); > kfree(mapping); > > - /* > - * Mark the page dirty only if the fault is handled successfully, > - * making sure we adjust the canonical IPA if the mapping size has > - * been updated (via a THP upgrade, for example). > - */ > + /* Mark the page dirty only if the fault is handled successfully. */ > if (writable && !ret) > mark_page_dirty_in_slot(kvm, s2fd->memslot, > gpa_to_gfn(canonical_ipa)); > -- > 2.43.0 > Reviewed-by: Leonardo Bras <leo.bras@arm.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-10-30 11:50 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-29 17:52 [PATCH v2 0/2] KVM: arm64: Dirty logging fixes/cleanups Wei-Lin Chang 2026-10-29 17:52 ` [PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode Wei-Lin Chang 2026-10-30 5:11 ` Gavin Shan 2026-10-30 11:42 ` Leonardo Bras 2026-10-29 17:52 ` [PATCH v2 2/2] KVM: arm64: Remove stale remark on canonical IPA alignment Wei-Lin Chang 2026-10-29 18:39 ` Fuad Tabba 2026-10-30 5:12 ` Gavin Shan 2026-10-30 11:50 ` Leonardo Bras
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.