Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4623730rdh; Wed, 29 Nov 2023 06:35:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFAENmn3m3d1veQF8SjDS08uZ9VesESPj6PHCenjrHFkTofjf1jwZRt8WCCj7VBSvNVwOd X-Received: by 2002:a05:6a21:2711:b0:187:8eca:8dc6 with SMTP id rm17-20020a056a21271100b001878eca8dc6mr17848029pzb.34.1701268554631; Wed, 29 Nov 2023 06:35:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701268554; cv=none; d=google.com; s=arc-20160816; b=qR8oN0InJ8fMRRWTGLFB/g9y7R9/ojtSMdiNXsL3GQJXVKw4D/HFGsa+Eo/KnTiGcH h3VcrJ9alL2fFUbj27nC0cbgSeq8NynZ2aSjbmhzyFFtMw99l254zSqfE8pS2xDmXsOO BJhqG0xQmrRYn8BpXVS64/MGBCZFPNjJ6JOxEqjpw+zKn0ApHgzjME1xb6HgkfYE4fOs pOWonwMe9BFU3UuBbusrlo4UhNNEeer+lb+dZwWCjow0BDjd9alail/M2VvcNTAm7+zl JD6x3YXYjcabpOEzB3jxARsvAVvL8Fx+mU5HOxYsTDtt7E2nUCeWuDvwaqZwRgxn1ZbM edhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=84dgAyyjWyetZQdS5ITnDLJAcSc79AlusTv7kFI15mM=; fh=0M3JPXXuI9GXlB995TLGVJ+O045xV7Cdi7q2Ksu8yq4=; b=IBUml5EYit0GSW/BehZv0jyNAHQCWGdOJlQCfeF69xU1dkcC+tkjZ7zGfjj5BdmaDL NzohSHQBYC2l7A854+Ji9fmhdXmWWpYxOubfMPp3taDdgFrLf2Wa6XoLhxCIc0dQ+uSZ 2Cx1WyRuWM37r4teWZ1maANl9Bf765wlUL8OQ01mMLSvjjUmUs6lQY7Nvff9LINJqFJh dk/T7n/sbIwJJ8rYO3Zm1rXpu68kU0QT2WZzQ1oKirPoAePVX1XqZklNG7Gv/cWbs6vm /A1c/mBirefBDKCWYGYheRbmQA3xqsyK8n9hSiT+dbmWw3F5NRmw3tuqLIOCYZQ00EmK tOgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nUXwUblM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p4-20020a056a000b4400b006cd94e0c112si6090077pfo.285.2023.11.29.06.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 06:35:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nUXwUblM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 081C48039DEB; Wed, 29 Nov 2023 06:35:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234350AbjK2Ofe (ORCPT + 99 others); Wed, 29 Nov 2023 09:35:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234323AbjK2Of3 (ORCPT ); Wed, 29 Nov 2023 09:35:29 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADDFD19A; Wed, 29 Nov 2023 06:35:35 -0800 (PST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ATEX1M4007854; Wed, 29 Nov 2023 14:35:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=84dgAyyjWyetZQdS5ITnDLJAcSc79AlusTv7kFI15mM=; b=nUXwUblM1WYfj7+b8+vyi4NgclDC522CYawTZvmpBQ3jEGYKiXbhur8GrRMRDJF6Mj2s /RWFr/XoN35c4w2kJmgKkcMHBC9LSLNSqyCWDnLsyY+HX2izduQ6jc4EplXL4SnyI79d 1GG1L1YQR5/JaEREne5pRRZ3wM7RWcMkAO0SyxPj8om8NYkGPoqlpHd7XhGt40KWU5w8 /KZ6RYmzm0+eyxJ/YzNDpyQSB9M4vK5AKv34Oa3h0rFhRYZDzXobpbd1q19UF3OoO2xY 4vYA9Awbb0354S7M9+RaXtSQSO+bJHBq4W5LJ5Xds28v8VjtW4VlzqbXcTxQgfR4U9ek wQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3up75k03tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 14:35:33 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3ATEXOvf009646; Wed, 29 Nov 2023 14:35:32 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 3up75k03t0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 14:35:32 +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 3ATE6Qe0004403; Wed, 29 Nov 2023 14:35:31 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ukwy1y71q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 14:35:31 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3ATEZV1523397088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Nov 2023 14:35:31 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B48C5805F; Wed, 29 Nov 2023 14:35:31 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3971558051; Wed, 29 Nov 2023 14:35:30 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.149.198]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Nov 2023 14:35:30 +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, pasic@linux.ibm.com, alex.williamson@redhat.com, borntraeger@linux.ibm.com, kwankhede@nvidia.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, david@redhat.com Subject: [PATCH] s390/vfio-ap: handle response code 01 on queue reset Date: Wed, 29 Nov 2023 09:35:24 -0500 Message-ID: <20231129143529.260264-1-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Wh_sxyqNi8eoxitQQ6JunvZBuky1cP6p X-Proofpoint-GUID: 47QYZ6reoqUfJKHJWdjE3qAOhmpsEUSD 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=2023-11-29_12,2023-11-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 priorityscore=1501 malwarescore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311290110 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 06:35:51 -0800 (PST) In the current implementation, response code 01 (AP queue number not valid) is handled as a default case along with other response codes returned from a queue reset operation that are not handled specifically. Barring a bug, response code 01 will occur only when a queue has been externally removed from the host's AP configuration; nn this case, the queue must be reset by the machine in order to avoid leaking crypto data if/when the queue is returned to the host's configuration. The response code 01 case will be handled specifically by logging a WARN message followed by cleaning up the IRQ resources. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 4db538a55192..91d6334574d8 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1652,6 +1652,21 @@ static int apq_status_check(int apqn, struct ap_queue_status *status) * a value indicating a reset needs to be performed again. */ return -EAGAIN; + case AP_RESPONSE_Q_NOT_AVAIL: + /* + * This response code indicates the queue is not available. + * Barring a bug, response code 01 will occur only when a queue + * has been externally removed from the host's AP configuration; + * in which case, the queue must be reset by the machine in + * order to avoid leaking crypto data if/when the queue is + * returned to the host's configuration. In this case, let's go + * ahead and log a warning message and return 0 so the AQIC + * resources get cleaned up by the caller. + */ + WARN(true, + "Unable to reset queue %02x.%04x: not in host AP configuration\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + return 0; default: WARN(true, "failed to verify reset of queue %02x.%04x: TAPQ rc=%u\n", @@ -1736,6 +1751,22 @@ static void vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q) q->reset_status.response_code = 0; vfio_ap_free_aqic_resources(q); break; + case AP_RESPONSE_Q_NOT_AVAIL: + /* + * This response code indicates the queue is not available. + * Barring a bug, response code 01 will occur only when a queue + * has been externally removed from the host's AP configuration; + * in which case, the queue must be reset by the machine in + * order to avoid leaking crypto data if/when the queue is + * returned to the host's configuration. In this case, let's go + * ahead and log a warning message then clean up the AQIC + * resources. + */ + WARN(true, + "Unable to reset queue %02x.%04x: not in host AP configuration\n", + AP_QID_CARD(q->apqn), AP_QID_QUEUE(q->apqn)); + vfio_ap_free_aqic_resources(q); + break; default: WARN(true, "PQAP/ZAPQ for %02x.%04x failed with invalid rc=%u\n", -- 2.41.0