lkml.org 
[lkml]   [2021]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC: timer passthrough 5/9] KVM: vmx: use tsc_adjust to enable tsc_offset timer passthrough
Date
On Fri, Feb 05 2021 at 13:43, Peter Zijlstra wrote:
> On Fri, Feb 05, 2021 at 06:03:13PM +0800, Zhimin Feng wrote:
>> +static void vmx_adjust_tsc_offset(struct kvm_vcpu *vcpu, bool to_host)
>> +{
>> + u64 tsc_adjust;
>> + struct timer_passth_info *local_timer_info;
>> +
>> + local_timer_info = &per_cpu(passth_info, smp_processor_id());
>> +
>> + if (to_host) {
>> + tsc_adjust = local_timer_info->host_tsc_adjust;
>> + wrmsrl(MSR_IA32_TSC_ADJUST, tsc_adjust);
>> + vmcs_write64(TSC_OFFSET, vcpu->arch.tsc_offset);
>> + } else {
>> + rdmsrl(MSR_IA32_TSC_ADJUST, tsc_adjust);
>> + local_timer_info->host_tsc_adjust = tsc_adjust;
>> +
>> + wrmsrl(MSR_IA32_TSC_ADJUST, tsc_adjust + vcpu->arch.tsc_offset);
>> + vmcs_write64(TSC_OFFSET, 0);
>> + }
>> +}
>
> NAK
>
> This wrecks the host TSC value, any host code between this and actually
> entering that VM will observe batshit time.

VMCS TSC offset is there for a reason...

Thanks,

tglx

\
 
 \ /
  Last update: 2021-02-05 19:29    [W:0.120 / U:1.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site