From nobody Tue Feb 28 12:38:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PQxk80by3z3vPwy; Tue, 28 Feb 2023 12:38:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PQxk76RfFz43y4; Tue, 28 Feb 2023 12:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677587919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kSkzwBEbH7JhL2GMhqEFbCiu64SnoGYDFrbmUV7QfTI=; b=N7+R0ibYHY5q667CZA7ooY3sb5mAMy2zw7jlQJQqdSoDNd+MTizJszdLrbQyZisFo5Dxsb hdw8bbnesX8nCLi7iE1bIljQUkFgkMCsO1T+SMInCn0AiZWZx+RkZ73yjeKhoi613p9Xzy BUuwL9u4HcBIH5x7Bf0kCIAu3ZcDSycBi8SyUDA/M8Xk/bNe2zoiD5fRPeq4C4baldr5nm 3Sl/oGubaN39fdCOJOhuud2FjeICiRU3rLHw8Kq2PACPvQYlYnvRbsykWW5UfM1KDSqauv LKraVPP7fhm/9zHIhaqCbu9yQbBJcWbr586mDQ9XLColMC6uG0bAN/1n9bLIUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677587919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kSkzwBEbH7JhL2GMhqEFbCiu64SnoGYDFrbmUV7QfTI=; b=ACt665CBPO5XIsT0RDDLoQZHDshDm5x/ZdxV7x+JG3Nt3uAxsJaQIXI7Z0IEpHq5zrd++A sjwjj1r5WownN1ZZkA1+5AWDPGU2WuxPNi71RkA6AwhqMJfmNFxnsoHEn1UFq098wRYjPf urQW4n4iga8rpHJO6vBB7wBQ2jWfIwiO2wLo2XrAan7m/uLAV7vPfIpeww6TTVUNYUReHH BydXxbbr5r9AKJfRV2igQIylhFefbxVNvmrDKYCwcBqbjXX6JPb3KP1JVGL73DMZ0Cys7i GZyPMT6D/HbwGMPd2zVCxpEyiJBzZMWroICSPs1K7pzLjuq/Zw8AUa0cWDZM3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677587919; a=rsa-sha256; cv=none; b=QmylFEKr+GoCIn+m9iO2oI9kYeOYhk1VRjhGeA3dG/d3DbRWI8hB+/F3zEzYJbQO9C683m oZflerLYV0uxrr7nzbRB2UDaYJIJda+fgWl2GgJmPJ2Bq86yz0TKhF2ZpZzzjE6JJP45Wh rUVx16gSeGv59qHfVS2mUb1phTGX4Cra7FVkYDhpH16Er7avByfAJVFUa28qcGxBZEhT3E kqf7R2eX8zrGKbnWkHq9YVO4Y6AHe+lHy21hyHhnFkMeXst/VSp8xcF9HaZkHxraSWeNVX nWlNte9iOJg+JL+eQXWv+7WIHDTNWO3l6L8NtG1I1Z+k1rNiZtUoY52nU2hx1g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PQxk75YDLz16gw; Tue, 28 Feb 2023 12:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31SCcdMT043075; Tue, 28 Feb 2023 12:38:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31SCcdF0043074; Tue, 28 Feb 2023 12:38:39 GMT (envelope-from git) Date: Tue, 28 Feb 2023 12:38:39 GMT Message-Id: <202302281238.31SCcdF0043074@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 8104fc31a234 - main - bhyve: fix restore of kernel structs List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8104fc31a234bad1ba68910f66876395fc58ebdc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=8104fc31a234bad1ba68910f66876395fc58ebdc commit 8104fc31a234bad1ba68910f66876395fc58ebdc Author: Vitaliy Gusev AuthorDate: 2023-02-28 10:32:49 +0000 Commit: Corvin Köhne CommitDate: 2023-02-28 12:37:53 +0000 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: 39ec056e6dbd89e26ee21d2928dbd37335de0ebc ("vmm: Rework snapshotting of CPU-specific per-vCPU data.") MFC after: 2 weeks Sponsored by: vStack Differential Revision: https://reviews.freebsd.org/D38476 --- sys/amd64/include/vmm.h | 2 -- sys/amd64/include/vmm_snapshot.h | 3 +-- sys/amd64/vmm/amd/svm.c | 10 ---------- sys/amd64/vmm/intel/vmx.c | 7 ------- sys/amd64/vmm/vmm.c | 4 ---- usr.sbin/bhyve/snapshot.c | 1 - 6 files changed, 1 insertion(+), 26 deletions(-) diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h index bd6510b92527..4d6242a8134d 100644 --- a/sys/amd64/include/vmm.h +++ b/sys/amd64/include/vmm.h @@ -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; }; diff --git a/sys/amd64/include/vmm_snapshot.h b/sys/amd64/include/vmm_snapshot.h index d08f980e7988..c4d7fc4d4371 100644 --- a/sys/amd64/include/vmm_snapshot.h +++ b/sys/amd64/include/vmm_snapshot.h @@ -47,8 +47,7 @@ struct vmctx; enum snapshot_req { - STRUCT_VMX, - STRUCT_VIOAPIC, + STRUCT_VIOAPIC = 1, STRUCT_VM, STRUCT_VLAPIC, VM_MEM, diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c index ee1154ef85b6..d995b68ebdc6 100644 --- a/sys/amd64/vmm/amd/svm.c +++ b/sys/amd64/vmm/amd/svm.c @@ -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 diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index fa94c707001c..91406f0614ce 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -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 diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 794ec5ab6597..36a129e8ec8f 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -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; diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 0c9e32abd326..6143f6f3a489 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -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 },