Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3212159pxu; Tue, 8 Dec 2020 06:28:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHd2GYx5SHurz7LtdnMug8lplVCzfQMySE2l2a7ljcBNlxcOIwSpia3vVHPONpDH2ysW5w X-Received: by 2002:a05:6402:142f:: with SMTP id c15mr25023784edx.33.1607437689345; Tue, 08 Dec 2020 06:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607437689; cv=none; d=google.com; s=arc-20160816; b=s+OzVAX4MmbgczIOZqafuy+awc1d5+vcB0oHaeYiV6nFNehZBWJ9cnCvrbcfgM4rBg +fw/QWbSXJR7M3XV+HniF1nLQTq8Bgug0bfqH9DTxR14QJhxAo9rqEJbXohLrnsFaee4 XGmTZGYfMz+bFV7+X2dFZyPFkVE8nBMUh2HIczC1gU/Nt3D8HhPdOeAm/sSHc541nCFA xUDKGcGhSfH8Z06SKyPd8gmUWgEyIfqFL1v3D9vBPiDrl42sDZt25W7iOuX+mILz21ZG p+sJEZhxUCIMAzKJDnM3it9ICP9mkvJCaZIqFPA9IYAaM0h4bgZXi9nvDj331tctSMEq 8L9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=yYABeUJ41wkb4dfuaHr9ztBYcxYNx2eYwG9YnsUg4D0=; b=cPiUrLNCA1WnaDwCvoKVjt/f9TbDI6cZl70OjG22jJh7073M67Sddd8XyvdExjf5dD 0BvbivkAy4wQMrPKS8ytCkxjqI2Inja2eTDBX7lt7F6ybu67ydgiwFCXx+Xd/6DbtFL9 cvzZrXwqZMkC6+8bdl0zvNcVFhvavRd6WxZ5iDjOfH2x89mXGi9CLaEzOekbzkHSnrl4 AAFUXntgEB7c3jaCgKO+6/48/Ux4DZcoytS7VcHJzFj0EAIxVEyJMGYQhIDk4i0fuN46 5y+QUquyaYfuQ485Kbfqv5KKotoxyM10972V07v9C9YOolVJ5G2PWdIbUH5gHfSTXzVP 6UPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DY1k5prd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gu26si7466645ejb.461.2020.12.08.06.27.45; Tue, 08 Dec 2020 06:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DY1k5prd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729840AbgLHOZQ (ORCPT + 99 others); Tue, 8 Dec 2020 09:25:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44898 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729461AbgLHOZP (ORCPT ); Tue, 8 Dec 2020 09:25:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607437429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yYABeUJ41wkb4dfuaHr9ztBYcxYNx2eYwG9YnsUg4D0=; b=DY1k5prdr2tO6ZiSQ5QcLKWMULsoIp9Ta4A29tukZAEO8s/1hEVbkJfaajak2NJkmYwh4J Gp/8uw3B3DZ4hqmq6HBGWvB7r/BOLzG7YVsdPVJDdF9+VveSG0oef6RwG4XPHi3BW8xu8p SDxUmmYU0TB+Ji+NNykDSiF4u+b9AEk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-591-ZkxIiaedPvS_iNIQaWCyTQ-1; Tue, 08 Dec 2020 09:23:45 -0500 X-MC-Unique: ZkxIiaedPvS_iNIQaWCyTQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F07DF180A089; Tue, 8 Dec 2020 14:23:42 +0000 (UTC) Received: from fuller.cnet (ovpn-112-8.gru2.redhat.com [10.97.112.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7DEAB620DE; Tue, 8 Dec 2020 14:23:42 +0000 (UTC) Received: by fuller.cnet (Postfix, from userid 1000) id 4CA80416D862; Mon, 7 Dec 2020 20:16:56 -0300 (-03) Date: Mon, 7 Dec 2020 20:16:56 -0300 From: Marcelo Tosatti To: Maxim Levitsky Cc: kvm@vger.kernel.org, "H. Peter Anvin" , Paolo Bonzini , Jonathan Corbet , Jim Mattson , Wanpeng Li , "open list:KERNEL SELFTEST FRAMEWORK" , Vitaly Kuznetsov , Thomas Gleixner , Sean Christopherson , open list , Ingo Molnar , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Joerg Roedel , Borislav Petkov , Shuah Khan , Andrew Jones , Oliver Upton , "open list:DOCUMENTATION" Subject: Re: [PATCH v2 0/3] RFC: Precise TSC migration Message-ID: <20201207231656.GC27492@fuller.cnet> References: <20201203171118.372391-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201203171118.372391-1-mlevitsk@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 03, 2020 at 07:11:15PM +0200, Maxim Levitsky wrote: > Hi! > > This is the second version of the work to make TSC migration more accurate, > as was defined by Paulo at: > https://www.spinics.net/lists/kvm/msg225525.html Maxim, Can you please make a description of what is the practical problem that is being fixed, preferably with instructions on how to reproduce ? > I omitted most of the semi-offtopic points I raised related to TSC > in the previous RFC where we can continue the discussion. > > I do want to raise another thing that I almost forgot. > > On AMD systems, the Linux kernel will mark the guest tsc as > unstable unless invtsc is set which is set on recent AMD > hardware. > > Take a look at 'unsynchronized_tsc()' to verify this. > > This is another thing that IMHO should be fixed at least when > running under KVM. > > Note that I forgot to mention that > X86_FEATURE_TSC_RELIABLE also short-circuits this code, > thus giving another reason to enable it under KVM. > > Changes from V1: > > - added KVM_TSC_STATE_TIMESTAMP_VALID instead of testing ns == 0 > - allow diff < 0, because it is still better that capping it to 0 > - updated tsc_msr_test unit test to cover this feature > - refactoring > > Patches to enable this feature in qemu are in the process of > being sent to qemu-devel mailing list. > > Best regards, > Maxim Levitsky > > Maxim Levitsky (3): > KVM: x86: implement KVM_{GET|SET}_TSC_STATE > KVM: x86: introduce KVM_X86_QUIRK_TSC_HOST_ACCESS > kvm/selftests: update tsc_msrs_test to cover > KVM_X86_QUIRK_TSC_HOST_ACCESS > > Documentation/virt/kvm/api.rst | 65 +++++++++++++ > arch/x86/include/uapi/asm/kvm.h | 1 + > arch/x86/kvm/x86.c | 92 ++++++++++++++++++- > include/uapi/linux/kvm.h | 15 +++ > .../selftests/kvm/x86_64/tsc_msrs_test.c | 79 ++++++++++++++-- > 5 files changed, 237 insertions(+), 15 deletions(-) > > -- > 2.26.2 >