Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2918796pxb; Fri, 8 Oct 2021 19:16:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDMoz6Sq9XcXQJ/Cct7WFODYXgqAavwdndyr0VxwiugvEkJ83qDqXOrQJuOkFYV2JCb8ki X-Received: by 2002:a17:906:4d04:: with SMTP id r4mr8774483eju.252.1633745806903; Fri, 08 Oct 2021 19:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633745806; cv=none; d=google.com; s=arc-20160816; b=ejUHvE5jV0Ewm7kyjsHXEFi6+4mD5A7zJwu4D0TSauQmpS9Alftz9uVHiXv8jdzmax /p/QoS+Nnez3lpyRQ+cUsLHbRCdW+5Ec83pjs+rIsCSlGIhRm5iTvGZj/0fqliuwtkPN lqQvUW8K3Ha4MguQNj8mrbo3Dzj3aIbg8WXZcWDNcRacNjAty8D3usF9KomYs0Il7r8z xxz2h283VhTJjGBb2ruXkF/ieBn22TCbbUgGUhRnLG3kTrAPNXVB/b0UnfbiZQKTnEnW YNdLlIr5NaDOGC/j0jDNMgeUgaax9NFdPBZsGdG3ZWusSxV0FBn1COkmoyFvuFOXiwYU daOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=JkZfdKKKsnqnpAtGUC7eJv8NSTwENPUfH6MKqHK3m28=; b=vdblfkcWQ/+HQn7Q+d5zN+P0x8q8Wg3b5xxDT1Hzi1gzg8SPS9PSQGV3ULsINlOQ9F XZcd+Z7UdhILQacN/isYJpeLz5MXwitQcs+B8PwVRBQ/iFoLwpQuC8HJEITxD6y4IKGC L/v6+sqAq2PTfQww6XS5hIqy/ppV+iT7Z9sCAqyNu2kPmXLlnmN77v4nYu7L6ZAGusEn +HKbOCvafw33zDZTVj6cbYxiC0rRrISLNbwYUrnHRZ/PJYAe+Jf5ttg/1qTutcEXwPfg xB88sNyBCBDV3nd90iIRuxQJ6GyYtWVOX1IcVh+6TrO3PY0SXwCD86UkTHj4qjtrxSYu /w5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qVLIqxee; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si1471574ejk.223.2021.10.08.19.16.23; Fri, 08 Oct 2021 19:16:46 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=qVLIqxee; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244605AbhJICQY (ORCPT + 99 others); Fri, 8 Oct 2021 22:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244355AbhJICP4 (ORCPT ); Fri, 8 Oct 2021 22:15:56 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E501AC061775 for ; Fri, 8 Oct 2021 19:13:31 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id q17-20020a25b591000000b005a07d27bbdaso15038041ybj.3 for ; Fri, 08 Oct 2021 19:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=JkZfdKKKsnqnpAtGUC7eJv8NSTwENPUfH6MKqHK3m28=; b=qVLIqxee/wprC+4bjZNYJueP2zjkd+ggVBKmgUwNSOpnEV7X/9yGfblAJrRqdCWEih HkkaQsOOaOeL+/6gKeVGYHju8vK+HKNcdt3bTPsONepW8SXVyQdRvqfaAKZcB8+jVwae l3QyVEsfib1Ds5XSLDwK5fjGQZuWnnjDxgzphYDPgXfwssEpRJVHvOakRnpFdPD78q0R +0gwjhJzjz6GJsBbS0TZrWfFGUf6BV3+uE57g+PTVVc8UKWIe6wyeSoVcPpQNBbE7SiU oPp2V17b+NBHZjC8Iixu81AY6DPeXf4DpNjHUN5949xj5Ej8bfX8i2do7PuBJAHe/oBY ATyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=JkZfdKKKsnqnpAtGUC7eJv8NSTwENPUfH6MKqHK3m28=; b=hn7fAt++Go/5WrU7dvxJFAvfOyRWCvWC8rHwt1KnNLYiiCDylFkg8mDqRMC+IQgG+D vkFzfpH9b3TCsLSBs1/zFlkyYZktsjV/jKFn1dLxtGeCsr9Fg5/0U8r+UFBoHManQIE0 DTw0pEsEjEqHcWAqDcn88UnQd6fq8Xxa6mZpPjaYzCuMKg6v7EA10muFP+GnJTnsLyxu RxGFvHXfydh/bmhjvjr5wighisAgkugA+LlcAZXRxD6kh/NDHPjMcpRd67Gn5iPisnJi BxWFgWYZENOMaCjDwSHdbgKQVP2+D24BzW+NOLdStthmHX756L5uHAJPLZs7WOR2beLU RfMg== X-Gm-Message-State: AOAM531hQlPTMtfKxazXMe1yUJ9qyGKEC/otqViBr/lvicM4uDXQ1HB1 Rh3FCuQph+voek1lOO/hTEXF1XJRaMc= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:e39b:6333:b001:cb]) (user=seanjc job=sendgmr) by 2002:a5b:d03:: with SMTP id y3mr7590634ybp.400.1633745611129; Fri, 08 Oct 2021 19:13:31 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 8 Oct 2021 19:12:13 -0700 In-Reply-To: <20211009021236.4122790-1-seanjc@google.com> Message-Id: <20211009021236.4122790-21-seanjc@google.com> Mime-Version: 1.0 References: <20211009021236.4122790-1-seanjc@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH v2 20/43] KVM: VMX: Skip Posted Interrupt updates if APICv is hard disabled From: Sean Christopherson To: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , Oliver Upton , Jing Zhang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Explicitly skip posted interrupt updates if APICv is disabled in all of KVM, or if the guest doesn't have an in-kernel APIC. The PI descriptor is kept up-to-date if APICv is inhibited, e.g. so that re-enabling APICv doesn't require a bunch of updates, but neither the module param nor the APIC type can be changed on-the-fly. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/posted_intr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 3263056784f5..351666c41bbc 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -28,11 +28,14 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) unsigned int dest; /* - * In case of hot-plug or hot-unplug, we may have to undo - * vmx_vcpu_pi_put even if there is no assigned device. And we - * always keep PI.NDST up to date for simplicity: it makes the - * code easier, and CPU migration is not a fast path. + * To simplify hot-plug and dynamic toggling of APICv, keep PI.NDST and + * PI.SN up-to-date even if there is no assigned device or if APICv is + * deactivated due to a dynamic inhibit bit, e.g. for Hyper-V's SyncIC. */ + if (!enable_apicv || !lapic_in_kernel(vcpu)) + return; + + /* Nothing to do if PI.SN==0 and the vCPU isn't being migrated. */ if (!pi_test_sn(pi_desc) && vcpu->cpu == cpu) return; -- 2.33.0.882.g93a45727a2-goog