From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBB83C433FE for ; Thu, 10 Dec 2020 11:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9131823D56 for ; Thu, 10 Dec 2020 11:49:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729571AbgLJLto (ORCPT ); Thu, 10 Dec 2020 06:49:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54161 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728117AbgLJLto (ORCPT ); Thu, 10 Dec 2020 06:49:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607600897; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vy7qUFqmJ4w+Yqe/3zBzEgAxcvrIudav4UoG7qWP05M=; b=ZIA1qekM+njfi9yjrP/elOhzUDVE4DKhu+UEJo7ikMU7kvfZE7t59FaW9nNFif2lmrGWFV 6ZXh9DGaIkHjyPIXc7alHjipdB5CuOcZqD/o+xe8Wx20EOVwyLQsGGT4vEwl9V3RTwYRPW iiTEdIv70FXsmrzfOcHhvyRuYsvV1+U= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182--cX4dDdwNIugHBi59rFj7A-1; Thu, 10 Dec 2020 06:48:15 -0500 X-MC-Unique: -cX4dDdwNIugHBi59rFj7A-1 Received: by mail-ej1-f72.google.com with SMTP id u15so1520702ejg.17 for ; Thu, 10 Dec 2020 03:48:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Vy7qUFqmJ4w+Yqe/3zBzEgAxcvrIudav4UoG7qWP05M=; b=qzruhpZwk0q3tRBUGG1O/rg8eb/DJiK/u32cludzYOPFXkr7paO/HDOPpz9mn6IqJp oV+9S1D3YP1CkC4+wQFnn/vBoZYK0ofXo+SsituWqR6Y7GFSlRdxQiZURDz8BzopuvQE G3al1HBYUw/GOBrmM0LUvz7Nr0bqFu0suN3OLD3d3ghl1DoGhAgkRWrRMpGoAwQEwngj hVG9+QdCBnqjH1oN02uJFQ6ca5v4Vst8dHJP5vJca6pdwHFvOXT+TIfl1+oy2V6wNeRH 06EuMqAI7pdnvmMw8lQIuHWjZuEHCdYts4Gfn4njpMUOFDL3+NyzlX1rUkCzBT/Z4Tet zqNQ== X-Gm-Message-State: AOAM53051jxJYqDz8HxWV2VarPG0VRW0V3AqQK/XVjCZnSvcShaDhhOk 8WlnEQFJydcxsrWIbSqAz7SoJvSSBne4q5OiSWUfV98eIl9+odismJCBvNXJD2Wj6ls3FmRGLWm Tkm0ZyCOxG1jLPmPApcirdJ13 X-Received: by 2002:aa7:d41a:: with SMTP id z26mr6393020edq.267.1607600893838; Thu, 10 Dec 2020 03:48:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwT1BgKb53bvs2L+9goeNkFTaweyYQb4Mx9OhlhD01G0jFvMtjmublR8JhvmFDTnhy+1qlKKg== X-Received: by 2002:aa7:d41a:: with SMTP id z26mr6392996edq.267.1607600893671; Thu, 10 Dec 2020 03:48:13 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id j20sm4182609ejy.124.2020.12.10.03.48.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Dec 2020 03:48:12 -0800 (PST) From: Paolo Bonzini Subject: Re: [PATCH v2 0/3] RFC: Precise TSC migration To: Maxim Levitsky , kvm@vger.kernel.org Cc: "H. Peter Anvin" , Jonathan Corbet , Jim Mattson , Wanpeng Li , "open list:KERNEL SELFTEST FRAMEWORK" , Vitaly Kuznetsov , Marcelo Tosatti , 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" References: <20201203171118.372391-1-mlevitsk@redhat.com> Message-ID: <566e8346-1e78-2737-be86-0ec27ad147a5@redhat.com> Date: Thu, 10 Dec 2020 12:48:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201203171118.372391-1-mlevitsk@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I'm queueing patches 2 and 3 for now, since the sane MSR interface is a prerequisite anyway. Paolo On 03/12/20 18:11, 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 > > 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(-) >