[PATCH v2 1/2] KVM: arm64: Fix dirty logging detection in ring-only mode
Leonardo Bras
leo.bras at arm.com
Fri Oct 30 04:42:03 PDT 2026
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 at linux.dev>
> Tested-by: Fuad Tabba <fuad.tabba at linux.dev>
> Signed-off-by: Wei-Lin Chang <weilin.chang at arm.com>
> Cc: stable at 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 at arm.com>
Awesome, thanks for taking the suggestion!
Leo
More information about the linux-arm-kernel
mailing list