Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2758718rdb; Mon, 4 Dec 2023 06:54:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAxzvDJo+lEuOlOCp5hErw+2w2McA+YLkqyNikQfqfpkSoqeSmJrRPbAdGHm6rXz4bAQ6r X-Received: by 2002:a05:6a20:7f96:b0:18f:97c:4f40 with SMTP id d22-20020a056a207f9600b0018f097c4f40mr2072604pzj.76.1701701675847; Mon, 04 Dec 2023 06:54:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701701675; cv=none; d=google.com; s=arc-20160816; b=cS5+QX1qUMLzDQrozi54Pxybap6kA0eJ5Rrp53Z+nJ7Wpeg/IdZebe1p1uemOR755q z+gD+9ou6HRNmwBgKDaSaD4xQ8JxZA3jyCr3CKf5Oo7EzqG2/a7u073gB1NGtaaJXPXX jYqhDlqIu+q0RwUPBRZQnuziiG7ZRUyqDK4Pof9QZZa5pX1DY63Bqri1H/kNYZ/GPsVE BfRVgHrNQH9pYdP2bSWxR/Jfpwu7t66ZYTwTr6VBjIoJxD69PdCj6+3eW5smMVNihfor W0aZkKFLi5uIr0+08ByyoXTkT6QvlqNSMUOUDFyQr5SlOoYvoqYe9jFlvIjQ/ZNPtvzP D8Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=0H1CuKAYogqCZsn/ksRFsa0G5IRLpU8w0lcNqSiLkgI=; fh=mr7MEWMJ8iyDuc4OmAXj/da9Y1YeVrGDe/C4/AWbABI=; b=Cue/NJvi1Q5PU+mf0vv/PpYGJuSqoNa0AjPiVm3d2aTRixPopuleJ9+yAkzJzoQwFI cMeLKNJKjmXrKFau4C0ZT571fFn+48sixKN2TRuHyNCFShr0OVAUtTSZfKShGK6RWHl6 M3+uY2FB+ZjTkmqBEL0ZjWCDu8XoSCVfnovCqDh3UXHnZlIz0PKI/+zpKngyGPl6izY9 6Xb9Hth2DWVxQtb9QhwIoJ9SaGk6VpAurl9AJosId/bFEBrdn0U2LxOtTu6LLYf6r2jR E1WSt7fiAyD6cIo0L238lPlZpib8WdcMLBcRSl8PAkzkrCR9YRinWcaX+l2j0KZOsevO 0GFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=J5nDe2bJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j16-20020a635950000000b005c65758770fsi4379473pgm.487.2023.12.04.06.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 06:54:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=J5nDe2bJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 1A846808BD2E; Mon, 4 Dec 2023 06:54:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345741AbjLDOyQ (ORCPT + 99 others); Mon, 4 Dec 2023 09:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234155AbjLDOyP (ORCPT ); Mon, 4 Dec 2023 09:54:15 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62EFFA1; Mon, 4 Dec 2023 06:54:21 -0800 (PST) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B4Eq96E020640; Mon, 4 Dec 2023 14:54:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=0H1CuKAYogqCZsn/ksRFsa0G5IRLpU8w0lcNqSiLkgI=; b=J5nDe2bJY8810A2POgau07YJ+6BBhLAgOgcvI2Ci205uilYsK9d+daXaH84IKWe5itOG C1AR894X1yKWRJ+YVYFUH6SyrQlFUuRoToPOerVgjfLQvyHuw+X7J4Cu1K+7TzN46a/a AExr1ZZhPzYlfxdNxp/+c2YJxq/X9ycZQNiXgIcIONv3kIChUNDWX7Io8QZelrjqEFBm BWHwFCDvEcuzzc/1948Y8fvO7EBS6e7GZtGFUu7X2NPLbBSPzJ2jnU+ZPOSO/c6PBL7T reBo+H4mJ8+jMAP/h+53DWgoXiL/UbeyTMGW0MitQ6PfEv6dQhiTtiqPvoj+peEXBgqB 6w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3usekcdq5c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Dec 2023 14:54:18 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B4ERj1B026528; Mon, 4 Dec 2023 14:54:06 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3usekcdpwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Dec 2023 14:54:06 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3B4EJSev020522; Mon, 4 Dec 2023 14:53:52 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3urv8dnjc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Dec 2023 14:53:52 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3B4Erp3R24707688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Dec 2023 14:53:51 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 888815805A; Mon, 4 Dec 2023 14:53:51 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE24C5803F; Mon, 4 Dec 2023 14:53:50 +0000 (GMT) Received: from [9.61.175.228] (unknown [9.61.175.228]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 Dec 2023 14:53:50 +0000 (GMT) Message-ID: <1f4720d7-93f1-4e38-a3ad-abaf99596e7c@linux.ibm.com> Date: Mon, 4 Dec 2023 09:53:50 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] s390/vfio-ap: handle response code 01 on queue reset Content-Language: en-US To: Christian Borntraeger , 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, kwankhede@nvidia.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, david@redhat.com References: <20231129143529.260264-1-akrowiak@linux.ibm.com> From: Tony Krowiak Organization: IBM In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: LiPqEQEffht9-OMuMmPGu4mqf9N3NKXc X-Proofpoint-ORIG-GUID: FusNM78Gsy9mHp2FC5kLwwcm7lUPOau7 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-12-04_13,2023-12-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312040112 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 06:54:33 -0800 (PST) On 11/29/23 12:12, Christian Borntraeger wrote: > Am 29.11.23 um 15:35 schrieb Tony Krowiak: >> 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. >> > > To me it looks like this can be triggered by the LPAR admin, correct? So it > is not desireable but possible. > In that case I prefer to not use WARN, maybe use dev_warn or dev_err > instead. > WARN can be a disruptive event if panic_on_warn is set. Yes, it can be triggered by the LPAR admin. I can't use dev_warn here because we don't have a reference to any device, but I can use pr_warn if that suffices. > > >> 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",