Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106930415
D37146.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D37146.diff
View Options
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -2804,10 +2804,12 @@
static int
vm_snapshot_vcpus(struct vm *vm, struct vm_snapshot_meta *meta)
{
+ uint64_t tsc, now;
int ret;
int i;
struct vcpu *vcpu;
+ now = rdtsc();
for (i = 0; i < VM_MAXCPU; i++) {
vcpu = &vm->vcpu[i];
@@ -2819,13 +2821,15 @@
SNAPSHOT_VAR_OR_LEAVE(vcpu->guest_xcr0, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(vcpu->exitinfo, meta, ret, done);
SNAPSHOT_VAR_OR_LEAVE(vcpu->nextrip, meta, ret, done);
- /* XXX we're cheating here, since the value of tsc_offset as
- * saved here is actually the value of the guest's TSC value.
+
+ /*
+ * Save the absolute TSC value by adding now to tsc_offset.
*
* It will be turned turned back into an actual offset when the
* TSC restore function is called
*/
- SNAPSHOT_VAR_OR_LEAVE(vcpu->tsc_offset, meta, ret, done);
+ tsc = now + vcpu->tsc_offset;
+ SNAPSHOT_VAR_OR_LEAVE(tsc, meta, ret, done);
}
done:
@@ -2836,33 +2840,10 @@
vm_snapshot_vm(struct vm *vm, struct vm_snapshot_meta *meta)
{
int ret;
- int i;
- uint64_t now;
-
- ret = 0;
- now = rdtsc();
-
- if (meta->op == VM_SNAPSHOT_SAVE) {
- /* XXX make tsc_offset take the value TSC proper as seen by the
- * guest
- */
- for (i = 0; i < VM_MAXCPU; i++)
- vm->vcpu[i].tsc_offset += now;
- }
ret = vm_snapshot_vcpus(vm, meta);
- if (ret != 0) {
- printf("%s: failed to copy vm data to user buffer", __func__);
+ if (ret != 0)
goto done;
- }
-
- if (meta->op == VM_SNAPSHOT_SAVE) {
- /* XXX turn tsc_offset back into an offset; actual value is only
- * required for restore; using it otherwise would be wrong
- */
- for (i = 0; i < VM_MAXCPU; i++)
- vm->vcpu[i].tsc_offset -= now;
- }
done:
return (ret);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 3:38 PM (41 m, 41 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15723690
Default Alt Text
D37146.diff (1 KB)
Attached To
Mode
D37146: vmm: Simplify saving of absolute TSC values in snapshots.
Attached
Detach File
Event Timeline
Log In to Comment