From nobody Thu Apr 2 23:54:07 2026 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 9C89B3264E2; Wed, 25 Mar 2026 21:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472522; cv=none; b=oHbALnnmg0yVhRxovjrRSlEQUTXWPb+bsS8aj4Xauuxe6c/H6CCqn5LsxOcjZBlw4VjXPCQt1MBA/vSaqiB2hHslTY7A9DN/Qq2x5eTKOink/C3QQbdjqKcmAwKU7xiTdsGL5T1wcU6lShSGZaFp+KLd9t42cKtBpoYpkey6A10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472522; c=relaxed/simple; bh=p76+bNHj1RzRVON3iTskt71WjJtdn+xktZomXKhr8xE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J/qgIY1imYyH0MHEWtubOsA+sNVOB8eSLCpTkUX134BO7PnsiodJichqGVzGd8sBzJ/UCs+nrGW+2oYGl9+lXvtGzrkDF7mszNBnZY4gsCb88HSNqv/RtXXvR3BAs4cbx/iaNNlL5YR7jjbtaYDqvQF1v1iAojC7VMwKLjr5AYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Uk56U2E8; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="Uk56U2E8" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PCEI8B691552; Wed, 25 Mar 2026 21:01:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=aovKZRY1qNFleNNyr SFpjmfdwG746o8nAcCzl3rHXKE=; b=Uk56U2E8YuJ7RKmyH0nvdv0reyIeoUZQ+ lb9gpmS3nfIPzJdnPd6zsY/ppCk4rv6IM0YvlQVPz4199V9b198/2j+8zVJCFTSf JIkqZMEhEDKc0D7k8XKNMnmF/JYV46+uag2YyBVu2Y3D2ktXZheQPp2X0d+FaEsC V4mlCT2ijyj7ZGmi/8TD69pwok4eniYxLd33ekKHwn5Gu1bCx4x5wr92rnT8+HFh J3st0tUc6Nzwuk9h50cpDeZm8Z22QiFptGDy+pD2AAvmaQ+C6CUcTiPfq1WoAWgX n+L22871YKYVfHBykDYZfRsea/5VH5t+arQ+byOpGv4M0ElSKQo7w== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1ktv1hhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:55 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PJxqwk005976; Wed, 25 Mar 2026 21:01:54 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d261yrat0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:54 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1qtf39649784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:52 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 941425805D; Wed, 25 Mar 2026 21:01:52 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9175C58056; Wed, 25 Mar 2026 21:01:51 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:51 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 01/24] fixup! KVM: s390: Remove non-atomic dat_crstep_xchg() Date: Wed, 25 Mar 2026 17:00:48 -0400 Message-ID: <20260325210149.888028-2-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vwtmCUSz4j-IhH-zNlNSJf8MZCkjjf7r X-Authority-Analysis: v=2.4 cv=aMr9aL9m c=1 sm=1 tr=0 ts=69c44d43 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=lXafCBgdT3Pbg7ryY5UA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX1vSvm7bJpVxD WeNShLLuR3tDhV9wzyny/Zdq/f6u/XVwpMBFlauGSeUTKo9y0J6K3iMtLaX4AyNGnAQs8iRx72Q Y5A1WeGP+Ob9LBPHMWVn+6YJAsX4CBJbG1NfmIQEBj48nbM9b2+dLGdb7RLV4SuCodLlxGLbNyI oHny4xD/RU/EpOjsbdinC+TzmihQ88cPw1Im2Dw/7awBfwwQFtdJJxxgPnywPaxbj0Jq1IQJ3yx OIfL/zaEQ2iD3+hTfoW2/JVKTMEGUDvs39Xh6QkZMcEPt1NO/Y99OC+4Hbkqnt4nboJMX6o5qA0 9qLNbtwaDda5dNILwH1oOar4xXTOYq1hNt9GFgnTRUUOaYcS2tZPixggf91F2CAApBdWNFwiz6N xq3f9EtYSdXnApqmf94bl2GXOac2HUWboESiUYskthmYJB0VZZf246gjfsx4r7SN+CK9nPH4AKn gVPtw1PFY3qkfpfvhOg== X-Proofpoint-GUID: vwtmCUSz4j-IhH-zNlNSJf8MZCkjjf7r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 clxscore=1011 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" From: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- arch/s390/kvm/gmap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kvm/gmap.h b/arch/s390/kvm/gmap.h index 967a280b3235..19379d162777 100644 --- a/arch/s390/kvm/gmap.h +++ b/arch/s390/kvm/gmap.h @@ -198,7 +198,7 @@ static inline bool __must_check _gmap_crstep_xchg_atomi= c(struct gmap *gmap, unio union crste oldcrste, union crste newcrste, gfn_t gfn, bool needs_lock) { - unsigned long align =3D 8 + (is_pmd(*crstep) ? 0 : 11); + unsigned long align =3D is_pmd(*crstep) ? _PAGE_ENTRIES : _PAGE_ENTRIES *= _CRST_ENTRIES; =20 lockdep_assert_held(&gmap->kvm->mmu_lock); if (!needs_lock) --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 9152B3264D9; Wed, 25 Mar 2026 21:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472521; cv=none; b=ei0tmLlGiLqyC5YNLCrr/4+RlrThzf8HLPJoJO5HWxML8kdWMx4ksWwmsAKPsSp8jqNyo+v+UB4HzKEA3GRCTI+ym7JwzpuQXxcczwIVO7s9y9sGbe8Sve3WHeKaY3PQ0t/8298/0z2d0z/73AbXXx8CM0EnrM9/ohEpZk0ZRgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472521; c=relaxed/simple; bh=Jbg5tReGP4DqzSflGqDEnwPJOObH5/PLrLZ/LD3W9cI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZhRMT1hOjjllVDuIpoQFZ5I6ficuPPfM3AwJVKIU7nD/RSgaKP5KRENsJKjmsuyJ4GDGlT03wZ03xw0GIdhNKZ8vj7vVNuBJy6Wslwx1FS6AVoNpunKYX0GEaTZhTVGyudvbsAyvIWf1zMod8QYoX3gIoDD4Svn2KkcUXUNAzqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=BXIUmAjs; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="BXIUmAjs" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PFG4El2665123; Wed, 25 Mar 2026 21:01:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=c4OAktMSaRxE9CV3M XiOV7sMtw4Du7qGD+4GsaEwCSM=; b=BXIUmAjs/sB897cPJ3YGxS5UFceFMG3gV 6L9cp7hmuUkiucUrg7ACSaYZYGi2JE5qsPtX4XQa5ZcJWNBOLVwA8ivqUnQ5aCP7 KBr6h2cD7cs+0PahvlU60nyrlht/fx4/InsY1usYLTtPwp1nV4Y05Wq0Z3jG2Lmt i2Ast0M686m9cglz3nHsaTx+HzEfNSCWW7nwTUBbbGr+YF/SMxl7mo9mLGnBjrsi vsDd+qDWkko9O0fnCd2XXzhWoNQGIzrEbWNHntaTk64BR4/OnBSFNKI8H5WWRCbO DykwKSZvq/AhpyN42s/3kvx9vqzByJQlhAWqQQxKzXayqe+pZdYPg== 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 4d1ktv1hhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:56 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PJSBq7008749; Wed, 25 Mar 2026 21:01:55 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d26nnr7qn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:55 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1rjj25232078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:54 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA5C958052; Wed, 25 Mar 2026 21:01:53 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B251358068; Wed, 25 Mar 2026 21:01:52 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:52 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 02/24] s390/vfio-ap: Store queue hardware info when probed Date: Wed, 25 Mar 2026 17:00:49 -0400 Message-ID: <20260325210149.888028-3-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: K0QSp4cxrXHlOQssTz1J4kJOw6Om22h8 X-Authority-Analysis: v=2.4 cv=aMr9aL9m c=1 sm=1 tr=0 ts=69c44d44 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=TnwwbuCvOpPni-GgRwAA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX6DNbOsPXoDBo QQDpgpnuPS4NbbFG9IOnWdcsBAQCgOMyxt4J2fmLV9q/YTb/7qy0HRo7VVZ05dVufBML5Xjm7i2 jCM5UDPNktVRSSSKjW2wdz4SvBvbKUgUqpX3RMNc9/XnTiaVifohRzUuAWKxkho0c7efMaS/7CX lvqvzC9stfeRvS4/gP2IbZjOgfiF8WbquIE8AEDbSBZbrm2aEt18K1VlcVgQ8KpN4ai5DIL1YrY ArwNk1cT/jYhqe3r7xbO6N0cxGuomGHIKJ1RlN2VHnbMQUAEBF/WXv7UnUUOlURyMal4FVH5mbf EnXOx77IJ7I2EoPki7SfHYo04E5ljuYa84J2citKh39/VJmHl5vlZqjShexGvTuuKI3s72k8D+x 0MjkEBZKb/jF35fUj+ppcq3e4mySSL38EhZ6cZFU7U1B9/nZQVoCAUlwrv1rli5C97+K/RdtA/G U7y5ivGP+UPOnCf4Eyw== X-Proofpoint-GUID: K0QSp4cxrXHlOQssTz1J4kJOw6Om22h8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Store the output of the PQAP(TAPQ) command with the struct vfio_ap_queue object when a queue device is probed. This data can be retrieved from the object passed to the probe callback. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 5 ++++- drivers/s390/crypto/vfio_ap_private.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index 44b3a1dcc1b3..ef3101f6865e 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -2419,6 +2419,7 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) struct vfio_ap_queue *q; DECLARE_BITMAP(apm_filtered, AP_DEVICES); struct ap_matrix_mdev *matrix_mdev; + struct ap_queue *ap_queue; =20 ret =3D sysfs_create_group(&apdev->device.kobj, &vfio_queue_attr_group); if (ret) @@ -2430,8 +2431,10 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) goto err_remove_group; } =20 - q->apqn =3D to_ap_queue(&apdev->device)->qid; + ap_queue =3D to_ap_queue(&apdev->device); + q->apqn =3D ap_queue->qid; q->saved_isc =3D VFIO_AP_ISC_INVALID; + memcpy(&q->hwinfo, &ap_queue->card->hwinfo, sizeof(q->hwinfo)); memset(&q->reset_status, 0, sizeof(q->reset_status)); INIT_WORK(&q->reset_work, apq_reset_check); matrix_mdev =3D get_update_locks_by_apqn(q->apqn); diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index 9bff666b0b35..39c85bab05c3 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -150,6 +150,7 @@ struct vfio_ap_queue { struct list_head reset_qnode; struct ap_queue_status reset_status; struct work_struct reset_work; + struct ap_tapq_hwinfo hwinfo; }; =20 int vfio_ap_mdev_register(void); --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 4AFF3327BFB; Wed, 25 Mar 2026 21:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472526; cv=none; b=bwNWy5OzE+hgpSjMNEMkosSenXO7p22dMmZq9JmwbT+naMwEPBR1t2XFJEjO1WrusySp2itgq63hQbVIuqrlK5qGdc5lWkshbqkk6P8v25VUc1vCcKl71gWYEgN0S8NXtqAW6AKnJNQIy5b0ms8xij4jJGUNRqkDUGpNboEilq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472526; c=relaxed/simple; bh=woITMfbXQfKGswNRfdlqlBqqZ0U5Rllds2mj7PPz1XY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nftaSasmoLEXvPbmwydwJlfSxjLhy18RwNklccHZ2qkFpZesqwhYyZfpRgLJ47Yv6RuBiA8omUWeU8r02Dh68ZD0HB+7OVofFZYDoNfvnFPCLrdbuwNAAydZBG1NKtDWgbumwEvkm34r8WiDCDmIWLLC2sbe8tXH5RdWVIvxvis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=NkfGVCKX; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="NkfGVCKX" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PC16bk819878; Wed, 25 Mar 2026 21:01:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=PzosAF6DMyyWiGzFJ t8R+3Zb+FSwaKqKAhCSCWjVzgw=; b=NkfGVCKXU0pEw2bIR7gqNTxIkcIIAKClN 8kJkdr5ZAU0gC5SiCaw5z4Endvgbsoznc/UtFmtEaf1AMIgwzjdlp23fjNuohRIC uLFHdpLvMD6axH7p7O8jPPvmxGXtDqhjwNiqaJu/Mk6VO+7q2S1BERXknFPXGDpZ 0od71FkcgXsl8ltj/p9szOfX+VZTiHuhpTqejiqBsNFascC+wTvjTfEO6qhOmDxu Zruxtn4EOkw2qMoLPkjSIWTYfamcQBnqkvGw2aF2qjbszv2vlx/pdyM7TSf/g8j0 06ZXpbaTE6gUmow8Mp74Z0wAPn5OMlHM6pR6VvrPNHlNwqE4oJkrA== 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 4d1kumsjr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:57 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PK04Yg009126; Wed, 25 Mar 2026 21:01:56 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d26nnr7qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:56 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1VNt26542758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:31 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD4A158052; Wed, 25 Mar 2026 21:01:54 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C95A058056; Wed, 25 Mar 2026 21:01:53 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:53 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 03/24] s390/vfio-ap: Provide access to queue objects and related info Date: Wed, 25 Mar 2026 17:00:50 -0400 Message-ID: <20260325210149.888028-4-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 2vgpeMwLyBN22ESXqbu0ufsXYy6JvTqI X-Proofpoint-ORIG-GUID: 2vgpeMwLyBN22ESXqbu0ufsXYy6JvTqI X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX3mecj5MxGQ9G 8TL4ce0M2rn5yeT04+3tMUvNP5FPPOFbz7EnR55jnsqnmOCaJD/p3bHoHvmeRhrO0DwNQrot72j Gz3fwUe05W3N3ohTgPbran60x40FoylDdmDFsZ7UX9KgmWkbr5FxcvX5Chypbt0qSkNqshHZzWL 2/+wxMMhOt7Zm0WtFXw5RKppWV5tsNSroGIVPXfWVuT8KCy6uDGkki3BjqHtts9SgWQD67JOHUz DNzDqnP0KvD+DEZlXfH6QxEQjPo23XWZpF8ZM77F2WmGDJRGT3p7ObqkluEoZ9t1J5SJVElI7sO dtd1xe3atJUhT750ruKEUWwgU5QUWVRbFpbz9Rfncha1Fi/HHPbzkuGt+yEQMGg0Hs6WgvnNX8Z TzvQT+LwiAymQT6S9tLDlJNliJ9otFjknLbixxhgnWb7z5BW2czb08GmoDvQnESrz78H9+EpLd1 nSlNs3QKeaQKhStx2LA== X-Authority-Analysis: v=2.4 cv=KbXfcAYD c=1 sm=1 tr=0 ts=69c44d45 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=aJOwoqrUralclMrAr6UA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1011 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Provide the following: 1. A function that returns a struct vfio_ap_queue object representing a queue that is bound to the vfio_ap device driver and is assigned to an mdev 2. A function that returns the number of queues that are or will be passed through to a guest when the mdev is attached to a guest. There is already a function for #1; however, it is a static function in drivers/s390/crypto/vfio_ap_ops.c. The function will be defined in the drivers/s390/crypto/vfio_ap_private.h file and made non-static. Note that it would probably make sense to ensure that the mdevs_lock is held for this function, so a call to lockdep_assert_held(&matrix_dev->mdevs_lock) will be added to the function implementation. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 20 +++++++++++++++++--- drivers/s390/crypto/vfio_ap_private.h | 4 ++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index ef3101f6865e..cd85866b81a0 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -203,12 +203,12 @@ static inline void get_update_locks_for_queue(struct = vfio_ap_queue *q) * Return: the pointer to the vfio_ap_queue struct representing the queue = or * NULL if the queue is not assigned to @matrix_mdev */ -static struct vfio_ap_queue *vfio_ap_mdev_get_queue( - struct ap_matrix_mdev *matrix_mdev, - int apqn) +struct vfio_ap_queue *vfio_ap_mdev_get_queue(struct ap_matrix_mdev *matrix= _mdev, int apqn) { struct vfio_ap_queue *q; =20 + lockdep_assert_held(&matrix_dev->mdevs_lock); + hash_for_each_possible(matrix_mdev->qtable.queues, q, mdev_qnode, apqn) { if (q && q->apqn =3D=3D apqn) @@ -2098,6 +2098,20 @@ static void vfio_ap_mdev_request(struct vfio_device = *vdev, unsigned int count) release_update_locks_for_mdev(matrix_mdev); } =20 +int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix) +{ + unsigned long apid, apqi; + int num_queues =3D 0; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + for_each_set_bit_inv(apid, ap_matrix->apm, AP_DEVICES) + for_each_set_bit_inv(apqi, ap_matrix->aqm, AP_DOMAINS) + num_queues++; + + return num_queues; +} + static int vfio_ap_mdev_get_device_info(unsigned long arg) { unsigned long minsz; diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index 39c85bab05c3..d66586825ef4 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -153,6 +153,10 @@ struct vfio_ap_queue { struct ap_tapq_hwinfo hwinfo; }; =20 +struct vfio_ap_queue *vfio_ap_mdev_get_queue(struct ap_matrix_mdev *matrix= _mdev, int apqn); + +int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix); + int vfio_ap_mdev_register(void); void vfio_ap_mdev_unregister(void); =20 --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 4D46432D0D4; Wed, 25 Mar 2026 21:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472528; cv=none; b=GvfKZasmIeNXJ5nn8uVLi1HzcTC2jmN36idMpWOv5bYGhC68nm6g/MtSv8F5O5OnxiVrwz1XDHDtEPTuCyyW07fABWNJpPp1+cX1yzsL6AAJb+gGhGKqK9cTbSdSq07/9yux3ZPvWEXYOTmuQf8qGt1gXsVRNaUp4nw+dgpsUAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472528; c=relaxed/simple; bh=qWk58MCyl06Gi/6BvcjfDCVv30z6KhS31oL6rE+tI6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FgAS8P6s+yx1smwF3T/lx217+IB+MiDwvOsseJM0QWATWBVV0iPSDTyt5c6PtRQKjlp7Gjl0q5tUEuqicZVgtBR/DMV5MZDUoD7P2RH9kZdTEkemz5bF7JjlRXsLL4HHY/rcSxn1J0nhYCBZRDXGW8KPk5/CrQ7kRF29DOtaqkg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Vls4bdCQ; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="Vls4bdCQ" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PD2r6c646583; Wed, 25 Mar 2026 21:01:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=lRLZkMo7hL5smzrsL S0zL6G7KkjdnA9D7UD1/727aHs=; b=Vls4bdCQmfsd0gdZqKj00LFQ3Qww/9/Yd YadG4rhTgHkykMlywNt0W+ceCpuaB6y/Eqcg2vNQED+Qb1gZYo3PfwN/7A73WlL8 WKhU2bo8riEvV+CZAFuzzxjm7uwTDNT/dPI5QaqXtSxSM3zEev871QClWu8fexxw FCwmj2z2wmOTNCJsgGd3YRMfoBa+MiAjuGPKjvnMP/N0zhdjRVH7ryXTF0WR32mV p1Xu4yoy/sek3BfIzJvlmrSeycrc0LL3sgM6qemusAiyTWOD+8zchdsAgN8j4d8w Uh0gl0Kx/swqMPkLZVXJ788pqm7HNKGElnGoXqE2DYjeMqGVVMZ9g== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kumsjr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:58 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKTq4n012203; Wed, 25 Mar 2026 21:01:58 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk8161-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:58 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1uvd61145366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:56 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E325558068; Wed, 25 Mar 2026 21:01:55 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB70958056; Wed, 25 Mar 2026 21:01:54 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:54 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 04/24] s390/vfio-ap: Add header file for xfer of vfio device caps to userspace Date: Wed, 25 Mar 2026 17:00:51 -0400 Message-ID: <20260325210149.888028-5-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: PXps_1z3y-onma2ajD8hI8MDwTj6XHLN X-Proofpoint-ORIG-GUID: PXps_1z3y-onma2ajD8hI8MDwTj6XHLN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX/UtMT/+3Cpb4 bR/rsHovxIZm2NMCYSTGUwP5wrFJQXU6QIWK+Aw6wDRUFmPMRDTbwdorIZAUhF6Mw/WqWXoThmI JTghT+SKL6hGCBJyBIkovqb4W5JLAdIxBdA50Bxv1okm9rtwY2yUAZEJ/+mllt9fUWxBdKClmTf mdgP3EHpzyOZdzF6kBh11kdWsn1sqQPiWzGPSIIGL5h/gKRs9ChcgBtocnF2hfRZVqiqkwxPMdw aAkaD5N6ZjnzzJ6+h5oWZAZM1aKiwqDm+XcRptNgypvI3RX41pWFsDG35j5nX0tk4TskN994mAR D2f3ZNSsAg+wzXJsnCIU4lK1K/3GvaZkZfXACNiuOYIUTqTYtxF+O6wfWT8yG02gGDMJXNbiEMI icKcknWlq4GCp5xavEqaPy8lC7hBhssd9hL6gzw86HRTC8ULev5SM2bZ4+d1yVl/dB/4w/3aKug Xizj0sMAbAo2zhkjUMw== X-Authority-Analysis: v=2.4 cv=KbXfcAYD c=1 sm=1 tr=0 ts=69c44d47 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=I-WApvqTOFCiUe7Gdr0A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Adds the vfio_ap.h file used to transfer vfio device capabilities to userspace in response to the VFIO_DEVICE_GET_INFO ioctl. The device capabilities includes an object specifying the vfio device attributes. This object contains a flag indicating whether the vfio device is migratable. Note: The migratable flag could have been returned as a capability unto itself, but returning it as one attribute of a set of attributes allows for this capability to easily be extended to include additional attributes in the future if need be. Signed-off-by: Anthony Krowiak --- include/uapi/linux/vfio_ap.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 include/uapi/linux/vfio_ap.h diff --git a/include/uapi/linux/vfio_ap.h b/include/uapi/linux/vfio_ap.h new file mode 100644 index 000000000000..9ee14f8649ed --- /dev/null +++ b/include/uapi/linux/vfio_ap.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Interfaces for vfio-ap + * + * Copyright IBM Corp. 2025 + * + * Author(s): Anthony Krowiak + */ + +#ifndef INCLUDE_UAPI_LINUX_VFIO_AP_H_ +#define INCLUDE_UAPI_LINUX_VFIO_AP_H_ + +#include +#include + +#define VFIO_DEVINFO_CAP_AP_ATTRS_VERSION 1 +#define VFIO_DEVINFO_CAP_AP_ATTRS_ID 1 + +/** + * struct vfio_device_info_cap_ap_attrs - vfio device capability object us= ed + * supply the device attributes to + * userspace. + * + * @header: the header used to extend the struct vfio_device_info object + * to provide the vfio device attributes to userspace + * @migratable: indicates whether the vfio device is migratable (1) or + * not (0). + */ +struct vfio_device_info_cap_ap_attrs { + struct vfio_info_cap_header header; + int migratable; +}; + +#endif /* INCLUDE_UAPI_LINUX_VFIO_AP_H_ */ --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 AD9F9329C7F; Wed, 25 Mar 2026 21:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472527; cv=none; b=JjCTCZM9Al5EGtRYwfNzP0f7enaNaEBjQA79useFWajU59byWrnVNMOUymw9vynmzFQ0FcjWl2C1gUBeVo/pGgl864daLRbVXJySJT1LFBE+qZPad09lefwgQ2PvVaLzvB3c0A7S0Qh8wGGOhBdqvwaslrSmiORdF57mFPX+rNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472527; c=relaxed/simple; bh=u4CaiVCrKNvlGyKoHcj35sUlKt6KR32/aT5GSDFNhUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tg+w0iLqU3S3unWx21iPaAhvzVeinOmBPgr4eMZlqSoBMbN4iUrlR0dHNMPEcPNNu61t/Z34IGImb8CwEBr41+5nWXeoF0sZfLgZjJh2yChZFofwSM9df1dJlO8aUy6lSlLXJhcrCbe36KF+quRF1pMn61x+0DGsfB3o5xQVvNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Iwie2X/h; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="Iwie2X/h" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PCkDlZ755965; Wed, 25 Mar 2026 21:02:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=8mmNKYydXdYtAcrLN CQrgPJbTDLmjEo3ArIPx112Q0M=; b=Iwie2X/h/M1AyApl76qM00Sl7252f5aVO /L+4NZScOMCf09MS/6n55p4k8YL575dyPEdcKoaid9XqRRwdWWWoJH9qsqOdCIKc JMe/fZf7oyP5PuiAnib6rg4BjjCEeWzqs4FK8Z/S/wSLWyH0vKl6qKV9uHzHftJq DDBN57jMzuOCVdb+w3XD1oUkMHXZa+HAr+4LUuOdU+Xgdf5pCoyeiNYa+4iXAkbj ilm2ccqdWMt8KcXi5tvzoobFlXnT+iWq4zf73wb0oGdQkwrDNloQn3PyR2gF2ysw 3WSOypRslWNECrXz5DLRttXkPlb2ni1F+wGHrNB5tLuM/9gE0uVxA== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kty2cae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:00 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PImIJE006009; Wed, 25 Mar 2026 21:01:58 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d261yratf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:58 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1vGp11272850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:57 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D8705805D; Wed, 25 Mar 2026 21:01:57 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DB2858056; Wed, 25 Mar 2026 21:01:56 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:55 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 05/24] MAINTAINERS: Add new header file for the S390 VFIO AP DRIVER maintainers Date: Wed, 25 Mar 2026 17:00:52 -0400 Message-ID: <20260325210149.888028-6-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=IqITsb/g c=1 sm=1 tr=0 ts=69c44d48 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=lhH0Bl395LoeofpH:21 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8 a=dFtATCiH9KAnvEo0D2wA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX6fmfHIjAAO69 t0DiW/jQ/s3eMJpi1i5LzCheIIkGPYHXq0exh639tb5sMJVuHEk0ZEVdZbg7qAJO0BnDBkO4u62 Ba1PaObCEKQDbU8TDkONMF09GOS45KPgpjBn3WU9ob/nl7ZXiH+2ELo2ijSxYEK9PymaddVRCiK IsckBjlc9Rwo3JwXJs9N3JDY9PquNdoDal+4nbOuiyZ2glCZvesZFvyl9FknpG1cj2jjhsHjCUA llnZPGuqMYp/MDqt3Ni+QPLIvcDUhX+cx7yUN4Thb8iwxTUiLruLfSvyt3nkYAI10volwDzYGov Y6fCxznqxbU3lB2woKhn8RipVc3y7ddtAzHk4nRmGoNNUITPBPFrstyoJDP0NKvd4d0Siu8cQ5t NXtHYnB9xy8RDPkRqrWaXToxEnGnpdtegfCLUXvE0wS5XHUKbU1S8PP6RfIcZ5uvaUiJz/11+hz ssh1ztg/1Dga+X0KG5A== X-Proofpoint-GUID: DwRV3PjEELbnPJV3tP40uaZb4qUEcH4y X-Proofpoint-ORIG-GUID: DwRV3PjEELbnPJV3tP40uaZb4qUEcH4y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1011 spamscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Add new header file include/uapi/linux/vfio_ap.h for the S390 VFIO AP DRIVER maintainers. Signed-off-by: Anthony Krowiak --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7d10988cbc62..b84896648860 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -23339,6 +23339,7 @@ L: linux-s390@vger.kernel.org S: Supported F: Documentation/arch/s390/vfio-ap* F: drivers/s390/crypto/vfio_ap* +F: include/uapi/linux/vfio_ap.h =20 S390 VFIO-CCW DRIVER M: Eric Farman --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 ADA7B329E49; Wed, 25 Mar 2026 21:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472528; cv=none; b=YYMT97HTCHE9lP7fynId/T9Iq7SZklX6GEB0Cwn5/wXVILRT0LDrk6dZouiROtW8wZoLhc42VYhd2Npmk2A65jGfXpvqHgdTxqvjQF185yGE4LxuirOj/qCl7N49d3AWqtaJ/6JwQqHXkVE64QCw5VbfJQj53Sd70GeJqN1KplM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472528; c=relaxed/simple; bh=n0IUcWyUGkiHQUrRxnv8JmHBbDrT69coP9fhXUOEPAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=adFoxYXYGoKxX8PvLZkTbPGsR/zxawl9u46jKmXIRZD8DnDIASidZljkAEQj3rA4/gFOiShL2C+EVk4gf2+5dVrflvb8pNDfWCv1lFwDtfzXNreWdBwWd59uMqEbtsjdbgGmbeqm0GCdUNXqAopq6bz6zc5wBgFfuxYz7+O2iAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=G/hhsY94; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="G/hhsY94" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PCZ5EN665898; Wed, 25 Mar 2026 21:02:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=3+zEMG6BeMhrq7AUl EwhY8LZvBlGokmfd/7fUZ+5Mys=; b=G/hhsY94KmsDE9BQWl7xhrdtVkvRGGz6n I/Rw6VVVsbCd7lYAqkczJlebCN6g4NaMuTmbcEl58N5vCNcpS0dUSI+C9mPqoxOJ 6N5WSoIyB+SpNF0OGocw6mCaj0xlZJ9sirSk8kVWVLwVFW2Qgln8Kh7GytcF5p0p w9fCbBAXBhZyWU09yH/Zgd7h07zM5IBUCkOaFyYqQbaQ/KYBudoLZEhWH9A7qLPs S1+4PpOn0Ussm3XJC2JGUmuZtfMpZ0ak7my3jAIwW3dotCiVyJng1DM+ogOBNUV8 Rx+XY63LFFNkpdBlZ8xk40l4QvZRy0FKZpxF9ONiZWjTpMyC1QgAg== 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 4d1kwa2de7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:00 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PH1jQV004398; Wed, 25 Mar 2026 21:01:59 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d28c27ybj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:01:59 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1wGl31392264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:58 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25E0F58052; Wed, 25 Mar 2026 21:01:58 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B8825805D; Wed, 25 Mar 2026 21:01:57 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:57 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 06/24] s390/vfio-ap: A sysfs 'migratable' attribute to enable/disable migration of guest Date: Wed, 25 Mar 2026 17:00:53 -0400 Message-ID: <20260325210149.888028-7-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: CaObrp45d5ZIVo55TC1TYKuLB0WUm9sb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX8400CGy0vMPN V53yOZGmcYsgVdTl8BM9lLyt9WFoiJf1RVsdw0RIj0HGpD9Sde6FORgguSvF1wx9iuBNist2jHu 1NFgGNxU5EKL0/DWl+fqRzxOyJYStL6QNENBKLNeWdPsLUc1ZjgCfByhskJFIJwq243WZ+2X/Da 37yJiKUXit2onjNBXmZOabS7nzXMtnRdjlbTpOO3Bt99Vs/2Y/3tFhoi7CDt0Ezt5UeeBw4Rh4T oQW62REliIZXdaiuoWvhUSJK1PrNeFfpQjhCTQshNUAfIBTZZOLri8DYV3mw2zrCYkJmEpqqurE 06HCejvMbddenopVf2E/ZMmRYNsn2PYN7NMjA1KBo9wnbtItfpeUOLQi7jdna0MmDn2i35fK+KS cCqlo2F86u4lib/iGRVYeFx7vYJZS40pG4aFbtAIeTBlrBorDL2S3frLFNogY/5MIyGUlumopEH QYjUzkF627NnaRBe3ww== X-Proofpoint-GUID: CaObrp45d5ZIVo55TC1TYKuLB0WUm9sb X-Authority-Analysis: v=2.4 cv=OsZCCi/t c=1 sm=1 tr=0 ts=69c44d48 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=IcrxAOHjyUdORsvOTCUA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 clxscore=1015 phishscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" This patch creates a new R/W sysfs attribute of the vfio-ap mediated device that will ultimately be used to enable and disable migration of the guest to which the mediated device is attached. The value for this attribute is an int to be stored with the mediated device. A value of 1 indicates the vfio device can be migrated, and a value of 0 indicates migration is blocked. The initial value will be set to 0. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 46 +++++++++++++++++++++++++++ drivers/s390/crypto/vfio_ap_private.h | 3 ++ 2 files changed, 49 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index cd85866b81a0..97ec1f2fdbd1 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -32,6 +32,8 @@ =20 #define AP_RESET_INTERVAL 20 /* Reset sleep interval (20ms) */ =20 +#define VFIO_AP_DEVICE_MIGRATABLE_DEFAULT 0 + static int vfio_ap_mdev_reset_queues(struct ap_matrix_mdev *matrix_mdev); static int vfio_ap_mdev_reset_qlist(struct list_head *qlist); static struct vfio_ap_queue *vfio_ap_find_queue(int apqn); @@ -802,6 +804,7 @@ static int vfio_ap_mdev_probe(struct mdev_device *mdev) goto err_put_vdev; matrix_mdev->req_trigger =3D NULL; matrix_mdev->cfg_chg_trigger =3D NULL; + matrix_mdev->migratable =3D VFIO_AP_DEVICE_MIGRATABLE_DEFAULT; dev_set_drvdata(&mdev->dev, matrix_mdev); mutex_lock(&matrix_dev->mdevs_lock); list_add(&matrix_mdev->node, &matrix_dev->mdev_list); @@ -1785,6 +1788,48 @@ static ssize_t ap_config_store(struct device *dev, s= truct device_attribute *attr } static DEVICE_ATTR_RW(ap_config); =20 +static ssize_t migratable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ap_matrix_mdev *matrix_mdev; + size_t nchars; + + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D dev_get_drvdata(dev); + nchars =3D sysfs_emit(buf, "%d\n", matrix_mdev->migratable); + mutex_unlock(&matrix_dev->mdevs_lock); + + return nchars; +} + +static ssize_t migratable_store(struct device *dev, struct device_attribut= e *attr, + const char *buf, size_t count) +{ + struct ap_matrix_mdev *matrix_mdev; + int migratable; + int ret; + + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D dev_get_drvdata(dev); + + ret =3D kstrtoint(buf, 10, &migratable); + if (ret) + goto out_unlock; + + if (migratable !=3D 0 && migratable !=3D 1) { + ret =3D -EINVAL; + goto out_unlock; + } + + matrix_mdev->migratable =3D migratable; + ret =3D count; +out_unlock: + mutex_unlock(&matrix_dev->mdevs_lock); + + return ret; +} +static DEVICE_ATTR_RW(migratable); + static struct attribute *vfio_ap_mdev_attrs[] =3D { &dev_attr_assign_adapter.attr, &dev_attr_unassign_adapter.attr, @@ -1796,6 +1841,7 @@ static struct attribute *vfio_ap_mdev_attrs[] =3D { &dev_attr_control_domains.attr, &dev_attr_matrix.attr, &dev_attr_guest_matrix.attr, + &dev_attr_migratable.attr, NULL, }; =20 diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index d66586825ef4..b75299c9c1d0 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -104,6 +104,8 @@ struct ap_queue_table { * PQAP(AQIC) instruction. * @mdev: the mediated device * @qtable: table of queues (struct vfio_ap_queue) assigned to the mdev + * @migratable: an int value indicating whether the vfio device can be + * migrated (1) or not (0) * @req_trigger eventfd ctx for signaling userspace to return a device * @cfg_chg_trigger eventfd ctx to signal AP config changed to userspace * @apm_add: bitmap of APIDs added to the host's AP configuration @@ -120,6 +122,7 @@ struct ap_matrix_mdev { crypto_hook pqap_hook; struct mdev_device *mdev; struct ap_queue_table qtable; + int migratable; struct eventfd_ctx *req_trigger; struct eventfd_ctx *cfg_chg_trigger; DECLARE_BITMAP(apm_add, AP_DEVICES); --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 48151331230; Wed, 25 Mar 2026 21:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472529; cv=none; b=khGVW5rhrx9pSf2iRw070EulN+iIH3lvJRtx5WunTFgZAkekOq4qTc9xHhU3czkELmcyChD5dbMwE2uHQz6So5jssMippydtYObxUf6ij3fZv+hHka9lF5LXU8s58R9GGaKpfgz/c6XWWplWEV3gfp/FNm+bLCBymwPpY6J1tbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472529; c=relaxed/simple; bh=uRKV0D+Q6XMD+HEKRlc4uERZOxMIlh8pi35qiHiVGrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=czBGNzUs7JN/cQYPu8vWCrksRHhI8dWDlOaHCcccSuGml1rvnrt3rlmtlgey4hkaD3IixpxytU9y6TkKs3G9vhtPzCNBFtsoGA+Ef/lhDilG+plOUXTOhjuuNRpdX3KC7ADWT3QqCT6pbjhmfc6f8Zp4GzkvjTBC1VEp5Gef9GU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qOWC7+ZX; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="qOWC7+ZX" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PILXrM3744362; Wed, 25 Mar 2026 21:02:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=qSmUbhgMZy+IxLkdr ByGeR2wsIm+CKil+CHEI0vVd8E=; b=qOWC7+ZXUHgqIYOnG23Pp9YlpvWV2MHoz v++XJI1ox1dRriCDy3SbUWulcqPDMatNdPT+Vni8wQiYeXatefq+3rTxMBNC9Mof 1KnB3NRd2PtGH59KmSWjNUUCUk7PH3bBNIYtQKSXLFS4WdlGprQ0Fvws6X09kZMd KJfbyDhqsETjQBn1U7+HvVO/XzW8H2lqlNjcwW01LcCoK2njKB3RzIYJ8OCwEkeC LlTMOb1K+UGp2xOrRI6o9y6seiM2AR0e6qCqJujgpe3nFJMGsoPdjjxgxNN3Ekbr QYRCi3ErzAtDqaeNd9hqq2DEsY4g7jqW5A7D/ysWidwDN452y5ExA== 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 4d1kwa2dea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:01 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PJ62Ai031631; Wed, 25 Mar 2026 21:02:00 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d25nt0brj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:00 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1xKo20120222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:59 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 439ED58052; Wed, 25 Mar 2026 21:01:59 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4466F58068; Wed, 25 Mar 2026 21:01:58 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:58 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 07/24] s390/vfio-ap: Add 'migratable' feature to sysfs 'features' attribute Date: Wed, 25 Mar 2026 17:00:54 -0400 Message-ID: <20260325210149.888028-8-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: iRugTJjjWMLkFvKGujEYGPRZXZtpw-5Z X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX4QmHo2flNmxO oipIDuVWUBP2rwyFrRXTRwpRvojuf69lhJPH6n7pkbvqejaLMZw3XVg9+BMpKRxt0hMZT17hBAa xy3QuUQf48+at5sAcP+fnNTAXgwPuhXA9srgDhHPaVv7JV8b41hF2K8EaBBTB7crGfI6bzNEz5N INaKorkt/zhsklZ3x0eCQW1OaniaCTIeXLhpL4CrUa4PDX4TNNq0Y3YojAfrXHJXwy+0gjxvlT2 2wetDIRItV3DdvKrslww+XROe1yjDTvhIuQXfgAu53rpApQu5XD7zYI+yyU4SaBiTXYpO76Evdp a7kixYO3up2KE7OncszYsGKk7/DEZGM2aIB2t2xH1W06ghcCwbNZZ2Azz9mRmmPniHo1j0j6ctN rE/JNeNdZRbhCA4NOk614YuDNK2Xky9KvcnOgZhnK5OUeQERRKg+bjaRwRXMFEKuUJ+HHZFgSvl 99XNC2w177KCD8jzu1A== X-Proofpoint-GUID: iRugTJjjWMLkFvKGujEYGPRZXZtpw-5Z X-Authority-Analysis: v=2.4 cv=OsZCCi/t c=1 sm=1 tr=0 ts=69c44d49 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=CB_8iKbeFirw2v3l3xgA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 clxscore=1011 phishscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Add the 'migratable' feature to the features provided by the sysfs /sys/devices/vfio_ap/matrix/feature attribute to indicate that migration of vfio devices is supported. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_a= p_drv.c index fd7394d81880..d2fc3598cd24 100644 --- a/drivers/s390/crypto/vfio_ap_drv.c +++ b/drivers/s390/crypto/vfio_ap_drv.c @@ -26,9 +26,11 @@ MODULE_LICENSE("GPL v2"); struct ap_matrix_dev *matrix_dev; debug_info_t *vfio_ap_dbf_info; =20 +#define FEATURES "guest_matrix hotplug ap_config migratable" + static ssize_t features_show(struct device *dev, struct device_attribute *= attr, char *buf) { - return sysfs_emit(buf, "guest_matrix hotplug ap_config\n"); + return sysfs_emit(buf, "%s\n", FEATURES); } static DEVICE_ATTR_RO(features); =20 --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 662D232E128; Wed, 25 Mar 2026 21:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472529; cv=none; b=f1fIFDaUcUaYRRBp5rzb7E3jfoa81d1N+zW3C75vDSIfabKll6hPQtDj6EG+/PMaRzsxHhXXaE+87B3Rntj9+rOhupZjnQkSGGOREic7gcpKPth7QN9iLHbILgrCTmWSJR62F3JG8J4DLfiRes3DZdDF+ptc+N3Z8jdLn2IuJUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472529; c=relaxed/simple; bh=wZZ6KGzcPw+tHfeTLVFF8Jj1c8LFpuNuGM9I8tNuD+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eTKh8Jxc+bvtqapdcp2BP1fr3DDMq9j0Go+U7Q0St1xyk7AK3ZUi0ybHvrZBz1ZwNL9kD7Lk4Q4P042MDgQlyv9VPrw8MzSc12J7+Xk05j4JK4YVWo4wfiFT3gLsjaPlRvvdMHizGJ8XIGPbb3g6vo/eH4PIfN/F1ff0vJ05tlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=WI7THO/+; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="WI7THO/+" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PCe3V11172616; Wed, 25 Mar 2026 21:02:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=dPenDZePWoPZJANVB mvb4TFVdmepbA62uWGzQ/5qRO8=; b=WI7THO/++Ej8VAl8SsPjX9kGLqaiFTxTS V8olcxZ+5S5YczaxN5aBS6tv8FlMLH8Mm0KvAsQMtMVKBYan/11LLy2Hm99VI253 T3C5jDJIRBKUQZZgiruSymndYEnni6Z2TNT9CUwpLjVX0fg7G5jGLh8Ro/KHrrD7 qEjPuoTLX9cai9jkP2Aqr5BWi5C7bucyIsftmjAgMb/Fil9xN4OOg/xT6ehveRC3 FWWats7052xHZbGV0mSuwIJiOXd104N+od8H4/2Sr2quIBlYCSTJHx1+emddvOBL rDIDWxTb093Zr21X8kTYYmsrId0sfG2fOXZ16Fu4KGXJAOREZx1Pg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kumsjre-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:02 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PJ6cSo005996; Wed, 25 Mar 2026 21:02:02 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d261yratm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:02 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL20JD29098534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:00 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58FF35805D; Wed, 25 Mar 2026 21:02:00 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61B6C58056; Wed, 25 Mar 2026 21:01:59 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:01:59 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 08/24] s390/vfio-ap: Signal event to enable/disable live guest migration Date: Wed, 25 Mar 2026 17:00:55 -0400 Message-ID: <20260325210149.888028-9-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kvuHsxsrUrf8M_oJxTVwEa87_L8YU9xf X-Proofpoint-ORIG-GUID: kvuHsxsrUrf8M_oJxTVwEa87_L8YU9xf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX0tK457Lgq8W1 oXSmFszGoWw3UrkdVAMwOZd4iUSNEvWWSiSvtzEphWqhx0lRauf+yD6CU5g+V/nR1KzQ0QOMKy+ 8fVMeGxiiK3toS6zGMDS//9ZROkgnxn9nfBjT4PYKoIFi5zgR91CD5u/zyJB216DskUJGB1ajgI BjPLbo1I2SfYGuZjxlEGyJobuGFPWlgDOROiirLbuUT/NtbFInHB5idYcnrIFXLEuC5LSKIv3Oo btVwctKE1A1/Q3Vf+nDrx/YPe0QOvz4lN3Bu5W6ybDF3VzRWFNxTFJnbsNUj78MBNz06DO5iJ4+ sK0tfigosI/gZ9V5LV2UNrVE3V1ovGa8KD8coDnrRAmtgfbZn30OfC418XzNWHhwKtcjG/C6wRg IB/fOpy6SCbEMHzGuPLLbB1Hjr6GkgHwMryNaMl0RmgaANn7iIlBkZTI/ukc3odeSHM79mTS0t0 uOUP1YGPmy1ctGth6fA== X-Authority-Analysis: v=2.4 cv=KbXfcAYD c=1 sm=1 tr=0 ts=69c44d4a cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=gJh2Cn48l-pVlJ6rztwA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Defines two new eventfd contexts for signaling userspace to enable and disable vfio device migration. The IRQ indexes defined for these events are defined in an enum in the include/uapi/linux/vfio.h header file: VFIO_AP_ENABLE_MIG_IRQ_INDEX: enable vfio device migration VFIO_AP_DISABLE_MIG_IRQ_INDEX: disable vfio device migration Information about those IRQs can be retrieved from userspace via the VFIO_DEVICE_GET_IRQ_INFO ioctl. These events are initialized by the vfio_ap device driver via the in response to the VFIO_DEVICE_SET_IRQ_INFO ioctl. The eventfd for these IRQs will be signaled whenever the sysfs migratable attribute of the mediated device is changed. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 70 +++++++++++++++++++++++++-- drivers/s390/crypto/vfio_ap_private.h | 6 +++ include/uapi/linux/vfio.h | 2 + 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index 97ec1f2fdbd1..213832263dc9 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -658,6 +658,18 @@ static void signal_guest_ap_cfg_changed(struct ap_matr= ix_mdev *matrix_mdev) eventfd_signal(matrix_mdev->cfg_chg_trigger); } =20 +static void signal_enable_migration(struct ap_matrix_mdev *matrix_mdev) +{ + if (matrix_mdev->enable_mig_trigger) + eventfd_signal(matrix_mdev->enable_mig_trigger); +} + +static void signal_disable_migration(struct ap_matrix_mdev *matrix_mdev) +{ + if (matrix_mdev->disable_mig_trigger) + eventfd_signal(matrix_mdev->disable_mig_trigger); +} + static void vfio_ap_mdev_update_guest_apcb(struct ap_matrix_mdev *matrix_m= dev) { if (matrix_mdev->kvm) { @@ -805,6 +817,8 @@ static int vfio_ap_mdev_probe(struct mdev_device *mdev) matrix_mdev->req_trigger =3D NULL; matrix_mdev->cfg_chg_trigger =3D NULL; matrix_mdev->migratable =3D VFIO_AP_DEVICE_MIGRATABLE_DEFAULT; + matrix_mdev->enable_mig_trigger =3D NULL; + matrix_mdev->disable_mig_trigger =3D NULL; dev_set_drvdata(&mdev->dev, matrix_mdev); mutex_lock(&matrix_dev->mdevs_lock); list_add(&matrix_mdev->node, &matrix_dev->mdev_list); @@ -1821,7 +1835,18 @@ static ssize_t migratable_store(struct device *dev, = struct device_attribute *att goto out_unlock; } =20 + if (matrix_mdev->migratable =3D=3D migratable) { + ret =3D count; + goto out_unlock; + } + matrix_mdev->migratable =3D migratable; + + if (matrix_mdev->migratable) + signal_enable_migration(matrix_mdev); + else + signal_disable_migration(matrix_mdev); + ret =3D count; out_unlock: mutex_unlock(&matrix_dev->mdevs_lock); @@ -2193,10 +2218,9 @@ static ssize_t vfio_ap_get_irq_info(unsigned long ar= g) =20 switch (info.index) { case VFIO_AP_REQ_IRQ_INDEX: - info.count =3D 1; - info.flags =3D VFIO_IRQ_INFO_EVENTFD; - break; case VFIO_AP_CFG_CHG_IRQ_INDEX: + case VFIO_AP_ENABLE_MIG_IRQ_INDEX: + case VFIO_AP_DISABLE_MIG_IRQ_INDEX: info.count =3D 1; info.flags =3D VFIO_IRQ_INFO_EVENTFD; break; @@ -2296,6 +2320,40 @@ static int vfio_ap_set_cfg_change_irq(struct ap_matr= ix_mdev *matrix_mdev, unsign return 0; } =20 +static int vfio_ap_set_mig_irq(struct eventfd_ctx **mig_trigger, + unsigned long arg) +{ + s32 fd; + void __user *data; + unsigned long minsz; + struct eventfd_ctx *mig_ctx; + + minsz =3D offsetofend(struct vfio_irq_set, count); + data =3D (void __user *)(arg + minsz); + + if (get_user(fd, (s32 __user *)data)) + return -EFAULT; + + if (fd =3D=3D -1) { + if (*mig_trigger) + eventfd_ctx_put(*mig_trigger); + *mig_trigger =3D NULL; + } else if (fd >=3D 0) { + mig_ctx =3D eventfd_ctx_fdget(fd); + if (IS_ERR(mig_ctx)) + return PTR_ERR(mig_ctx); + + if (*mig_trigger) + eventfd_ctx_put(*mig_trigger); + + *mig_trigger =3D mig_ctx; + } else { + return -EINVAL; + } + + return 0; +} + static int vfio_ap_set_irqs(struct ap_matrix_mdev *matrix_mdev, unsigned long arg) { @@ -2313,6 +2371,12 @@ static int vfio_ap_set_irqs(struct ap_matrix_mdev *m= atrix_mdev, return vfio_ap_set_request_irq(matrix_mdev, arg); case VFIO_AP_CFG_CHG_IRQ_INDEX: return vfio_ap_set_cfg_change_irq(matrix_mdev, arg); + case VFIO_AP_ENABLE_MIG_IRQ_INDEX: + return vfio_ap_set_mig_irq(&matrix_mdev->enable_mig_trigger, + arg); + case VFIO_AP_DISABLE_MIG_IRQ_INDEX: + return vfio_ap_set_mig_irq(&matrix_mdev->disable_mig_trigger, + arg); default: return -EINVAL; } diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index b75299c9c1d0..514de4a73678 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -108,6 +108,10 @@ struct ap_queue_table { * migrated (1) or not (0) * @req_trigger eventfd ctx for signaling userspace to return a device * @cfg_chg_trigger eventfd ctx to signal AP config changed to userspace + * @enable_mig_trigger: eventfd ctx to signal userspace to enable vfio de= vice + * migration + * @disable_mig_trigger: eventfd ctx to signal userspace to disable vfio d= evice + * migration * @apm_add: bitmap of APIDs added to the host's AP configuration * @aqm_add: bitmap of APQIs added to the host's AP configuration * @adm_add: bitmap of control domain numbers added to the host's AP @@ -125,6 +129,8 @@ struct ap_matrix_mdev { int migratable; struct eventfd_ctx *req_trigger; struct eventfd_ctx *cfg_chg_trigger; + struct eventfd_ctx *enable_mig_trigger; + struct eventfd_ctx *disable_mig_trigger; DECLARE_BITMAP(apm_add, AP_DEVICES); DECLARE_BITMAP(aqm_add, AP_DOMAINS); DECLARE_BITMAP(adm_add, AP_DOMAINS); diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index bb7b89330d35..c661b8b22ead 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -673,6 +673,8 @@ enum { enum { VFIO_AP_REQ_IRQ_INDEX, VFIO_AP_CFG_CHG_IRQ_INDEX, + VFIO_AP_ENABLE_MIG_IRQ_INDEX, + VFIO_AP_DISABLE_MIG_IRQ_INDEX, VFIO_AP_NUM_IRQS }; =20 --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 EEE223358D6; Wed, 25 Mar 2026 21:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472531; cv=none; b=OnjjFmgzU59pqpU+VfZcGIu0vi1B4hEs1/26XlnUBfDYydQ7m230pOpgMiLSqyO4y8AL9VNya7R8sQ/yL8cLs99NXr51rfaS8IFVJOQeUXHGB9UuoeZ9SR8HHTsay4lU+2CDLH0/K68ZhUx3awIXYUbr9vz3g1eYaoLcEiceCdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472531; c=relaxed/simple; bh=Qv4p7AyHFLvqFpaNj2gh19V8Lp6RSO+suHmyJvAO7d0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n2X6Pqyjd/CtxAXOZceIeTe9r5aeVlZN795EBE8halVlHbaJ7SxIy4VgB1lC5G9kSFzYve4COI9pmZUJpEcILRgn6knAsCc3cSgKrU9Q2+Ie9TmLlPmZu8A/A6zD4Qaeu8vSAchOa0Evq2y/q4548xzHQF0ud8CEEKOjhP/rGag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Tb8U/qsw; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="Tb8U/qsw" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PFj5fg2969041; Wed, 25 Mar 2026 21:02:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=TYIEND5dhh+b75WgB e8kOpp81wHwKnGDTtTxcUzNu5M=; b=Tb8U/qswBvWnDzA2YbxWQhi4HiMuMl7EQ h0agn5iAz/6HRi02eAGgkybJPygrsApp1nBJNyR8eNbM6Jm6sGplfcx7IFIUz2va B/Lkn4FLBfwEArblGZfU8qrLjILLKIXVN/vG0uv6bYhqzQJicUHfIcllLjkm5nhp FOCRhrFlg3Su1bQzSk+XQphwrXcN2rFKNS+08R+pi2OIL1PMC7gE8CX7uKWODZo8 j5dHap2hyKmyHJr0psto2T4nC+MnkskFnI1DU5+g8bm3w8Hi2rAVJl/fuJUGys4T QTPHuhk3Do9izvuToRSQ2e900qJBVyyYY5mej9K31GR8cUq7+LFPw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kty2car-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:04 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKC8F7026900; Wed, 25 Mar 2026 21:02:03 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d275m0532-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:03 +0000 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 62PL21QW29098580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:01 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F66058067; Wed, 25 Mar 2026 21:02:01 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 772A858056; Wed, 25 Mar 2026 21:02:00 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:00 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 09/24] s390/vfio-ap: Return value of sysfs migratable attribute from VFIO_DEVICE_GET_INFO ioctl Date: Wed, 25 Mar 2026 17:00:56 -0400 Message-ID: <20260325210149.888028-10-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=IqITsb/g c=1 sm=1 tr=0 ts=69c44d4c cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=boy5AC6DYhcG1jmkY4oA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX+Wc75xC/U0Dq wncv9JCyx09NDpkTe5C0f/QRml6PkWlP39KlqgmN8d9knX3cElNeeeSBN89hIOve0QbQK4ScZ1i uTK443ubuEXs7Jj8RiZkrW6H2rfHxeMXaFhNbxk4t6M1CppzqPN0wpRdFQd9z0jyT35Mby79/C/ Q06TOFn6ZKIpI4U+RjGdk3SXJVDFzAk2/oglFPalM3UfRzxCRMvXF/XJ3AMAq/k8oQ+kkVXfbKO wYvUH21WcLpKJHxsTHYJIj65zk8BTyAEiAKBjySPHcy+OctQe5DLbWdbUfKl+KKiQ6AyJBjEqcm tJM0g2AM50lw0uyoZnQMUi7aI7B99+aMQW3iMKDNlciwOpGhcZjdxuGXNKwz511l7PkyQzYUPXi MN1g+lp8uqvuJ36FPAaJFw3JlBcX+GAwbHoBOdB2j7/oFjlKdvoFiHkx1uCJeSUoYsUiCc+0IVt 2iGPtiQGes5PU1DX+Ug== X-Proofpoint-GUID: rOYcLK78lB5YvXxe5cnRRr9Xs7Q-DS3o X-Proofpoint-ORIG-GUID: rOYcLK78lB5YvXxe5cnRRr9Xs7Q-DS3o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Extends the 'vfio_device_info' object passed to the VFIO_DEVICE_GET_INFO ioctl to include a vfio device capability specifying the value of the mdev's sysfs 'migratable' attribute. This value may be used to enable or block live guest migration when the vfio device is realized in userspace. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 75 ++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index 213832263dc9..d487628027c7 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include "vfio_ap_private.h" #include "vfio_ap_debug.h" @@ -2183,11 +2184,75 @@ int vfio_ap_mdev_get_num_queues(struct ap_matrix *a= p_matrix) return num_queues; } =20 -static int vfio_ap_mdev_get_device_info(unsigned long arg) +static int vfio_ap_add_caps_to_dev_info(struct vfio_device_info *dev_info, + unsigned long arg, + struct vfio_info_cap *caps) { + lockdep_assert_held(&matrix_dev->mdevs_lock); + + if (caps->size) { + dev_info->flags |=3D VFIO_DEVICE_FLAGS_CAPS; + if (dev_info->argsz < sizeof(*dev_info) + caps->size) { + dev_info->argsz =3D sizeof(*dev_info) + caps->size; + } else { + vfio_info_cap_shift(caps, sizeof(*dev_info)); + + if (copy_to_user((void __user *)arg + sizeof(*dev_info), + caps->buf, caps->size)) { + kfree(caps->buf); + return -EFAULT; + } + + dev_info->cap_offset =3D sizeof(*dev_info); + } + + kfree(caps->buf); + } + + return 0; +} + +static int vfio_ap_add_attrs_cap_to_caps(struct ap_matrix_mdev *matrix_mde= v, + struct vfio_info_cap *caps) +{ + struct vfio_device_info_cap_ap_attrs cap; + + lockdep_assert_held(matrix_dev->mdevs_lock); + cap.migratable =3D matrix_mdev->migratable; + cap.header.id =3D VFIO_DEVINFO_CAP_AP_ATTRS_ID; + cap.header.version =3D VFIO_DEVINFO_CAP_AP_ATTRS_VERSION; + + return vfio_info_add_capability(caps, &cap.header, sizeof(cap)); +} + +static int vfio_ap_add_caps(struct ap_matrix_mdev *matrix_mdev, + unsigned long arg, + struct vfio_device_info *dev_info) +{ + struct vfio_info_cap caps =3D { .buf =3D NULL, .size =3D 0 }; + int ret =3D 0; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + ret =3D vfio_ap_add_attrs_cap_to_caps(matrix_mdev, &caps); + if (ret) + return ret; + + ret =3D vfio_ap_add_caps_to_dev_info(dev_info, arg, &caps); + if (ret) + return ret; + + return 0; +} + +static int vfio_ap_mdev_get_device_info(struct ap_matrix_mdev *matrix_mdev, + unsigned long arg) +{ + int ret; unsigned long minsz; struct vfio_device_info info; =20 + lockdep_assert_held(&matrix_dev->mdevs_lock); minsz =3D offsetofend(struct vfio_device_info, num_irqs); =20 if (copy_from_user(&info, (void __user *)arg, minsz)) @@ -2200,6 +2265,12 @@ static int vfio_ap_mdev_get_device_info(unsigned lon= g arg) info.num_regions =3D 0; info.num_irqs =3D VFIO_AP_NUM_IRQS; =20 + ret =3D vfio_ap_add_caps(matrix_mdev, arg, &info); + if (ret) + return ret; + + minsz =3D min_t(size_t, info.argsz, sizeof(info)); + return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; } =20 @@ -2395,7 +2466,7 @@ static ssize_t vfio_ap_mdev_ioctl(struct vfio_device = *vdev, mutex_lock(&matrix_dev->mdevs_lock); switch (cmd) { case VFIO_DEVICE_GET_INFO: - ret =3D vfio_ap_mdev_get_device_info(arg); + ret =3D vfio_ap_mdev_get_device_info(matrix_mdev, arg); break; case VFIO_DEVICE_RESET: ret =3D vfio_ap_mdev_reset_queues(matrix_mdev); --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 B509C346E4A; Wed, 25 Mar 2026 21:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472532; cv=none; b=J0JdWeD/ua2NvpeKZODVpd7ZKTYUAzu7oGj5HdH4yIBkMqb2+zpeEcVBjSQVFmEx84MBsBqA7NL0lYfzEymSKSHzu35Y0LDbESsOhXfr0SgQoPhm5bBcrPopXy9dOMBFI0UG9t2wa7QDntgE6ZXRX+jf+5V8rx91kU7jC9dRsnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472532; c=relaxed/simple; bh=4I0g/89g/lYK3Q1XAhKUw07p0vdBvLCNzPUzmO0cSGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pgr5pVgFSJd2IxNLlD8hbMoAQqQp1Moqg/WP99hsHeel39L7hCQ8wY2LYsEtzpntNOd8ClKa3MFAzc9A13IXXh5fn0deo+hIntnGFthIkgwkbRtsN0lE5OelIzXTOyBshFxLL/fbjhuvaBE4F+4Sh3VNopU3fTsbs5QL9iX1eeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=gsE9dqza; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="gsE9dqza" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PEiJNV3111761; Wed, 25 Mar 2026 21:02:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=vPhQ/Jc1b3P48fO8W BU2mNGDvqreJ4p4wKs1Elq0NEA=; b=gsE9dqzaLx016YplzNArnKnYjiznRnVB7 uXvrNck2NugtaywWYkTkQeoEpXZkNDHLE3YDEsUIUIfEjxbq/k87KAqaLSPsptcr LuWePWE8orgymo1MZTwvQR7aOwTcWLRs0nwFx11jkJYxMuWWy/hDtx16TLujagje Dmc2IYAdqgvIyMrf+94eV57jLS7WUnN5NmBqM58QTlAw96KKtfipGjIyUoHZld+G uaB/ZorBiFqzGhwYmbzysmhZNy/CwaQDYVu8W2DLspbjVVewoB/faHaFFPVcDoAH 0UUGzRMrwplJIHtJ+3uF5+msZEVFsRQkwyYtxEvrYJDrHYCViKi/w== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kumsjrp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:05 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKBGn8012213; Wed, 25 Mar 2026 21:02:04 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk816m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:04 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL222L39191038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:03 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95E9558067; Wed, 25 Mar 2026 21:02:02 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9314858056; Wed, 25 Mar 2026 21:02:01 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:01 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 10/24] s390/vfio-ap: Data structures for facilitating vfio device migration Date: Wed, 25 Mar 2026 17:00:57 -0400 Message-ID: <20260325210149.888028-11-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: IWkUQK2r2UAM-h8qZtUMfg2hz_k-Nza0 X-Proofpoint-ORIG-GUID: IWkUQK2r2UAM-h8qZtUMfg2hz_k-Nza0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX+Y8hfL+OIMgG y5VQ4fESIZrmYoKBMCM+D1Eok07tzSnQQPGLV5ZyDt6cq0zpWARjHhm2ES6j9RBiy2VT5VVuuMZ lmSiLgHsL1WFyu7KI+zRQVFC0KZoZt9poTQT2KBqgKm5+ZK7H74SdTLrSBo3tBhnN+JcApah+3B dvZqds+RfqH9OQwJxUhzjOttuTCxF450SAMmwqaADbHKtqeVJJDoXEjdxNzFwx3zkcWIKae9+fx pfQI0t+lgNHxgXGyXxJR9KTGoM/EvavHklV2Sl5Gsm7EGp8HZV6ZkK1OxuTwXy12J+P4BrlIg9Z aGxJsk5mlGWhck0u9QJRlBUJ3dw360CwkLTTS2FTWoQWfPZXEnWhVGbpbzvNT5ULTQ2Qat/+rjZ +LZiI8ixdoOfwxJ9wPqSO4WeBx/JcXtelOfeRm/skhdNdIANfhBWwJ61YhlF6BqLfJ4PUqVYJqm KrNbQSVzN9nP1gKe9bA== X-Authority-Analysis: v=2.4 cv=KbXfcAYD c=1 sm=1 tr=0 ts=69c44d4d cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=8LKZ2_jO19hrQNhpKIYA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Creates the data structures used to facilitate state transitions during vfio device migration. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/Makefile | 2 +- drivers/s390/crypto/vfio_ap_migration.c | 68 +++++++++++++++++++++++++ drivers/s390/crypto/vfio_ap_private.h | 2 + 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 drivers/s390/crypto/vfio_ap_migration.c diff --git a/drivers/s390/crypto/Makefile b/drivers/s390/crypto/Makefile index e83c6603c858..20f29184825a 100644 --- a/drivers/s390/crypto/Makefile +++ b/drivers/s390/crypto/Makefile @@ -34,5 +34,5 @@ pkey-uv-objs :=3D pkey_uv.o obj-$(CONFIG_PKEY_UV) +=3D pkey-uv.o =20 # adjunct processor matrix -vfio_ap-objs :=3D vfio_ap_drv.o vfio_ap_ops.o +vfio_ap-objs :=3D vfio_ap_drv.o vfio_ap_ops.o vfio_ap_migration.o obj-$(CONFIG_VFIO_AP) +=3D vfio_ap.o diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c new file mode 100644 index 000000000000..2c5978dde61d --- /dev/null +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Drives vfio_ap mdev migration. + * + * Copyright IBM Corp. 2025 + */ +#include "uapi/linux/vfio_ap.h" + +#include "vfio_ap_private.h" + +/** + * vfio_ap_migration_data - the data needed to migrate a guest with pass-t= hrough + * access to AP devices + * + * @mig_state: the current migration state + * @resuming_migf: the object used to resume the target guest + * @saving_migf: the object used to save the state of the source guest + */ +struct vfio_ap_migration_data { + enum vfio_device_mig_state mig_state; + struct vfio_ap_migration_file *resuming_migf; + struct vfio_ap_migration_file *saving_migf; +}; + +/** + * vfio_ap_queue_info - the information for an AP queue + * + * @data: contains the queue information returned in GR2 from the PQAP(TAP= Q) + * command + * @apqn: the APQN of the queue + */ +struct vfio_ap_queue_info { + u64 data; + u16 apqn; +}; + +/** + * vfio_ap_config - the guest's AP configuration + * + * @num_queues: the number of queues passed through to the guest + * @qinfo: an array of vfio_ap_queue_info objects, each specifying the + * queue information for a queue passed through to the guest + */ +struct vfio_ap_config { + unsigned int num_queues; + struct vfio_ap_queue_info qinfo[]; +}; + +/** + * vfio_ap_migration_file - object used to facilitate migration of a guest= with + * pass-through access to AP devices + * + * @matrix_mdev: the mediated device attached to the guest being migrated + * @filp: the file used to facilitate communication between userspace + * and the vfio_ap device driver during a particular phase of + * the migration + * @disabled: boolean value indicating whether this object is disabled (t= rue) + * or not (false) + * @ap_config: the information for each queue passed through to a guest + * @config_sz: the size of @ap_config when filled with queue information + */ +struct vfio_ap_migration_file { + struct ap_matrix_mdev *matrix_mdev; + struct file *filp; + bool disabled; + struct vfio_ap_config *ap_config; + size_t config_sz; +}; diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index 514de4a73678..24db7d32e41c 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -116,6 +116,7 @@ struct ap_queue_table { * @aqm_add: bitmap of APQIs added to the host's AP configuration * @adm_add: bitmap of control domain numbers added to the host's AP * configuration + * @mig_data: vfio device migration data */ struct ap_matrix_mdev { struct vfio_device vdev; @@ -134,6 +135,7 @@ struct ap_matrix_mdev { DECLARE_BITMAP(apm_add, AP_DEVICES); DECLARE_BITMAP(aqm_add, AP_DOMAINS); DECLARE_BITMAP(adm_add, AP_DOMAINS); + void *mig_data; }; =20 /** --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 A040834889C; Wed, 25 Mar 2026 21:02:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472533; cv=none; b=YaFgWABKghFYaizMKXSDJJz7VHqX3XzadRp5c9eOS89E4KxDTS2LTBWmbe7jcC+2/KcLdVTpOCJTQUAs34q5RqPBUXWTPa+WO2Epm6OCHc/CT9EoYe2OR+CcrgtEqg+rg3AF6JrtBf3eqjFBeDeyA67RBfHbdZvcjzbLrRrFmsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472533; c=relaxed/simple; bh=ubwcCZuLSZ6ZB4fdlP1RWs7uWagIJWw4LzYL2LiGC3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cWRCpjfz2VF4floj0iLE9FqhlzAzYRji43ZzV2ShiGKLyHlq7QiQD6pGhtkGAMWtk35QgTN4Wn+zpG3fheXhCD3hwZKwU4ezRjRDXkuGtTAeQpGpJE63C1cqB63LjZ/UPl6NtvJD3GwVEveuyUnOUR3xX2SHp/DolltbZ9gyJiA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=jlayIiou; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="jlayIiou" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PGeqxr3444471; Wed, 25 Mar 2026 21:02:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=9B9nD8oe+4Pg83vbu 3quAaAPaTki0tBUESAz95ocZgw=; b=jlayIiouGniPjyv6scLdgG+cTFswyg3fj 3GfcsFFjSYQUbCXNxSKx0fK2I0UqxyO5fK3cgh4oI2G8Ro8tNlkcRamfdFptfnEj xHfi2N3YVw+ShHSdZhOk1i092wc5e/sV1imvLZ0xPmLa7MqlFFy0rL5BYBQsIgJM CM3OndgGF7hT8yMYiTg4OMxGLrIhuj5NrYjb7YzC1GfZMY49o4w3SYwfHrQx/asR YCbX7ENgSWygNqGsTsSrllQjGglphPaX+AMV2SrIrreeJKZ7xOBJsC4pNq04Y698 eFxRS6yhmw7lbSlIjXQS645IzP8lA387JPNs3RUTSdw+MRoLDWKbw== 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 4d1ktv1hja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:05 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PGlKQL004369; Wed, 25 Mar 2026 21:02:05 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d28c27yc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:05 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL23xU5702378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:03 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD9AB58056; Wed, 25 Mar 2026 21:02:03 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B431C58069; Wed, 25 Mar 2026 21:02:02 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:02 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 11/24] s390/vfio-ap: Initialize/release vfio device migration data Date: Wed, 25 Mar 2026 17:00:58 -0400 Message-ID: <20260325210149.888028-12-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: r3JQDMACK-y5F09qqtNggD9244ZeitFi X-Authority-Analysis: v=2.4 cv=aMr9aL9m c=1 sm=1 tr=0 ts=69c44d4e cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=22LHVZlmPUAi0_1XYEgA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX2ySuYJrw7vMC Ueb1N+PqmvMK4hCdx3lLRWClpJ3MVuogID4JMrG6YI4h6ikhm7lr80YjZdOslomlernKrAyR9/Q ZSUe3mL2YrXmln5QQCa2GzK4kliG3tXBGOZu2f/MaBXY9n5Ukwy6UOPF2Mxsg5IzLjs0r10ZyQn OR/2nAQMBYga48NnGPyrJwvcxsvslNjgGaBtwAJnk1RKYDSl0phDbEwhcEC59glDpmz/keDNff/ Wo4AQjWT9rcBhOAoiVvzHZ3RakZS5eXTKn7mpjo9oHX0vg/Y52FrdpmPX/SawF7VGb/KHGOQ+RY VtEIKjkODTrpWzSOo/k+GtSljzLh1msX34KCVWsrlTrvVtxoaXyg3b6cmAgZmJWsTy2TBwRlLnb +DX0AXTiT1rxekMXXvdtHK4c69PQAdT4DNP4R3cd33Epf9sNwuyymqIZem01dSGyf9ddweFMEK2 SEfqvXAt6WlhUUxDeyw== X-Proofpoint-GUID: r3JQDMACK-y5F09qqtNggD9244ZeitFi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 clxscore=1011 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Provides the functions that initialize and release the data structures used during live guest migration. These functions should be called when the mdev fd is opened and closed respectively. The function to release the data structures shall also be invoked when the mdev is released. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 94 +++++++++++++++++++++++++ drivers/s390/crypto/vfio_ap_ops.c | 41 +++++++++-- drivers/s390/crypto/vfio_ap_private.h | 3 + 3 files changed, 131 insertions(+), 7 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index 2c5978dde61d..76cbbe1adb7a 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -4,6 +4,7 @@ * * Copyright IBM Corp. 2025 */ +#include #include "uapi/linux/vfio_ap.h" =20 #include "vfio_ap_private.h" @@ -66,3 +67,96 @@ struct vfio_ap_migration_file { struct vfio_ap_config *ap_config; size_t config_sz; }; + +static void vfio_ap_disable_file(struct vfio_ap_migration_file *migf) +{ + lockdep_assert_held(&matrix_dev->mdevs_lock); + migf->matrix_mdev =3D NULL; + migf->disabled =3D true; + migf->filp->f_pos =3D 0; +} + +static void vfio_ap_release_mig_files(struct ap_matrix_mdev *matrix_mdev) +{ + struct vfio_ap_migration_data *mig_data; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + mig_data =3D matrix_mdev->mig_data; + + if (mig_data->resuming_migf) { + vfio_ap_disable_file(mig_data->resuming_migf); + fput(mig_data->resuming_migf->filp); + mig_data->resuming_migf =3D NULL; + } + + if (mig_data->saving_migf) { + vfio_ap_disable_file(mig_data->saving_migf); + fput(mig_data->saving_migf->filp); + mig_data->saving_migf =3D NULL; + } +} + +static struct file *vfio_ap_set_state(struct vfio_device *vdev, + enum vfio_device_mig_state new_state) +{ + return NULL; +} + +static int vfio_ap_get_state(struct vfio_device *vdev, + enum vfio_device_mig_state *current_state) +{ + return -EOPNOTSUPP; +} + +static int vfio_ap_get_data_size(struct vfio_device *vdev, + unsigned long *stop_copy_length) +{ + return -EOPNOTSUPP; +} + +static const struct vfio_migration_ops vfio_ap_migration_ops =3D { + .migration_set_state =3D vfio_ap_set_state, + .migration_get_state =3D vfio_ap_get_state, + .migration_get_data_size =3D vfio_ap_get_data_size, +}; + +/** + * vfio_ap_init_migration_data - initialize migration data and functions + * + * @matrix_mdev: pointer to object containing the mdev state + * + * Return: zero if initialization is successful; otherwise, returns a erro= r. + */ +int vfio_ap_init_migration_data(struct ap_matrix_mdev *matrix_mdev) +{ + struct vfio_ap_migration_data *mig_data; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + mig_data =3D kzalloc_obj(struct vfio_ap_migration_data, GFP_KERNEL); + if (!mig_data) + return -ENOMEM; + + mig_data->mig_state =3D VFIO_DEVICE_STATE_STOP; + matrix_mdev->vdev.migration_flags =3D VFIO_MIGRATION_STOP_COPY; + matrix_mdev->vdev.mig_ops =3D &vfio_ap_migration_ops; + matrix_mdev->mig_data =3D mig_data; + + return 0; +} + +/** + * vfio_ap_release_migration_data: reclaim private migration data + * + * @vdev: pointer to the mdev + */ +void vfio_ap_release_migration_data(struct ap_matrix_mdev *matrix_mdev) +{ + lockdep_assert_held(&matrix_dev->mdevs_lock); + if (!matrix_mdev->mig_data) + return; + + vfio_ap_release_mig_files(matrix_mdev); + kfree(matrix_mdev->mig_data); + matrix_mdev->mig_data =3D NULL; +} diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index d487628027c7..1ff9994bd7ec 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -790,18 +790,30 @@ static bool vfio_ap_mdev_filter_matrix(struct ap_matr= ix_mdev *matrix_mdev, =20 static int vfio_ap_mdev_init_dev(struct vfio_device *vdev) { - struct ap_matrix_mdev *matrix_mdev =3D - container_of(vdev, struct ap_matrix_mdev, vdev); + struct ap_matrix_mdev *matrix_mdev; =20 + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); matrix_mdev->mdev =3D to_mdev_device(vdev->dev); vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->matrix); matrix_mdev->pqap_hook =3D handle_pqap; vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); hash_init(matrix_mdev->qtable.queues); + mutex_unlock(&matrix_dev->mdevs_lock); =20 return 0; } =20 +static void vfio_ap_mdev_release_dev(struct vfio_device *vdev) +{ + struct ap_matrix_mdev *matrix_mdev; + + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); + vfio_ap_release_migration_data(matrix_mdev); + mutex_unlock(&matrix_dev->mdevs_lock); +} + static int vfio_ap_mdev_probe(struct mdev_device *mdev) { struct ap_matrix_mdev *matrix_mdev; @@ -2124,19 +2136,33 @@ static int vfio_ap_mdev_reset_qlist(struct list_hea= d *qlist) =20 static int vfio_ap_mdev_open_device(struct vfio_device *vdev) { - struct ap_matrix_mdev *matrix_mdev =3D - container_of(vdev, struct ap_matrix_mdev, vdev); + struct ap_matrix_mdev *matrix_mdev; + int ret; =20 if (!vdev->kvm) return -EINVAL; =20 - return vfio_ap_mdev_set_kvm(matrix_mdev, vdev->kvm); + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); + ret =3D vfio_ap_init_migration_data(matrix_mdev); + mutex_unlock(&matrix_dev->mdevs_lock); + + if (ret) + return ret; + + ret =3D vfio_ap_mdev_set_kvm(matrix_mdev, vdev->kvm); + + return ret; } =20 static void vfio_ap_mdev_close_device(struct vfio_device *vdev) { - struct ap_matrix_mdev *matrix_mdev =3D - container_of(vdev, struct ap_matrix_mdev, vdev); + struct ap_matrix_mdev *matrix_mdev; + + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); + vfio_ap_release_migration_data(matrix_mdev); + mutex_unlock(&matrix_dev->mdevs_lock); =20 vfio_ap_mdev_unset_kvm(matrix_mdev); } @@ -2555,6 +2581,7 @@ static const struct attribute_group vfio_queue_attr_g= roup =3D { =20 static const struct vfio_device_ops vfio_ap_matrix_dev_ops =3D { .init =3D vfio_ap_mdev_init_dev, + .release =3D vfio_ap_mdev_release_dev, .open_device =3D vfio_ap_mdev_open_device, .close_device =3D vfio_ap_mdev_close_device, .ioctl =3D vfio_ap_mdev_ioctl, diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index 24db7d32e41c..cad49b509f7a 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -181,4 +181,7 @@ void vfio_ap_on_cfg_changed(struct ap_config_info *new_= config_info, void vfio_ap_on_scan_complete(struct ap_config_info *new_config_info, struct ap_config_info *old_config_info); =20 +int vfio_ap_init_migration_data(struct ap_matrix_mdev *matrix_mdev); +void vfio_ap_release_migration_data(struct ap_matrix_mdev *matrix_mdev); + #endif /* _VFIO_AP_PRIVATE_H_ */ --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 A0371348895; Wed, 25 Mar 2026 21:02:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472533; cv=none; b=GMVzH8mo8KZMoxJwLrsik9aS4nzSj6QpmFo5cHJg6bO7Qo9dcdDzE3vKXcNZX1IJ1Wz8941kuvopdUNcttN2wfH5EQwES0Pz7W8p2KLdOe6AYqPMuEOZQK2Jc7DxvzFJuhYO7QrF7h6vNjt5zpRgJsv3CwHrUtqrgymJwDq8FIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472533; c=relaxed/simple; bh=pUnRt60E4eVwuV/JK2wFa8KNuRSP42svA6IpzNxVhEY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FJAEFa0qpwK5j1CmWdEgPUx47qCxHV2m9Th3D1Ki/EE9vcug9NlmlM6lvxULD/OokuTqz2uRgAPjXAITEYlv7IeI/DQDRdB7Njwybib/6Wzhcmele7wr1x66dxIyNUfmWLJAbkk+TI9pzBXvIlBrao5TcXpiu7wJNMIRKp3pyjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Rwu/pXJs; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="Rwu/pXJs" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62P9Wrll094514; Wed, 25 Mar 2026 21:02:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=uBu1K38NNRbHA+kc7 FmrfFTckZQKlirl+LLZ1sU1V0w=; b=Rwu/pXJs2X24M4EgoOHj8L+xcd+5rTPP/ +6kNd6znfACFOJlI3yGkKfUZ7Ovd0z7pZk+PISKqoqrhZBANdHLBzJj4tHQN8ABe eP+yj2XR6rZLKrBh8Q046oZE4D6VEJoT3zvtY/sOARv1qEANRaMqAD0Pgfm3mUCL CC4DvuKzNuKOyrrDNt/YSMZ1c+wjgeaQRzxcsBmkqZiiMcwmIIr0iu5yPHjC2X8s hXxCX5JuFrXhELpB+w4L7y9yPWABGuKb7qRrRjWwACd1vLN6UnTL3uXWU56375Fc J5N0S1VwQX31jaaBpT2LvoXROt7gGLBvbMuOdyUxL12xKBwwH5IjA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1ky09feb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:07 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PK8tHa011824; Wed, 25 Mar 2026 21:02:06 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk816v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:06 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL24LB26804892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:04 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C39FE5805D; Wed, 25 Mar 2026 21:02:04 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBF9358052; Wed, 25 Mar 2026 21:02:03 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:03 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 12/24] s390-vfio-ap: Callback to set vfio device mig state during guest migration Date: Wed, 25 Mar 2026 17:00:59 -0400 Message-ID: <20260325210149.888028-13-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX+BQWm4vZVRuS Na7XaGhx0TJGuo8GoFT1Z9fDgpUEF/MuSMFeUUPJefwNsKNrCi2t1qWduLl2Ysk7IbVNVMzpe+D 3P4lPjAVXwIVbLkmrtjo4gdWBvfqETbX15ukkZqyyJW3IbE6nJvppoNCm17rd/GIb0WMgxNREQ0 cRWzeAUG31D0MBWPC22/mVLAFTDpRene2xk7wics3mljO45WCmb0B5f4ubOMBjnmCoTInqp2PgG Y0MbHm2zRV2E4HdVw/Z0f64v5VBgLyNhgbXNhrMcv5/Ey6B3Paz7/CS5Ueh4NKN2YsArTaGR0a1 ddWI/ERyau0amUqXwxpxySFUUEW7ItKeTEhmAxIJYgK12M1l2f1C4d3fJ3K0SXyt4eH4OrXIRov +mORcnmYBZa8m2hbJx0xmHDnmzMKMtuGxvd5oz9h6xXdVsj9fnYLhAOKfsfHk4Wf4fxBzG6Qa1j lA23VqOPOzj1+pOW5ZQ== X-Authority-Analysis: v=2.4 cv=JK42csKb c=1 sm=1 tr=0 ts=69c44d4f cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=A_qOOsZ8MQ48mD1vPGUA:9 X-Proofpoint-ORIG-GUID: vldIpQ9aAhu5QiYCol8YDjgvbhKi8qZh X-Proofpoint-GUID: vldIpQ9aAhu5QiYCol8YDjgvbhKi8qZh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Implements the callback that sets a new migration state of a vfio device during live migration of guests with pass-through access to AP devices. This callback is mandatory for VFIO_DEVICE_FEATURE_MIGRATION support. The function pointer for this callback is specified via the 'migration_set_state' field of the 'vfio_migration_ops' structure which is stored with the VFIO device when the 'vfio_device' structure representing the mediated device is initialized. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 87 ++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index 76cbbe1adb7a..a8b109bc5cf9 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -96,10 +96,95 @@ static void vfio_ap_release_mig_files(struct ap_matrix_= mdev *matrix_mdev) } } =20 +static struct file * +vfio_ap_transition_to_state(struct ap_matrix_mdev *matrix_mdev, + enum vfio_device_mig_state new_state) +{ + struct vfio_ap_migration_data *mig_data; + enum vfio_device_mig_state cur_state; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + mig_data =3D matrix_mdev->mig_data; + cur_state =3D mig_data->mig_state; + dev_dbg(matrix_mdev->vdev.dev, "%s: %d -> %d\n", __func__, cur_state, + new_state); + + if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP && + new_state =3D=3D VFIO_DEVICE_STATE_STOP_COPY) { + /* TODO */ + return ERR_PTR(-EOPNOTSUPP); + } + + if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP && + new_state =3D=3D VFIO_DEVICE_STATE_RESUMING) { + /* TODO */ + return ERR_PTR(-EOPNOTSUPP); + } + + if (cur_state =3D=3D VFIO_DEVICE_STATE_RESUMING && + new_state =3D=3D VFIO_DEVICE_STATE_STOP) { + /* TODO */ + return ERR_PTR(-EOPNOTSUPP); + } + + if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP_COPY && + new_state =3D=3D VFIO_DEVICE_STATE_STOP) { + /* TODO */ + return ERR_PTR(-EOPNOTSUPP); + } + + if ((cur_state =3D=3D VFIO_DEVICE_STATE_STOP && + new_state =3D=3D VFIO_DEVICE_STATE_RUNNING) || + (cur_state =3D=3D VFIO_DEVICE_STATE_RUNNING && + new_state =3D=3D VFIO_DEVICE_STATE_STOP)) { + /* TODO */ + return ERR_PTR(-EOPNOTSUPP); + } + + /* vfio_mig_get_next_state() does not use arcs other than the above */ + WARN_ON(true); + + return ERR_PTR(-EINVAL); +} + static struct file *vfio_ap_set_state(struct vfio_device *vdev, enum vfio_device_mig_state new_state) { - return NULL; + int ret; + struct file *filp =3D NULL; + struct ap_matrix_mdev *matrix_mdev; + enum vfio_device_mig_state next_state; + struct vfio_ap_migration_data *mig_data; + + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); + mig_data =3D matrix_mdev->mig_data; + dev_dbg(vdev->dev, "%s -> %d\n", __func__, new_state); + + while (mig_data->mig_state !=3D new_state) { + ret =3D vfio_mig_get_next_state(vdev, mig_data->mig_state, + new_state, &next_state); + if (ret) { + filp =3D ERR_PTR(ret); + break; + } + + filp =3D vfio_ap_transition_to_state(matrix_mdev, next_state); + if (IS_ERR(filp)) + break; + + mig_data->mig_state =3D next_state; + + if (WARN_ON(filp && new_state !=3D next_state)) { + fput(filp); + filp =3D ERR_PTR(-EINVAL); + break; + } + } + + mutex_unlock(&matrix_dev->mdevs_lock); + + return filp; } =20 static int vfio_ap_get_state(struct vfio_device *vdev, --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 E5C533264E2; Wed, 25 Mar 2026 21:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472536; cv=none; b=VsnqE/MQb0/DbpkQ+doodcDLTnSGPuCtQolcGzsWd+wguePAaqxBbajuqzbxUB/qXUT5fsojPRjahX/g193uKQpzosVY0EKwLb/RzFzmpg8FynzqlCC7V0hCc1iN084IBWYgSLy4lU1eBcf/b8+sNaZ6YiKg58IGV4Js51QGfwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472536; c=relaxed/simple; bh=r1BBO8THHMD1nvEdzLFbhKsfOs+aaK6tcAlXZfrclc4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pB2f/gM1DZzs19Gs7+RrLSSfh0JyyCiglKRES/j6roSUzdqMNLVq9exY2GcR9bMHNRx/YHkLgQ0iYtfhGFD4lSMRAwVRSm6icZSbGJGioPu6tl//jsUG+5g75X9HbRlPFo+CUYuklRTXrEWJlHQyQ/sjzRdm3vTCXK//9Qm8WKE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=W1FpEpV5; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="W1FpEpV5" 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 62PITXbl3850414; Wed, 25 Mar 2026 21:02:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=aRsoX3F8eLgpQ8AJ8 3uz73PGQ0Uf1COx5P29N1OoJiY=; b=W1FpEpV5ArebsxWWCZXd5MMQ3K+8F2kAp Rqnc8qVghNV0ZlDLnc6Tu0C1VYjl0+8z5QnTXsEy7SZMm+6iR81AXL13Rp31B6tT kDa0uYV565Aszlxo56YPkhlQACtqkemo5jAulYSVJRpYzLSIcUxQmGeRgYEhbHaA vx9X0LJU4T6FGynQR3ckPDo8TibO8kELinJclOfp9KvdX3s63zgCc7zgRqyZ2TQI tnbYZ7Ky6qpn0oh4Iprsta09XI6Q2wDX8R80gGaGGjxU3Ai3ZMUafPAVGNAmnVdU pMduMUNK4mqLsSXoPDoaB0L/sVUeyXZvlzRCMaZKH8gRAzhBKvDqg== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kxqjeq9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:08 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PK32jK026864; Wed, 25 Mar 2026 21:02:07 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d275m053n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:07 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL25if6554614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:06 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA1505806E; Wed, 25 Mar 2026 21:02:05 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1E4758052; Wed, 25 Mar 2026 21:02:04 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:04 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 13/24] s390/vfio-ap: Transition guest migration state from STOP to STOP_COPY Date: Wed, 25 Mar 2026 17:01:00 -0400 Message-ID: <20260325210149.888028-14-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 8nBXdxKT5OtJ9xWlojuD2ZkfkPfVn0o2 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX2IjgXdbdxHvO TTF/JX8zaAIAQgNGpaZRXn0zRV69KxHUXuNrLqjWXtokx9rBE+Zx7NQe1Cqgq2Q/jjqONPnfxp5 jhkggeLg6hTFAmf9R/Hm2aJ9LEQTZrb56Rw7N5Kdvk/T4gQbZ+uYgFGB8v3XbJct9C8lkd1wz8R bxoL5DRfdkzp81J69+lYA7xqclTg5aUHbtd6sMhXai79d5VJ8P5DPkENV4YQxrPpiinn+ccGeR7 Y+4q5M/bVbgx+dpd9un1k8QnG7XhNhbyL8ChKDGejejWhUxGx60cWWpQE6iloW0MyQNv3nYCxND OIs8PN+A/ad5ndNTSaUWQun+2ctK41/VU4Oxn8Mk4MCnE03G12o05LxlyhwQnwNv06dt93+o9Yf SghuM7iieF8S6ZQaPicJ8R+5qqQiwp3PYDcbm5vRtPkcAjtfhzvNkaxashHdvgl0uaBoANeqBO4 8toDTL07nuDmx6Mmzlg== X-Authority-Analysis: v=2.4 cv=bLEb4f+Z c=1 sm=1 tr=0 ts=69c44d50 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=M0PqInsX-VO7aBZjA1gA:9 X-Proofpoint-GUID: 8nBXdxKT5OtJ9xWlojuD2ZkfkPfVn0o2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" The transition of the guest migration state from VFIO_DEVICE_STATE_STOP to VFIO_DEVICE_STATE_STOP_COPY begins the process of saving the vfio device state. The vfio device state is comprised of the guest's AP configuration which specifies the adapters, domains and control domains to which the guest will be given access. To begin the process of saving the vfio device state, the VFIO AP device driver will: 1. Allocate an object in which to store the guest's AP configuration information comprised of the APQN and hardware information for each queue passed through to the source guest. 2. Opens a file stream that will be used to read the AP configuration stored with the object created in #1. The AP configuration will be read from this file stream when the guest is resumed on the target system to verify that the AP configuration of the source and target guests are compatible. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 166 +++++++++++++++++++++++- 1 file changed, 164 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index a8b109bc5cf9..ecc9f0f6819e 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -4,6 +4,7 @@ * * Copyright IBM Corp. 2025 */ +#include #include #include "uapi/linux/vfio_ap.h" =20 @@ -96,12 +97,160 @@ static void vfio_ap_release_mig_files(struct ap_matrix= _mdev *matrix_mdev) } } =20 +static ssize_t vfio_ap_save_read(struct file *, char __user *, size_t, lof= f_t *) +{ + /* TODO */ + return -EOPNOTSUPP; +} + +static int vfio_ap_release_migf(struct inode *, struct file *) +{ + /* TODO */ + return -EOPNOTSUPP; +} + +static const struct file_operations vfio_ap_save_fops =3D { + .owner =3D THIS_MODULE, + .read =3D vfio_ap_save_read, + .compat_ioctl =3D compat_ptr_ioctl, + .release =3D vfio_ap_release_migf, +}; + +static struct vfio_ap_config +*vfio_ap_allocate_config(struct ap_matrix_mdev *matrix_mdev, size_t *confi= g_sz) +{ + struct vfio_ap_config *ap_config; + size_t qinfo_size; + int num_queues; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + num_queues =3D vfio_ap_mdev_get_num_queues(&matrix_mdev->shadow_apcb); + qinfo_size =3D num_queues * sizeof(struct vfio_ap_queue_info); + *config_sz =3D qinfo_size + sizeof(struct vfio_ap_config); + ap_config =3D kzalloc(*config_sz, GFP_KERNEL_ACCOUNT); + + if (!ap_config) + return ERR_PTR(-ENOMEM); + + ap_config->num_queues =3D num_queues; + + return ap_config; +} + +static void vfio_ap_store_queue_info(struct vfio_ap_migration_file *migf) +{ + unsigned long *apm, *aqm, num_queues, apid, apqi, apqn, data; + struct ap_matrix_mdev *matrix_mdev; + struct vfio_ap_queue *q; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + matrix_mdev =3D migf->matrix_mdev; + apm =3D matrix_mdev->shadow_apcb.apm; + aqm =3D matrix_mdev->shadow_apcb.aqm; + num_queues =3D 0; + + for_each_set_bit_inv(apid, apm, AP_DEVICES) { + for_each_set_bit_inv(apqi, aqm, AP_DOMAINS) { + apqn =3D AP_MKQID(apid, apqi); + q =3D vfio_ap_mdev_get_queue(matrix_mdev, apqn); + + if (!q) + continue; + + migf->ap_config->qinfo[num_queues].apqn =3D apqn; + data =3D q->hwinfo.value; + migf->ap_config->qinfo[num_queues].data =3D data; + num_queues +=3D 1; + dev_dbg(matrix_mdev->vdev.dev, + "%s (%d): qinfo: apqn=3D%04lx data=3D%016lx\n", + __func__, __LINE__, apqn, data); + } + } +} + +static struct vfio_ap_migration_file +*vfio_ap_allocate_migf(struct ap_matrix_mdev *matrix_mdev) +{ + struct vfio_ap_migration_file *migf; + struct vfio_ap_config *ap_config; + size_t config_size; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + migf =3D kzalloc_obj(struct vfio_ap_migration_file, GFP_KERNEL_ACCOUNT); + if (!migf) + return ERR_PTR(-ENOMEM); + + ap_config =3D vfio_ap_allocate_config(matrix_mdev, &config_size); + if (IS_ERR(ap_config)) { + kfree(migf); + return ERR_CAST(ap_config); + } + + migf->ap_config =3D ap_config; + migf->config_sz =3D config_size; + migf->matrix_mdev =3D matrix_mdev; + + return migf; +} + +static void vfio_ap_deallocate_migf(struct vfio_ap_migration_file *migf) +{ + kfree(migf->ap_config); + kfree(migf); +} + +static struct file *vfio_ap_open_file_stream(struct vfio_ap_migration_file= *migf, + const struct file_operations *fops, + int flags) +{ + struct file *filp; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + filp =3D anon_inode_getfile("vfio_ap_migf", fops, migf, flags); + if (IS_ERR(filp)) + return ERR_CAST(filp); + + stream_open(filp->f_inode, filp); + + return filp; +} + +static struct vfio_ap_migration_file * +vfio_ap_save_mdev_state(struct ap_matrix_mdev *matrix_mdev) +{ + struct vfio_ap_migration_data *mig_data; + struct vfio_ap_migration_file *migf; + struct file *filp; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + mig_data =3D matrix_mdev->mig_data; + + migf =3D vfio_ap_allocate_migf(matrix_mdev); + if (IS_ERR(migf)) + return ERR_CAST(migf); + + filp =3D vfio_ap_open_file_stream(migf, &vfio_ap_save_fops, O_RDONLY); + if (IS_ERR(filp)) { + vfio_ap_deallocate_migf(migf); + return ERR_CAST(filp); + } + + migf->filp =3D filp; + mig_data->saving_migf =3D migf; + vfio_ap_store_queue_info(mig_data->saving_migf); + + return mig_data->saving_migf; +} + static struct file * vfio_ap_transition_to_state(struct ap_matrix_mdev *matrix_mdev, enum vfio_device_mig_state new_state) { struct vfio_ap_migration_data *mig_data; enum vfio_device_mig_state cur_state; + struct vfio_ap_migration_file *migf; =20 lockdep_assert_held(&matrix_dev->mdevs_lock); mig_data =3D matrix_mdev->mig_data; @@ -109,10 +258,23 @@ vfio_ap_transition_to_state(struct ap_matrix_mdev *ma= trix_mdev, dev_dbg(matrix_mdev->vdev.dev, "%s: %d -> %d\n", __func__, cur_state, new_state); =20 + /* + * Begins the process of saving the vfio device state by creating and + * returning a streaming data_fd to be used to read out the internal + * state of the vfio-ap device on the source host. + */ if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP && new_state =3D=3D VFIO_DEVICE_STATE_STOP_COPY) { - /* TODO */ - return ERR_PTR(-EOPNOTSUPP); + migf =3D vfio_ap_save_mdev_state(matrix_mdev); + if (IS_ERR(migf)) + return ERR_CAST(migf); + + if (migf) { + get_file(migf->filp); + return migf->filp; + } + + return NULL; } =20 if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP && --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 E16BD348879; Wed, 25 Mar 2026 21:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472537; cv=none; b=pMtpMdxymZOvOUZGWysZE7RykrA6h0yLHiHNkN+grzy50kGqIIod63R/fXSqIR41zQXJKnoFtIXKLQ0LGmT9VXSuhUXkAcBaP0XNcehcjEw2+Y/+iDtXtclz8Fotkzs9cwl7zAqQWTrtlOewCtPQLre1t+5B6SBrHF9o9vhUTTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472537; c=relaxed/simple; bh=1uwJahfo9ffSwr4Mhrk9Fron3HPbiIv444UxsjB5PTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dOM2V+MU4aQdFiXM4edyAFUO5UnNkdHVqqAbYEOZWqhA0N8FbV0UxydIOpw7pFobL+mpOJSnGm2tGcMETZT1iM5H7L0LyHMsRVHut48MXjGKwkJpEA9yUZOxjahP6qq+Afic4a9/uLNcMMydGczwpdeNeM80RT8V49Ay0GHiBMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=nAC9hrrt; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="nAC9hrrt" 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 62PJJQc8265856; Wed, 25 Mar 2026 21:02:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=bDWULt6XhlbBcd0q0 imaFliokdDLLH09ol0T03eBEcM=; b=nAC9hrrtWCLZK5n4+mlT4l8kp+/KasR2O nzO5q5wkORyPjVcyyRqgKwWruBIai4OJWEtFfsNcnCFUdlT/ZFyuzOAjyE/zfx3B 54eTMF0HHfgxgVF4Do+RD+6w4uNKNK+0waYtHPRIdLcXpK2Oy5Zs/v2bYEODdkh6 Mww8hq1+JigBArfKCIGXhtAuBOhQjxG5FFFYi1Av/+TTSssGGEOoTYWGhxQ+EINQ zuDCD9kNjc7DM3Zj2kLvKWIpmxOAFsDvE0oHKYwY+slLF7tKpywwQ4R62gMKW8pQ yBYJhg80bA64kB6GAu4j31Dp0I48NYoTtcfa1z2TokDUH9cALDXQQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kxqjeqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:10 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PGmstP012177; Wed, 25 Mar 2026 21:02:09 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk8178-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:09 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL1hkI28443374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:01:43 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE87658065; Wed, 25 Mar 2026 21:02:06 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 046B35805D; Wed, 25 Mar 2026 21:02:06 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:05 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 14/24] s390/vfio-ap: File ops called to save the vfio device migration state Date: Wed, 25 Mar 2026 17:01:01 -0400 Message-ID: <20260325210149.888028-15-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: QR2hNFjdR1_pCaOzvpYxvShWgwGRlTzM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfXxs77U2uBchho 0S8r41EIgT/sXS8A2qWSDCryIFPqOJcvYT92h3U8dwpXYlsHCWAK2autOdpwsZ2W01L8gRhQTv5 bRV5AzVYZW31ua6J55s+U71Xyan3kILzEnHVZVox0eMtuhPtMT9K91OV7N//V6TzLJjix+ZuN1B IFvURn5oLvWo7dcnkOunK8ZHjFeS8I/Lsp/nCttrQoST66rE4rrCC6ckwDFuKewSf0uW+ThIG4Y 5DNL1ytY3b7TpvtYwmNHNLPSRjXU53H5NUHbRnKb87lnFruZCj9KjnbInyt/x6kp6aKDTi1LMjq oFffW4gYyO0+LTZPTpZ76JmDbzfCXgnkbnf/YnPJkPSuoOHsgBxqo0fxinRiwQx0TeGOuEV6Wkx 8MvpMAnJcS0EbgB+y90kW1Z02ghm786GB7cZdS9a9kPAK8A0dm3beW/0etuiGTF+5hxrrmw5fc4 KweNcYfrzhyRFWZ+tWQ== X-Authority-Analysis: v=2.4 cv=bLEb4f+Z c=1 sm=1 tr=0 ts=69c44d52 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=ziKF1hX67kHMkuPFGWMA:9 X-Proofpoint-GUID: QR2hNFjdR1_pCaOzvpYxvShWgwGRlTzM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Implements two callback functions that were added to the 'file_operations' structure for the file created to save the state of the vfio device when the migration state transitioned from VFIO_DEVICE_STATE_STOP to VFIO_DEVICE_STATE_STOP_COPY: * Read callback This function copies the guest's AP configuration information to userspace. The information copied is comprised of the APQN of each queue device passed through to the guest along with its hardware information. This data will be used to verify the source and target guests have compatible AP configurations. * Release callback This function deallocates the object used to save the state of the vfio device. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 78 +++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index ecc9f0f6819e..a340dca1426c 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -97,16 +97,82 @@ static void vfio_ap_release_mig_files(struct ap_matrix_= mdev *matrix_mdev) } } =20 -static ssize_t vfio_ap_save_read(struct file *, char __user *, size_t, lof= f_t *) +static ssize_t validate_save_read_parms(struct vfio_ap_migration_file *mig= f, + loff_t *pos, size_t len) { - /* TODO */ - return -EOPNOTSUPP; + lockdep_assert_held(&matrix_dev->mdevs_lock); + + if (migf->disabled) { + dev_err(migf->matrix_mdev->vdev.dev, + "%s (%d): migration file is disabled\n", + __func__, __LINE__); + return -ENODEV; + } + + if (*pos > migf->config_sz) { + dev_err(migf->matrix_mdev->vdev.dev, + "%s (%d): file pos (%llu) exceeds migf->config size (%zu)\n", + __func__, __LINE__, *pos, migf->config_sz); + return -EINVAL; + } + + return 0; } =20 -static int vfio_ap_release_migf(struct inode *, struct file *) +static ssize_t vfio_ap_save_read(struct file *filp, char __user *buf, + size_t len, loff_t *pos) { - /* TODO */ - return -EOPNOTSUPP; + struct vfio_ap_migration_file *migf; + ssize_t ret =3D 0; + + if (pos) + return -ESPIPE; + + mutex_lock(&matrix_dev->mdevs_lock); + + pos =3D &filp->f_pos; + migf =3D filp->private_data; + + ret =3D validate_save_read_parms(migf, pos, len); + if (ret) + goto out_unlock; + + len =3D min_t(size_t, migf->config_sz - *pos, len); + if (len) { + if (copy_to_user(buf, (void *)migf->ap_config + *pos, len)) { + ret =3D -EFAULT; + dev_err(migf->matrix_mdev->vdev.dev, + "%s (%d): failed to copy config data to user\n", + __func__, __LINE__); + goto out_unlock; + } + + *pos +=3D len; + ret =3D len; + } + + dev_dbg(migf->matrix_mdev->vdev.dev, + "%s (%d): copied %zu bytes of AP config data to user\n", + __func__, __LINE__, len); + +out_unlock: + mutex_unlock(&matrix_dev->mdevs_lock); + + return ret; +} + +static void vfio_ap_deallocate_migf(struct vfio_ap_migration_file *migf); + +static int vfio_ap_release_migf(struct inode *inode, struct file *filp) +{ + struct vfio_ap_migration_file *migf; + + mutex_lock(&matrix_dev->mdevs_lock); + migf =3D filp->private_data; + vfio_ap_deallocate_migf(migf); + mutex_unlock(&matrix_dev->mdevs_lock); + + return 0; } =20 static const struct file_operations vfio_ap_save_fops =3D { --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 D6979365A0D; Wed, 25 Mar 2026 21:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472543; cv=none; b=FS2Aq7pvFUEuUSEEC7u04vhkWj9doQrgEsFPyxpOw+e8ulB9kUYIsJkW5vg51Hn3DJYNkHPHnM7VCUeHu3vtwcBfyNL6hRdbuTbqLmiCG4rjIF2mwXQwnU7CNGvR0ImRRCdQBX+NPH+2kxkJb6/1eqGDxXKQbUhCZcDivIppna8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472543; c=relaxed/simple; bh=gf3qZz7olvk49MuUu4bQ27Fa08dU/AAhp4flv6uNO9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MrHsOqtmdmutRvsvqf6gW/xwrk6Uhap+vOUSKZUQhA7VwSAgxXZN0CvJy3slW3w1gvqoZgeHAB/YGeZ8110WdCHuOGXn20QW6kJPQj7jLrS7T89NyJyPwl6MRr2iLGDclzlJxTwMaWiCahn1LGXZU32sSH6h3al2QpNNANMFr7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qMsuB8vm; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="qMsuB8vm" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PHuq023105965; Wed, 25 Mar 2026 21:02:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=aySYdd3dDt5eKJMgp q3U08nb1UZ1Sn9tO2GSTFKQQVY=; b=qMsuB8vmlH9utX/97Ug6YeMp88EcbCmmk oK3gaTTzVAqtA4VRB00H4BVt8qxb+W51bCHAymj33U4IXadbIeX20mmbFRwAirMO J+ney8wGB9XmmWIuLPXafYdQ8aSfXcr0qG2QkRTrxrK8ARcX0KhPMAn27sjZ8O+y t1RKmsTM6K5RVxx9l1HEia7y8QIC09+ON8e3bh30P2WKqAGrYj0jJ7TKNAKs0Q5T HQJTorYYhP+qyYXG9AL4lfHnN82KVDUjkIl1hQgcUVenIWz+ga1dtnHVrM9ImlSo uoj7bP4XT5JhLWAHnJ4kfOBRRnzMHoG/EowyHPW6Z90hHRgqwF5WQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1ktv1hjp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:10 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKC8F8026900; Wed, 25 Mar 2026 21:02:09 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d275m053u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:09 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL28Pp38928788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:08 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 144485805D; Wed, 25 Mar 2026 21:02:08 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1BE3958056; Wed, 25 Mar 2026 21:02:07 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:07 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 15/24] s390/vfio-ap: Transition device migration state from STOP to RESUMING Date: Wed, 25 Mar 2026 17:01:02 -0400 Message-ID: <20260325210149.888028-16-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: CxI9jjkuhzvmFVBRYJjQAGjZ5bST7LNB X-Authority-Analysis: v=2.4 cv=aMr9aL9m c=1 sm=1 tr=0 ts=69c44d52 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=DHoCqielVpiR_Jvp3-wA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX5SIprQFtmlkN F7TAibLf9K4Xmk33cM8HcrR/Eayw/OFsxfAG8cT8aKb6eqxryS+yQ9XfGvXxaW9J338YqWDk76U 8pJvIVQRN1VEY7GPtxpo1gWUIbxNDCayWoND0S7GMSmp+xmppP1+S11ZXkQmaNJEBlAo2aUZJ3B qvhnSeM0HMvaR0S+klJm22ydmJKL+oSbzvaRDLyhpnLFyoNbeSWStt7LcSH3Cze+efypEac2DfB VskzYDP3kD2iClWBcWLVO7O8VWLgilo3JtjbEdAzun2p6YfZKOcGZ+l0RMFRgz9gnhe+HQUz0hh Co2U+/CxjZHEAMEehXGrHTrbbnONqDdDzDv80waWfgVerJUnaRgfUndkA2KcDfRXMvuY/wYA6nV h2YIaUDmhVjOOqm4KFGK+ctGNTqTlaOjZ0bY9U9+JGeoD90hxN01tSwrrx//jacdgYPAPDagbUg 00mfFVs/JIfkRRK2pcw== X-Proofpoint-GUID: CxI9jjkuhzvmFVBRYJjQAGjZ5bST7LNB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Transitioning from VFIO_DEVICE_STATE_STOP to VFIO_DEVICE_STATE_RESUMING starts a process of restoring the device state of the vfio device on the target system. To prepare for restoring the device state, open a file stream to receive the guest's AP configuration saved when the device state on the source system transitioned from VFIO_DEVICE_STATE_STOP to VFIO_DEVICE_STATE_STOP_COPY. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 55 ++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index a340dca1426c..a243ea134794 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -310,6 +310,46 @@ vfio_ap_save_mdev_state(struct ap_matrix_mdev *matrix_= mdev) return mig_data->saving_migf; } =20 +static ssize_t vfio_ap_resume_write(struct file *filp, const char __user *= buf, + size_t len, loff_t *pos) +{ + /* TODO */ + return -EOPNOTSUPP; +} + +static const struct file_operations vfio_ap_resume_fops =3D { + .owner =3D THIS_MODULE, + .write =3D vfio_ap_resume_write, + .release =3D vfio_ap_release_migf, +}; + +static struct vfio_ap_migration_file * +vfio_ap_resume_mdev_state(struct ap_matrix_mdev *matrix_mdev) +{ + struct vfio_ap_migration_data *mig_data; + struct vfio_ap_migration_file *migf; + struct file *filp; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + mig_data =3D matrix_mdev->mig_data; + + migf =3D vfio_ap_allocate_migf(matrix_mdev); + if (IS_ERR(migf)) + return ERR_CAST(migf); + + filp =3D vfio_ap_open_file_stream(migf, &vfio_ap_resume_fops, O_WRONLY); + if (IS_ERR(filp)) { + vfio_ap_deallocate_migf(migf); + return ERR_CAST(filp); + } + + migf->matrix_mdev =3D matrix_mdev; + migf->filp =3D filp; + mig_data->resuming_migf =3D migf; + + return migf; +} + static struct file * vfio_ap_transition_to_state(struct ap_matrix_mdev *matrix_mdev, enum vfio_device_mig_state new_state) @@ -343,10 +383,21 @@ vfio_ap_transition_to_state(struct ap_matrix_mdev *ma= trix_mdev, return NULL; } =20 + /* + * Starts the process of restoring the state of the vfio-ap device + * on the target host by creating a filestream to be used to transfer + * the internal state of the vfio-ap device on the source host that + * was saved during the STOP_COPY phase of the migration. + */ if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP && new_state =3D=3D VFIO_DEVICE_STATE_RESUMING) { - /* TODO */ - return ERR_PTR(-EOPNOTSUPP); + migf =3D vfio_ap_resume_mdev_state(matrix_mdev); + if (IS_ERR(migf)) + return ERR_CAST(migf); + + get_file(migf->filp); + + return migf->filp; } =20 if (cur_state =3D=3D VFIO_DEVICE_STATE_RESUMING && --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 EC3B934E75D; Wed, 25 Mar 2026 21:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472538; cv=none; b=AlO7nEeACo6Nd8ekPlvmVqvbD+Zq5RdtCz7d/qf2VMEXnd512MMd0lZ0b+3xXw+EYVbKz3Am18QbVgwoc56+BBq9X1rre1JzTc6Uv5MwjqQW5m9sOnFErnEEC+2yS32m1zWpjxN3uYLxfBE5LlA5rvJLmp0Ym2oHa0ebPSsBjyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472538; c=relaxed/simple; bh=COwPxmzHqaPyyVJlWPc1tULVeVxuMv3oNmQzP+8yYEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OuDja/DAuyzWNrw8n6x4Q17jhvvov0pRnDw+rjmFrH89FDO5+CJKCv7x1XwlNK+Yb+b/6qvhKHgJO28bwIEIQjSCtEllDOyIKWovvdmyZngj8lhltCu4zuEPl/Xs4px14vJ7czMfxcg05pae0l//oS4hrFGzQW4fj+3KbQtJwf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=h2S4rv8f; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="h2S4rv8f" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62P9LXHq369072; Wed, 25 Mar 2026 21:02:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=VZA/Sxb1u1h8QP9Zn sm4MdHcjMP57Ut6dhVSYuu62JM=; b=h2S4rv8fQCdDnbWD8LZO5uxPTa6SlO+Sb +mmC161maHstBSa4ZIeADZdE8Q40CVnF3BKQC7Qe5Q1TSMiFsO20CKVKLE5rf6z2 nOIURWD7WM9Dq0nc7ntEGayXzhrdXnAogWqR49AEoblXlG/tkSWpjsHLZFuXOkBb bwGK4eN1oyyWxhMeAUCj+uS3wij2e6WDdwG1rSUD5bfeheE/ZWBl77xQXdAGPWJ7 VQ8ASiXBRylBeWcFZAZna6mp0F/VZR6yGODy2WK60OaC8nKxl7L1EUizz+ikUoSB /9EjiFIb5JH2qmSzlgFreVEEQ9LByV/IcLFjnEeGBAUrw7HgwVPow== 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 4d1ky09fen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:11 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PJweEd009115; Wed, 25 Mar 2026 21:02:11 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d26nnr7s8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:11 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL29rk27460312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:09 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BD8158052; Wed, 25 Mar 2026 21:02:09 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3253858056; Wed, 25 Mar 2026 21:02:08 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:08 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 16/24] s390/vfio-ap: File ops called to resume the vfio device migration Date: Wed, 25 Mar 2026 17:01:03 -0400 Message-ID: <20260325210149.888028-17-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX2ggJVDudtBiH c95P/yG4obfAAMqbNQ9sP5DYYF6ft4yVRS6HQBDFwrmrDkkpQO3NekH5sBYufW+bD7tRMAq8/bf RPc8NEYwG8qL0l9//3Uir4jvh67DhjSufkyd3wkicIRLksYT2xfozViI2MaeFxP8FR1m2MRKnaF p7sMyO+/KqCphBfZ6LzFit6RwQjRv9eOy/PuEgR/Nh3xbW9E8GJlzVcYPQ2FpO3RUF+RUr3009O rtmIolfbYvjPiM2BPH7IX7OEjmiA+3Jxbqu+SB5MOQxZJUPgkpDF1SYcfXJDBdju75zCN+SBkHC SZx9DJbCB4OJvEmuwjAHbUi4WUdyCR6VpEdxSRqtSgMkkuyQZguycpPdfGZG+sE0F2ACn7G7eQR p9dv1I1dwXm9NZbd4+tSzs6XaCPI+9Afo3RwBG4Q1+3wI0Nbmm8O8GIJ+PFgw+uYRvogOgMGgiu r7RuAZoEyLf3c7ZTdaw== X-Authority-Analysis: v=2.4 cv=JK42csKb c=1 sm=1 tr=0 ts=69c44d53 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=mUIIkNJziSJENXg-bOUA:9 X-Proofpoint-ORIG-GUID: fYsd9nSm-9NCjwCvN9pP41A7s_U0JSKl X-Proofpoint-GUID: fYsd9nSm-9NCjwCvN9pP41A7s_U0JSKl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Implements two callback functions that were added to the 'file_operations' structure for the file created to restore the state of the vfio device when the migration state transitioned from VFIO_DEVICE_STATE_STOP to VFIO_DEVICE_STATE_RESUMING: * Write callback The write callback retrieves the vfio device migration state saved to the file stream created when the vfio device state was transitioned from VFIO_DEVICE_STATE_STOP to VFIO_DEVICE_STATE_STOP_COPY. The saved state contains the guest's AP configuration information. Since the guest's AP configuration on the target system is supplied by the mediated device residing thereon, the migration state passed into this callback will not be used to restore the vfio device state, but to verify that the source and target AP configurations are compatible since the mediated devices on the source and target systems may differ. The verification rules are: o The source and target AP configurations must have the same number of APQNs o Each APQN in the source guest's AP configuration must also be in the target guest's configuration o Each APQN in the source and target guests' AP configurations must reference a queue device with compatible hardware: - The source and target queues must have the same facilities installed - APSC facility - APQKM facility - AP4KC facility - The source and target queues must have the same mode - Coprocessor-mode - Accelerator-mode - XCP-mode - The source and target queues must have the same APXA facility setting - If the APXA facility is installed on target queue, it must also be installed on the source queue - If the APXA facility is not installed on target queue, it must also not be installed on the source queue - The source and target queues must have the same classification - Full native card function - Stateless functions - The binding and associated state ~ At the time of migration, the queue on the target guest will neither be bound nor associated, so the binding and associated state for both the source and target must indicate that the queue is usable for all messages (i.e., BS bits equal to 00). - The AP type of the target queue must be the same or newer than the source queue * Release callback This function deallocates the object used to restore the state of the vfio device when the file is released. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 525 +++++++++++++++++++++++- 1 file changed, 523 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index a243ea134794..d9b6dba53181 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -10,6 +10,36 @@ =20 #include "vfio_ap_private.h" =20 +/* + * Masks the fields of the queue information returned from the PQAP(TAPQ) + * command. In order to migrate a guest, it's AP configuration must be + * compatible with AP configuration assigned to the target guest's mdev. + * This mask is used to verify that the queue information for each source = and + * target queue is compatible (i.e., the masked fields are equivalent). + * + * The relevant fields covered by this mask are: + * S bit 0: APSC facility installed + * M bit 1: APQKM facility installed + * C bit 2: AP4KC facility installed + * Mode bits 3-5: + * D bit 3: CCA-mode facility + * A bit 4: accelerator-mode facility + * X bit 5: XCP-mode facility + * N bit 6: APXA facility installed + * SL bit 7: SLCF facility installed + * Classification (functional capabilities) bits 8-16 + * bit 8: Native card function + * bit 9: Only stateless functions + * AP Type bits 32-40: + */ +#define QINFO_DATA_MASK 0xffffc000ff000000 + +/* + * Masks the bit that indicates whether full native card function is avail= able + * from the 8 bits specifying the functional capabilities of a queue + */ +#define CLASSIFICATION_NATIVE_FCN_MASK 0x80 + /** * vfio_ap_migration_data - the data needed to migrate a guest with pass-t= hrough * access to AP devices @@ -234,6 +264,53 @@ static void vfio_ap_store_queue_info(struct vfio_ap_mi= gration_file *migf) } } =20 +static int validate_resume_write_parms(struct vfio_ap_migration_file *migf, + size_t len, loff_t *pos) +{ + loff_t total_len; + int ret =3D -EIO; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + if (!migf->matrix_mdev) { + pr_err("migration failed: matrix_mdev object not linked to migration fil= e"); + goto done; + } + + if (*pos < 0) { + dev_err(migf->matrix_mdev->vdev.dev, + "migration failed: invalid migration file position (%lli) for write\n", + *pos); + goto done; + } + + if (check_add_overflow((loff_t)len, *pos, &total_len)) { + dev_err(migf->matrix_mdev->vdev.dev, + "migration failed: pos (%llu) plus len (%zu) operation overflowed loff_= t precision\n", + *pos, len); + goto done; + } + + if (total_len > migf->config_sz) { + dev_err(migf->matrix_mdev->vdev.dev, + "migration failed: source guest's AP config size (%llu) larger than tar= get's (%lu)", + total_len, migf->config_sz); + goto done; + } + + if (migf->disabled) { + dev_err(migf->matrix_mdev->vdev.dev, + "migration failed: migration file is disabled"); + goto done; + } + + dev_dbg(migf->matrix_mdev->vdev.dev, "resume write parameters validated\n= "); + ret =3D 0; + +done: + return ret; +} + static struct vfio_ap_migration_file *vfio_ap_allocate_migf(struct ap_matrix_mdev *matrix_mdev) { @@ -310,11 +387,455 @@ vfio_ap_save_mdev_state(struct ap_matrix_mdev *matri= x_mdev) return mig_data->saving_migf; } =20 +static void report_facilities_compatibility(struct ap_matrix_mdev *matrix_= mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + if (src_hwinfo->apsc !=3D target_hwinfo->apsc) { + if (src_hwinfo->apsc) { + dev_err(matrix_mdev->vdev.dev, + "APSC facility installed in source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "APSC facility not installed in target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "APSC facility not installed in source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "APSC facility installed in target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } + + if (src_hwinfo->mex4k !=3D target_hwinfo->mex4k) { + if (src_hwinfo->mex4k) { + dev_err(matrix_mdev->vdev.dev, + "mex4k facility installed in source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "mex4k facility not installed in target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "mex4k facility not installed in source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "mex4k facility installed in target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } + + if (src_hwinfo->crt4k !=3D target_hwinfo->crt4k) { + if (src_hwinfo->crt4k) { + dev_err(matrix_mdev->vdev.dev, + "crt4k facility installed in source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "crt4k facility not installed in target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "crt4k facility not installed in source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "crt4k facility installed in target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } +} + +static void report_mode_compatibility(struct ap_matrix_mdev *matrix_mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + if (src_hwinfo->cca !=3D target_hwinfo->cca) { + if (src_hwinfo->cca) { + dev_err(matrix_mdev->vdev.dev, + "Coprocessor-mode facility installed in source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "Coprocessor-mode facility not installed target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "Coprocessor-mode facility not installed in source queue %02lx.%04lx\n= ", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "Coprocessor-mode facility installed target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } + + if (src_hwinfo->accel !=3D target_hwinfo->accel) { + if (src_hwinfo->accel) { + dev_err(matrix_mdev->vdev.dev, + "Accelerator-mode facility installed source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "Accelerator-mode facility not installed target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "Accelerator-mode facility not installed source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "Accelerator-mode facility installed target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } + + if (src_hwinfo->ep11 !=3D target_hwinfo->ep11) { + if (src_hwinfo->ep11) { + dev_err(matrix_mdev->vdev.dev, + "XCP-mode facility installed source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "XCP-mode facility not installed target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "XCP-mode facility not installed source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "XCP-mode facility installed target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } +} + +static void report_apxa_compatibility(struct ap_matrix_mdev *matrix_mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + if (src_hwinfo->apxa !=3D target_hwinfo->apxa) { + if (src_hwinfo->apxa) { + dev_err(matrix_mdev->vdev.dev, + "AP-extended-addressing (APXA) facility installed in source queue %02l= x.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "AP-extended-addressing (APXA) facility not installed in target queue = %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "AP-extended-addressing (APXA) facility not installed in source queue = %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "AP-extended-addressing (APXA) facility installed in target queue %02l= x.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } +} + +static void report_slcf_compatibility(struct ap_matrix_mdev *matrix_mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + if (src_hwinfo->slcf !=3D target_hwinfo->slcf) { + if (src_hwinfo->slcf) { + dev_err(matrix_mdev->vdev.dev, + "Stateless-command-filtering (SLCF) available in source queue %02lx.%0= 4lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "Stateless-command-filtering (SLCF) not available in target queue %02l= x.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } else { + dev_err(matrix_mdev->vdev.dev, + "Stateless-command-filtering (SLCF) not available in source queue %02l= x.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "Stateless-command-filtering (SLCF) available in target queue %02lx.%0= 4lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } +} + +static void report_class_compatibility(struct ap_matrix_mdev *matrix_mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + unsigned long src_native, target_native; + + src_native =3D src_hwinfo->class & CLASSIFICATION_NATIVE_FCN_MASK; + target_native =3D target_hwinfo->class & CLASSIFICATION_NATIVE_FCN_MASK; + + if (src_native !=3D target_native) { + /* + * If the source queue has full native card function and the + * target queue has only stateless functions available, then + * there may be instructions that will not execute on the + * target queue. + * + * If the source queue has only stateless card functions and the + * target queue has full native card function available, then + * we are okay because the target queue can run all card + * functions. + */ + if (src_native) { + dev_err(matrix_mdev->vdev.dev, + "Full native card function available on source queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + dev_err(matrix_mdev->vdev.dev, + "Only stateless functions available on target queue %02lx.%04lx\n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } + } +} + +static void report_bs_compatibility(struct ap_matrix_mdev *matrix_mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + if (src_hwinfo->bs || target_hwinfo->bs) { + dev_err(matrix_mdev->vdev.dev, + "Bind/associate state for source (%01x) and target (%01x) queue %02lx.%= 04lx are not compatible\n", + src_hwinfo->bs, target_hwinfo->bs, + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + } +} + +static void report_aptype_compatibility(struct ap_matrix_mdev *matrix_mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + dev_err(matrix_mdev->vdev.dev, + "AP type of source (%02x) not compatible with target (%02x)\n", + src_hwinfo->at, target_hwinfo->at); +} + +/* + * Log a device error reporting that migration failed due to queue + * incompatibilities followed by a device error for each incompatible feat= ure. + */ +static void report_qinfo_incompatibilities(struct ap_matrix_mdev *matrix_m= dev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + dev_err(matrix_mdev->vdev.dev, + "Migration failed: Source and target queue (%02lx.%04lx) not compatible\= n", + AP_QID_CARD(apqn), AP_QID_QUEUE(apqn)); + + report_facilities_compatibility(matrix_mdev, apqn, src_hwinfo, target_hwi= nfo); + report_mode_compatibility(matrix_mdev, apqn, src_hwinfo, target_hwinfo); + report_apxa_compatibility(matrix_mdev, apqn, src_hwinfo, target_hwinfo); + report_slcf_compatibility(matrix_mdev, apqn, src_hwinfo, target_hwinfo); + report_class_compatibility(matrix_mdev, apqn, src_hwinfo, target_hwinfo); + report_aptype_compatibility(matrix_mdev, apqn, src_hwinfo, target_hwinfo); + report_bs_compatibility(matrix_mdev, apqn, src_hwinfo, target_hwinfo); +} + +static bool qinfo_compatible(struct ap_matrix_mdev *matrix_mdev, + unsigned long apqn, + struct ap_tapq_hwinfo *src_hwinfo, + struct ap_tapq_hwinfo *target_hwinfo) +{ + unsigned long src_bits, target_bits; + + src_bits =3D src_hwinfo->value & QINFO_DATA_MASK; + target_bits =3D target_hwinfo->value & QINFO_DATA_MASK; + + /* + * If all relevant bits are the same, or only the AP type of the source + * and target queue differ but the source type is older than the target + * type, then no incompatibilities will be reported. The AP types are + * considered compatible even if they differ as long as the source type + * is older than the target type since AP devices are backwards + * compatible. + */ + if (src_bits =3D=3D target_bits || + (src_hwinfo->fac =3D=3D target_hwinfo->fac && + src_hwinfo->at <=3D target_hwinfo->at)) { + return true; + } + + report_qinfo_incompatibilities(matrix_mdev, apqn, src_hwinfo, + target_hwinfo); + + return false; +} + +static int matrixes_compatible(struct vfio_ap_migration_file *migf) +{ + struct ap_matrix_mdev *matrix_mdev; + struct ap_tapq_hwinfo src_hwinfo; + struct vfio_ap_queue *q; + unsigned long apqn; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + matrix_mdev =3D migf->matrix_mdev; + + for (int i =3D 0; i < migf->ap_config->num_queues; i++) { + apqn =3D migf->ap_config->qinfo[i].apqn; + q =3D vfio_ap_mdev_get_queue(matrix_mdev, apqn); + memcpy(&src_hwinfo, &migf->ap_config->qinfo[i].data, + sizeof(src_hwinfo)); + + if (!qinfo_compatible(matrix_mdev, apqn, &src_hwinfo, &q->hwinfo)) + return -EFAULT; + } + + return 0; +} + +static bool apqns_match(struct vfio_ap_migration_file *migf) +{ + struct ap_matrix_mdev *matrix_mdev; + unsigned long apid, apqi, apqn; + bool ret =3D true; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + matrix_mdev =3D migf->matrix_mdev; + + for (int i =3D 0; i < migf->ap_config->num_queues; i++) { + apqn =3D migf->ap_config->qinfo[i].apqn; + apid =3D AP_QID_CARD(apqn); + apqi =3D AP_QID_QUEUE(apqn); + + if (!test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) || + !test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { + dev_err(matrix_mdev->vdev.dev, + "migration failed: queue %02lx.%04lx not assigned to guest matrix\n", + apid, apqi); + ret =3D false; + } + } + + return ret; +} + +static int vfio_ap_validate_num_queues(struct vfio_ap_migration_file *migf) +{ + int num_migf_queues, num_mdev_queues; + struct ap_matrix_mdev *matrix_mdev; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + matrix_mdev =3D migf->matrix_mdev; + num_mdev_queues =3D vfio_ap_mdev_get_num_queues(&matrix_mdev->shadow_apcb= ); + num_migf_queues =3D migf->ap_config->num_queues; + + if (num_mdev_queues !=3D num_migf_queues) { + dev_err(matrix_mdev->vdev.dev, + "migration failed: number of queues on source (%d) and target (%d) gues= ts differ\n", + num_migf_queues, num_mdev_queues); + return (num_mdev_queues > num_migf_queues) ? -ENODEV : -E2BIG; + } + + return 0; +} + +static int do_post_copy_validation(struct vfio_ap_migration_file *migf, lo= ff_t pos) +{ + unsigned long nqueues_offset; + int ret; + + nqueues_offset =3D offsetofend(struct vfio_ap_config, num_queues); + if (pos >=3D nqueues_offset) { + ret =3D vfio_ap_validate_num_queues(migf); + if (ret) + return ret; + + if (pos =3D=3D migf->config_sz) { + if (!apqns_match(migf)) + return -ENODEV; + ret =3D matrixes_compatible(migf); + if (ret) + return ret; + } + } + + return 0; +} + +/** + * vfio_ap_resume_write - store the AP configuration information sent from= the + * source guest into the migration file. + * @filp: the file used to send the AP configuration information from the = source + * guest. + * @buf: buffer containing the AP configuration information sent from the + * source guest + * @len: the length of the AP configuration information contained in @buf + * *pos: a pointer to store the file position after retrieving the AP con= fig + * information from @buf + */ static ssize_t vfio_ap_resume_write(struct file *filp, const char __user *= buf, size_t len, loff_t *pos) { - /* TODO */ - return -EOPNOTSUPP; + struct vfio_ap_migration_data *mig_data; + struct vfio_ap_migration_file *migf; + ssize_t ret =3D 0; + + if (pos) + return -ESPIPE; + + mutex_lock(&matrix_dev->mdevs_lock); + + pos =3D &filp->f_pos; + migf =3D filp->private_data; + + if (ap_is_se_guest()) { + dev_err(migf->matrix_mdev->vdev.dev, + "Migration failed: Target is a secure execution guest\n"); + return -EOPNOTSUPP; + } + + mig_data =3D migf->matrix_mdev->mig_data; + + ret =3D validate_resume_write_parms(migf, len, pos); + if (ret) + goto out_unlock; + + if (copy_from_user((void *)migf->ap_config + *pos, buf, len)) { + dev_err(migf->matrix_mdev->vdev.dev, + "%s (%d): failed to copy queue information from userspace", + __func__, __LINE__); + ret =3D -EFAULT; + goto out_unlock; + } + + *pos +=3D len; + + ret =3D do_post_copy_validation(migf, *pos); + if (ret) + goto out_unlock; + + ret =3D len; + + dev_dbg(migf->matrix_mdev->vdev.dev, + "%s (%d): %zu bytes of queue information stored in the migration file", + __func__, __LINE__, len); + +out_unlock: + mutex_unlock(&matrix_dev->mdevs_lock); + + return ret; } =20 static const struct file_operations vfio_ap_resume_fops =3D { --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 D2DE6350D58; Wed, 25 Mar 2026 21:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472539; cv=none; b=rLu6u0HZBUx5dN2odmgRfawLGQ7eqYp5YkJCYH49Eru1HTOYRfeQC3JXHbSx6zom1rrrvQ4b4RasyrWqw1jqQc83Xjie8+L3XugNDBGh/bZrB91WvZSBzM6CAId2xA4z8bomciS6R2HTRISd7TPPvAborbGI5fhNpuVifVo+wgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472539; c=relaxed/simple; bh=W27qIR0QTvdMKsjZ5Xi7w4X4egVpwD9N1UyS+yPpRvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZGgFNrvMQuMl1Zp2CaHuB/vLxj/+n3dSA0hQHukhrReEfz0UchvdIqSRVyZB8mdqPEMG6VTVVjwmp0jQ3Z9LPefEfHwCisvdJ+/jSfV3mXkUR1BygrxvWpxzxeVVpKndJcMzeY7rZRgdLnA7dwla0GaMx+PWcV7s3YC7cy+R0Wg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=cbxxLs+q; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="cbxxLs+q" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PHPR4j2886998; Wed, 25 Mar 2026 21:02:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=W1g6VWskXyE5TIscU M0SF1SwGst1kHyO5V+AZxyi1EU=; b=cbxxLs+qTfs6j2iXn9f+DIfZ8+SasuYNb HbRDyR8kAMDtCu0O4WPCMiIB/t98FnP7ATI/O5iLAq6FWGAzSbSFljlQJuFDFjLs pVB01Y52SrjirNsj248qJWIpZMcW9lGBBo37IeC61p2QI4Iku+UNp4XIBJXXOhYP V0g8A6WUc2CLcPJtXbIgz/irOZBS+8LeTFLanDwNX53sC1b27OOHW9FPU97Ib+TV m9ucvm/m/g0DR/DsmnqpuSBiMrAyOycfgpIxGosyUIh8ZW8CYyKBWxxD8SjBTdkY DUN0c1hfDrqe5PVjx8YXMDqKEFmf8pmZFreaX5sBq1COh74qBPcIA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kumsjs8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:12 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PGkfdU011789; Wed, 25 Mar 2026 21:02:11 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk817j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:11 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL2AAJ25494128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:10 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 515D558052; Wed, 25 Mar 2026 21:02:10 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59DE25805D; Wed, 25 Mar 2026 21:02:09 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:09 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 17/24] s390/vfio-ap: Transition device migration state from RESUMING to STOP Date: Wed, 25 Mar 2026 17:01:04 -0400 Message-ID: <20260325210149.888028-18-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: IVdK_6QGBRdEg7npmw_6ENsjU76tKrhE X-Proofpoint-ORIG-GUID: IVdK_6QGBRdEg7npmw_6ENsjU76tKrhE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX6cAybXtBD1Ns dZGKT0c7S/hPTP+dEoBtqMkPj97FHgKV4CeM2FkrThO5/km9Wpn7g5lENpCYM4Ah3Whr4ZFnoQ2 PdPVueSRr3C/z4FEUvQUrrMK3z6pxwMPGETbB3S3vx7xZLfgHbH0riKtxhCVLQODR0iIkSbkJRh KYSKwXaac5qMYwv+zm8F5lx7b5iMVfoSzr2Y94l7U19cg1wuqY8kKwUmz+MXTNKjS4BpqmdySkt oM09/oBs51ZYNJKf9ArXSBSKaEu7ATxfuF3q6g1fTr+yDGgIX3jO6JBAIXQPBJDtox8HMkTcq9p AcUUF3t9p5XNBLjEtm4zCQiOlMnkJvxicUA3MY7snxGjBRkrMD29DLH/M61Dl27OTxp+RNkmDrz 3L2h3H9VSA7E7IlzkHaWEMG54wmotED1HF7+tQlLnJLbnJG2TDiFdVxxsa/zkQHv/Ch2SIbJH14 8bkjsd/wRag7FkORuhw== X-Authority-Analysis: v=2.4 cv=KbXfcAYD c=1 sm=1 tr=0 ts=69c44d54 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=15JG798O9DgAUossVzIA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Leaving the RESUMING state terminates a data transfer of the internal state of the vfio-ap device on the source host to the vfio-ap device on the target host. This state transition indicates the vfio_ap driver should complete the incorporation of data written to the data transfer FD into the into the vfio-ap device. Since a vfio-ap device does not virtualize a physical device, there is no internal device state to incorporate; so, the only thing left to do is release the migration files used to help facilitate the migration process. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index d9b6dba53181..71cae26eab96 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -921,10 +921,20 @@ vfio_ap_transition_to_state(struct ap_matrix_mdev *ma= trix_mdev, return migf->filp; } =20 + /* + * Terminates the data transfer session of the vfio-ap device state + * between the source and target hosts. Since the vfio-ap device does + * not virtualize a DMA device, there is no internal device state to + * incorporate into the vfio-ap device on the target; so, the only + * thing left to do is release the migration files used to process + * the vfio device migration. Note that this state transition is for + * the vfio-ap device on the target host. + */ if (cur_state =3D=3D VFIO_DEVICE_STATE_RESUMING && new_state =3D=3D VFIO_DEVICE_STATE_STOP) { - /* TODO */ - return ERR_PTR(-EOPNOTSUPP); + vfio_ap_release_mig_files(matrix_mdev); + + return NULL; } =20 if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP_COPY && --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 63F21355F2B; Wed, 25 Mar 2026 21:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472543; cv=none; b=HuvYCx84NZPdgumhKEXX58S14RCtB3/1RUhCDDIj+uZSQkuY6KQctfxjpP8HRNLLN243FtO694NlE0prIRXQDSVbBtfcjth4BfEEm8XopTHoEFy9YzuXQDt9xX7x2X7WzeZ6T90XJGA9xD4eyKXsvUV/2lcyafGlALbhxqvF/qQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472543; c=relaxed/simple; bh=x49gUmg84nIcGNbnNC5PiOP5Js5LVwr7I1FeTIDRsbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PZK5Zjdshhh6CrhiahpQnlCjXftR6bVstGUUi68aaL6cDz+ZB5TReqxpCzj22ozmtQCI/vw6N+rfR2q+bWKq0HWTgwj6lsk7v/WGp4nWLxvlBzxEHupwLaZ4JM42UePxj7HtPeZprWTTSUEdht2vH9G5WiaFiz3Z7hjBhWr27KE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=MMT/cPF5; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="MMT/cPF5" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PJdd563640057; Wed, 25 Mar 2026 21:02:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=Nni1PDFaVHOEzEMnd wcVSod1HhhJR6TPsjMs/h4ArZk=; b=MMT/cPF5jNjRj8HhhoRb2sBnvg4A1ugOB uVf+H/a+Wp2yXY0bTCS19H+EaHhxmy0cg8V1Zt133nzphBjpGUqYdP3sDxdeloZc P6SijME42Mrml5TFZc2QQQZJk7+YrluSY79LCJLnTBoSvFxLQOzvrRTtNcpD0hiK BCrIhDz+c/XbleM1NuiXliV5z2ZDOIITyBQGxCrmoYmaIUWmZ17IkpY/6FO6dVh0 a81fv5J3e7FnQZ/sdU+5BdDMAtqJ6lIR46+N0lHW4JU7A+m8oo+kLy7a7acaBM7X yzEvC2QM7GPBoHw3K6PW2h8b+Vsad8/sS6m+Y8vphIcMzwxD7DU1A== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1ky09fev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:13 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKTq4v012203; Wed, 25 Mar 2026 21:02:13 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk817m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:13 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL2BWE26608350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:11 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6CAF558052; Wed, 25 Mar 2026 21:02:11 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75BAC58056; Wed, 25 Mar 2026 21:02:10 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:10 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 18/24] s390/vfio-ap: Transition device migration state from STOP_COPY to STOP Date: Wed, 25 Mar 2026 17:01:05 -0400 Message-ID: <20260325210149.888028-19-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfXxqEHYLvW1yFe VNTfXNyUMFxdYoSbSsfZBVxIIoJeYItQY3oxCW0zu1FhMYGAmJvzGfY6aaYr1xhPfme51GxF0Km ONNmRb3H1pE0Ewb5oSdvhBT7jj3w268xXDR1Xdn50EWdN+hUl6nUGWz6p6E7/3ULC7RxSIUNb2L ymxBrNaqsRcK9NjYQxxr5+ArUokM7FxqC6rzeykcOiobGmppLyNURfjPZcoDKNIskLKI152iiEr wXbC96+TNb8u0fuKG005FMAXOHrKK4t2GGsLyrLprY2UC4SKUNmRvi+M6NNdmObJ0mjK7lyVZeP Ryf91uHlrrTBywxm9tDnUAL+agciQXIe1ol2Dz7l7c3NRZLiGWjDzMhospSiU4vRMGVdP0tRYbw SVeAHSHyJs85nLeY8D0BBRMnXBPWw3p5DZs4wK4pt3aGnOufenqp8D5dGnACOMZxuvYYm+H5flJ 9TX5/6QWvtm03TzJlaA== X-Authority-Analysis: v=2.4 cv=JK42csKb c=1 sm=1 tr=0 ts=69c44d55 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=W1q30hmNGJXHcFJiBUoA:9 X-Proofpoint-ORIG-GUID: hCPrI2gEIW6PbHJp5mMwdPSwfCLAuZ6h X-Proofpoint-GUID: hCPrI2gEIW6PbHJp5mMwdPSwfCLAuZ6h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Typically at this point, interrupt processing for the device, DMA and other changes to the device's external state must be prohibited. For VFIO AP, there is no physical DMA device virtualized by the vfio-ap device . It merely manages the guest's AP configuration that identifies the devices passed through to the guest, but does not have access to any of them. Those AP devices are passed through and controlled exclusively by the SIE program used to start the guest. The only thing to do at this point is release all migration objects used to manage migration of the guest. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index 71cae26eab96..c6e01294be7f 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -937,10 +937,18 @@ vfio_ap_transition_to_state(struct ap_matrix_mdev *ma= trix_mdev, return NULL; } =20 + /* + * Stop the operation of the vfio-ap device. Since the vfio-ap device + * does not virtualize a DMA device, there is no physical device to + * stop; so, the only thing left to do is release the migration files + * used to process the vfio device migration. Note that this state + * transition is for the vfio-ap device on the source host. + */ if (cur_state =3D=3D VFIO_DEVICE_STATE_STOP_COPY && new_state =3D=3D VFIO_DEVICE_STATE_STOP) { - /* TODO */ - return ERR_PTR(-EOPNOTSUPP); + vfio_ap_release_mig_files(matrix_mdev); + + return NULL; } =20 if ((cur_state =3D=3D VFIO_DEVICE_STATE_STOP && --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 94A2432FA29; Wed, 25 Mar 2026 21:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472549; cv=none; b=bNrS/ThTNuoMkDWSbOASyQr69K9RhMNpi3uN1PQodHS44ypHdzK7goBEWlF7UZoUR+aYHi+llEAb2dJ2i9ufPCCUw+ZJ2RjW3ydhz0T2j+KL6SOF5ydCTihBOkvubk75XCCKjlJFp7abv9eI2b8eNIFyEeHJqpynXiGeS6UYt0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472549; c=relaxed/simple; bh=ZWgq5gmFkF1ib2CmNhxe/VmwrHzB9PgL6nHBhck+q2w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nti1dQoRvNxrbqQE5IwPPUDT1kUtEEtbTTKPyYSZ6wLgtYuBdIOiIV9/NvdHWT/u94aQQCjDzVfzNaRLgFp2iPK1UU4T102Yr5DFlpqPw+cJJtjYxaIR3J22Rq8tQoySQ6CDF+nFO6/s2tsZBJZdDdOnwhdlhGAok/jJ+goxHl0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=kwmfNCn2; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="kwmfNCn2" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PAbRUv657177; Wed, 25 Mar 2026 21:02:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=qswCz1UpnVnJiDCZx 7upZEgt/WaJPR3f9D8fTs/6+uI=; b=kwmfNCn2JdA4AInKmozCifMeFCzCunFmd i0i0KVnZscwDRsYOSNUDkELEn832YY9Kz4nAALs7RLI8EZQGMnxoPzfBsU3ouHEr 0K2irE3bvIBsNB4PljsGCkkKTMbrTaoIz6KV5TjXZcdnzjYx3XbAMrD6A22a4Xh8 66gOvLu1R9HcmNzKs2VS7RtotQ5mItqNaXq/D3IY/kbmi0L2EQTb4LiQie7uApf6 +oTMcQYmQcPSa68cvGkhlNrwfsakLH8vfwvApy7gBP2M83arlTHRGrw2ObEX9os9 El2c6zSEjN8I45nBLwPDxsM7seVxrptC8nSW2ZQt33v46ToDON42A== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kty2cbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:14 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKBGnE012213; Wed, 25 Mar 2026 21:02:14 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk817s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:14 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL2CkH11207256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:12 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82DF458052; Wed, 25 Mar 2026 21:02:12 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B2FF5805D; Wed, 25 Mar 2026 21:02:11 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:11 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 19/24] s390/vfio-ap: Transition device migration state from STOP to RUNNING and vice versa Date: Wed, 25 Mar 2026 17:01:06 -0400 Message-ID: <20260325210149.888028-20-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=IqITsb/g c=1 sm=1 tr=0 ts=69c44d56 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=YI3AHy_hWZklpQ5N57sA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfXywJyEeAcBpGx 9Eadaszmxj0guwYSQjWsE+uMmiLBlBmL94Z0SHSgQHf2pMPW8iMesknOESbu1HjmqmlUZc89q4g aivNdbZRhPWzd1GlrkS30xgLgg39bsSiIHH1s9w+OUIEvXsDIXbp574Od/hVHOqAlDSp08cjqx1 wzTfjEgTk8YXsYJntlq0fz75YMxVmBlH9SEXcNLJu8zJdRTgvT8fW3oGrb6cDCJGN34+EhcUAzU 0NQvkM13vi2mubJvvAhEewySMNeEt5dU6R0AY79+lkiOtqtp1uYwevUcOQ70bmOEDXtLvrQiN3B +uxQUOrn1Zz+ep7KXQ/ir0QXcPEp0MpClOCzF2plVXQfsYR+h9vrlC8bpW3psJzAOqCrbzNgH/S SjskK0Dk0D32xbz+oOhFe16GbSMldb2xlTlv3f4Vpapgd4oIX9oISfMwl2PB3CovrWxqbPGuTwO ibHtyIIy2hw5u8TkE5g== X-Proofpoint-GUID: tdCv9LbScMba0AP546GH4Q_aJ_-0vGFx X-Proofpoint-ORIG-GUID: tdCv9LbScMba0AP546GH4Q_aJ_-0vGFx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" The transition from STOP to RUNNING and vice versa indicates that the vfio device is operating normally and migration is not currently taking place. In this case, just set the new state and if there are any migrations files used to help facilitate migration hanging around, release them. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index c6e01294be7f..750299fb1a84 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -951,12 +951,18 @@ vfio_ap_transition_to_state(struct ap_matrix_mdev *ma= trix_mdev, return NULL; } =20 + /* + * These states indicates migration has either not been initiated or + * has completed and the vfio-ap device is operating normally; so + * just set the new migration state. Just in case, release the + * migration files used to facilitate migration if any are hanging + * around. + */ if ((cur_state =3D=3D VFIO_DEVICE_STATE_STOP && new_state =3D=3D VFIO_DEVICE_STATE_RUNNING) || (cur_state =3D=3D VFIO_DEVICE_STATE_RUNNING && new_state =3D=3D VFIO_DEVICE_STATE_STOP)) { - /* TODO */ - return ERR_PTR(-EOPNOTSUPP); + return NULL; } =20 /* vfio_mig_get_next_state() does not use arcs other than the above */ --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 8F36F33C51D; Wed, 25 Mar 2026 21:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; cv=none; b=qbVSRkjcNupujFeB4skbJsE14pU7oz28xZWKKXKFS+i5qVcEA9x19XI47Fnt5ZlOk8wauM9NX64CjRRmqwa4wMDv0N9baEV7Rj12vDbwqtpZJdR9lLhvPSdpIvVf9S3upF0cFagWYsMyl7+qF0AGApULVLh3v4TeFmaq2q2aLYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; c=relaxed/simple; bh=ZMYVh9y2crFkEKfAj0FsywjfRTFtIUhuX7Zg0+UGYQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HJtOSe31RA7cgd0dQA5hDtOhvHaAD8oEBkamowheCzK9RNEliT93RbWmWYWKeJkVgEGfGKG8+IXmB2ajcIpXcMmtqnKxRj4A1phuUEXSqxDnbfmIy5+RWzC+JkQzK9CVI4hqJmq6kaRSgL227v7sGOsz1tm7+hGQQOvL84SS7eU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=N3P3FwoL; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="N3P3FwoL" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PEipQ52664877; Wed, 25 Mar 2026 21:02:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=7Wy00jRlb5i4CubN2 2qDRIAndGEJ3vI0vn5+E5znbo8=; b=N3P3FwoLoFlGUO1+sJQB3aomC8MhqoCTQ TZo3MBRqbv7NRqZobr1un26DOMnADTqvsVHbOXllt1tpyu5Tv1UteJ/dpTlr1Obx rM+uOWevSEuT2tmilZPE/npKBYqR1xzsU9JsmPsi9XQpOLyRPoXDdSCB7Gkyrl4k bs0wER1KAIxBqHo/yuMg/nkwfPhia4BQL+/qhOar/iHweMwcse2qiAuoaJVAw6mO 0/xI2i7rrVpxgaGZaPCsLQG7RTf8Z+UmJqH9fWD6TjAQKB1TYmo737Z+uoNWj4W4 c/g1Q/5cg1YI3tM9Gqz07Ju9Lvy6fogscg/7y+sCUlAgDcjWcpN/w== 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 4d1ktv1hk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:16 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKw5uD004380; Wed, 25 Mar 2026 21:02:15 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d28c27yd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:15 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL2DRV19399342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:14 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 999C658068; Wed, 25 Mar 2026 21:02:13 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A16C158056; Wed, 25 Mar 2026 21:02:12 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:12 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 20/24] s390-vfio-ap: Callback to get the current vfio device migration state Date: Wed, 25 Mar 2026 17:01:07 -0400 Message-ID: <20260325210149.888028-21-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: XrlngK-rxkO77sRrpwuaYZynZ4xQf7KL X-Authority-Analysis: v=2.4 cv=aMr9aL9m c=1 sm=1 tr=0 ts=69c44d58 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=3m_Bk1FAMoj1bHXj4eYA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX1a3xCjX0EjGD 2z8NS8fXwf9HzGn6Y8cihezc/ywBkCESEn+9KsZEa/b5iqOL7Ft2c9hrNZZWWkYsgUGo/cj26pY e2K1j6SEvCINziiBqDdM429ZdOP9CHWxwi3q4D4EpS/HipyQ4NOISDl8vhUlBLzLZ5pSZ48yoLU vUeS8UolX5yu1vmzNhvdTRXEpLeTtrUiH00B1u+EGNcrm5o6SdfqZchsY4Gk/rMCBnqgWHxlv4e KgYJnPhHMUqxi9c5IPGa4AukofDTM3AhjnlSfGUKm+1g44IjPM2K8ty7UPW9AIu4yR9ivonGJmU oDmU/NYQHTj/1OWZVLpmzQCacK8koQK1C7W6sfxfS93e0Eqydp3LiMWI4N0REhjtPcaLMhAFZ9j JymxU2B2MqgFi3OgJVgOVMcUIeOC6TmspS9qEkOT2EIdXW0VcuXPbjHDaCMYxvEwFoMWxR26jVe 3dy7cFMWZ+jt0vG3J6w== X-Proofpoint-GUID: XrlngK-rxkO77sRrpwuaYZynZ4xQf7KL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Implements the callback that returns the current vfio device migration state during live migration of guests with pass-through access to AP devices. The function pointer for this callback is specified via the 'migration_get_state' field of the 'vfio_migration_ops' structure which is stored with the VFIO device when the 'vfio_device' structure representing the mediated device is initialized. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index 750299fb1a84..305fd3221be1 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -1014,7 +1014,18 @@ static struct file *vfio_ap_set_state(struct vfio_de= vice *vdev, static int vfio_ap_get_state(struct vfio_device *vdev, enum vfio_device_mig_state *current_state) { - return -EOPNOTSUPP; + struct ap_matrix_mdev *matrix_mdev; + struct vfio_ap_migration_data *mig_data; + + mutex_lock(&matrix_dev->mdevs_lock); + + matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); + mig_data =3D matrix_mdev->mig_data; + *current_state =3D mig_data->mig_state; + + mutex_unlock(&matrix_dev->mdevs_lock); + + return 0; } =20 static int vfio_ap_get_data_size(struct vfio_device *vdev, --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 ADB5433D6F8; Wed, 25 Mar 2026 21:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; cv=none; b=AHrGdRzZAmUMNQBp+VO6BQdAsxS3nFjxRbrYpkeqDBOZwy7aJJ8B4PJU/E4I9XmG9Gv2WyG4f2rRMbjRVta4DwvjpxiF7+vracPDmdgcnAu7QaV+godt4FcsPTKSc5zs2MWm/PCs/hDjEw4Hp0XzhjoOnHfORExmv44WB8z+7c0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; c=relaxed/simple; bh=U/OdCEGBREHZJlGOgivpcIQ2KN4JlB/GyUanYv486bs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZqjuXLJSG9FMpurUPwKrw35wiVpgs8ZVXx2nHTfz9XjNTJlgm00g0necs8ChTAGjqXW7hZxUnrtDtR2ydtulscrkjwghP/1Gz6JnwFk93X1yVVSPMnzi4RleIdIsoSh8WvXpOl1hMFFmOh67TZBYsvFLRFozaTbILZ60zQnhM2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=O9yyBJbF; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="O9yyBJbF" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62P9iUT1552077; Wed, 25 Mar 2026 21:02:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=AT1mFfKoJ9CjE/dAU LEqpNxMxTik69M8mCInP7X93gM=; b=O9yyBJbFcu2mjmwKOYNrT6QissaREfhnk LhADuWkvOkWsxNU83WnY+duUZW7+TwJWjoodsxVXKXK+FchLtVBtslq8E2WKQ3uY Z2x+XniKvcTcNubXVnErol/l+yOWHdi/0Grqm2Wb/dRfn4R/bqWbhHqM9zYnd+fX Lhep6z0rAUuwyZ2Z/wW8F/LvLJRqfRrY6BFR/O+IqM43Sf+PAItMxs1sEgr+FY9p yZVtvTBh360gStaHgAgew/vbWlGjw32joVnvUgiXfNxkgq2pqugy9E0w5YgSCUwU +oq387A0xrbUEilSn0PoefNLP4/82IPhE1KpVQXWlqWjDDgMDNJHQ== 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 4d1ky09ff2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:17 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKw5uE004380; Wed, 25 Mar 2026 21:02:16 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d28c27yda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:16 +0000 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 62PL2Esm10355348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:15 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADD2F58068; Wed, 25 Mar 2026 21:02:14 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B802C58056; Wed, 25 Mar 2026 21:02:13 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:13 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 21/24] s390/vfio-ap: Callback to get the size of data to be migrated during guest migration Date: Wed, 25 Mar 2026 17:01:08 -0400 Message-ID: <20260325210149.888028-22-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX6q5t5KOgfPO7 6q2PLem/DzXK7w5QBDyob1OuuGfEun+VF8BAZdCWuEaKWigtvQCNu/v2L/omIh8zKwkNj+3dJiM uRks9k1lO5wI+JFS5YjxDfg1fBC0o6LZNwy+DLJmLSNuAfd6qKQ82YCdrGPwUBY2cXD+IO48tkF e1gyYFcVUrc0H7pvbTvC5DX+w3TshmEwZjW+sm0+z8DHrV3I9Vd9qBC9wWJWLB8bfR1hf/NTHCQ 5GMY2nTg3rr+u0TBirt0SnN59513uwPRvbLlKUxgbp43Wqg/RRcT51t1QRaSsqWcOf7Ix020kQB yEm5Gd+2OsMpLa/3A9K0UmgOCTxVYvB36J5BTAfPr2mdaXxVASKp4csi+H9MknnA6buip6teroU Z+g0hmIDk2N5wWqcanWYMl1FeW4QDUYtUFE43xYL/aXHCFPqM4yASA5LwrU5OFz1tZ5zRAW5CO5 LkAY3cMbtRzMwiJuxrw== X-Authority-Analysis: v=2.4 cv=JK42csKb c=1 sm=1 tr=0 ts=69c44d59 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=vZ-Ft76KQvoWVpZ_:21 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=dNOmgfuV3ZSo10a98CMA:9 X-Proofpoint-ORIG-GUID: _Uy-j11J_hFigo7g-_aX2hlObYiSSDPM X-Proofpoint-GUID: _Uy-j11J_hFigo7g-_aX2hlObYiSSDPM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Callback to get the estimated data length of the data that will be required to complete reading of the vfio device's internal state. It's mandatory for VFIO_DEVICE_FEATURE_MIGRATION migration support. The function pointer for this callback is specified via the 'migration_get_data_size' field of the 'vfio_migration_ops' structure which is stored with the VFIO device when the 'vfio_device' structure representing the mediated device is initialized. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index 305fd3221be1..fa163b129c66 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -1031,7 +1031,18 @@ static int vfio_ap_get_state(struct vfio_device *vde= v, static int vfio_ap_get_data_size(struct vfio_device *vdev, unsigned long *stop_copy_length) { - return -EOPNOTSUPP; + struct ap_matrix_mdev *matrix_mdev; + size_t qinfo_sz; + int num_queues; + + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); + num_queues =3D vfio_ap_mdev_get_num_queues(&matrix_mdev->shadow_apcb); + qinfo_sz =3D num_queues * sizeof(struct vfio_ap_queue_info); + *stop_copy_length =3D qinfo_sz + sizeof(struct vfio_ap_config); + mutex_unlock(&matrix_dev->mdevs_lock); + + return 0; } =20 static const struct vfio_migration_ops vfio_ap_migration_ops =3D { --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 C6A3B33DEC0; Wed, 25 Mar 2026 21:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; cv=none; b=cMXyW48CjEPGQZCcyWZWcjRATM6/5lDYta2XCX6OUFVvI8sU7ua02K5BwoF71BbvLKavcHQ5i8qr9XwFdmmdMj6NLZspdPgBlXFxT0GS7U2z26NxlST1wAqvqiVqR+5YAlVNiFTM2VFmPuO+SCL/PtEE/cB7v+gvTJfARHSkvEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; c=relaxed/simple; bh=Xz+GB2Ro+pI2ffB+pDRxp9noK47ECyWLDkREbbllQlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k0074hB9vijxNL4a1ZxvKAuzT9opVzJzFw7vsm9Q+unaRhGH8HIL6IGnYHxGPTlUUXGHI5j2b96B6da74aJ6sZMj4o6tADJOTzcA6Rj5eJw2VH1XuuP1+bKCPiBtryGGYgZ9ExJViMnN9qdON1baoLSJM3Ahw7uLEoA6+PKW9S4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=pmrH/Xn1; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="pmrH/Xn1" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PGeqxt3444471; Wed, 25 Mar 2026 21:02:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=BA0N3O8cGMiGIAxpL ybHJB0+iDxyZnkAa/sXqJ2Exys=; b=pmrH/Xn11/t11iYhPpxVpBl6OMFtuVOAQ /ayXvciFL+uxRIZ2bgPofjVthGr9ePczAX8GEVOj5tkAZ8PSV9nVpb7XAtQo/U2g qttOLAhYuC0uuGdKQnS0eu3V36s0Iy7Ax/6UWXQzktRvfUYrVkyJunjy4nQjzsPj 8bCzVqj9Ui9YYHjtZJmX+rHVz1Sg3VyAoUJXTKAx76G+FrdpVcCSKg5SkA3qbsNY 8SvB2asKZPVLE5/SbDXPeGQcN+nM1U6w01OXpMUjYTtwP0RIrfJYVKBdIBb1QY6V bsFSEsAtP64UdBv41d0x5POD9UQiDA2sri5C++N+QSUFosM0gqFbw== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1ktv1hk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:18 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PImIJN006009; Wed, 25 Mar 2026 21:02:17 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d261yrav2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:17 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL2GVW19726990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:16 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC79C58052; Wed, 25 Mar 2026 21:02:15 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCAF258056; Wed, 25 Mar 2026 21:02:14 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:14 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 22/24] s390/vfio-ap: Provide API to query whether migration is in progress Date: Wed, 25 Mar 2026 17:01:09 -0400 Message-ID: <20260325210149.888028-23-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bbdIn4_XmxL1c2X6Rag1N9A6F_PSQkBn X-Authority-Analysis: v=2.4 cv=aMr9aL9m c=1 sm=1 tr=0 ts=69c44d5a cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=KVO1Mmj0cRKhcOrYc_gA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX6cAmv7hWyrgB xOeAtSY19P3cm6eiDRvrNdjn2OZWBZ49n6DagbJiv0hwhOt3ZPKDrrp+AT4cHW0vm3yEAo09cNg 809kpHT0Gy2xT1yA4jlMbop1AOBcbmPAt1JC6ILEuAriwBoAYO9tf7U4gEjvRe+rSLhmQcIJABd 03+1HEdm49Ryi8sX9rMxr1c9Ghcp6Om0YOBGGf/tXpBPn7mhiea62jgFcj5QN44c0y06+ACYCdC nMFuLG5+OAEsvaCDVqhAqtjWaHpm8n1uEz9Ye74YXhoQsjefQQk+obVF+oqt80AV6MK2ROr15vJ ZxLCDhqu3UFfL/tKy33IZ94IcsT0z2jyI7ZYbZtbUhkivy0PjADQxzkaHTHyeFXWNRv12DM7JT0 CgiQ6GFQUcVZgRWsXyfgpu2YswftlD6HDZWeNGpcXwKNykjvOoA46pbVFK6HYkyoqbRYuhcpe/z KgkFoTOWiMjvt7AlOnw== X-Proofpoint-GUID: bbdIn4_XmxL1c2X6Rag1N9A6F_PSQkBn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Provides an AP to query whether a live guest migration is in progress. This can be called to determine whether an action should be allowed during migration; for example, allowing a system administrator to disable migration while it is in progress. Other uses may be to prevent changing a guest's AP configuration while a migration is in progress. The only means the vfio_ap device driver has to determine that a migration is in progress is via the callback functions specified in the 'struct vfio_migration_ops' object associated with the vfio device. The very first callback invoked during migration is the callback specified in the 'migration_get_data_size' field of the structure. This callback will set a flag indicating that migration is in progress. The flag will be cleared when the vfio device migration state transitions from VFIO_DEVICE_STATE_STOP_COPY to VFIO_DEVICE_STATE_STOP. At this point, the internal state of the vfio device on the source has been copied and will be restored on the target. Note that the 'migration_get_data_size' callback occurs after migration has been initiated, so there is a short period of time during which the API will erroneously indicate migration is not in progress. This, unfortunately, is unavoidable given the only means of determining that a migration is in progress is via these callbacks. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 40 ++++++++++++++++++++++++- drivers/s390/crypto/vfio_ap_private.h | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/= vfio_ap_migration.c index fa163b129c66..8a7628fcf285 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -47,11 +47,14 @@ * @mig_state: the current migration state * @resuming_migf: the object used to resume the target guest * @saving_migf: the object used to save the state of the source guest + * @mig_in_progress flag indicating whether migration is in progress (true) + * or not (false) */ struct vfio_ap_migration_data { enum vfio_device_mig_state mig_state; struct vfio_ap_migration_file *resuming_migf; struct vfio_ap_migration_file *saving_migf; + bool mig_in_progress; }; =20 /** @@ -971,18 +974,30 @@ vfio_ap_transition_to_state(struct ap_matrix_mdev *ma= trix_mdev, return ERR_PTR(-EINVAL); } =20 +static void vfio_ap_set_mig_in_progress(struct vfio_ap_migration_data *mig= _data, + enum vfio_device_mig_state prev_state, + enum vfio_device_mig_state new_state) +{ + lockdep_assert_held(&matrix_dev->mdevs_lock); + if (prev_state =3D=3D VFIO_DEVICE_STATE_STOP_COPY && + new_state =3D=3D VFIO_DEVICE_STATE_STOP) { + mig_data->mig_in_progress =3D false; + } +} + static struct file *vfio_ap_set_state(struct vfio_device *vdev, enum vfio_device_mig_state new_state) { int ret; struct file *filp =3D NULL; struct ap_matrix_mdev *matrix_mdev; - enum vfio_device_mig_state next_state; + enum vfio_device_mig_state prev_state, next_state; struct vfio_ap_migration_data *mig_data; =20 mutex_lock(&matrix_dev->mdevs_lock); matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); mig_data =3D matrix_mdev->mig_data; + prev_state =3D mig_data->mig_state; dev_dbg(vdev->dev, "%s -> %d\n", __func__, new_state); =20 while (mig_data->mig_state !=3D new_state) { @@ -1006,6 +1021,7 @@ static struct file *vfio_ap_set_state(struct vfio_dev= ice *vdev, } } =20 + vfio_ap_set_mig_in_progress(mig_data, prev_state, new_state); mutex_unlock(&matrix_dev->mdevs_lock); =20 return filp; @@ -1031,12 +1047,15 @@ static int vfio_ap_get_state(struct vfio_device *vd= ev, static int vfio_ap_get_data_size(struct vfio_device *vdev, unsigned long *stop_copy_length) { + struct vfio_ap_migration_data *mig_data; struct ap_matrix_mdev *matrix_mdev; size_t qinfo_sz; int num_queues; =20 mutex_lock(&matrix_dev->mdevs_lock); matrix_mdev =3D container_of(vdev, struct ap_matrix_mdev, vdev); + mig_data =3D matrix_mdev->mig_data; + mig_data->mig_in_progress =3D true; num_queues =3D vfio_ap_mdev_get_num_queues(&matrix_mdev->shadow_apcb); qinfo_sz =3D num_queues * sizeof(struct vfio_ap_queue_info); *stop_copy_length =3D qinfo_sz + sizeof(struct vfio_ap_config); @@ -1051,6 +1070,24 @@ static const struct vfio_migration_ops vfio_ap_migra= tion_ops =3D { .migration_get_data_size =3D vfio_ap_get_data_size, }; =20 +/** + * vfio_ap_migration_in_progress: Indicates whether a live guest migration= is in + * progress or not. + * + * @matrix_mdev: pointer to object maintaining the vfio device state + * + * Return: returns true if a migration is in progress; otherwise, returns = false. + */ +bool vfio_ap_migration_in_progress(struct ap_matrix_mdev *matrix_mdev) +{ + struct vfio_ap_migration_data *mig_data; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + mig_data =3D matrix_mdev->mig_data; + + return mig_data->mig_in_progress; +} + /** * vfio_ap_init_migration_data - initialize migration data and functions * @@ -1069,6 +1106,7 @@ int vfio_ap_init_migration_data(struct ap_matrix_mdev= *matrix_mdev) return -ENOMEM; =20 mig_data->mig_state =3D VFIO_DEVICE_STATE_STOP; + mig_data->mig_in_progress =3D false; matrix_mdev->vdev.migration_flags =3D VFIO_MIGRATION_STOP_COPY; matrix_mdev->vdev.mig_ops =3D &vfio_ap_migration_ops; matrix_mdev->mig_data =3D mig_data; diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index cad49b509f7a..e04644c335fe 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -183,5 +183,6 @@ void vfio_ap_on_scan_complete(struct ap_config_info *ne= w_config_info, =20 int vfio_ap_init_migration_data(struct ap_matrix_mdev *matrix_mdev); void vfio_ap_release_migration_data(struct ap_matrix_mdev *matrix_mdev); +bool vfio_ap_migration_in_progress(struct ap_matrix_mdev *matrix_mdev); =20 #endif /* _VFIO_AP_PRIVATE_H_ */ --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 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 3D2A63890E8; Wed, 25 Mar 2026 21:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; cv=none; b=cdhKrhvZLkp74Wh6OAjtWpc1s6bTTuQ3SsAcPbhq2r1rnNgNlzDwtG6AyhxnSDjDpjVogIV3vi1VQaN8hEzYef/PGfPfvcJYRdqtkMpF52ARzpcF76lnXgr7vj+c7tS6g5HJfVOEmj+kZYWgxv+iwgEWrlKUbXHsx6YkuNrrh2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472545; c=relaxed/simple; bh=1+w+VmNGh7UWWoGPd/8zusryaGihqFcVScXp247ZUIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XfMXhPTY9LXtDxhLbpYRlo9w5aoQ7FzKUze81H6c+wMkZirYuwppXKrzJlUkmK+c/slbkwqEQZF8d9TfxB+Ub9sVH76bt2FnQE6Dw5cHcPxE6nUbHHpxxZYv64uQJXM+R5/z2+7IGR0DGHtUBxgwv5tFmMV/+a1vgTwFi6VFZfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ZMNQTloD; arc=none smtp.client-ip=148.163.158.5 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) header.d=ibm.com header.i=@ibm.com header.b="ZMNQTloD" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PA5dAG415280; Wed, 25 Mar 2026 21:02:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=8JJFpHxKBELvsQ6SM fSoQpelPUfFPaiRyKfo8dluKoQ=; b=ZMNQTloDC2tFYX9evHrpmoqIkUgINfMzR n5F9XaKKVsKaj7znFIRLKmq3bbPuKow37+9brXfpXQruWkKlYKjIU42qRwQRM+8J xfk2+FoEIDav+lblKfaA99dPlmefgE7aKGbAHFG5jJK/8NMetOJP3BHKQ7XIybz+ Rluh2isxS26etHjtU5PF63N73hNznfQN41zcbcOVcqy2+ErggfA0DKIpcmKYIaLp 1bHrGOS98n68hTNaJE1wV7tPxGtpHqqJR7rOLAsFzKZK+c96YmnNnYNygF99SLWl 5EpH7SUDlm0lfJZaAsMtxxY6Z7SdWFXNWJJDY8TzB0Cb3ZXfOBWdQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kumsjsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:19 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PK32jQ026864; Wed, 25 Mar 2026 21:02:18 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d275m054p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:18 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL2H4f15663798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:17 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 047505805D; Wed, 25 Mar 2026 21:02:17 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 06DF158056; Wed, 25 Mar 2026 21:02:16 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:15 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 23/24] s390/vfio-ap: Disallow blocking migration in progress Date: Wed, 25 Mar 2026 17:01:10 -0400 Message-ID: <20260325210149.888028-24-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 22nzF0RYFEgEjOjkxTzWbffdY32ZTOAF X-Proofpoint-ORIG-GUID: 22nzF0RYFEgEjOjkxTzWbffdY32ZTOAF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfXx1eDeb9yr3wJ lDCtQ4Sp/0yesvP8xr2EMaeXAYhGEYXUW07/D+oQlVATv49l5HtGY8qD+b7TGDmIM9ANeJEOEkF ExPDBD1VZagbWDt55d9n7VooI35ORCnCSPTYY0S8v2Sq4PP5bJyE1IJxBztPA55s9bmAyyhTL3B fVFKoV/JWddHnKqhcIDhShJT3xw8kMqWWdUVqPaRNCEZT8ktF2TffID22XadCIL2NMZMJrLCL6h s1yjpPT/h551jSFyp/AhEAVuE6jlejdcPtrUBs6dqfrmMVJbpvUXNa24HmIYHrmflt1qDRkNmMy zlXEHAmklVnEnQw3sSu5QdSva6vRl8LDV02GsD/DKDZUis3wPG04ZJr91UtDt0z7ERUCVKGD+aT 6unhKe2AhqFG0bySTeQGjQfkBtG2srmrrPMqVD19dHCIKm6JFIEotOUm3C1hAIUcXSaLftPNHHQ m9ge/HY6h7QNlBD8VmA== X-Authority-Analysis: v=2.4 cv=KbXfcAYD c=1 sm=1 tr=0 ts=69c44d5b cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=yxLGV8IA72irMGqYBd8A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" The sysfs 'migratable' attribute allows a system administrator to enable or block live guest migration. If an attempt to block migration is attempted while a migration is in already in progress, the migration will complete leaving the system administrator believing that it was blocked. To prevent this scenario, the operation will fail with the "Device or resource busy" (-EBUSY) error if a migration is in progress. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index 1ff9994bd7ec..c8d454e52665 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1853,6 +1853,12 @@ static ssize_t migratable_store(struct device *dev, = struct device_attribute *att goto out_unlock; } =20 + if (!migratable && matrix_mdev->migratable && + vfio_ap_migration_in_progress(matrix_mdev)) { + ret =3D -EBUSY; + goto out_unlock; + } + matrix_mdev->migratable =3D migratable; =20 if (matrix_mdev->migratable) --=20 2.52.0 From nobody Thu Apr 2 23:54:07 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 568A838F638; Wed, 25 Mar 2026 21:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472550; cv=none; b=M7Ienhubd5eg/2hWUN0pz0F0QKhHpyGJ4XcXSvJ0O58mj2X2xZbsHjk9PbOtrGHQ3cLSHlspNSeKj6/TC9io8Ls7aKHj17ThBMgXH+srEvep1VkBQ9e9D1qmO/7Hq2FaRRDkOQySJ8BB3iTt4kdzdZhELn7m22NgcjL7nEiBgjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774472550; c=relaxed/simple; bh=I/wWZ9C0shTDrsq8fuNsIdndXcbIv7ccuWuwLKjWqr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tHF8cn2O07ADpbHVncJEHNvZfObQwJ9JJLpIw35qnfZq2v19WlszmAyKTelRocYlxmrPphtpEaOlj0tWnH3s0IPGT64ovBJvlw98Xy6OlQgFqqFmFpprFth6TlmLFFdEPJK6eb64Qwad8G3jSlfT0rCOYiC2UBbIkrbYlCcViAs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ADD8botm; arc=none smtp.client-ip=148.163.156.1 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) header.d=ibm.com header.i=@ibm.com header.b="ADD8botm" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PIUhas3819926; Wed, 25 Mar 2026 21:02:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=gXuvojxTJHljWArPR minBWWRAB18H+vkJf9CV9BRxZc=; b=ADD8botmOwfZEWTvfCoOiVtRieDBrzKFV Jar1OobtqyfNc40F5MYSYAY5fgy3iQtzNgAsv929fxnpCbkDRPvVr7DeM1ti14KI wjyU+ksB0CuW5Ah1XRRSOeZUCjsD+5amE/5tVigW/Z1EzdZcKqPQC87aJwBZaBqt 7IzEL89d2bZie9K6rrPZTh/cNTAMCWyg5gdVNQQFbxISBQM/9EeAlAzFpP+K0a5U z8MldHiTXcRn3L6hE01odPZtPucfAdltb0mbcdyQA1k7a8v7Jt2HZg2/QIgvH+WK H3zU/44TatwsejU/eMudVtGLk/SQSYtUfcs80OD9l6hl9FlYKLNZQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kty2cbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:21 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 62PKTq4x012203; Wed, 25 Mar 2026 21:02:20 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d27vk818e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Mar 2026 21:02:20 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 62PL2IUv5112696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2026 21:02:18 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1C2D95805D; Wed, 25 Mar 2026 21:02:18 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2281658052; Wed, 25 Mar 2026 21:02:17 +0000 (GMT) Received: from li-4c4c4544-004d-4810-8043-b7c04f423534.ibm.com.com (unknown [9.61.136.69]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 25 Mar 2026 21:02:17 +0000 (GMT) From: Anthony 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, mjrosato@linux.ibm.com, pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com, fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH v1 24/24] s390/vfio-ap: Add live guest migration chapter to vfio-ap.rst Date: Wed, 25 Mar 2026 17:01:11 -0400 Message-ID: <20260325210149.888028-25-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260325210149.888028-1-akrowiak@linux.ibm.com> References: <20260325210149.888028-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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=IqITsb/g c=1 sm=1 tr=0 ts=69c44d5d cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=ymCyIV2yq4vNEUg3yzkA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDE0OSBTYWx0ZWRfX0Zu+UG2o7g9J ohe7nid3mY1yfDBsocEnPeLC5C/MYDtaYJB4CTBr5EhFBAgErHoeVu6pM+3RyYr4Bv43DxHGotj hpKeaIoxui0BXlAYtX0ivqephVvWNOinlYLRPF0mn21w7tt3+GJnqZ2gvHICZNtnGB+kUn86vjl MMDsQEgYeINrEjblHIRrsv0ije33dXCTKCaTBid9Vt/C3U5R2AJBOriUL3XR+RSgwecGvljPXsd UcqDIHPwRkD8Q2kslmD9mn2OKVxRNvrVf3j3qHmU0YUPTmaDZNEFmQri2Q/K2nq5yt+FkNUkFX0 0f9IxsyLlJ3s0e29wjw6RMynh49G8WTkm0G/FBZSr7mZwOnszDJ97ujiCdSkqB5DpdN+gfJRuAx UIdl+IHk6qgL8ZHHqIDBHKbkJ1k1g3znZQ+AQtcsa4mW4wg76oRZKDolXyIcP6HKnIdxwpid/iE ZyMFKjQYNYaPP6WkfxQ== X-Proofpoint-GUID: GUHQsRgNDdQ4_Y-hCNgXFVMTbK_taun5 X-Proofpoint-ORIG-GUID: GUHQsRgNDdQ4_Y-hCNgXFVMTbK_taun5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250149 Content-Type: text/plain; charset="utf-8" Add a 'Live Guest Migration' chapter to the Documentation/arch/s390/vfio-ap.rst document to describe the details for initiating live guest migration for a guest to which AP adapters, domains and control domains have been passed through. Signed-off-by: Anthony Krowiak --- Documentation/arch/s390/vfio-ap.rst | 339 ++++++++++++++++++++-------- 1 file changed, 246 insertions(+), 93 deletions(-) diff --git a/Documentation/arch/s390/vfio-ap.rst b/Documentation/arch/s390/= vfio-ap.rst index eba1991fbdba..9df7614fd62b 100644 --- a/Documentation/arch/s390/vfio-ap.rst +++ b/Documentation/arch/s390/vfio-ap.rst @@ -1016,7 +1016,7 @@ guest_matrix dyn ap_config =20 the following features are advertised: =20 ----------------+----------------------------------------------------------= -----+ ++--------------+----------------------------------------------------------= -----+ | Flag | Description = | +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ | guest_matrix | guest_matrix attribute exists. It reports the matrix of = | @@ -1025,105 +1025,258 @@ the following features are advertised: +--------------+----------------------------------------------------------= -----+ | dyn | Indicates hot plug/unplug of AP adapters, domains and con= trol | | | domains for a guest to which the mdev is attached. = | -+------------+------------------------------------------------------------= -----+ ++--------------+----------------------------------------------------------= -----+ | ap_config | ap_config interface for one-shot modifications to mdev co= nfig | +--------------+----------------------------------------------------------= -----+ +| migratable | Indicates that live guest migration is supported for gues= ts | +| | to which crypto devices are passed through = | ++--------------+----------------------------------------------------------= -----+ =20 -Limitations -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Live guest migration is not supported for guests using AP devices without -intervention by a system administrator. Before a KVM guest can be migrated, -the vfio_ap mediated device must be removed. Unfortunately, it can not be -removed manually (i.e., echo 1 > /sys/devices/vfio_ap/matrix/$UUID/remove)= while -the mdev is in use by a KVM guest. If the guest is being emulated by QEMU, -its mdev can be hot unplugged from the guest in one of two ways: - -1. If the KVM guest was started with libvirt, you can hot unplug the mdev = via - the following commands: - - virsh detach-device - - For example, to hot unplug mdev 62177883-f1bb-47f0-914d-32a22e3a8804= from - the guest named 'my-guest': - - virsh detach-device my-guest ~/config/my-guest-hostdev.xml - - The contents of my-guest-hostdev.xml: - -.. code-block:: xml - - - -
- - - - - virsh qemu-monitor-command --hmp "device-del " - - For example, to hot unplug the vfio_ap mediated device identified on= the - qemu command line with 'id=3Dhostdev0' from the guest named 'my-gues= t': - -.. code-block:: sh - - virsh qemu-monitor-command my-guest --hmp "device_del hostdev0" - -2. A vfio_ap mediated device can be hot unplugged by attaching the qemu mo= nitor - to the guest and using the following qemu monitor command: - - (QEMU) device-del id=3D - - For example, to hot unplug the vfio_ap mediated device that was spec= ified - on the qemu command line with 'id=3Dhostdev0' when the guest was sta= rted: - - (QEMU) device-del id=3Dhostdev0 - -After live migration of the KVM guest completes, an AP configuration can be -restored to the KVM guest by hot plugging a vfio_ap mediated device on the= target -system into the guest in one of two ways: - -1. If the KVM guest was started with libvirt, you can hot plug a matrix me= diated - device into the guest via the following virsh commands: - - virsh attach-device - - For example, to hot plug mdev 62177883-f1bb-47f0-914d-32a22e3a8804 i= nto - the guest named 'my-guest': - - virsh attach-device my-guest ~/config/my-guest-hostdev.xml - - The contents of my-guest-hostdev.xml: - -.. code-block:: xml - - - -
- - - +Live Guest Migration +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +A guest to which crypto devices (i.e., AP adapters, domains and control do= mains) +have been passed through can be migrated to another system if both the sou= rce +and destination guests meet the following requirements: =20 - virsh qemu-monitor-command --hmp \ - "device_add vfio-ap,sysfsdev=3D,id=3D" +* The destination guest will be started with the same QEMU command line as= the + source guest, so the mediated device supplying the AP configuration on b= oth + the source and destination guests must have the same name (UUID). =20 - For example, to hot plug the vfio_ap mediated device - 62177883-f1bb-47f0-914d-32a22e3a8804 into the guest named 'my-guest'= with - device-id hostdev0: +* The AP configuration passed through to both the source and destination g= uests + must be compatible. As such, each AP configuration: =20 - virsh qemu-monitor-command my-guest --hmp \ - "device_add vfio-ap,\ - sysfsdev=3D/sys/devices/vfio_ap/matrix/62177883-f1bb-47f0-914d-32a22= e3a8804,\ - id=3Dhostdev0" + * Must have the same number of APQNs =20 -2. A vfio_ap mediated device can be hot plugged by attaching the qemu moni= tor - to the guest and using the following qemu monitor command: + * Each APQN assigned to the source guest must also be assigned to the + destination guest =20 - (qemu) device_add "vfio-ap,sysfsdev=3D,id=3D" + * Each APQN assigned to the source guest and destination guest must refe= rence + a queue with compatible hardware capabilities: =20 - For example, to plug the vfio_ap mediated device - 62177883-f1bb-47f0-914d-32a22e3a8804 into the guest with the device-= id - hostdev0: ++--------------+----------------------------------------------------------= -----+ +| Hardware | Description = | +| Capabilities | = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| facilities | * AP special command facility (APSC) = | +| | * AP 4096-bit ME PKU commands facility (AP4KM) = | +| | * AP 4096-bit CRT PKU commands (AP4KC) = | ++--------------+----------------------------------------------------------= -----+ +| mode | * CCA-mode = | +| | * Accelerator-mode = | +| | * XCP-mode (EP11) = | ++--------------+----------------------------------------------------------= -----+ +| AP extended | APXA installed = | +| addressing | = | ++--------------+----------------------------------------------------------= -----+ +| command | Command filtering available = | +| filtering | = | ++--------------+----------------------------------------------------------= -----+ +| functional | * Full native card function = | +| capabilities | * Only stateless functions = | ++--------------+----------------------------------------------------------= -----+ +| secure | The guest running on the source host can not have any que= ues | +| execution | bound or associated with it = | ++--------------+----------------------------------------------------------= -----+ +| AP type | * No AP type = | +| | * PCICC (Leeds-2) = | +| | * PCICA (Leeds-2 Lite) = | +| | * PCIXCC = | +| | * CEX2A = | +| | * CEX2C = | +| | * CEX3A = | +| | * CEX3C = | +| | * CEX4S = | +| | * CEX5S = | +| | * CEX6S = | +| | * CEX7S = | +| | * CEX8S = | +| | = | +| | Note: The AP type on the source and destination guests ca= n | +| | differ if the queue passed through to the target gu= est | +| | is a newer model (backwards compatible) = | ++--------------+----------------------------------------------------------= -----+ =20 - (QEMU) device-add "vfio-ap,\ - sysfsdev=3D/sys/devices/vfio_ap/matrix/62177883-f1bb-47f0-914d-32= a22e3a8804,\ - id=3Dhostdev0" +Enabling and disabling live guest migration +------------------------------------------- +By default, live guest migration will be disabled for guests that use cryp= to +devices. A r/w sysfs 'migratable' attribute for each mediated device is pr= ovided +to enable/disable live guest migration for the guest to which the mediated +device is attached. The valid values for this attribute are 1 (enable) and +0 (disable). + +To enable live migration: + + echo 1 /sys/bus/mdev/devices/$UUID/migratable + +To disable live migration: + + echo 0 /sys/bus/mdev/devices/$UUID/migratable + +The 'migratable' attribute allows migration to be dynamically enabled or +disabled for the guest to which the mediated device is attached; however, +if migration of the vfio-ap device is already in progress, the operation w= ill +be rejected with a 'Device or resource busy' message. + +Live guest migration failures due to AP configuration errors +------------------------------------------------------------ +The VFIO AP mediated device is not used to provide userspace with direct a= ccess +to a device as is the case with other devices that use the VFIO framework = to +pass them through to a guest. The sole purpose of the VFIO AP mediated dev= ice +is to manage an AP configuration for a guest. An AP configuration is compr= ised +of the AP adapter IDs (APID), AP queue indexes (APQI) and domain numbers o= f the +control domains to which a guest will be granted access. Once the VFIO AP +mediated device is attached to the guest, its AP configuration is set by t= he +vfio_ap device driver. Once set, all access to the AP devices is handled +by the s390 Interpretive Execution facility; in other words, the vfio_ap d= evice +driver plays no role in providing direct access to these AP devices. + +The only role that the vfio_ap device driver plays in the migration proces= s is +to verify that the AP configuration for the source guest is compatible wit= h the +AP configuration of the destination guest. Incompatibility will result in = a live +guest migration failure. This section describes how to debug this type of +failure. + +The destination host is missing the mediated device with the same name as = the +mdev attached to the source guest +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ + +**Source host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | *error: device not found: mediated device '$UUID' not fou= nd* | ++--------------+----------------------------------------------------------= ----------+ + +The source guest is not enabled for migration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +**Source host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | *error: Requested operation is not valid: = | +| | cannot migrate domain: $UUID: Migration is disabled for V= FIO | +| | device* = | ++--------------+----------------------------------------------------------= ----------+ + + +The AP configuration of the source and destination guests are not compatib= le +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~ +**Source host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | *error: operation failed: job 'migration in' failed: load= of | +| | migration failed: Bad address* = | ++--------------+----------------------------------------------------------= ----------+ +| Kernel log: | N/A = | ++--------------+----------------------------------------------------------= ----------+ +| QEMU log: | *initiating migration* = | +| | = | +| | *qemu-system-s390x: Sibling indicated error 1* = | ++--------------+----------------------------------------------------------= ----------+ + +**Destination host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | N/A = | ++--------------+----------------------------------------------------------= ----------+ +| Kernel log: | *vfio_ap_mdev $UUID: Migration failed: Source and target = queues | +| | ($APQN) are not compatible* = | +| | = | +| | The message above will be followed by one or more message= s | +| | enumerating the incompatible features; for example: = | +| | = | +| | *vfio_ap_mdev $UUID: APSC facility installed in source qu= eue $APQN*| +| | = | +| | *vfio_ap_mdev $UUID: APSC facility not installed in targe= t queue | +| | $APQN* = | +| | = | +| | *AP type of source ($APTYPE) not compatible with target (= $APTYPE)* | ++--------------+----------------------------------------------------------= ----------+ +| QEMU log: | *initiating migration* = | +| | = | +| | *qemu-system-s390x: error while loading state section id = ...* | +| | = | +| | *shutting down, reason=3Dfailed* = | +| | = | +| | *terminating on signal 15 from pid 1196 (/usr/sbin/virtqe= mud)* | ++--------------+----------------------------------------------------------= ----------+ + +The AP configuration of the source guest has more APQNS than the destinati= on guest +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~ +**Source host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | *error: operation f1e166ee77e6failed: job 'migration in' = failed: load of | +| | migration failed: Input/output error* = | ++--------------+----------------------------------------------------------= ----------+ +| Kernel log: | N/A = | ++--------------+----------------------------------------------------------= ----------+ +| QEMU log: | *initiating migration* = | +| | = | +| | *qemu-system-s390x: Sibling indicated error 1* = | ++--------------+----------------------------------------------------------= ----------+ + +**Destination host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | N/A = | ++--------------+----------------------------------------------------------= ----------+ +| Kernel log: | *vfio_ap_mdev $UUID: = | +| | migration failed: source guest's AP config size (xx) larg= er than | +| | target's (yy)* = | ++--------------+----------------------------------------------------------= ----------+ +| QEMU log: | *initiating migration* = | +| | = | +| | *qemu-system-s390x: error while loading state section id = ...* | +| | = | +| | *shutting down, reason=3Dfailed* = | +| | = | +| | *terminating on signal 15 from pid 1196 (/usr/sbin/virtqe= mud)* | ++--------------+----------------------------------------------------------= ----------+ + +The AP configuration of the source guest has fewer APQNS than the destinat= ion guest +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~ +**Source host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | *error: operation failed: job 'migration in' failed: load= of | +| | migration failed: No such device* = | ++--------------+----------------------------------------------------------= ----------+ +| Kernel log: | N/A = | ++--------------+----------------------------------------------------------= ----------+ +| QEMU log: | *initiating migration* = | +| | = | +| | *qemu-system-s390x: Sibling indicated error 1* = | ++--------------+----------------------------------------------------------= ----------+ + +**Destination host** + ++--------------+----------------------------------------------------------= ----------+ +| Log | Message = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ +| Console log: | N/A = | ++--------------+----------------------------------------------------------= ----------+ +| Kernel log: | *vfio_ap_mdev $UUID: = | +| | migration failed: number of queues on source (x) and targ= et (y) | +| | guests differ* = | ++--------------+----------------------------------------------------------= ----------+ +| QEMU log: | *initiating migration* = | +| | = | +| | *qemu-system-s390x: error while loading state section id = ...* | +| | = | +| | *shutting down, reason=3Dfailed* = | +| | = | +| | *terminating on signal 15 from pid 1196 (/usr/sbin/virtqe= mud)* | ++--------------+----------------------------------------------------------= ----------+ --=20 2.52.0