Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1443758pxb; Thu, 28 Oct 2021 03:56:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgFfAafKCTboZp2wuBeqc/UAu4uYKPKR8lhFBhPGX3dWmnGfCT+jmA8yveJTeT6bKQmX6w X-Received: by 2002:aa7:8a53:0:b0:47b:e1e1:6405 with SMTP id n19-20020aa78a53000000b0047be1e16405mr3522940pfa.37.1635418579194; Thu, 28 Oct 2021 03:56:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635418579; cv=none; d=google.com; s=arc-20160816; b=p2yh8cbeREcIiylmcIKnkqrzq8+8WHmNuUZZdT9lMAys5Ts2q5Gy6rWJ9z6+CxBa0u dK3eHisH94SvW7JfomLh3JSv37ce139ZeBbfSrK/Ut3agMLx86cdR9g0Gs/E9zJifZj9 L6lP2m+EInblcKbbg5SFHtnORqU5b7BUgoibTDATIRWwjRp29CnFyoT7OOGVqPM3Ym0/ VVfT/WbUEy0ybzcWw3JnNG+/tIDE04ikeQZS2qCPKpshAgr8ECOFXGsyiF2ngULawFfJ z3tGOKGmvLf0AO0ptY7md91nmoD3t2ooifAe2wRYE51jZov5QjKrFXzgKyP7ghnJ/1uf CcsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=rVBM4WS2LhpDG29Lqha3fLHlxhnITE0Ru8HhYa7oBTo=; b=yDnYzaSygcD1PDSMQWplJrK47MnvoozWpkJUgcHYa5u8qofW1AdPjBMgVao7nDG+PL VR4L9zUX4LmmHoPxPYH6COIUNwL3uBUDWKWbRi2ga9ThoAB8HVIhFtNzZuicxhB2H+Me B+YHh4hVNjSJspY2+aKafzgBEHjhNn6r52Zf/efUyPJSc/WMPhqic4aP3wLCGROCAeND Y98u0R5r+Qd0Rp58katnfGx308jjgmswhCoewtgLYHMBT+3zGZQSn4BbolxLVRpmETcS bNoXiCFDblWqLLJzPceZKVWtpIKozAE1WT8sOgKJR3NjysBdWARmohGSh68o1TXF/AVe wOow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L9PAbC84; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si3895456pgv.179.2021.10.28.03.56.05; Thu, 28 Oct 2021 03:56:19 -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=@redhat.com header.s=mimecast20190719 header.b=L9PAbC84; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbhJ1K5g (ORCPT + 99 others); Thu, 28 Oct 2021 06:57:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27134 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbhJ1K5f (ORCPT ); Thu, 28 Oct 2021 06:57:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635418508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rVBM4WS2LhpDG29Lqha3fLHlxhnITE0Ru8HhYa7oBTo=; b=L9PAbC84/LYjkngpINVbd0Gc3DYtieZC109/kQ6DyNcXp0IvGAj6zaCByaA+GBEb0o3YF7 CvL1U1qoMiBpdH3OEMLSzVSccQXhn4AgStEQPumLLsNFdI0RBc5U2xQcyZ8FhGK/mEHPfI ODdwhVOPJpRen+Y+T6LDT4R9pqOQYjo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-376-rG3SRiItNtexXrDC84-blA-1; Thu, 28 Oct 2021 06:55:03 -0400 X-MC-Unique: rG3SRiItNtexXrDC84-blA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0F8D18D6A2C; Thu, 28 Oct 2021 10:54:59 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D81760D30; Thu, 28 Oct 2021 10:54:41 +0000 (UTC) Message-ID: <72804198c24493c95e4a28bcd670bff32b945278.camel@redhat.com> Subject: Re: [PATCH v2 25/43] KVM: VMX: Save/restore IRQs (instead of CLI/STI) during PI pre/post block From: Maxim Levitsky To: Sean Christopherson , 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 , 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 Date: Thu, 28 Oct 2021 13:54:40 +0300 In-Reply-To: <20211009021236.4122790-26-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-26-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > 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); > } > > /* Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky