Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1690869rdd; Thu, 11 Jan 2024 06:42:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFErQ8kJLH7/UKR8CU/xhKDQvGWolKziXHyI9k6EVlxXEc5QlvikT4Kqeap2PAuWzR7i/3g X-Received: by 2002:a05:600c:4c94:b0:40e:52e9:3e18 with SMTP id g20-20020a05600c4c9400b0040e52e93e18mr473271wmp.178.1704984173446; Thu, 11 Jan 2024 06:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704984173; cv=none; d=google.com; s=arc-20160816; b=1EpAToAoi692iK2513YB/vYA98VfdGrtHdPGka1w/3dZ7F1yaWAp1RYrIpnMhCci1U XF6yGWaeiXtqqoIMeWkF5venQkhiUPPCL/Zg4tpQM6i4gL+K/V0HYuB/nHzXKKhF/L15 9zgvDGWFtt1LTP54YQ5CHpYtHWhEkLQ9Y9LQdVhYK+Nr3gxn+VAXkBm9IljEsjUzkTjm rAkLw9Icz/cg0/sEbdyyqZAiFuqFFum0wFvqo/yCvyqQntl68C0gjEmJlB1sOFSPsAEY L+JCS04mAYt0Yi/SKwRdW/JuCEcufMeIrQE8ooDtWiHyxNfiuQoP8b1fCUq9RN4/yxX6 QSRQ== 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=okxyoCKivlUzW/qO6muklIQ3fMr/f8RnjzKwA9CMYH0=; fh=89dtS/PwPJUSahQCrBwvdQ9UYtztJf8P1g5jTeyUoxY=; b=cEKl/g6bcD132He68PVffnrTf09MFC4QBRha+AparDKQclKuw6zQbRKBTD/bCSVgnM mc1byaRlFuytHkBEARwI11Jwk+JV9aMca3bR2CP5xV3lv/ou3CmR5ePyaxEWsJ2RfA1u 2dNb8gXWXFaq1SElSTyjV2aBB7bC7bYoA9r2uQjm3adkkqmEsfzt8LiR3BGubyfhzsT6 I4cKfqWO8grMLXJEaTE9yBrcqdCYlHhwZaAdR/GjEOQt8QiphJI49tZWjFAzXgamF3ma KsQGd0uXqMf7LAq6MeazW2B+cCigiAVZHKBRk8B7h8Y8ME1mcanr+M8P/WEWuraqHcHP T+WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=c9xrWb1i; spf=pass (google.com: domain of linux-kernel+bounces-23726-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23726-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 t10-20020a1709063e4a00b00a2a224d5420si576444eji.776.2024.01.11.06.42.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:42:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23726-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=c9xrWb1i; spf=pass (google.com: domain of linux-kernel+bounces-23726-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23726-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 34ABF1F22683 for ; Thu, 11 Jan 2024 14:42:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C80994C623; Thu, 11 Jan 2024 14:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="c9xrWb1i" 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 7017E4C60A; Thu, 11 Jan 2024 14:42:25 +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 (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40BEgDCA001664; Thu, 11 Jan 2024 14:42:23 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=okxyoCKivlUzW/qO6muklIQ3fMr/f8RnjzKwA9CMYH0=; b=c9xrWb1iLad2G4lNlHTkH8QpVfcweeD1x/ML6CWO1oGHgjozoJplz36wygyIaiVs4dAV IYWm8ZK4IdE8SzAuPGXWhjjQz6ptQq7IeGl6An7M/BnghmiS7dqUecnXkh6Gt8Q0FaQ/ FcwU4MW2++0Od4NXIrrtAAJU97Ng2SV3V+1vvkdW/oGCPN7oZxhayGuKTrzIcBpydvPU NW6fVrnLYyMCulQfIT8N5XzpPCPfzDhfjGRqu8kbCxGTgsDMdmwNDRyZnavNoHs+rI8v JN2lxKRU745quIS+Q1BIyCt8UJOY6Ty9HBvhjM11VmC7806pd5a6QeJiIgsNAHG+UR26 Ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjbejtynf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:42:23 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40BEgMS6002358; Thu, 11 Jan 2024 14:42:22 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjbejtyff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:42:22 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40BDdTYR027026; Thu, 11 Jan 2024 14:38:56 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vfkw2bgej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:38:56 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40BEcs3G64160094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jan 2024 14:38:55 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C869B58068; Thu, 11 Jan 2024 14:38:54 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E23C45805F; Thu, 11 Jan 2024 14:38:53 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.174.181]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 11 Jan 2024 14:38:53 +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, stable@vger.kernel.org Subject: [PATCH v3 6/6] s390/vfio-ap: do not reset queue removed from host config Date: Thu, 11 Jan 2024 09:38:40 -0500 Message-ID: <20240111143846.8801-7-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111143846.8801-1-akrowiak@linux.ibm.com> References: <20240111143846.8801-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: llQTwOpTAACHOQWaVZ4CTAW-iTxLstV6 X-Proofpoint-ORIG-GUID: nVca7illIL0GGAJlfm3rT78XO5MlJU-W 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-11_07,2024-01-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401110116 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index e014108067dc..84decb0d5c97 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -2197,6 +2197,8 @@ 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) { /* If the queue is assigned to the guest's AP configuration */ @@ -2214,8 +2216,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