From 683ea4d22bbcc892ac7c5bb996d1b134831dfdc3 Mon Sep 17 00:00:00 2001 From: Vitaliy Gusev Date: Fri, 29 Dec 2023 09:03:20 -0900 Subject: [PATCH] vmm: MTRR should be saved/restored This fixes restoring a Linux VM if it was suspended while in the GRUB menu. Adding MTTR increases the kernel dump size by 256 bytes per vCPU. Sponsored by: vStack Reviewed by: markj, rew Differential Revision: https://reviews.freebsd.org/D43226 --- sys/amd64/vmm/amd/svm.c | 2 ++ sys/amd64/vmm/intel/vmx.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c index 3fda9454090..f1106158e44 100644 --- a/sys/amd64/vmm/amd/svm.c +++ b/sys/amd64/vmm/amd/svm.c @@ -2781,6 +2781,8 @@ svm_vcpu_snapshot(void *vcpui, struct vm_snapshot_meta *meta) SNAPSHOT_VAR_OR_LEAVE(vcpu->asid.gen, meta, err, done); SNAPSHOT_VAR_OR_LEAVE(vcpu->asid.num, meta, err, done); + SNAPSHOT_BUF_OR_LEAVE(&vcpu->mtrr, sizeof(vcpu->mtrr), meta, err, done); + /* Set all caches dirty */ if (meta->op == VM_SNAPSHOT_RESTORE) svm_set_dirty(vcpu, 0xffffffff); diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index 317ed7e5d7f..b7c1544ac0b 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -4200,6 +4200,9 @@ vmx_vcpu_snapshot(void *vcpui, struct vm_snapshot_meta *meta) SNAPSHOT_BUF_OR_LEAVE(vcpu->pir_desc, sizeof(*vcpu->pir_desc), meta, err, done); + SNAPSHOT_BUF_OR_LEAVE(&vcpu->mtrr, + sizeof(vcpu->mtrr), meta, err, done); + vmxctx = &vcpu->ctx; SNAPSHOT_VAR_OR_LEAVE(vmxctx->guest_rdi, meta, err, done); SNAPSHOT_VAR_OR_LEAVE(vmxctx->guest_rsi, meta, err, done);