David Brown wrote:
>> Does the problem occur with 'taskset 1 qemu ...'?  This pins the guest
>> on one core.
>
> Sorry for the late response but yes that seems to be working fine now.
>
>> The core-not-2's main problem is that I don't test regularly with it.
>> It is slightly strange (no 64-bit support, hence some important msrs are
>> missing) so it has triggered a lot of kvm bugs.
>
> Ah okay good thing I have one and can test things then ;)
>

Please check the attached patch (without taskset).  The patch attempts
to keep the time stamp counter monotonic, even if the guest migrates
from core to core.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.

diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index b909b54..6beb0f1 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -160,6 +160,7 @@ static void __vcpu_clear(void *arg)
 		vmcs_clear(vcpu->vmcs);
 	if (per_cpu(current_vmcs, cpu) == vcpu->vmcs)
 		per_cpu(current_vmcs, cpu) = NULL;
+	rdtscll(vcpu->host_tsc);
 }
 
 static void vcpu_clear(struct kvm_vcpu *vcpu)
@@ -376,11 +377,16 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu)
 {
 	u64 phys_addr = __pa(vcpu->vmcs);
 	int cpu;
+	u64 tsc_this, delta;
 
 	cpu = get_cpu();
 
-	if (vcpu->cpu != cpu)
+	if (vcpu->cpu != cpu) {
 		vcpu_clear(vcpu);
+		rdtscll(tsc_this);
+		delta = vcpu->host_tsc - tsc_this;
+		vmcs_write64(TSC_OFFSET, vmcs_read64(TSC_OFFSET) + delta);
+	}
 
 	if (per_cpu(current_vmcs, cpu) != vcpu->vmcs) {
 		u8 error;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to