Skip to content

Commit

Permalink
vmm: [snapshot] MTRR should be saved/restored
Browse files Browse the repository at this point in the history
Ubuntu 22.04 (Linux 5.15.0-84-generic) gets panic (hangs) if do:

 1. Snapshot VM while it is in GRUB menu
 2. Resume
 3. Boot Linux.

Linux dmesg:

  total RAM covered: 1M
  gran_size: 64K  chunk_size: 64K         num_reg: 4      lose cover RAM: 92K
  ...
  mtrr_cleanup: can not find optimal value
  please specify mtrr_gran_size/mtrr_chunk_size
  WARNING: BIOS bug: CPU MTRRs don't cover all of memory, losing 510MB of RAM.
  WARNING: CPU: 0 PID: 0 at arch/x86/kernel/cpu/mtrr/cleanup.c:978
                              mtrr_trim_uncached_memory+0x426/0x469
  ...
  BUG: unable to handle page fault for address: ffff9d0047e15ff8

-
Adding MTTR increases kernel dump size for 256 bytes per vCPU:
-

Sponsored by:		vStack
Differential Revision:	https://reviews.freebsd.org/D43226
  • Loading branch information
gusev-vitaliy committed Dec 28, 2023
1 parent 61e2161 commit d3cc0ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/amd64/vmm/amd/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions sys/amd64/vmm/intel/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d3cc0ec

Please sign in to comment.