bhyve: fix restore of kernel structs

vmx_snapshot() and svm_snapshot() do not save any data and error occurs at
resume:

Restoring kernel structs...
vm_restore_kern_struct: Kernel struct size was 0 for: vmx
Failed to restore kernel structs.

Reviewed by:		corvink, markj
Fixes:			39ec056e6d ("vmm: Rework snapshotting of CPU-specific per-vCPU data.")
MFC after:		2 weeks
Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D38476
This commit is contained in:
Vitaliy Gusev 2023-02-28 11:32:49 +01:00 committed by Corvin Köhne
parent 281b496f22
commit 8104fc31a2
No known key found for this signature in database
GPG Key ID: D854DA56315E026A
6 changed files with 1 additions and 26 deletions

View File

@ -184,7 +184,6 @@ typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max);
typedef void (*vmi_vmspace_free)(struct vmspace *vmspace);
typedef struct vlapic * (*vmi_vlapic_init)(void *vcpui);
typedef void (*vmi_vlapic_cleanup)(struct vlapic *vlapic);
typedef int (*vmi_snapshot_t)(void *vmi, struct vm_snapshot_meta *meta);
typedef int (*vmi_snapshot_vcpu_t)(void *vcpui, struct vm_snapshot_meta *meta);
typedef int (*vmi_restore_tsc_t)(void *vcpui, uint64_t now);
@ -210,7 +209,6 @@ struct vmm_ops {
vmi_vlapic_cleanup vlapic_cleanup;
/* checkpoint operations */
vmi_snapshot_t snapshot;
vmi_snapshot_vcpu_t vcpu_snapshot;
vmi_restore_tsc_t restore_tsc;
};

View File

@ -47,8 +47,7 @@
struct vmctx;
enum snapshot_req {
STRUCT_VMX,
STRUCT_VIOAPIC,
STRUCT_VIOAPIC = 1,
STRUCT_VM,
STRUCT_VLAPIC,
VM_MEM,

View File

@ -2415,15 +2415,6 @@ svm_vlapic_cleanup(struct vlapic *vlapic)
}
#ifdef BHYVE_SNAPSHOT
static int
svm_snapshot(void *vmi, struct vm_snapshot_meta *meta)
{
if (meta->op == VM_SNAPSHOT_RESTORE)
flush_by_asid();
return (0);
}
static int
svm_vcpu_snapshot(void *vcpui, struct vm_snapshot_meta *meta)
{
@ -2656,7 +2647,6 @@ const struct vmm_ops vmm_ops_amd = {
.vlapic_init = svm_vlapic_init,
.vlapic_cleanup = svm_vlapic_cleanup,
#ifdef BHYVE_SNAPSHOT
.snapshot = svm_snapshot,
.vcpu_snapshot = svm_vcpu_snapshot,
.restore_tsc = svm_restore_tsc,
#endif

View File

@ -4093,12 +4093,6 @@ vmx_vlapic_cleanup(struct vlapic *vlapic)
}
#ifdef BHYVE_SNAPSHOT
static int
vmx_snapshot(void *vmi, struct vm_snapshot_meta *meta)
{
return (0);
}
static int
vmx_vcpu_snapshot(void *vcpui, struct vm_snapshot_meta *meta)
{
@ -4254,7 +4248,6 @@ const struct vmm_ops vmm_ops_intel = {
.vlapic_init = vmx_vlapic_init,
.vlapic_cleanup = vmx_vlapic_cleanup,
#ifdef BHYVE_SNAPSHOT
.snapshot = vmx_snapshot,
.vcpu_snapshot = vmx_vcpu_snapshot,
.restore_tsc = vmx_restore_tsc,
#endif

View File

@ -254,7 +254,6 @@ DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace))
DEFINE_VMMOPS_IFUNC(struct vlapic *, vlapic_init, (void *vcpui))
DEFINE_VMMOPS_IFUNC(void, vlapic_cleanup, (struct vlapic *vlapic))
#ifdef BHYVE_SNAPSHOT
DEFINE_VMMOPS_IFUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta))
DEFINE_VMMOPS_IFUNC(int, vcpu_snapshot, (void *vcpui,
struct vm_snapshot_meta *meta))
DEFINE_VMMOPS_IFUNC(int, restore_tsc, (void *vcpui, uint64_t now))
@ -2917,9 +2916,6 @@ vm_snapshot_req(struct vm *vm, struct vm_snapshot_meta *meta)
int ret = 0;
switch (meta->dev_req) {
case STRUCT_VMX:
ret = vmmops_snapshot(vm->cookie, meta);
break;
case STRUCT_VMCX:
ret = vm_snapshot_vcpu(vm, meta);
break;

View File

@ -155,7 +155,6 @@ static const struct vm_snapshot_dev_info snapshot_devs[] = {
static const struct vm_snapshot_kern_info snapshot_kern_structs[] = {
{ "vhpet", STRUCT_VHPET },
{ "vm", STRUCT_VM },
{ "vmx", STRUCT_VMX },
{ "vioapic", STRUCT_VIOAPIC },
{ "vlapic", STRUCT_VLAPIC },
{ "vmcx", STRUCT_VMCX },