From patchwork Mon Jan 15 18:54:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Krowiak X-Patchwork-Id: 188313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1887843dyc; Mon, 15 Jan 2024 10:57:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5VX3WGf8c1uCanbCuKUBziV6zin6G6ddFBN4/tBXQzmy5d1/pCpXxL/nkYkZAbheV8k7o X-Received: by 2002:a05:6358:471d:b0:175:c293:6b45 with SMTP id j29-20020a056358471d00b00175c2936b45mr3496195rwn.64.1705345048491; Mon, 15 Jan 2024 10:57:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705345048; cv=none; d=google.com; s=arc-20160816; b=E6PPfd0GbLYl/LxhZoA0T98ZiTWG0caJe4O+vR0yrEd+6POMudlomml9UC20i2nwdF YvpPOGpsQCpGXGMQ9ZMWGMyEyg9fT6spE3C/AHr9cq/FmITPE+Jy7Hg7DawZTgniVOvw Hf8eouo/eZKOLR8t20hKL9ONgZXzvLmyIDhIr6pgn70reeHse0AT6+sBRuazKUaxxKXB q3Yc0qEbvjuAz/O84+3nr25u19L4zyGCZHjWiZCoxUt2N94z3dJCTLLPxi2jt7epRbz5 F8a3YEgGitx1ForNlkXsJBJTOogqH23Zf2IpDFecLJLzYsVJgRkNYmNHM7H5K9p3muir RfOQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26418-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e20-20020a656794000000b005cd811e2ffesi9553966pgr.18.2024.01.15.10.57.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 10:57:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26418-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26418-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4E9B0B21E66 for ; Mon, 15 Jan 2024 18:57:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E16801A582; Mon, 15 Jan 2024 18:54:58 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788183889123841080 X-GMAIL-MSGID: 1788183889123841080 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)