powerpc/xive: Discard disabled interrupts in get_irqchip_state()
Subsystems (2)
PATCH 1/1 powerpc/xive: Discard disabled interrupts in get_irqchip_state()
When an interrupt is passed through, the KVM XIVE device calls the set_vcpu_affinity() handler which raises the P bit to mask the interrupt and to catch any in-flight interrupts while routing the interrupt to the guest.
On the guest side, drivers (like some Intels) can request at probe time some MSIs and call synchronize_irq() to check that there are no in flight interrupts. This will call the XIVE get_irqchip_state() handler which will always return true as the interrupt P bit has been set on the host side and lock the CPU in an infinite loop.
Fix that by discarding disabled interrupts in get_irqchip_state().
--- arch/powerpc/sysdev/xive/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/sysdev/xive/common.c +2 -1
@@ -945,7 +945,8 @@ static int xive_get_irqchip_state(struct irq_data *data,* interrupt to be inactive in that case. */ *state = (pq !=XIVE_ESB_INVALID ) && !xd->stale_p && - (xd->saved_p || !!(pq &XIVE_ESB_VAL_P )); + (xd->saved_p || (!!(pq &XIVE_ESB_VAL_P ) && + !irqd_irq_disabled (data)));return 0 ;default :return -EINVAL ;
Signature · 1 line
2.31.1
I have used a KVM guest with a passthrough ethernet adapter and the lspci output to identify the adapter.
From mboxrd@z Thu Jan 1 00:00:00 1970
Return-Path: <SRS0=o3RY=O7=lists.ozlabs.org=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id 96058C433EF for <[email protected]>; Mon, 11 Oct 2021 07:11:10 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B21F760F24 for <[email protected]>; Mon, 11 Oct 2021 07:11:09 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B21F760F24
Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kaod.org
Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org
Received: from boromir.ozlabs.org (localhost [IPv6:::1])
by lists.ozlabs.org (Postfix) with ESMTP id 4HSVMH6wGdz3bjR for <[email protected]>; Mon, 11 Oct 2021 18:11:07 +1100 (AEDT)
Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized)
smtp.mailfrom=kaod.org (client-ip=79.137.123.220;
helo=smtpout2.mo529.mail-out.ovh.net; [email protected];
receiver=<UNKNOWN>)
X-Greylist: delayed 504 seconds by postgrey-1.36 at boromir;
Mon, 11 Oct 2021 18:10:42 AEDT
Received: from smtpout2.mo529.mail-out.ovh.net
(smtpout2.mo529.mail-out.ovh.net [79.137.123.220])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by lists.ozlabs.org (Postfix) with ESMTPS id 4HSVLp4Pwcz2yPv
for <[email protected]>; Mon, 11 Oct 2021 18:10:42 +1100 (AEDT)
Received: from mxplan5.mail.ovh.net (unknown [10.109.156.216])
by mo529.mail-out.ovh.net (Postfix) with ESMTPS id 0EC30C3BBB9B;
Mon, 11 Oct 2021 09:02:09 +0200 (CEST)
Received: from kaod.org (37.59.142.95) by DAG4EX1.mxp5.local (172.16.2.31)
with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 11 Oct
2021 09:02:09 +0200
Authentication-Results: garm.ovh; auth=pass
(GARM-95G0010762b5aa-8db3-4685-afb6-69febc946e19,
044DEDDE8B0E05FD49EE52B84AFD98BA54CEE260) [email protected]
X-OVh-ClientIp: 82.64.250.170
From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <[email protected]>
To: <[email protected]>
Subject: [PATCH] powerpc/xive: Discard disabled interrupts in
get_irqchip_state()
Date: Mon, 11 Oct 2021 09:02:03 +0200
Message-ID: <[email protected]>
X-Mailer: git-send-email 2.31.1
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-Originating-IP: [37.59.142.95]
X-ClientProxiedBy: DAG3EX1.mxp5.local (172.16.2.21) To DAG4EX1.mxp5.local
(172.16.2.31)
X-Ovh-Tracer-GUID: 1fcd0286-05cf-4e09-8d7f-6cb5e00e2edd
X-Ovh-Tracer-Id: 16244765333835647968
X-VR-SPAMSTATE: OK
X-VR-SPAMSCORE: 0
X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrvddthedgudduvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvufffkffogggtgfhisehtkeertdertdejnecuhfhrohhmpeevrogurhhitgcunfgvucfiohgrthgvrhcuoegtlhhgsehkrghougdrohhrgheqnecuggftrfgrthhtvghrnhepfedvuedtvdeikeekuefhkedujeejgffggffhtefglefgveevfeeghfdvgedtleevnecukfhppedtrddtrddtrddtpdefjedrheelrddugedvrdelheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehmgihplhgrnhehrdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtoheptghlgheskhgrohgurdhorhhg
X-BeenThere: [email protected]
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Linux on PowerPC Developers Mail List <linuxppc-dev.lists.ozlabs.org>
List-Unsubscribe: <https://lists.ozlabs.org/options/linuxppc-dev>,
<mailto:[email protected]?subject=unsubscribe>
List-Archive: <http://lists.ozlabs.org/pipermail/linuxppc-dev/>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <https://lists.ozlabs.org/listinfo/linuxppc-dev>,
<mailto:[email protected]?subject=subscribe>
Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <[email protected]>,
[email protected]
Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org
Sender: "Linuxppc-dev"
<linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org>
When an interrupt is passed through, the KVM XIVE device calls the set_vcpu_affinity() handler which raises the P bit to mask the interrupt and to catch any in-flight interrupts while routing the interrupt to the guest.
On the guest side, drivers (like some Intels) can request at probe time some MSIs and call synchronize_irq() to check that there are no in flight interrupts. This will call the XIVE get_irqchip_state() handler which will always return true as the interrupt P bit has been set on the host side and lock the CPU in an infinite loop.
Fix that by discarding disabled interrupts in get_irqchip_state().
--- arch/powerpc/sysdev/xive/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/sysdev/xive/common.c +2 -1
@@ -945,7 +945,8 @@ static int xive_get_irqchip_state(struct irq_data *data,* interrupt to be inactive in that case. */ *state = (pq !=XIVE_ESB_INVALID ) && !xd->stale_p && - (xd->saved_p || !!(pq &XIVE_ESB_VAL_P )); + (xd->saved_p || (!!(pq &XIVE_ESB_VAL_P ) && + !irqd_irq_disabled (data)));return 0 ;default :return -EINVAL ;
Signature · 1 line
2.31.1
I have used a KVM guest with a passthrough ethernet adapter and the lspci output to identify the adapter.
Michael Ellerman
AppliedQuoted 5 lines · Cédric Le Goater
When an interrupt is passed through, the KVM XIVE device calls the
set_vcpu_affinity()handler which raises the P bit to mask the interrupt and to catch any in-flight interrupts while routing the interrupt to the guest.
Quoted 7 lines
On the guest side, drivers (like some Intels) can request at probe time some MSIs and call
synchronize_irq()to check that there are no in flight interrupts. This will call the XIVEget_irqchip_state()handler which will always return true as the interrupt P bit has been set on the host side and lock the CPU in an infinite loop.[...]
Applied to powerpc/fixes.
[1/1] powerpc/xive: Discard disabled interrupts in get_irqchip_state()
https://git.kernel.org/powerpc/c/6f779e1d359b8d5801f677c1d49dcfa10bf95674
cheers