Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1873374pxv; Fri, 16 Jul 2021 20:59:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw38WfBec5a7Ry8x0+m8vJHLqx+tnbA5ZZHT9RqfRlOFlDebi1EGUFDSeGxsjzura78MBOk X-Received: by 2002:a05:6402:10c7:: with SMTP id p7mr19370132edu.159.1626494351580; Fri, 16 Jul 2021 20:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626494351; cv=none; d=google.com; s=arc-20160816; b=sAwEWkCZqmWGDD0beLgUePpM7s/nPMN1Xq26H+0AIE1W4LdzRLj9b1nMmh81z4e3D8 8EVLOcndkfBcszp3mbHgEnGWgkAUz6h1xmE3i64556/g9dPfixtbXn1kWWWoNJKbJAFe x14gkPVYo5v19SHu8EH5ZZJzefXUT19awyuWqIEwr5h7zJmiTRBNlP9iQ4U0XLRmudPA 3vC1rqoDMz9Fjk54W6ferfq2WG3Ksc6EiOE3UNRW0fMyiqut5Fyp7LiBDBhWujkVk/FJ C5Bn0Hidp0F5smW9Ad+1YhiKuQothNSiiK3YM8z2MBIFvZVCDlRSh6MSO0t5Ze3Z4BIr Xbuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ERGlNaSC3Gw0lhSQsffNiyETnsALHobGKPe5jrKBVJk=; b=YcuTAKKFUoh85IZGcx5l8djxodGfDpY2Ts0iKxED6vSnleTqYNTvG1nzOASojM7k2N QqJ9NKrXPvJYRKUiUO7/D5cKK07vsSMcBz7vo93rKDVznfDmUxNnYZNuSTS2W94N8mg2 sfeZKAJWSC4f/SmzfBY2AFgN8jYorMCM4Va8wfjSKaX2Rae62w2l8dilESvTIr6lUXsm YLz5G+1OYSuow9jBJPV7n96irFq/Za7/rvkmlPgH6LM8wG4bTMv6sFtcm/1gkjMvRVlT FCtEqjSc7gty57cjlYIheldYi8DnXE8VBEhfgUgWJXTFvMJMZ5BMPnd85ttVQXiII1Ic 9lTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si16254781edj.420.2021.07.16.20.58.14; Fri, 16 Jul 2021 20:59:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232520AbhGQD6r (ORCPT + 99 others); Fri, 16 Jul 2021 23:58:47 -0400 Received: from mga18.intel.com ([134.134.136.126]:57567 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229982AbhGQD6q (ORCPT ); Fri, 16 Jul 2021 23:58:46 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10047"; a="198076984" X-IronPort-AV: E=Sophos;i="5.84,246,1620716400"; d="scan'208";a="198076984" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2021 20:55:50 -0700 X-IronPort-AV: E=Sophos;i="5.84,246,1620716400"; d="scan'208";a="497327097" Received: from zengguan-mobl.ccr.corp.intel.com (HELO [10.254.211.215]) ([10.254.211.215]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2021 20:55:45 -0700 Subject: Re: [PATCH 6/6] KVM: VMX: enable IPI virtualization To: Paolo Bonzini , Sean Christopherson , 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 Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Robert Hu , Gao Chao , Emanuele Giuseppe Esposito References: <20210716064808.14757-1-guang.zeng@intel.com> <20210716064808.14757-7-guang.zeng@intel.com> <8aed2541-082d-d115-09ac-e7fcc05f96dc@redhat.com> From: Zeng Guang Message-ID: <89f240cb-cb3a-c362-7ded-ee500cc12dc3@intel.com> Date: Sat, 17 Jul 2021 11:55:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <8aed2541-082d-d115-09ac-e7fcc05f96dc@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/16/2021 5:52 PM, Paolo Bonzini wrote: > On 16/07/21 08:48, Zeng Guang wrote: >> >> +    if (!(_cpu_based_3rd_exec_control & TERTIARY_EXEC_IPI_VIRT)) >> +        enable_ipiv = 0; >> + >>       } > > Please move this to hardware_setup(), using a new function > cpu_has_vmx_ipiv() in vmx/capabilities.h. > ok, we will change it to follow current framework. >>      if (_cpu_based_exec_control & >> CPU_BASED_ACTIVATE_TERTIARY_CONTROLS) { >> -        u64 opt3 = 0; >> +        u64 opt3 = enable_ipiv ? TERTIARY_EXEC_IPI_VIRT : 0; >>          u64 min3 = 0; > > I like the idea of changing opt3, but it's different from how > setup_vmcs_config works for the other execution controls.  Let me > think if it makes sense to clean this up, and move the handling of > other module parameters from hardware_setup() to setup_vmcs_config(). > May be an exception for ipiv feature ? >> + >> +    if (vmx->ipiv_active) >> +        install_pid(vmx); > > This should be if (enable_ipiv) instead, I think. > > In fact, in all other places that are using vmx->ipiv_active, you can > actually replace it with enable_ipiv; they are all reached only with > kvm_vcpu_apicv_active(vcpu) == true. > enable_ipiv as a global variable indicates the hardware capability to enable IPIv. Each VM may have different IPIv configuration according to kvm_vcpu_apicv_active status. So we use ipiv_active per VM to enclose IPIv related operations. >> +    if (!enable_apicv) { >> +        enable_ipiv = 0; >> +        vmcs_config.cpu_based_3rd_exec_ctrl &= ~TERTIARY_EXEC_IPI_VIRT; >> +    } > > The assignment to vmcs_config.cpu_based_3rd_exec_ctrl should not be > necessary; kvm_vcpu_apicv_active will always be false in that case and > IPI virtualization would never be enabled. > We originally intend to make vmcs_config consistent with the actual ipiv capability and decouple it from other factors. As you mentioned , it's not necessary to update vmcs_config.cpu_based_3rd_exec_ctrl in this case. We will remove it. Thanks. > Paolo >