]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: SEV: initialize regions_list of a mirror VM
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Nov 2021 00:50:30 +0000 (19:50 -0500)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:49:10 +0000 (09:49 +0100)
BugLink: https://bugs.launchpad.net/bugs/1953731
[ Upstream commit 2b347a387811cb4aa7bcdb96e9203c5019a6fb41 ]

This was broken before the introduction of KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM,
but technically harmless because the region list was unused for a mirror
VM.  However, it is untidy and it now causes a NULL pointer access when
attempting to move the encryption context of a mirror VM.

Fixes: 54526d1fd593 ("KVM: x86: Support KVM VMs sharing SEV context")
Message-Id: <20211123005036.2954379-7-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
arch/x86/kvm/svm/sev.c

index ff19ce0780fea24d0739714aac6ce2fe2590b9ac..ca0effb79eab9f4b47a3fbbf75146624d9102a63 100644 (file)
@@ -1805,6 +1805,7 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd)
        mirror_sev->fd = source_sev.fd;
        mirror_sev->es_active = source_sev.es_active;
        mirror_sev->handle = source_sev.handle;
+       INIT_LIST_HEAD(&mirror_sev->regions_list);
        /*
         * Do not copy ap_jump_table. Since the mirror does not share the same
         * KVM contexts as the original, and they may have different