Message ID | 20221013095849.705943-1-vkuznets@redhat.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp182448wrs; Thu, 13 Oct 2022 02:59:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UPG5Vm/RaGDCy/NLRw+WNDL96W0/4vkPYlR5rNQN6C5vH6AXmILm0XENteUd6VVKINYY5 X-Received: by 2002:a63:2b10:0:b0:451:5df1:4b17 with SMTP id r16-20020a632b10000000b004515df14b17mr29093624pgr.61.1665655172728; Thu, 13 Oct 2022 02:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665655172; cv=none; d=google.com; s=arc-20160816; b=bHyostsBY+3+UQFBJg0fuxBepvn8RHzC7T1SnEaahI5w6NWd5h1dG0lQ1XjNsqJ26E oZjounRCh+UwQSzuMIs6hKGqCOh+4YcHP/YhEAV9rhOYUYXM+KpIRRYAd+5uNH2CUIG7 NYkteHLpzZVIvfsRb0LCW6dAGIiMJUlYvpgXp9PvTJF+RxNR1gv6pc5s7iWL3Q7SAjB3 /MUCzPysOrqcTKuOefswm6iCl3m1+T3f7qp9OFgUtNfBZFKr/mJRpD9xvz46LQXO0XRP etWVbakMqCDB+b0O4S/JN24MXxFtoZ20dMhLIWbQdO6l++9dw3kpKw83ywiVEy7siHxM lBKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gYxJpUZHmyKC80uPxIoHuIFfPUSzpQt5TX3nlakaHIg=; b=N0eUCnAs6SyhXhEB125sytGZkVG63uot9B2KklIWC3BW2iXAoqaSR1Z9lxsPVEfsn9 6KcYn9yzaGKC3qFhRiGZ4pnSvUxf6EwlNFIUt6QfYbnxvwR7hEszsuab+0G0wi72EXMZ Rs+EPJckWs5oPSv7eGHngqX0zXynJvC1xUC9jGRq6f7q3Urxmx+0tgIBJFEfKYPsq7pT plgSWV55unx6wuLXTEFpxa5a4wqcjfdmB9IQtjTUIsse5q2YUJfAD49Sfob/5zpSerAe I52lhtFSsFywrSFYobw1mrkruKLLyDYz/mXpsDrGWk8ucKaBMCM+VaGGEnhE8HUlBEtc X/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aR62nCEB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i190-20020a639dc7000000b0043c22f8bd77si23290102pgd.742.2022.10.13.02.59.20; Thu, 13 Oct 2022 02:59:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aR62nCEB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229671AbiJMJ7F (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 05:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbiJMJ65 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 05:58:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0386AF9848 for <linux-kernel@vger.kernel.org>; Thu, 13 Oct 2022 02:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665655135; 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; bh=gYxJpUZHmyKC80uPxIoHuIFfPUSzpQt5TX3nlakaHIg=; b=aR62nCEBPuKecNM2v7Y2CKmV+7cBta9Nf0O0Go+h0vjg8JOilVd3xlHA7EZT1Oyf7gmb9M IiJh6jESiTimkdbc3TfDdzoIrxG7jDYYZV40lE2LTpw8s++NvKzOlXajvy6TY3NulSzDhr yAWPdQOIlqdSetWX8LOV95Nypt+bIo0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-48-VHKHGMaUPeSTH3j1n_rTJw-1; Thu, 13 Oct 2022 05:58:53 -0400 X-MC-Unique: VHKHGMaUPeSTH3j1n_rTJw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26175858F17; Thu, 13 Oct 2022 09:58:53 +0000 (UTC) Received: from ovpn-194-196.brq.redhat.com (ovpn-194-196.brq.redhat.com [10.40.194.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEA0347505F; Thu, 13 Oct 2022 09:58:50 +0000 (UTC) From: Vitaly Kuznetsov <vkuznets@redhat.com> To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com> Cc: Wanpeng Li <wanpengli@tencent.com>, Jim Mattson <jmattson@google.com>, Michael Kelley <mikelley@microsoft.com>, Maxim Levitsky <mlevitsk@redhat.com>, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 0/7] KVM: x86: Hyper-V invariant TSC control feature Date: Thu, 13 Oct 2022 11:58:42 +0200 Message-Id: <20221013095849.705943-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746566038808831173?= X-GMAIL-MSGID: =?utf-8?q?1746566038808831173?= |
Series |
KVM: x86: Hyper-V invariant TSC control feature
|
|
Message
Vitaly Kuznetsov
Oct. 13, 2022, 9:58 a.m. UTC
Changes since v4: - s,HV_INVARIANT_TSC_EXPOSED,HV_EXPOSE_INVARIANT_TSC, [Michael] - Add Michael's R-b to PATCH1 - Use 'KVM-only' instead of 'scattered' in PATCH2's subject [Sean, Jim] - Do not set CPUID_8000_0007_EDX to 'NCAPINTS + 1' explicitly [Sean] - Use the opportunity and switch to 'true'/'false' for 'msr->write'/ 'msr->fault_exepected' in 'hyperv_features' test [Sean] - Fix HVCALL_NOTIFY_LONG_SPIN_WAIT test breakage by setting HYPERV_CPUID_ENLIGHTMENT_INFO.EBX. - "KVM: selftests: Test that values written to Hyper-V MSRs are preserved" patch added [Sean] Original description: Normally, genuine Hyper-V doesn't expose architectural invariant TSC (CPUID.80000007H:EDX[8]) to its guests by default. A special PV MSR (HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x40000118) and corresponding CPUID feature bit (CPUID.0x40000003.EAX[15]) were introduced. When bit 0 of the PV MSR is set, invariant TSC bit starts to show up in CPUID. When the feature is exposed to Hyper-V guests, reenlightenment becomes unneeded. Note: strictly speaking, KVM doesn't have to have the feature as exposing raw invariant TSC bit (CPUID.80000007H:EDX[8]) also seems to work for modern Windows versions. The feature is, however, tiny and straitforward and gives additional flexibility so why not. Vitaly Kuznetsov (7): x86/hyperv: Add HV_EXPOSE_INVARIANT_TSC define KVM: x86: Add a KVM-only leaf for CPUID_8000_0007_EDX KVM: x86: Hyper-V invariant TSC control KVM: selftests: Rename 'msr->available' to 'msr->fault_exepected' in hyperv_features test KVM: selftests: Convert hyperv_features test to using KVM_X86_CPU_FEATURE() KVM: selftests: Test that values written to Hyper-V MSRs are preserved KVM: selftests: Test Hyper-V invariant TSC control arch/x86/include/asm/hyperv-tlfs.h | 3 + arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kernel/cpu/mshyperv.c | 2 +- arch/x86/kvm/cpuid.c | 11 +- arch/x86/kvm/hyperv.c | 19 + arch/x86/kvm/hyperv.h | 27 ++ arch/x86/kvm/reverse_cpuid.h | 7 + arch/x86/kvm/x86.c | 4 +- .../selftests/kvm/include/x86_64/hyperv.h | 144 +++++--- .../selftests/kvm/include/x86_64/processor.h | 1 + .../selftests/kvm/x86_64/hyperv_features.c | 330 +++++++++++------- 11 files changed, 366 insertions(+), 183 deletions(-)
Comments
On Thu, Oct 13, 2022, Vitaly Kuznetsov wrote: > Normally, genuine Hyper-V doesn't expose architectural invariant TSC > (CPUID.80000007H:EDX[8]) to its guests by default. A special PV MSR > (HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x40000118) and corresponding CPUID > feature bit (CPUID.0x40000003.EAX[15]) were introduced. When bit 0 of the > PV MSR is set, invariant TSC bit starts to show up in CPUID. When the > feature is exposed to Hyper-V guests, reenlightenment becomes unneeded. > > Note: strictly speaking, KVM doesn't have to have the feature as exposing > raw invariant TSC bit (CPUID.80000007H:EDX[8]) also seems to work for > modern Windows versions. The feature is, however, tiny and straitforward > and gives additional flexibility so why not. > > Vitaly Kuznetsov (7): > x86/hyperv: Add HV_EXPOSE_INVARIANT_TSC define > KVM: x86: Add a KVM-only leaf for CPUID_8000_0007_EDX > KVM: x86: Hyper-V invariant TSC control > KVM: selftests: Rename 'msr->available' to 'msr->fault_exepected' in > hyperv_features test > KVM: selftests: Convert hyperv_features test to using > KVM_X86_CPU_FEATURE() > KVM: selftests: Test that values written to Hyper-V MSRs are preserved > KVM: selftests: Test Hyper-V invariant TSC control For the series, in case Paolo ends up grabbing this: Reviewed-by: Sean Christopherson <seanjc@google.com>
Sean Christopherson <seanjc@google.com> writes: > On Thu, Oct 13, 2022, Vitaly Kuznetsov wrote: >> Normally, genuine Hyper-V doesn't expose architectural invariant TSC >> (CPUID.80000007H:EDX[8]) to its guests by default. A special PV MSR >> (HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x40000118) and corresponding CPUID >> feature bit (CPUID.0x40000003.EAX[15]) were introduced. When bit 0 of the >> PV MSR is set, invariant TSC bit starts to show up in CPUID. When the >> feature is exposed to Hyper-V guests, reenlightenment becomes unneeded. >> >> Note: strictly speaking, KVM doesn't have to have the feature as exposing >> raw invariant TSC bit (CPUID.80000007H:EDX[8]) also seems to work for >> modern Windows versions. The feature is, however, tiny and straitforward >> and gives additional flexibility so why not. >> >> Vitaly Kuznetsov (7): >> x86/hyperv: Add HV_EXPOSE_INVARIANT_TSC define >> KVM: x86: Add a KVM-only leaf for CPUID_8000_0007_EDX >> KVM: x86: Hyper-V invariant TSC control >> KVM: selftests: Rename 'msr->available' to 'msr->fault_exepected' in >> hyperv_features test >> KVM: selftests: Convert hyperv_features test to using >> KVM_X86_CPU_FEATURE() >> KVM: selftests: Test that values written to Hyper-V MSRs are preserved >> KVM: selftests: Test Hyper-V invariant TSC control > > For the series, in case Paolo ends up grabbing this: > > Reviewed-by: Sean Christopherson <seanjc@google.com> > I completely forgot about this one! Any chance it can still be queueed for 6.2? Thanks!
Queued, thanks. Paolo