Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756775AbcKBSWM (ORCPT ); Wed, 2 Nov 2016 14:22:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49406 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754790AbcKBSWK (ORCPT ); Wed, 2 Nov 2016 14:22:10 -0400 Date: Wed, 2 Nov 2016 19:22:07 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, lcapitulino@redhat.com Subject: Re: [PATCH] KVM: x86: drop TSC offsetting kvm_x86_ops to fix KVM_GET/SET_CLOCK Message-ID: <20161102182206.GA7771@potion> References: <1478075883-22970-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1478075883-22970-1-git-send-email-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 02 Nov 2016 18:22:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1311 Lines: 28 2016-11-02 09:38+0100, Paolo Bonzini: > Since commit a545ab6a0085 ("kvm: x86: add tsc_offset field to struct > kvm_vcpu_arch", 2016-09-07) the offset between host and L1 TSC is > cached and need not be fished out of the VMCS or VMCB. This means > that we can implement adjust_tsc_offset_guest and read_l1_tsc > entirely in generic code. The simplification is particularly > significant for VMX code, where vmx->nested.vmcs01_tsc_offset > was duplicating what is now in vcpu->arch.tsc_offset. Therefore > the vmcs01_tsc_offset can be dropped completely. > > More importantly, this fixes KVM_GET_CLOCK/KVM_SET_CLOCK > which, after commit 108b249c453d ("KVM: x86: introduce get_kvmclock_ns", > 2016-09-01) called read_l1_tsc while the VMCS was not loaded. > It thus returned bogus values on Intel CPUs. > > Fixes: 108b249c453dd7132599ab6dc7e435a7036c193f > Reported-by: Roman Kagan > Signed-off-by: Paolo Bonzini > --- > arch/x86/include/asm/kvm_host.h | 3 --- > arch/x86/kvm/svm.c | 23 ----------------------- > arch/x86/kvm/vmx.c | 39 +++------------------------------------ > arch/x86/kvm/x86.c | 6 +++--- > 4 files changed, 6 insertions(+), 65 deletions(-) Yay, Reviewed-by: Radim Krčmář