Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1568132iog; Tue, 14 Jun 2022 08:33:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uuQ1gFRrubZMv9aeGvIi3WlAHcZARgc2/aHtauKq2jWqcWNJyg4U+TGCvgqC2PqCyb0MXM X-Received: by 2002:a17:906:58c8:b0:6fe:91d5:18d2 with SMTP id e8-20020a17090658c800b006fe91d518d2mr4793038ejs.190.1655220809768; Tue, 14 Jun 2022 08:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655220809; cv=none; d=google.com; s=arc-20160816; b=HXd7kvD0IDJcziVlMOV4qXjstLskaOye8Fd5AFgHUK1vY9IMjHIQOrQqXF93bYDFr5 gnoQTX9EC18paYKrzWm0h/MhyF3RWF+oFfMMTt/xQtVJJdPnEdwja9HknfejcrjUwuLK DThz+6httz8WibapE9TWuV9tvCddy3sQZ9/TBJcsa8XlAtJrc3fi7AH+BJpDj6OJu5Pa EsVzx6Lzz9HWtIkpbEDba7ig5R45+xTW1TqHYBxeNYmKJ2Mz5fMbSIaCyI2FUAjU5twe uYgASB+ulvCEb3DVKEoN3bxdUfm2J3sKZyUmbzwoTunXHXLuJyLiwyaRTf18y8NuNFXX ospg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=RS7cjzRsU35AKyG6Qmud17MN3MhX4pjeepmvXkcXxug=; b=x53ec3GmUHk/R6ToGjgAIc5livUVqCHpUU9I0Gc5i/FZYEV0LJgZo9bjjTpxF9kZZu 9hROxBpQNxSMX17jt2QIjvSkIoCebD3CWWMwnAJwowHDGoNC6vU4HGE3Syoxv1KTROVp IwQ25qUlzled1BW9txPyTO0wXjqcdYOAKwfzXAaG1sqDVhgzFMxH0G0J7k+eNpZXoI8y Ue59108u8vx9DywTjrOWYlZ79zbH7Jfq7kxJCFWHCg2EhAJI5nfNBxwl2dkM5lmqmOE1 axcvPwV+YdXdeRDPUAlIVXCnSslDMaZXOnOfXtW9EILxBGyxyVRbV/Zy2pQ05f14E3jb os6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=eaUX9oDz; 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=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a170906220300b006fee9ca7540si9848285ejs.244.2022.06.14.08.33.04; Tue, 14 Jun 2022 08:33:29 -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=@linux.microsoft.com header.s=default header.b=eaUX9oDz; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343975AbiFNP3W (ORCPT + 99 others); Tue, 14 Jun 2022 11:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356985AbiFNP25 (ORCPT ); Tue, 14 Jun 2022 11:28:57 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D7001B7AD; Tue, 14 Jun 2022 08:28:57 -0700 (PDT) Received: from anrayabh-desk (unknown [167.220.238.193]) by linux.microsoft.com (Postfix) with ESMTPSA id 73C7020C317B; Tue, 14 Jun 2022 08:28:51 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 73C7020C317B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655220536; bh=RS7cjzRsU35AKyG6Qmud17MN3MhX4pjeepmvXkcXxug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eaUX9oDzRz4AXlIoUX2No+UlMdfgH0fK/uyX9G2IvH35fheFVBF0ZppdYKHwvvLAh UgRUdQENcVjBzvunILFaoDl1jE1dZTl1ci+bbrdHR6lBteZ1U8tzLd5n3lG/bI3KuZ m/W/u8ssheXRLO2pM2l6u1tUe84duzEkOelUC7AU= Date: Tue, 14 Jun 2022 20:58:46 +0530 From: Anirudh Rayabharam To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ilias Stamatis , Maxim Levitsky , mail@anirudhrb.com, kumarpraveen@linux.microsoft.com, wei.liu@kernel.org, robert.bradford@intel.com, liuwe@microsoft.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: nVMX: Don't expose TSC scaling to L1 when on Hyper-V Message-ID: References: <20220613161611.3567556-1-anrayabh@linux.microsoft.com> <592ab920-51f3-4794-331f-8737e1f5b20a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham 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 On Mon, Jun 13, 2022 at 04:57:49PM +0000, Sean Christopherson wrote: > On Mon, Jun 13, 2022, Paolo Bonzini wrote: > > On 6/13/22 18:16, Anirudh Rayabharam wrote: > > > + if (!kvm_has_tsc_control) > > > + msrs->secondary_ctls_high &= ~SECONDARY_EXEC_TSC_SCALING; > > > + > > > msrs->secondary_ctls_low = 0; > > > msrs->secondary_ctls_high &= > > > SECONDARY_EXEC_DESC | > > > @@ -6667,8 +6670,7 @@ void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, u32 ept_caps) > > > SECONDARY_EXEC_RDRAND_EXITING | > > > SECONDARY_EXEC_ENABLE_INVPCID | > > > SECONDARY_EXEC_RDSEED_EXITING | > > > - SECONDARY_EXEC_XSAVES | > > > - SECONDARY_EXEC_TSC_SCALING; > > > + SECONDARY_EXEC_XSAVES; > > > /* > > > > This is wrong because it _always_ disables SECONDARY_EXEC_TSC_SCALING, > > even if kvm_has_tsc_control == true. > > > > That said, I think a better implementation of this patch is to just add > > a version of evmcs_sanitize_exec_ctrls that takes a struct > > nested_vmx_msrs *, and call it at the end of nested_vmx_setup_ctl_msrs like > > > > evmcs_sanitize_nested_vmx_vsrs(msrs); > > Any reason not to use the already sanitized vmcs_config? I can't think of any > reason why the nested path should blindly use the raw MSR values from hardware. vmcs_config has the sanitized exec controls. But how do we construct MSR values using them? Thanks, Anirudh.