From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796404086; b=JF2gS+v3c2sNPL7mmMU9a2Y6y9WLw9p3Dzm2HqnWkxEBwHhvP7Wm9NEPcALnEeShdTFy zQJWtwZVD3jChxTBW/Dd7KCYPb4YZiHvakA4/+n9afKCaGaf9j2NiuA6UvXoWqA9RL4Pu MrRbomf3zhqdPqX7UH2l+jI7i0FowhRrqxrDyUG1xyFVuZ0UJoIAiNll1SoywdmaYepiP cEfRccDctvcX5ZrOnbpsKeAs/XOGF8iQ8j9htXHRgbh3hrKaW8AI/LRLC0CQfqkBqfW0r gHgkGzjn1oVgKcXjDFviY178PwdSXKhlu1EpkoFVTwdmSWkuSiLdtkRdScaz63PyOpQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796404086; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-TM-AS-GCONF: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Details-Enc: X-Authority-Analysis:X-Proofpoint-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=iF8o/6AmcS4qj7AiSysuDRm0BbfS0yEtoBmtREG2WlY=; b=uJDV4R1APTEvqcsJcWNbgQmf5JmookR9zX8qpHRctzBCjx9rcZarO25X9p0UI6UWZI+P o8LjdeaQ5qmyZIVUumOC8wqsOqyaXxUKC2080g8aD5XLz4LOgl7Z4fV3nfCGq8gpVR2JC hQ2oZ7qQ6GMSDhxfFTA/xyuojcj7Mc6LcvNe2ZLpUax68qrEZMI70AIZSO2e2C0UuL074 CdS7iuNJdUFhUdGWumA23uyoT+dIIM6wRNVpP+keHgcGEuMycSqYlBmrH2gzUD3e5eOk2 zMBT8t3lmVTpUZsGBzIqCCmM/zJQZvThyYH+97c6wyAaD8nBwbh0BoEHZQoBVIINrWQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=nWTPnrs7; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA0CF606A322; Fri, 4 Dec 2026 17:08:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CA0CF606A322 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=nWTPnrs7 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B4EYk3G2517311; Fri, 4 Dec 2026 17:08:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=iF8o/6 AmcS4qj7AiSysuDRm0BbfS0yEtoBmtREG2WlY=; b=nWTPnrs7TWLlOsAckpUjnA f7IKtIohCgYIN2Am5BcR/83bGHx+GHWO+LQfzIDDEroF65lHll/n6Vx6kKc69YzE ajj6Hga3yYmzTer+2NcxWbSA0BDJK+u2t+urjMMHOSBrNGadmTuh2Pupcupz+BLO F8cKq7/uKik6WuP8LRzJ8+y5wjlbGbXB086Q7Rw4D35/QnRNTZGzo7W8w3K/SLdI hUBLK/+J1/2x6JpT3BlynrM6Xa4gayEaR0hO1MU3v1wqga1S3B8j4Ja0DPpRCUfb GHyoIhBjxw2My4NQ5DB82nghoo+LV1D8c8G+l3dkCKiv0vNsrM3KmlxngVsU6THA == 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 4jbqgc2yq8-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 04 Dec 2026 17:08:04 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B4EYKC52283349; Fri, 4 Dec 2026 17:08:04 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4jb7h9dwrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Dec 2026 17:08:03 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B4H82BL3473998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Dec 2026 17:08:02 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 200235805D; Fri, 4 Dec 2026 17:08:02 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63B1558056; Fri, 4 Dec 2026 17:08:01 +0000 (GMT) Received: from [9.61.23.56] (unknown [9.61.23.56]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 4 Dec 2026 17:08:01 +0000 (GMT) Message-ID: <02965a4e-980a-408e-b3f0-2cbe9157870e@linux.ibm.com> Date: Fri, 4 Dec 2026 12:08:00 -0500 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/5] s390/vfio-ap: Prevent passing unreset queues To: "Jason J. Herne" , linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, borntraeger@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, hca@linux.ibm.com, mjrosato@linux.ibm.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, jrossi@linux.ibm.com, stable@vger.kernel.org References: <20261203214531.1395796-1-jjherne@linux.ibm.com> <20261203214531.1395796-2-jjherne@linux.ibm.com> Content-Language: en-US From: Anthony Krowiak In-Reply-To: <20261203214531.1395796-2-jjherne@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: er1b-y4zOxteq7x90-6-hOrIfDE-68A8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjA0MDA2OCBTYWx0ZWRfX0tf2fuzBlxxl u6HuNFPQSvhunG+RdC5muPzns/YtHfzWJ3Ji2NHHumueAxvr0CYDfO8jgLCRFRtswyfHgcwO0SB aYPgfp6hGdhwAKmyyVrPYewSd8Twv9aMnuyVpajjmElcv7652bSRhWftONTpW14AScDq0nt1sx+ zrncLQDMXBlX6v1JkECKJQnldVe/UE1yQnPJb0xIdclpwAty4zncxEs6jxACzY0ZaSm5xsPPiCE Dm1ihMUqEAY3xvK13aMW/nvadoPHfh1RuNB+pjqp5KouzfR+5yGr7ZejJykJ637UQKtY5Mge8zv rLF2k1xNl/4Gf+8C8yRywobNExMDo5/UjFPmMr7mf2oh8HRYJXK+PFHSUNINw/tEDc+BN17RRnq VmpvWglZf/ds+m72SUKIg9bgM7Xlq9cWGUloH2i6uRiFXgB/mX+O3VNop3RnpnYwfkx5Q0lUVL6 Tk6VQ1DL+hXDATGzRIg== X-Authority-Analysis: v=2.4 cv=A435rKWG c=1 sm=1 tr=0 ts=6b12f374 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=M-r7d0WqD7-duQjC-qAA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: er1b-y4zOxteq7x90-6-hOrIfDE-68A8 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjA0MDA2OCBTYWx0ZWRfXxUTYZjFYRebu sBUcseSqrNWvoQl0zBF4Ezzy1s0agWNGm35HvRZjJRqkim4UiLRydY9l9cFnjV9lEGNbrJwDZcq sGom9DEwl6uBLUzmxvfQrbd5b0zz2v4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-04_03,2026-12-03_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612040068 On 12/3/26 4:45 PM, Jason J. Herne wrote: > vfio_ap_mdev_reset_queues() and _queue_passable() use q->reset_status > to decide whether a queue was reset and may be passed to a guest. > apq_reset_check() can leave the status from the initial ZAPQ (usually > AP_RESPONSE_NORMAL) in place when the reset is not confirmed, so an > unreset queue looks reset. Fix the cases where this happens: > > - TAPQ returns an invalid response code (-EIO), or > AP_RESPONSE_Q_NOT_AVAIL (-ENODEV, e.g. ZAPQ rc 00 then TAPQ rc 01): > the worker returns without saving the TAPQ status. Save it. In the > -EIO case the AQIC resources are still intentionally leaked, since > it is unknown whether the queue can still write to the NIB. Not > saving the status on -EIO predates the DECONFIGURED and > CHECKSTOPPED handling below. > > - AP_RESPONSE_DECONFIGURED and AP_RESPONSE_CHECKSTOPPED are treated > as success by apq_status_check(), but neither confirms a zeroize: > all status bits are zero for these codes and a checkstop resets the > queue rather than zeroizing it. Return -ENODEV for them so the > worker frees the AQIC resources (the queue can no longer write to > the NIB) and saves the status. > > Make _queue_passable() accept only AP_RESPONSE_NORMAL, so deconfigured > and checkstopped queues are no longer passed to a guest. This drops > the earlier policy of passing such queues through to avoid possible > data leaks. > > Fixes: c51f8c6bb5c8 ("s390/vfio-ap: allow deconfigured queue to be passed through to a guest") > Fixes: dd174833e44e ("s390/vfio-ap: remove upper limit on wait for queue reset to complete") > Fixes: a681226c675c ("s390/vfio-ap: handle hardware checkstop state on queue reset operation") > Cc: stable@vger.kernel.org > Signed-off-by: Jason J. Herne > --- > drivers/s390/crypto/vfio_ap_ops.c | 27 +++++++++++++++++++++++---- > 1 file changed, 23 insertions(+), 4 deletions(-) > > diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c > index 373ce574c431..10430b9446db 100644 > --- a/drivers/s390/crypto/vfio_ap_ops.c > +++ b/drivers/s390/crypto/vfio_ap_ops.c > @@ -694,8 +694,6 @@ static bool _queue_passable(struct vfio_ap_queue *q) > > switch (q->reset_status.response_code) { > case AP_RESPONSE_NORMAL: > - case AP_RESPONSE_DECONFIGURED: > - case AP_RESPONSE_CHECKSTOPPED: This doesn't take into account that the status of the queue could have changed since the last reset; for example, the queue could have been deconfigured via the HMC/SE or the sysfs config interface for a crypto card, or something could have occurred - e.g., a hardware failure - that moved the queue status to check stop state. The previous patch for this execute PQAP-TAPQ to verify that hasn't happened. > return true; > default: > return false; > @@ -1927,9 +1925,20 @@ static int apq_status_check(int apqn, struct ap_queue_status *status) > { > switch (status->response_code) { > case AP_RESPONSE_NORMAL: > + /* TAPQ => AP_RESPONSE_NORMAL means reset/zero complete. */ > + return 0; What is your reasoning for removing this: /* * This response code only indicates that the PQAP(ZAPQ) has * been initiated. The following bit settings in the status * returned from TAPQ must be verified to confirm that the * asynchronous portion of the queue zeroization has completed. */ if (status->queue_empty && !status->replies_waiting && !status->irq_enabled && !status->async) return 0; /* Async zeroization still in progress; keep waiting */ return -EBUSY; > case AP_RESPONSE_DECONFIGURED: > case AP_RESPONSE_CHECKSTOPPED: > - return 0; > + /* > + * The queue is non-operational: interrupts are not possible so > + * AQIC resources can be safely freed. However, zeroization > + * cannot be confirmed because all status bits are zeroed when > + * these response codes are returned. There is no way to > + * distinguish a zeroized queue from one that has not been > + * zeroized. Return -ENODEV to signal that AQIC resources should > + * be freed but that zeroization has not been confirmed. > + */ > + return -ENODEV; > case AP_RESPONSE_RESET_IN_PROGRESS: > case AP_RESPONSE_BUSY: > return -EBUSY; > @@ -1969,9 +1978,19 @@ static void apq_reset_check(struct work_struct *reset_work) > elapsed += AP_RESET_INTERVAL; > status = ap_tapq(q->apqn, NULL); > ret = apq_status_check(q->apqn, &status); > - if (ret == -EIO) > + if (ret == -EIO) { > + /* > + * Invalid TAPQ response code. It is unknown whether the > + * queue can still write to the NIB, so leak the AQIC > + * resources rather than let the NIB page be reused. > + * Record the status so the queue is not passable. > + */ > + memcpy(&q->reset_status, &status, sizeof(status)); > return; > + } > if (ret == -ENODEV) { > + /* Record the status so the queue is not passable. */ > + memcpy(&q->reset_status, &status, sizeof(status)); > vfio_ap_free_aqic_resources(q); > return; > }