Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3540741pxb; Mon, 4 Apr 2022 20:32:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZw5G1uJ2oNjc1yX00tsTetK5NxyHgliXlGfJ5XxZexIhnm7oHxoTlA9+3UK9NWDXnnnXk X-Received: by 2002:a17:902:8496:b0:156:a95d:69c7 with SMTP id c22-20020a170902849600b00156a95d69c7mr1438784plo.131.1649129519845; Mon, 04 Apr 2022 20:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649129519; cv=none; d=google.com; s=arc-20160816; b=nSgJJpo0+2x161q4CdN8UzjVvARoPVxvOW3Pkj8ihJtP5hpSJg43MoAEqVcUSqM235 fCow2sRuH7BtE+dw4r+kSinvvwnoh2USsr71BPEEUWA4f+lrxzYZU3LjHVTtLjS3sC1p OPC84g2qdRHeEat1gClt1bVcAMeRhqTW4fTuIjCMyNBk+7uF8aMZc66RGM3eBUDqYkHa C8vr8fiXsyvY7m3kNAnsrg7k/N+9oGcZwAkKfHcY5CSB+eDI8f9OMgl7BegHqkFYslhg xESyjWNEnq/xaYEzYDj84VLNZOk/qxCJLHGugU6oC/VMA9xmbNCyte4v1tkzBk0I8MNg /zFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=DIazVPKaeb1Z4lE19q2cb8p9oKV4pHoxsWvIVe39mzY=; b=GCT43QAf/L3zbxKAvj3KVmpWaqGw5Aom1iJh41xKtodw+JHn4Y+0FLO8oFLqqYXHrX qHB4/xqyGwCyy4gCmtfCBVskNwMbRavEfYXogt7rbJb+lQKPKX8OMJse1cFxaD3UONK0 bmNme7vK3lUGjzRtmBrwjmzwRDqMQnzpMFqu3YwIBPRzBRzgaWdQbaWzPlhyMKGrSNrD RwVhpJ0UT7DhEG5svx80PV/tQNh1q8o+ynMz8QyNusvwdPKGJZ7LLY9B6BlyfxIkyTBl qG9WSFQfB1kF7L9ICVJPTd9mqCHcJB5U0dvMVVX1ioOayb/P2QgQxx5z79nfURAVrNAV MlEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CKr++QeL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s21-20020a056a00179500b004fa3a8dffa3si14016911pfg.90.2022.04.04.20.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CKr++QeL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4392360425; Mon, 4 Apr 2022 18:31:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354837AbiDBNAq (ORCPT + 99 others); Sat, 2 Apr 2022 09:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238974AbiDBNAo (ORCPT ); Sat, 2 Apr 2022 09:00:44 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0B0413DE9; Sat, 2 Apr 2022 05:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648904332; x=1680440332; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=1oh9WbktFqlG6EG6X9CN0PCZbltAesQdU2DAWj+J/rg=; b=CKr++QeL2Wdaz4JQnjNr+yh8hR1Y4geLMbdcHxigFxFzNuW6P8PI3nuL VXwIphV6wrv8pYlAxY8vAQOLJTd2n9Qv0nMvvouZCSpUMRGJBJ6xb2bM5 E/d89jpy8ox7rwrbw55I4vQ63yplQzY3/j/9UyhBgV1kWFb4LHnFrYN0o en94PqMN+4NuTyqLGPFgL6Bh+xOUtqc0OP2FepTxlujaUF5sebUu+JLOM gHURBOJxHWcA9BccMCANS8s+kHX9duVlpcBc6ER67Pwauun8T097085Rw qYvYPJPF48V0Z4pZTdCOvyYndG8vkFHg90qqNTX7jvIOR0GL65U7lAO2p g==; X-IronPort-AV: E=McAfee;i="6200,9189,10304"; a="260286864" X-IronPort-AV: E=Sophos;i="5.90,230,1643702400"; d="scan'208";a="260286864" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2022 05:58:52 -0700 X-IronPort-AV: E=Sophos;i="5.90,230,1643702400"; d="scan'208";a="548132631" Received: from zengguan-mobl1.ccr.corp.intel.com (HELO [10.254.208.38]) ([10.254.208.38]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2022 05:58:45 -0700 Message-ID: <1c6ad344-299c-bd78-c6e7-79a815e15ef1@intel.com> Date: Sat, 2 Apr 2022 20:58:38 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v7 3/8] KVM: VMX: Detect Tertiary VM-Execution control when setup VMCS config Content-Language: en-US To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , "kvm@vger.kernel.org" , Dave Hansen , "Luck, Tony" , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , "Huang, Kai" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "Hu, Robert" , "Gao, Chao" , Robert Hoo References: <20220304080725.18135-1-guang.zeng@intel.com> <20220304080725.18135-4-guang.zeng@intel.com> From: Zeng Guang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_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 On 4/1/2022 6:41 AM, Sean Christopherson wrote: > 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; > } Make sense. I will change it.  Thanks. > Alternatively, we could take the control-to-modify directly and have no return, > but I like having the "u64 opt = ..." in the caller.