]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
KVM: x86: Introducing kvm_x86_ops VM init/destroy hooks
authorSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Wed, 4 May 2016 19:09:42 +0000 (14:09 -0500)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Sat, 11 Aug 2018 00:44:37 +0000 (20:44 -0400)
Adding function pointers in struct kvm_x86_ops for processor-specific
layer to provide hooks for when KVM initialize and destroy VM.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Orabug: 28220674
CVE: CVE-2018-3646

(cherry picked from commit 03543133cea646406307870823343912c1ef0a3a)

Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Conflicts:
arch/x86/kvm/x86.c
Contextual: different content
The commit was necessary for 47009da5 "x86/KVM: Warn user if KVM
is loaded SMT and L1TF CPU bug being present"

arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c

index 4b3cc2be726015f40359454f4f8ba3e3c1d7b6fa..10dd34d36ccd3909793f670103ef1887a7fec286 100644 (file)
@@ -711,6 +711,9 @@ struct kvm_x86_ops {
        bool (*has_emulated_msr)(int index);
        void (*cpuid_update)(struct kvm_vcpu *vcpu);
 
+       int (*vm_init)(struct kvm *kvm);
+       void (*vm_destroy)(struct kvm *kvm);
+
        /* Create, but do not attach this VCPU */
        struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
        void (*vcpu_free)(struct kvm_vcpu *vcpu);
index 70c5796c14e8064c6a6929dd9cffa98a87f9f2f0..d128875fd642db962396d921981ca99dbe9a382c 100644 (file)
@@ -7456,6 +7456,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
        INIT_DELAYED_WORK(&kvm->arch.kvmclock_update_work, kvmclock_update_fn);
        INIT_DELAYED_WORK(&kvm->arch.kvmclock_sync_work, kvmclock_sync_fn);
 
+       if (kvm_x86_ops->vm_init)
+               return kvm_x86_ops->vm_init(kvm);
+
        return 0;
 }
 
@@ -7518,6 +7521,8 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
                mem.slot = TSS_PRIVATE_MEMSLOT;
                kvm_set_memory_region(kvm, &mem);
        }
+       if (kvm_x86_ops->vm_destroy)
+               kvm_x86_ops->vm_destroy(kvm);
        kvm_iommu_unmap_guest(kvm);
        kfree(kvm->arch.vpic);
        kfree(kvm->arch.vioapic);