Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp30703rdb; Mon, 15 Jan 2024 10:56:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyWRgX0mW9rh4rTe8eT4dDHqqxU6a9PVOpHmKyFzVmzCfiKUFIBfFVMvJiArRQBLpThqi/ X-Received: by 2002:a05:600c:1c08:b0:40e:5fb9:a5ac with SMTP id j8-20020a05600c1c0800b0040e5fb9a5acmr2889170wms.32.1705345003749; Mon, 15 Jan 2024 10:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705345003; cv=none; d=google.com; s=arc-20160816; b=hkvv9Bv5HEL1FfWvmFsXzYQt8FIdfk/1FaYmIwXdH8FrP9vCb9R06zblKGi60UCln1 7UJyCma46UNCeJADxAtdcqF256/JMmltGe8xFB0Me7yO+u2J+T99Q8Xqd/qIcssh5LnX RO6wJ5LX8k8e+XakAsRbMM50uJlhg2koKNU/NL9HTw/SJSV1BjLGXEQwDxvLSCrPkb5/ GVzAzfvjXDJJSaE6CleHOq5uvsbrhdtdB0v5ZDgfppNArBT6BjJcVPLy3lQB/gD/LaDn 1wMteVpnv51IqJ7z/MRLCFBn7QSl+bE5eKdbRLsUxQTa/GHFAyIiSEYRWC0JN7EgR1ZQ zjKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QiVXsK0Tbzx56s4STPzPtbC2hmLhKdcNXHSamhEQq70=; fh=H6lVIw+KZeomf8cbJ+jDGydQlHrKW9Bp+9pD33yGxs8=; b=C13Yq0t/OvGtsxsEe0F1/I3w5VUPlhM1SvXBFrzeCz/aznQh8gC1WMBKBwBEUldo3n 5JhdbHmkvIm0AKFsYRJFALwKhSsY+Li8HlL6aqt/UGAxL5TbwdxjvB8KlB8bcg9mbxRS 5P/sPLSiYgiG5UdYXVhhY0yPFJ+Ygy1giCYThPrxAbpNm4SH+QTcvNW29DKk7exVctUc E+pUi5PBiW/OwcEhV08M+J3xLB+G0oi64dXB2Tda6a4yTruqg5lmEbFdQrzbg0patvQo Le16iQEpm40pPx+vp3P1VRtG57vfug+wlZgwGUPm4beLy6bv62f25SNRaoFo0zWUIUWx 4NQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZPj8HwLa; spf=pass (google.com: domain of linux-kernel+bounces-26418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a27-20020a170906191b00b00a23331d4ec9si3820821eje.903.2024.01.15.10.56.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 10:56:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZPj8HwLa; spf=pass (google.com: domain of linux-kernel+bounces-26418-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 563E91F20F5E for ; Mon, 15 Jan 2024 18:56:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9906199DD; Mon, 15 Jan 2024 18:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ZPj8HwLa" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9B5919469; Mon, 15 Jan 2024 18:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40FHx79q018410; Mon, 15 Jan 2024 18:54:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=QiVXsK0Tbzx56s4STPzPtbC2hmLhKdcNXHSamhEQq70=; b=ZPj8HwLa3VoR0c/sCGeTbjvwAqDpd3uCEcwcp8xNXMliBAEBi/erMyS4nqk4R0eBVFfu C1iZrZeGJN/Qt/kXACRvizuEhJOLZo/4tEuGxEhAAYOuwE3+xOmGFv1qKzkK92+nb0zv AftTsJDlb1NN06upxt7bP9Xst4S06tJDqUK7LDnvri4muUgCTkPF8dQvgWoMAVmGgGas aEJL+PGYEu9YEYummBP1Fmpwm7Yea2/9lWwCGArcFFxAsMt9IXhdAyxGR2ChbBlVJs9y /WOjf3KUQMhCs2tlWXtGvFHod75CdzKnba4/tCi+8FhCwIMDshAN2C2v8fFP8CSMEpjt 5w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vn7x8u3js-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:52 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40FIqGRP028552; Mon, 15 Jan 2024 18:54:51 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vn7x8u3jh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:51 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40FHFEws014779; Mon, 15 Jan 2024 18:54:50 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vm4usj7rh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:50 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40FIsnIU21758594 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Jan 2024 18:54:49 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E52A58056; Mon, 15 Jan 2024 18:54:49 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 791D35805A; Mon, 15 Jan 2024 18:54:48 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.164.202]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 15 Jan 2024 18:54:48 +0000 (GMT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: jjherne@linux.ibm.com, borntraeger@de.ibm.com, pasic@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, agordeev@linux.ibm.com, gor@linux.ibm.com, Tony Krowiak , stable@vger.kernel.org Subject: [PATCH v4 6/6] s390/vfio-ap: do not reset queue removed from host config Date: Mon, 15 Jan 2024 13:54:36 -0500 Message-ID: <20240115185441.31526-7-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115185441.31526-1-akrowiak@linux.ibm.com> References: <20240115185441.31526-1-akrowiak@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SG7HXdSgvtvmNDZ9uJ8dl18B9P1je-BJ X-Proofpoint-ORIG-GUID: RBacV-aimrM4LLgK1zIi9ncj-JgXn7_Z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-15_13,2024-01-15_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401150139 From: Tony Krowiak When a queue is unbound from the vfio_ap device driver, it is reset to ensure its crypto data is not leaked when it is bound to another device driver. If the queue is unbound due to the fact that the adapter or domain was removed from the host's AP configuration, then attempting to reset it will fail with response code 01 (APID not valid) getting returned from the reset command. Let's ensure that the queue is assigned to the host's configuration before resetting it. Signed-off-by: Tony Krowiak Reviewed-by: Jason J. Herne Reviewed-by: Halil Pasic Fixes: eeb386aeb5b7 ("s390/vfio-ap: handle config changed and scan complete notification") Cc: --- drivers/s390/crypto/vfio_ap_ops.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 550c936c413d..983b3b16196c 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -2215,10 +2215,10 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) q = dev_get_drvdata(&apdev->device); get_update_locks_for_queue(q); matrix_mdev = q->matrix_mdev; + apid = AP_QID_CARD(q->apqn); + apqi = AP_QID_QUEUE(q->apqn); if (matrix_mdev) { - apid = AP_QID_CARD(q->apqn); - apqi = AP_QID_QUEUE(q->apqn); /* If the queue is assigned to the guest's AP configuration */ if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { @@ -2234,8 +2234,16 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) } } - vfio_ap_mdev_reset_queue(q); - flush_work(&q->reset_work); + /* + * If the queue is not in the host's AP configuration, then resetting + * it will fail with response code 01, (APQN not valid); so, let's make + * sure it is in the host's config. + */ + if (test_bit_inv(apid, (unsigned long *)matrix_dev->info.apm) && + test_bit_inv(apqi, (unsigned long *)matrix_dev->info.aqm)) { + vfio_ap_mdev_reset_queue(q); + flush_work(&q->reset_work); + } done: if (matrix_mdev) -- 2.43.0