Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp404257iog; Wed, 15 Jun 2022 04:51:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tpQHn2HdYAvPMoblu034YNgVw6GafVYD7ZH+IOhnxC9yfaqqEFJPaHd0dxB7tVzH2FKY0u X-Received: by 2002:a17:90b:4b82:b0:1e6:7835:2f05 with SMTP id lr2-20020a17090b4b8200b001e678352f05mr9746704pjb.121.1655293911716; Wed, 15 Jun 2022 04:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655293911; cv=none; d=google.com; s=arc-20160816; b=WiHKYJWOADko0DJM54x+ImZ8VHGXG6tah9D9yoqxOZQAtxZ6yZ7TGX9+eN+K2V5EKX lmUGhn8TvGaCPJ3vDh5aUuNYl4801NKCU602v8CUnn3WB9kZvSujw422XWG0DfWyVtqd bohfnNlOMnNd7BLXbzpw7V0eAima+hJdXTDbIiY/BM7+9879GwVJhxC4DKpaLP6X3uc9 fHROivOOkslKyXWN2ENv5I4tdDNdviux5/UV9jmTC/fpg0ElnR2tW3vibDBu2MIF81bw RrW+x/YojAK8+jQSv1rXQJ7PTcoYqyYWUriFBurpH8hgUSeU7F8M1We9pOzL4HnYj/OI NhIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=deu1fZ+rJg4vtIyzufwUH9tCrx+7IF3P/lvcMVMcMto=; b=uId4oIsXDVPuM7uuwg4Kdfmn5FawUszWmpyq8smgfj2HwtfRi/JkX934orzJnnhy/9 Sy5K3NjCLvzzOATgA4SwyJv56rizxxnOr1KA9mEfOnUY+Hu2q8boJ7y8btoMtPEH38NV HJasnUgQTJ9To0tqWXrupG03WBbnNQ71YvQ40goHnQR/NT/T4REgn8qURl/9P4rHn45K W6nYOEFq8xjK/4lfk89nnlHqw8JZYXMFHI2/xjfBDuG99lmMh7V4pCa6KIsCzxiDwSAl sUFHC5C9MHRITd91bwOxhP6nvl6wG5a6ATNvDeBB3wCkXSPPEmqqYjMxIJQ1Elu9vEn9 C7kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jOY+f9s5; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g20-20020a62e314000000b0051b79672ca1si14148863pfh.123.2022.06.15.04.51.39; Wed, 15 Jun 2022 04:51:51 -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=jOY+f9s5; 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 S1347893AbiFOLbH (ORCPT + 99 others); Wed, 15 Jun 2022 07:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347864AbiFOLbC (ORCPT ); Wed, 15 Jun 2022 07:31:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 359C552E63 for ; Wed, 15 Jun 2022 04:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655292657; 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=deu1fZ+rJg4vtIyzufwUH9tCrx+7IF3P/lvcMVMcMto=; b=jOY+f9s5ny1+xF2LOeakdX57gA4kAOsuwKJlideOsv398UA6ruA9Va3a4K34d5B5XbanEo 6WfmCAFx1vMNlBLI5f0F6SDM7bJV2E4z2uqfAXDqO86LMHPmAK8c+xqldJc7TqBctjeVPJ +5kOkWNAGb13DBbPLWPWyHYOSyx1rrI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-YOCOutogNE2o2X49mqNIbQ-1; Wed, 15 Jun 2022 07:30:56 -0400 X-MC-Unique: YOCOutogNE2o2X49mqNIbQ-1 Received: by mail-wr1-f71.google.com with SMTP id h2-20020adfe982000000b002102da95c71so1751610wrm.23 for ; Wed, 15 Jun 2022 04:30:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=deu1fZ+rJg4vtIyzufwUH9tCrx+7IF3P/lvcMVMcMto=; b=gtAn9yJ33CK+qMDXkS44tfXm6LT1zegfeN3K5Hh9Br2GPYDd9iIQYujOILYXGJFGTG O3OPticeHcmKSkUrTo2xBCHrSWcaLgfNTtfch/9CsBYDp8GBIqFjo14ViZKhJ6gheV/O OeSaPcxiT2uPFhYdBB0uUcOpW0w96vVUv70rF1LCkAFG6O/ptkcwCJEJt+bh5FPz7bZi AKqMO1qIeVrOWlh0Gw6DRXN1cMnv40fcZZVYhaFXfXulvh7c3gjb1iWCJV4YihJLVfIx AiBoXt1ZnKx4+BrjvJ4o9Bt/76CtALDXhNiiWlYaI/XBk3srEGVtwP5yvaEy8gHQmRM2 P5eQ== X-Gm-Message-State: AJIora/SOklKUcDmCELjMZlRsk/SW6O/x4AxcEZN0Xv3Z8SH6JpliFYb 3GPT1E50VUx01VKnRu2VIymXk9STl1dv14IC4Qm4nRSWpMQTdhS0KUsG6CJuQp3w73DqNlRHeuq yX18QU8suTSSe8VTxo/GqiXMI X-Received: by 2002:a05:6000:1808:b0:21a:1322:cd9b with SMTP id m8-20020a056000180800b0021a1322cd9bmr9793136wrh.164.1655292655039; Wed, 15 Jun 2022 04:30:55 -0700 (PDT) X-Received: by 2002:a05:6000:1808:b0:21a:1322:cd9b with SMTP id m8-20020a056000180800b0021a1322cd9bmr9793119wrh.164.1655292654831; Wed, 15 Jun 2022 04:30:54 -0700 (PDT) Received: from fedora (nat-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id q17-20020adffed1000000b00219f9829b71sm12682321wrs.56.2022.06.15.04.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 04:30:54 -0700 (PDT) From: Vitaly Kuznetsov To: Anirudh Rayabharam , Paolo Bonzini Cc: mail@anirudhrb.com, kumarpraveen@linux.microsoft.com, Anirudh Rayabharam , wei.liu@kernel.org, robert.bradford@intel.com, liuwe@microsoft.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ilias Stamatis , Maxim Levitsky , Sean Christopherson Subject: Re: [PATCH] KVM: nVMX: Don't expose TSC scaling to L1 when on Hyper-V In-Reply-To: <87pmjbi90m.fsf@redhat.com> References: <20220613161611.3567556-1-anrayabh@linux.microsoft.com> <87sfo7igis.fsf@redhat.com> <87pmjbi90m.fsf@redhat.com> Date: Wed, 15 Jun 2022 13:30:53 +0200 Message-ID: <87ilp2i2oi.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.3 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,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org Vitaly Kuznetsov writes: > Vitaly Kuznetsov writes: > >> Anirudh Rayabharam writes: >> >> ... >> >>> >>> As per the comments in arch/x86/kvm/vmx/evmcs.h, TSC multiplier field is >>> currently not supported in EVMCS. >> >> The latest version: >> https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/datatypes/hv_vmx_enlightened_vmcs >> >> has it, actually. It was missing before (compare with e.g. 6.0b version >> here: >> https://github.com/MicrosoftDocs/Virtualization-Documentation/raw/live/tlfs/Hypervisor%20Top%20Level%20Functional%20Specification%20v6.0b.pdf) >> >> but AFAIR TSC scaling wasn't advertised by genuine Hyper-V either. >> Interestingly enough, eVMCS version didn't change when these fields were >> added, it is still '1'. >> >> I even have a patch in my stash (attached). I didn't send it out because >> it wasn't properly tested with different Hyper-V versions. > > And of course I forgot a pre-requisite patch which updates 'struct > hv_enlightened_vmcs' to the latest: > The good news is that TscMultiplies seems to work fine for me, at least with an Azure Dv5 instance where I can see Tsc scaling exposed. The bad news is that a few more patches are needed: 1) Fix 'struct hv_enlightened_vmcs' definition: https://lore.kernel.org/kvm/20220613133922.2875594-20-vkuznets@redhat.com/ 2) Define VMCS-to-EVMCS conversion for the new fields : diff --git a/arch/x86/kvm/vmx/evmcs.c b/arch/x86/kvm/vmx/evmcs.c index 6a61b1ae7942..707a8de11802 100644 --- a/arch/x86/kvm/vmx/evmcs.c +++ b/arch/x86/kvm/vmx/evmcs.c @@ -28,6 +28,8 @@ const struct evmcs_field vmcs_field_to_evmcs_1[] = { HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1), EVMCS1_FIELD(HOST_IA32_EFER, host_ia32_efer, HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1), + EVMCS1_FIELD(HOST_IA32_PERF_GLOBAL_CTRL, host_ia32_perf_global_ctrl, + HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1), EVMCS1_FIELD(HOST_CR0, host_cr0, HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1), EVMCS1_FIELD(HOST_CR3, host_cr3, @@ -78,6 +80,8 @@ const struct evmcs_field vmcs_field_to_evmcs_1[] = { HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1), EVMCS1_FIELD(GUEST_IA32_EFER, guest_ia32_efer, HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1), + EVMCS1_FIELD(GUEST_IA32_PERF_GLOBAL_CTRL, guest_ia32_perf_global_ctrl, + HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1), EVMCS1_FIELD(GUEST_PDPTR0, guest_pdptr0, HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1), EVMCS1_FIELD(GUEST_PDPTR1, guest_pdptr1, @@ -126,24 +130,47 @@ const struct evmcs_field vmcs_field_to_evmcs_1[] = { HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1), EVMCS1_FIELD(XSS_EXIT_BITMAP, xss_exit_bitmap, HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2), + EVMCS1_FIELD(ENCLS_EXITING_BITMAP, encls_exiting_bitmap, + HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2), + EVMCS1_FIELD(TSC_MULTIPLIER, tsc_multiplier, + HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2), ... so it is becoming more and more complicated to assemble for testing. Let me finish my testing and I'll put a series together and send it out to simplify the process. Stay tuned! -- Vitaly