Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3679620pxv; Mon, 19 Jul 2021 06:19:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/Kf3941DR4VypNiXg9CfVcvYWhy54eLL4Fej/rbTFohEo0/vvfNTjnw8c8KomaKxTxNhZ X-Received: by 2002:a05:6e02:1aae:: with SMTP id l14mr17414816ilv.35.1626700747793; Mon, 19 Jul 2021 06:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626700747; cv=none; d=google.com; s=arc-20160816; b=gg5/0ndPWbLQSLvYFZmU3hU/Rkh/PzWYR1pEdJkr5XYBUR2IhHzSkqDLy4ZkR/JfNr k7lo/9XBcWGUtmpRZuJDORU425FeBLo/rJJ/06QK/cR7+jSoryT1FaaajNU9iVAMAsZC CqVo13IUWCaETUPM7eNx4MIIpoTEjPg22WKaDMUifH0yRhwEmkJl0sw3YO9GjFaUmwr1 X/X9pdJbYzZuQCrZc6oeg35l6XtJD41pnegcfh0d/UH0h8pcWcIIrsTWagQhwmuqgxXw xXReJCU6/V7OswxHjW1YPvTyolzXQe1YfHRIzOHxHN3VbXeYTLs6hs6h55xCJqJ3RIm+ v2ZQ== 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=YmKIMKo+BRhQ4C32o0PbXBJiKK+ODpJHXV8MAuLsSiY=; b=ML4+lPENcX5TfUNSSZx1ynDGCqD8wu7tCcIoVwbXxA6mUTeRPGhFu3m5GIWf5hadTc 5ObhS3N+wa2qHsJSxEsG84RSggUrR6d6DZs2vrLV0u/EyrexM9/TX92iwS0KSnJXSqpc kIzQ5mbMM66BUtWWuFi4FebroySbqmfhX2CWr5BYUEtvZ10F+Fg5be6r/q/vqDcpgsXk BPMSTpJbwdm3N+LiOIfIY4esigQRl/Yr9K49Ql116wAkr6AXtDbPyV4jv8Kov+Ob4TpV Y95dztgWMLvOr2xr37j5lWy78Q/Uh0zMPdiealw4TUBBR43C2w+cV+3SUhvDIUM/Yu8j vHkQ== 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 z25si9417300iod.45.2021.07.19.06.18.55; Mon, 19 Jul 2021 06:19:07 -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 S237388AbhGSMge (ORCPT + 99 others); Mon, 19 Jul 2021 08:36:34 -0400 Received: from mga01.intel.com ([192.55.52.88]:6137 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237272AbhGSMge (ORCPT ); Mon, 19 Jul 2021 08:36:34 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10049"; a="232825154" X-IronPort-AV: E=Sophos;i="5.84,252,1620716400"; d="scan'208";a="232825154" 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 06:17:13 -0700 X-IronPort-AV: E=Sophos;i="5.84,252,1620716400"; d="scan'208";a="499913514" 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 06:17:08 -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: <026dffc0-032c-72a9-dd06-a46a3efe2add@intel.com> Date: Mon, 19 Jul 2021 21:16:59 +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. Though 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 runtime disable “IPI virtualization" for VM in this case and leads vmx->ipiv_active become false as well. So vmx->ipiv_active is more accurate to reflect runtime IPIv status. > Paolo >