From nobody Fri Mar 17 10:29:24 2023 X-Original-To: dev-commits-src-branches@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 4PdL390vQqz3yBTW; Fri, 17 Mar 2023 10:29:25 +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 4PdL385X8Bz3Gcf; Fri, 17 Mar 2023 10:29:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679048964; 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=O0v9LsQ279LxlDn0wpRXC8qCpjdK6eHgqQ8rmdP/7Xs=; b=WsTU0FoMulQgS/+S6RKhy6IRC2wmLwZLqi7HZDgyC6GT45gGIBNmEIHQ9nksenOVq30OHe LH08cPlizHvKEkbm2pQQeII159PblhMRkPhe3Z5f1SIQz61JO7F/yOU3X5J46wn9C9C8sd TgpLufdqbr7us/28JidFFOsl/lSDr6ECtjHVCtsjgPktIlzQ1YWaYv+jwK8A6yJMJOa4I7 ilEqLaZxE2YatiLEJqn+Ap/kEusfk3g7OgDH5fRj2rmfG4l78KgqZRO5vXW18hQyB+mjzx aZ0jmHqHamtnNtlM1S+XhSecfnJdl8gzHJeXJlCa4btYNYXZoVEKxY0H1eTU8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679048964; 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=O0v9LsQ279LxlDn0wpRXC8qCpjdK6eHgqQ8rmdP/7Xs=; b=ZIVI7bzDl+QHyvCoW6kZ2FxaQb3kU59yn/2Cu0b4Zo2+it6GK/p7Tk7qJIrVWFgjbX6Yl8 YFlyL3yELEtiGll3J6mDId+ANd34HN9rYMXLC/CkFtKk092MWsjauw3RcOYKw0ODQLWdNF gmP2uMW4ywTOvFBFRNgwBVHIRpua1pVHimSxqnQVteWMuhXTLLIS927TvnqydC1fgd7Ki9 BqoGCEMgpf8FMONldPSHiOhXaCOWf66aLhS6Is1eEF2CC30V1ca/oESV/pC8p7AOKYkbOz YTXawrT53KK1F/NIChApLH3gJOplhB2oZiwm+EgOeNnfGwoIKSGUv00ByIHL3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679048964; a=rsa-sha256; cv=none; b=jVlUY+NtQlGHhkQf3kfir0Fb6Lgz/06/Ry3+sGb0sPu8gFzRgzC5CC3n8N50hm9+iHksN0 GvOYxou+hhgjC2nKMLnkg1aHEDNivVuWLJBEDUABGBw1JWQfIEeWGBqfBVkMo21FYdooaJ TZdNXhp6K2vDb1oZ7t54bOyopZLzMztvp9ucX81TxYTQGoCyXa6/vLfGNUBGlpETGAnEws PBrfZgo9TFrKSlJJtukjlB61CTuDqEakXB0EbLc0F5WJFCYhJHH0/t6AAC6QHxmi+HxGsR 1KUtk45TiIgtKDhA8swDI7Zlc0EmtVdKJmrDqt+TZvP9fIH9HHp+zXLUozHfcw== 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 4PdL384dRNzMLx; Fri, 17 Mar 2023 10:29:24 +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 32HATOfl067332; Fri, 17 Mar 2023 10:29:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32HATOZu067331; Fri, 17 Mar 2023 10:29:24 GMT (envelope-from git) Date: Fri, 17 Mar 2023 10:29:24 GMT Message-Id: <202303171029.32HATOZu067331@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 38acc80a5b69 - stable/13 - bhyve: fix restore of kernel structs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 38acc80a5b696a0f9d029b5de209b6a2045332cd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=38acc80a5b696a0f9d029b5de209b6a2045332cd commit 38acc80a5b696a0f9d029b5de209b6a2045332cd Author: Vitaliy Gusev AuthorDate: 2023-02-28 10:32:49 +0000 Commit: Corvin Köhne CommitDate: 2023-03-17 10:26:33 +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 (cherry picked from commit 8104fc31a234bad1ba68910f66876395fc58ebdc) --- 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 cb883bb0e143..95f5597f7e1a 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 8cdf57608055..1b5e6946d785 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 },