Skip to content

Commit 676f819

Browse files
bibo-maobonzini
authored andcommitted
KVM: Discard zero mask with function kvm_dirty_ring_reset
Function kvm_reset_dirty_gfn may be called with parameters cur_slot / cur_offset / mask are all zero, it does not represent real dirty page. It is not necessary to clear dirty page in this condition. Also return value of macro __fls() is undefined if mask is zero which is called in funciton kvm_reset_dirty_gfn(). Here just return. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Message-ID: <20240613122803.1031511-1-maobibo@loongson.cn> [Move the conditional inside kvm_reset_dirty_gfn; suggested by Sean Christopherson. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent c31745d commit 676f819

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

virt/kvm/dirty_ring.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ static void kvm_reset_dirty_gfn(struct kvm *kvm, u32 slot, u64 offset, u64 mask)
5555
struct kvm_memory_slot *memslot;
5656
int as_id, id;
5757

58+
if (!mask)
59+
return;
60+
5861
as_id = slot >> 16;
5962
id = (u16)slot;
6063

0 commit comments

Comments
 (0)