Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1216292pxb; Fri, 1 Apr 2022 07:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFpjopIyZGCGKugtpbgLEbcyeHO+3DZBsNifgJnA8j7W2k8ypgIuAgMNy19Ce5tFl/RWFN X-Received: by 2002:a17:907:3d91:b0:6df:a01c:f7cd with SMTP id he17-20020a1709073d9100b006dfa01cf7cdmr88595ejc.255.1648823852442; Fri, 01 Apr 2022 07:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648823852; cv=none; d=google.com; s=arc-20160816; b=LVsWQIFgU7CgE4CQlOLxU9ihGQdh65rau7uKvy49+YWvAYF1WjJDkeFuz96JyJ3MhI X8FGD2FVVrJ9JkbC6kbNsovOnWTKR2pC0ixRPgaePaFuQIcriYnXt2XhnLjIu4KGgf+q jskyc8q8vtt+RoiO+dR62LnGA9qi12f8t/q9XQEpRiwzwXi5pnFM2xr7uq5RmhMzMmyp OYLURC7rATLtT/0noH2y7BJ+MwPjPlfWdaMAPjZDiWJBzRh26KJT7GMO/uRdwzqxdJd4 JIQgKuvUgDKK86nXaWNsnivpK6tQDE2E/piHfS2fSEa6gcj9ID3NeFdckcTSS9USknt1 aBbg== 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; bh=Wzx4h3J831JsKYMNZGvkQ7llH9BK5twqJrLQ0USMFVk=; b=tfHnK8+czCfPdp/taJMJT0zd2EspKC3HkZ0zURkFGgXjC7TaIzelOBvf0mrltJHPst BUR3M3sSX1EeguB8hJIcMhhce0335GTf4+seDX9vW4SwthE7N73tt34nitClbdNh2/j/ lVdwpThBdFslqZDwtgCVDjwf1LrQQIZmDxiBJERh6NBdLGHM643OErpSZoGI3pqgvf3R iF3FRkBDYuY38AuDMmMX2xAXT0NNCbjkcoKhtmIVbibPnuwRfz//VR/gUNy4c2TWveP6 DDE7cIy9TJgWz358S9+qHEqNHHkBjLQFw1YX8SgjhsQiceTQv5hCYtInusCTmBBscJOZ byLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Xtf7XTzh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a1709062a4400b006dfe65cdeefsi1700908eje.87.2022.04.01.07.37.06; Fri, 01 Apr 2022 07:37: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=@google.com header.s=20210112 header.b=Xtf7XTzh; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242634AbiCaWnN (ORCPT + 99 others); Thu, 31 Mar 2022 18:43:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242605AbiCaWnL (ORCPT ); Thu, 31 Mar 2022 18:43:11 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51C02215910 for ; Thu, 31 Mar 2022 15:41:23 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id s72so905964pgc.5 for ; Thu, 31 Mar 2022 15:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Wzx4h3J831JsKYMNZGvkQ7llH9BK5twqJrLQ0USMFVk=; b=Xtf7XTzhWR7t6NfeN54sWEY1W81DT0Gvy7A/N6JbR+VzgSteQDCd+Eugmmt6WCB6+P E+XQ0MaZx6Lj2Ys2HNhcglwFGBUo9wqKD0Dvgrsl59FE1qIX2xpGOID432kT3n9a93aV d83ZRxxrHb0yEb09xo36wb0eYO5yAIZO+lZUgddfw0XJUNEso3gcGu7PIWjpiHkMpH8D du/IZ88kpi+3TI64iacCrGrfWOQ6B+xi71Vb73/2RvnVNaWVfYrQmx0FkxVXIIyJCi9Q B79APqR3zMtDg6/y7UaP/fzHKU/waClPQQwtxbc0N28zAK9q39hW2B0SYMexRs6sGEAB XMUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Wzx4h3J831JsKYMNZGvkQ7llH9BK5twqJrLQ0USMFVk=; b=7cvKHnzojs5qU7D6zfsJ63vKo3xLR6KKq4h6m6eqKifJTPl05t4HGjwtgu+2UBqdZu nsQsVLcrYbyre0vr3Dq/qeN5PvJy1/ypEbnn5RWXfrsKxafiYyis3F1S/e9wNr2ZsUIg tQJYpo13hXYGY3HhENCI9DYAhonZ3d6U+JdIhawk7K4mXKbw1bCMFBwOD/CgBgE412f1 ae41cMeNG3ihuWEbbSUIxF0ZsjWx8GKqRIEKCVdSFmZb/WLejMaVIGRkQpBq9iDEEmpG MOf+xjLNzTseanwQfkhk9QoGrBbs4zjh8trjHUfnNrUZsj/YJ+Iabu9VWZnKxSSzZeLg WmNw== X-Gm-Message-State: AOAM532+v69H8t4oWK65Yo1/SmRCjClCJWSpu2KX2EIy+AxxfgoEoXtS LRXNoZpFwqK6452MdOlEPLyyTQ== X-Received: by 2002:a63:4005:0:b0:373:9ac7:fec1 with SMTP id n5-20020a634005000000b003739ac7fec1mr12512800pga.12.1648766482539; Thu, 31 Mar 2022 15:41:22 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id h2-20020a056a00218200b004f6519ce666sm508170pfi.170.2022.03.31.15.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 15:41:21 -0700 (PDT) Date: Thu, 31 Mar 2022 22:41:18 +0000 From: Sean Christopherson To: Zeng Guang Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, Dave Hansen , Tony Luck , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , Kai Huang , x86@kernel.org, linux-kernel@vger.kernel.org, Robert Hu , Gao Chao , Robert Hoo Subject: Re: [PATCH v7 3/8] KVM: VMX: Detect Tertiary VM-Execution control when setup VMCS config Message-ID: References: <20220304080725.18135-1-guang.zeng@intel.com> <20220304080725.18135-4-guang.zeng@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220304080725.18135-4-guang.zeng@intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 Fri, Mar 04, 2022, Zeng Guang wrote: > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index c569dc2b9192..8a5713d49635 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -2422,6 +2422,21 @@ static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, > return 0; > } > > +static __init int adjust_vmx_controls_64(u64 ctl_min, u64 ctl_opt, I slightly prefer controls64 over controls_64. As usual, KVM is inconsistent as a whole, but vmcs_read/write64 omit the underscore, so we can at least be somewhat consistent within VMX. > + u32 msr, u64 *result) > +{ > + u64 allowed1; > + > + rdmsrl(msr, allowed1); > + > + /* Ensure minimum (required) set of control bits are supported. */ > + if (ctl_min & ~allowed1) Eh, just drop @ctl_min. Practically speaking, there is zero chance tertiary controls or any other control of this nature will ever be mandatory. Secondary controls would fall into the same boat, but specifying min=0 allows it to share helpers, so it's the lesser of evils. With the error return gone, this can be static __init u64 adjust_vmx_controls64(u64 ctl_opt, u32 msr) { u64 allowed; rdmsrl(msr, allowed); return ctl_opt & allowed; } Alternatively, we could take the control-to-modify directly and have no return, but I like having the "u64 opt = ..." in the caller.