From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796335373; b=e2+DWz0BMhXv+NsYaDWe2Mo2yshdTEbuyzwqlN848jYNUaC5lQrMAApqbUfg+9soGpQO eYzQ9xjqmW5EmPtMLgsp3dlvnxz70t/tjeUHrI/pXN0D9xXXT355i9Od8Rhob6eZJDzNn 0Z8r52lORr2kqUuNit6TToOs7BT0Cc4swX+f8CcvTBntEEahGGfYVQ0PGAsAhpLFi38lk 3q5PeYE848K3q0F+ZiUChU9ULMAwDCf+aoOjLMWp6X7pjrwDhTCiONY/KUvAfuEZYcBgi bSr2OFFXNFbP4mPA4fWboFoubNQoouHgxHhyk/soP1a+yRF/XJ3tUDJsO3XQjphHdXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796335373; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=PkWMueRqJ64OImg1br9CrSVqRmDG99zBknsKNbZteVY=; b=WQ9Cm++XSFYV1JcKJuQA5aDm80N9fvi74S83l4lgY1nD302RkAwDHpbpXcGjHzkDa4rH NZN1mcldQa6SO/uNSVQTMB+exKQ8b0euqPzhw/bO3KdHBxtednTDvcGRiKw+SAlPIBtNY LTIQfivh4c/HLXXMhuEtdIjcvs31FtzyfstsyIjUwTh/q2UCO0JikyLZB9RWcKi3thwsA NlMavY5jhDJc9xRpP/M/Lovx+sGL7JED+RlF7qORSineNV1RwIUhvUzGwC7YWUJuGyjXM bAEjwopP20VUgiuXO/TudA7ObNPZVFGUxD5If++umaXPvHVQAzVT0++gGGZPrmTGpZg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fe67+aSN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4493606A32D for ; Thu, 3 Dec 2026 22:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fe67+aSN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29A391F0092B; Thu, 3 Dec 2026 22:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796335373; bh=PkWMueRqJ64OImg1br9CrSVqRmDG99zBknsKNbZteVY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=fe67+aSNjuTCJr6vUGLN8MtrXnDsj2WLt8riUcDlTtlUzvJM+h3KS0SbSbmR5I9bc +Hmy+4r7amHAOoplR97DjoIj+jQM2eivItAvbiTGUr+ufpUX8rBpnZL1zturlYJaHL 1EqHEZYmHmvqKr4YU/ixdljGxAcvwjLQtley1hfV7PrVTQNRTMRmyIIBqgUk3Q5nSw hXVveiceDBTmF28VBs7TX0EiodnKgCEQWeY5aIaicmWjg7IPPXyvjx+ZPbbG3ImQ03 bPKOYFqlNBhY/kw57nD4jro/hHiDro49XGbiCvvH6TjHRcCOF8mU2nta6OQbXzE+zF n56rfogcjAMwA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 4/5] s390/vfio-ap: clear matrix_mdev link for queues not reset on unassign Reply-To: sashiko-reviews@lists.linux.dev To: "Jason J. Herne" , linux-s390@vger.kernel.org Cc: "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261203214531.1395796-5-jjherne@linux.ibm.com> References: <20261203214531.1395796-1-jjherne@linux.ibm.com> <20261203214531.1395796-5-jjherne@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 22:02:52 +0000 X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] s390/vfio-ap: unreset unlink clears matrix_mdev with live AQIC state -- commit 53e525cdd277ac2c49c6360db65bfb03dbc20712 Author: Jason J. Herne s390/vfio-ap: clear matrix_mdev link for queues not reset on unassign This commit clears q->matrix_mdev when unassigning an adapter or domain for queues not in shadow_apcb, and releases their AQIC resources first if they are no longer in matrix_dev->info. > diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio= _ap_ops.c > index d460337e365f2..836551e9f65be 100644 > --- a/drivers/s390/crypto/vfio_ap_ops.c > +++ b/drivers/s390/crypto/vfio_ap_ops.c > @@ -1173,6 +1173,22 @@ static struct vfio_ap_queue > return q; > } > =20 > +/* > + * Unlink a queue that is not being reset. If it is no longer in the hos= t's AP > + * configuration it is gone, but vfio_ap_mdev_remove_queue() can't relea= se its > + * AQIC resources once the mdev link is cleared, so release them here. > + */ > +static void vfio_ap_unlink_mdev_fr_unreset_queue(struct vfio_ap_queue *q) > +{ > + if (!test_bit_inv(AP_QID_CARD(q->apqn), > + (unsigned long *)matrix_dev->info.apm) || > + !test_bit_inv(AP_QID_QUEUE(q->apqn), > + (unsigned long *)matrix_dev->info.aqm)) > + vfio_ap_free_aqic_resources(q); > + > + vfio_ap_unlink_mdev_fr_queue(q); > +} [Severity: High] Can this clear q->matrix_mdev while the queue still holds live AQIC resources and armed hardware interrupts? A queue filtered out of shadow_apcb (for example, when a sibling queue on the same adapter is unbound) stays in qtable.queues and matrix_dev->info. Because handle_pqap() does not check shadow_apcb, a guest can still run PQAP(AQIC) on it to pin a NIB page, register a GISC, and arm interrupts. Unassigning the adapter or domain then drops the queue from qtable.queues and clears q->matrix_mdev without resetting it. Hardware interrupts stay armed against the guest's NIB and GISA, and the orphaned NIB pin causes vfio_dma_do_unmap() to hit BUG_ON(++retries > 10) on DMA unmap. On the other branch where matrix_dev->info is clear, if the host re-adds the adapter before ap_scan_bus() removes the queue and the guest enables AQIC via handle_pqap(), vfio_ap_free_aqic_resources() unpins the NIB page without disabling hardware interrupts. Resetting any queue with active AQIC state before clearing q->matrix_mdev, or rejecting queues outside shadow_apcb in handle_pqap(), would avoid leaving armed interrupts behind. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203214531.1395= 796-1-jjherne@linux.ibm.com?part=3D4