From: Roger Pau Monné Date: Mon, 25 Nov 2019 15:16:18 +0000 (+0100) Subject: x86/tsc: update vcpu time info on guest TSC adjustments X-Git-Tag: archive/raspbian/4.11.3+24-g14b62ab3e5-1+rpi1^2~55^2~39 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=41d85cbeaff2bcb6ba1a28fcc322f91c4930b98b;p=xen.git x86/tsc: update vcpu time info on guest TSC adjustments If a HVM/PVH guest writes to MSR_IA32_TSC{_ADJUST} and thus changes the value of the time stamp counter the vcpu time info must also be updated, or the time calculated by the guest using the Xen PV clock interface will be skewed. Update the vcpu time info when the guest writes to either MSR_IA32_TSC or MSR_IA32_TSC_ADJUST. This fixes lockups seen when running the pv-shim on AMD hardware, since the shim will aggressively try to keep TSCs in sync by periodically writing to MSR_IA32_TSC if the TSC is not reliable. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu Reviewed-by: Jan Beulich master commit: 7eee9c16d6405a1a1f2e8c6472923db842c90cfb master date: 2019-10-23 17:01:56 +0100 --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 1924434960..2a9f40b6db 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -429,6 +429,8 @@ static void hvm_set_guest_tsc_msr(struct vcpu *v, u64 guest_tsc) hvm_set_guest_tsc(v, guest_tsc); v->arch.hvm_vcpu.msr_tsc_adjust += v->arch.hvm_vcpu.cache_tsc_offset - tsc_offset; + if ( v == current ) + update_vcpu_system_time(v); } static void hvm_set_guest_tsc_adjust(struct vcpu *v, u64 tsc_adjust) @@ -437,6 +439,8 @@ static void hvm_set_guest_tsc_adjust(struct vcpu *v, u64 tsc_adjust) - v->arch.hvm_vcpu.msr_tsc_adjust; hvm_funcs.set_tsc_offset(v, v->arch.hvm_vcpu.cache_tsc_offset, 0); v->arch.hvm_vcpu.msr_tsc_adjust = tsc_adjust; + if ( v == current ) + update_vcpu_system_time(v); } u64 hvm_get_guest_tsc_fixed(struct vcpu *v, uint64_t at_tsc)