From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED2CAC12002 for ; Mon, 19 Jul 2021 12:39:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D354D6113E for ; Mon, 19 Jul 2021 12:39:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237001AbhGSL6k (ORCPT ); Mon, 19 Jul 2021 07:58:40 -0400 Received: from mga01.intel.com ([192.55.52.88]:3319 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236811AbhGSL6j (ORCPT ); Mon, 19 Jul 2021 07:58:39 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10049"; a="232817083" X-IronPort-AV: E=Sophos;i="5.84,252,1620716400"; d="scan'208";a="232817083" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2021 05:39:19 -0700 X-IronPort-AV: E=Sophos;i="5.84,252,1620716400"; d="scan'208";a="499901418" Received: from zengguan-mobl.ccr.corp.intel.com (HELO [10.254.211.183]) ([10.254.211.183]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2021 05:39:14 -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 , "Luck, Tony" , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , "Huang, Kai" Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "Hu, Robert" , "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> <89f240cb-cb3a-c362-7ded-ee500cc12dc3@intel.com> <0d6f7852-95b3-d628-955b-f44d88a86478@redhat.com> From: Zeng Guang Message-ID: <949abcb7-5f24-2107-a089-5e6c1bee8cf2@intel.com> Date: Mon, 19 Jul 2021 20:38:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <0d6f7852-95b3-d628-955b-f44d88a86478@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/19/2021 4:32 AM, Paolo Bonzini wrote: > On 17/07/21 05:55, Zeng Guang wrote: >>>> +    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. > Understood, but in practice all uses of vmx->ipiv_active are guarded by > kvm_vcpu_apicv_active so they are always reached with vmx->ipiv_active > == enable_ipiv. > > The one above instead seems wrong and should just use enable_ipiv. enable_ipiv associate with "IPI virtualization" setting in tertiary exec controls and enable_apicv which depends on cpu_has_vmx_apicv(). kvm_vcpu_apicv_active still can be false even if enable_ipiv is true, e.g. in case irqchip not emulated in kernel. It's ok to use enable_ipiv here. vmcs setup succeed for IPIv but it won't take into effect as false kvm_vcpu_apicv_active disable “IPI virtualization" in this case. > Paolo >