Skip to content

Commit 4674164

Browse files
committed
KVM: SEV: do not use list_replace_init on an empty list
list_replace_init cannot be used if the source is an empty list, because "new->next->prev = new" will overwrite "old->next": new old prev = new, next = new prev = old, next = old new->next = old->next prev = new, next = old prev = old, next = old new->next->prev = new prev = new, next = old prev = old, next = new new->prev = old->prev prev = old, next = old prev = old, next = old new->next->prev = new prev = old, next = old prev = new, next = new The desired outcome instead would be to leave both old and new the same as they were (two empty circular lists). Use list_cut_before, which already has the necessary check and is documented to discard the previous contents of the list that will hold the result. Fixes: b566393 ("KVM: SEV: Add support for SEV intra host migration") Reviewed-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 53b7ca1 commit 4674164

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,8 +1613,7 @@ static void sev_migrate_from(struct kvm_sev_info *dst,
16131613
src->handle = 0;
16141614
src->pages_locked = 0;
16151615

1616-
INIT_LIST_HEAD(&dst->regions_list);
1617-
list_replace_init(&src->regions_list, &dst->regions_list);
1616+
list_cut_before(&dst->regions_list, &src->regions_list, &src->regions_list);
16181617
}
16191618

16201619
static int sev_es_migrate_from(struct kvm *dst, struct kvm *src)

0 commit comments

Comments
 (0)