Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2919101pxb; Fri, 8 Oct 2021 19:17:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx142eApk8UzPj7Iw3nF7TAg8iOFtT8WI5ZdqU2E5WLnFOj7WnG2Zh4v48PUQMn9rU5bJi X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr12215832edd.101.1633745837941; Fri, 08 Oct 2021 19:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633745837; cv=none; d=google.com; s=arc-20160816; b=Vnvd/FVnHu3xeb2+a4KsGFufS+DCPyEhGeuADDZFAF//0D6Jd507wGq+tbdjwLQiHl REK+uuUUkBPzLr2w0I0XpxZJxXIEVWMTWPdP0B8Bo2+ddb4qNyMXx14FzlKlMMu0LA39 puroXY2iDyIMd4m6pQUyZ6QXnCErSUkFjoIM7VmtccUwt7i6ZmrQ6B4xfEY8XLU3bSJ6 W6IQfveAOUUsNJ4RdxBiswBOK/JG02wa2asq6NBJZi/HPP902UZxx6+dcX0MPTYpk0nK lwKMJG5H4N+nQP0rRvd+/h62hSDUn5t1LEYm56Aitop242hZKKnYwVBOXo+7GF9/Y+uV ZJpw== 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=sIQRe0bn32KEKwbOVvtx42Ei92aBPRnG0u1z9yXF7CE=; b=0e8dT5rau85g4sgNmw0G19gqUw64XWE336ahtIAE4q5HtLdrL0TNxwVjHQFGucDZpH K8Y5ZLcbxqaq4aYudn0ylfW9zn0E4UhQK2d3UdT2BqD7JBNBAjHEYT+f95GupnEW1eDl Bu5AS9iEzoqwG3iLSrXaTv/QdCVH4buYIeBbK+dxP5Wqmb+0JMbYoXAGUZzM2nGZCGml jnxiLPNw6lYQP4jMxg0ps7V+P83d9Kg7wYiDFPchD4CoQxlgGruWqlpOfJEwhDaCJClS Omi0DadQMI8QG6/IwyJ1CKX5t+FSoiL+weX4feRVv9OZYyi4nw6hr3mhmvg73zFJmnXa mWyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=L08kypVl; 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 z16si1479153ejf.338.2021.10.08.19.16.54; Fri, 08 Oct 2021 19:17:17 -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=L08kypVl; 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 S244487AbhJICRO (ORCPT + 99 others); Fri, 8 Oct 2021 22:17:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244575AbhJICQk (ORCPT ); Fri, 8 Oct 2021 22:16:40 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 422B4C0617AD for ; Fri, 8 Oct 2021 19:13:44 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id i83-20020a252256000000b005b67a878f56so15033128ybi.17 for ; Fri, 08 Oct 2021 19:13:44 -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=sIQRe0bn32KEKwbOVvtx42Ei92aBPRnG0u1z9yXF7CE=; b=L08kypVluCyFKbpY0oUWWIYegtRsmlesq0wNJKsfeI8a+xUhccbxmouLf27lMOIMO9 m9aDG4U98QItV5Ohy31bYubmFprE/QZuQESLgVJSjhpfU/yNgKP/78Q9UuOg6rzwLHC0 I4lwz0lK7D60KgROmr99XXMz1SfThZEdbn4DKl+Bq52u94Dtdh0Eotn9sUFXLmNXNTbw 6AcWYEC/LOtNjiY9B+NbBHy51wS3Qc+ABq6bMsBOBRird64iFAtM2ABnk7IiuRD0HQUk sjoVTJNAcXG0HP9OnEd8LwZlRBWZpFzxibDplRt3XRCh0O4+qvRQnekLDqaQSXwlvM/O WhoA== 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=sIQRe0bn32KEKwbOVvtx42Ei92aBPRnG0u1z9yXF7CE=; b=J0mjdVH/hGbT6PziOhMTUmv3K9CHrfGqLFzy3yLXN6sV/hS/TFw8CB5sXCunK+qqcr IS33PtE0nEjEcKDbJIHwlRXctIdzin9W1Cqb8KLrWIFAd6HNkwst1ed+40rsie1dSNYw dJZK5F46wkUHT+YQn7CtVwMsbDMNF0NjAS6x969L/nFPKdZYJxFlZJSIFt6NCSTzYQHp UDrV9nGyQBVWSqn+pOvDVc9eYq2fkNCMx7Hwltcbo9kcrjGOC8R9FEUb/+GkCtJtpzHS PTc+luA39hDWq+OgQ3HghXp4nZdCAGnKYM3bOgCtrU0wPKXhVqESnjcxd8Nza37MGJNu 6S0g== X-Gm-Message-State: AOAM5303chg1MP9r+/YgmhH+rtwvsHaByR7WAVuXSVWIFndj5XFB/aSz +Xh8MtBSA7WETKDQ85krZhiIMFj2Yew= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:e39b:6333:b001:cb]) (user=seanjc job=sendgmr) by 2002:a25:393:: with SMTP id 141mr7017004ybd.534.1633745623429; Fri, 08 Oct 2021 19:13:43 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 8 Oct 2021 19:12:18 -0700 In-Reply-To: <20211009021236.4122790-1-seanjc@google.com> Message-Id: <20211009021236.4122790-26-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 25/43] KVM: VMX: Save/restore IRQs (instead of CLI/STI) during PI pre/post block 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 Save/restore IRQs when disabling IRQs in posted interrupt pre/post block in preparation for moving the code into vcpu_put/load(), and thus may be called with IRQs already disabled. No functional changed intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/posted_intr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 239e0e72a0dd..414ea6972b5c 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -140,6 +140,7 @@ int pi_pre_block(struct kvm_vcpu *vcpu) { struct pi_desc old, new; struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); + unsigned long flags; if (!kvm_arch_has_assigned_device(vcpu->kvm) || !irq_remapping_cap(IRQ_POSTING_CAP) || @@ -147,8 +148,7 @@ int pi_pre_block(struct kvm_vcpu *vcpu) vmx_interrupt_blocked(vcpu)) return 0; - WARN_ON(irqs_disabled()); - local_irq_disable(); + local_irq_save(flags); vcpu->pre_pcpu = vcpu->cpu; spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->cpu)); @@ -171,19 +171,20 @@ int pi_pre_block(struct kvm_vcpu *vcpu) if (pi_test_on(pi_desc)) __pi_post_block(vcpu); - local_irq_enable(); + local_irq_restore(flags); return (vcpu->pre_pcpu == -1); } void pi_post_block(struct kvm_vcpu *vcpu) { + unsigned long flags; + if (vcpu->pre_pcpu == -1) return; - WARN_ON(irqs_disabled()); - local_irq_disable(); + local_irq_save(flags); __pi_post_block(vcpu); - local_irq_enable(); + local_irq_restore(flags); } /* -- 2.33.0.882.g93a45727a2-goog