From nobody Sat Feb 7 23:55:00 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 8685C133414; Wed, 6 Mar 2024 14:08:50 +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=1709734133; cv=none; b=upvTmFOThbhPl8xD2A2Zp05JIeTGUQ4hFOmxlW6ieCh7EwAcCS7zowz/1gJYpTqN97/T1JVukhvosqTZ8HEmIYLHHzGj0HXuRLTbnA+X4I8LUqyPrEv95iLVi0rQAI52QYNdLCMccEyfOXDQvVUhUk4HltCYGibojUSmF3ONSEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709734133; c=relaxed/simple; bh=VS1AQhdQTxNirNpomKjqTD6WT1P/vvqx1Hx55sOh2ko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIPT+Q3ZKaG9gkRt1x/4S+jPE4Je95HB8BuWTAhLuTL0RX3JjJmNfqYf1P9atJZN47Xi2r2Xu87+2VhPacWrutpdEPpJk+9LqDTp04WIC42aVtR5CLya+hS1JRwEb4JxgL6ngTacAQejNEvdCFcVr/C5mgNc+OHGcnsWv3nLDEQ= 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=Zxi2LqBx; 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="Zxi2LqBx" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 426E8dxb012908; Wed, 6 Mar 2024 14:08:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=f5V34d+v+9WtCrL/6crwi8C/ZZrO1PefzMKrgvPQbDI=; b=Zxi2LqBxiNr10bOIh3S3OHxRr269/Mq64bJcXzy8mwoIQq01O1izZktrGGAsUY21GuyU NKSnE7erTa5EHYsHtaP3wo97PsR90VE8Kkte8XXU67MFWYB/drRT9gEMp3U7W1dUsYiO ncCEczkTI9WHky86aHtPrwTwrqKfcly4UzQ5KYKFhBLmXOV4h0S8ZGlWRgb/85xjgDvh DLJeURQmlyncGyYP2djZCwsrzPpCuk5aXF3FSl9htCfL+gM3ieGM1VMd4bqC9dEq98FU sMrd3ZfnaVw170Cl+NA+2FdgfOYJPZSkl6nsKzWSH6ST41tThdq4oddaRaBf0zp2CHF8 Ng== 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 3wpsyxg080-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:49 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 426Cmpuf025387; Wed, 6 Mar 2024 14:08:48 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wmetyq853-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:48 +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 426E8jdl38404408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Mar 2024 14:08:47 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 143B458068; Wed, 6 Mar 2024 14:08:45 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89B7058067; Wed, 6 Mar 2024 14:08:44 +0000 (GMT) Received: from jason-laptop.home.arpa (unknown [9.61.164.86]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 6 Mar 2024 14:08:44 +0000 (GMT) From: "Jason J. Herne" To: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, akrowiak@linux.ibm.com, borntraeger@de.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com Subject: [PATCH v2 1/5] s390/ap: Externalize AP bus specific bitmap reading function Date: Wed, 6 Mar 2024 09:08:39 -0500 Message-ID: <20240306140843.10782-2-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240306140843.10782-1-jjherne@linux.ibm.com> References: <20240306140843.10782-1-jjherne@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: 4Yx-_XQB6pBNpnOZwbZB8iz9kuqRX4B3 X-Proofpoint-GUID: 4Yx-_XQB6pBNpnOZwbZB8iz9kuqRX4B3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-06_08,2024-03-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 phishscore=0 suspectscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403060113 Content-Type: text/plain; charset="utf-8" Rename hex2bitmap() to ap_hex2bitmap() and export it for external use. This function will be used by the implementation of the vfio-ap queue_configuration sysfs attribute. Signed-off-by: Jason J. Herne Reviewed-by: Tony Krowiak Reviewed-by: Harald Freudenberger Tested-by: Matthew Rosato --- drivers/s390/crypto/ap_bus.c | 13 +++---------- drivers/s390/crypto/ap_bus.h | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index f46dd6abacd7..5d8e379eff44 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -1035,15 +1035,7 @@ void ap_bus_cfg_chg(void) ap_bus_force_rescan(); } =20 -/* - * hex2bitmap() - parse hex mask string and set bitmap. - * Valid strings are "0x012345678" with at least one valid hex number. - * Rest of the bitmap to the right is padded with 0. No spaces allowed - * within the string, the leading 0x may be omitted. - * Returns the bitmask with exactly the bits set as given by the hex - * string (both in big endian order). - */ -static int hex2bitmap(const char *str, unsigned long *bitmap, int bits) +int ap_hex2bitmap(const char *str, unsigned long *bitmap, int bits) { int i, n, b; =20 @@ -1070,6 +1062,7 @@ static int hex2bitmap(const char *str, unsigned long = *bitmap, int bits) return -EINVAL; return 0; } +EXPORT_SYMBOL(ap_hex2bitmap); =20 /* * modify_bitmap() - parse bitmask argument and modify an existing @@ -1135,7 +1128,7 @@ static int ap_parse_bitmap_str(const char *str, unsig= ned long *bitmap, int bits, rc =3D modify_bitmap(str, newmap, bits); } else { memset(newmap, 0, size); - rc =3D hex2bitmap(str, newmap, bits); + rc =3D ap_hex2bitmap(str, newmap, bits); } return rc; } diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h index 98814839ef30..954f8d36c2d9 100644 --- a/drivers/s390/crypto/ap_bus.h +++ b/drivers/s390/crypto/ap_bus.h @@ -343,6 +343,28 @@ int ap_parse_mask_str(const char *str, unsigned long *bitmap, int bits, struct mutex *lock); =20 +/* + * ap_hex2bitmap() - Convert a string containing a hexadecimal number (str) + * into a bitmap (bitmap) with bits set that correspond to the bits repres= ented + * by the hex string. Input and output data is in big endian order. + * + * str - Input hex string of format "0x1234abcd". The leading "0x" is opti= onal. + * At least one digit is required. Must be large enough to hold the number= of + * bits represented by the bits parameter. + * + * bitmap - Pointer to a bitmap. Upon successful completion of this functi= on, + * this bitmap will have bits set to match the value of str. If bitmap is = longer + * than str, then the rightmost bits of bitmap are padded with zeros. Must= be + * large enough to hold the number of bits represented by the bits paramet= er. + * + * bits - Length, in bits, of the bitmap represented by str. Must be a mul= tiple + * of 8. + * + * Returns: 0 on success + * -EINVAL If str format is invalid or bits is not a multiple= of 8. + */ +int ap_hex2bitmap(const char *str, unsigned long *bitmap, int bits); + /* * Interface to wait for the AP bus to have done one initial ap bus * scan and all detected APQNs have been bound to device drivers. --=20 2.41.0 From nobody Sat Feb 7 23:55:00 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 EAD36133425; Wed, 6 Mar 2024 14:08:50 +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=1709734132; cv=none; b=SaMqu4WmrTL7tq+7RVh/+xDUqYxhCmlHviVJPzQSnRc4/+SouCtOmpwH8wYPxVxlS7qLOiHApCSnokGfxnXDHDCHfl1GR7iGYUfZZiCJbrM/R+hZj0irjvVbZWdtabY95WOqvJgjv4ba04vG6nsitOOH5SnuHvuzyieSELx6pik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709734132; c=relaxed/simple; bh=lt6br/zcsf0BxVFb9DI9HA9gGx29f9KmnuXhNw86vjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TyXV8LREWxLEzB2hzQKT7CiGhD3R/CvF+lDA2Q2vUmrwERCoT3YAX5r53kmIzsz+G+JdYG3PLkVCn/iW7L8OzM/DdcOSvRwD0mf/d5sOxy3c0dU2vHuprrkIjqcNNF40MO4S7DM3iA1I5sSn2qQRjt7CgXPwlOABPCp+QCmVtyI= 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=fNfvkpxv; 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="fNfvkpxv" Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 426E3RCj020066; Wed, 6 Mar 2024 14:08:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=wueyJZ4PPou/jHHQ7D/OZdheN15Z6RQh96Oj72IlGak=; b=fNfvkpxvWe9XX+zNHA23VUNqE1poJ9K+HM+TLl4WSGSbazeaXr4VqpuVFMc8o2bhqU70 3y7ywdytIPR2qda5VNh6dF1jzU3hkcZSxvWCA2b0LhtvpkQwt/JVvw1CUuWrJ/9j+rP7 Uckj4nZJNWO9Bl1j0d2Jb/KevCxcZTFy3rArqFDDMkG3oJyAC2qbWcty3rmW56phJeVB P4x2w+vdP9YYvA+DmN34CwxQoyPD8hEjt0wK5F7op02Idh322GadbYY5GElG/+z+WkL6 IHuHZTrnuVPJlnaSS4kVA3ZusAtpv/Q4jredQZCG9BULej/GJJZvpQrVzjpdpVxcV4vV pQ== 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 3wpswn8f1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:49 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 426BxKZo024193; Wed, 6 Mar 2024 14:08:49 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wpjwsab60-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:49 +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 426E8j7033620470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Mar 2024 14:08:48 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B07E758070; Wed, 6 Mar 2024 14:08:45 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3097F58071; Wed, 6 Mar 2024 14:08:45 +0000 (GMT) Received: from jason-laptop.home.arpa (unknown [9.61.164.86]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 6 Mar 2024 14:08:45 +0000 (GMT) From: "Jason J. Herne" To: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, akrowiak@linux.ibm.com, borntraeger@de.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com Subject: [PATCH v2 2/5] s390/vfio-ap: Add sysfs attr, queue_configuration, to export mdev state Date: Wed, 6 Mar 2024 09:08:40 -0500 Message-ID: <20240306140843.10782-3-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240306140843.10782-1-jjherne@linux.ibm.com> References: <20240306140843.10782-1-jjherne@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: zkVvyfoaZU-Osqo6iQDpCOkKyX8yt1GR X-Proofpoint-ORIG-GUID: zkVvyfoaZU-Osqo6iQDpCOkKyX8yt1GR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-06_08,2024-03-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 phishscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403060113 Content-Type: text/plain; charset="utf-8" Add ap_config sysfs attribute. This will provide the means for setting or displaying the adapters, domains and control domains assigned to the vfio-ap mediated device in a single operation. This sysfs attribute is comprised of three masks: One for adapters, one for domains, and one for control domains. This attribute is intended to be used by mdevctl to query a vfio-ap mediated device's state. Signed-off-by: Jason J. Herne Reviewed-by: Tony Krowiak Tested-by: Matthew Rosato --- drivers/s390/crypto/vfio_ap_ops.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index 983b3b16196c..b1c1dc0233e1 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1557,6 +1557,32 @@ static ssize_t guest_matrix_show(struct device *dev, } static DEVICE_ATTR_RO(guest_matrix); =20 +static ssize_t write_ap_bitmap(unsigned long *bitmap, char *buf, int offse= t, char sep) +{ + return sysfs_emit_at(buf, offset, "0x%016lx%016lx%016lx%016lx%c", + bitmap[0], bitmap[1], bitmap[2], bitmap[3], sep); +} + +static ssize_t ap_config_show(struct device *dev, struct device_attribute = *attr, + char *buf) +{ + struct ap_matrix_mdev *matrix_mdev =3D dev_get_drvdata(dev); + int idx =3D 0; + + idx +=3D write_ap_bitmap(matrix_mdev->matrix.apm, buf, idx, ','); + idx +=3D write_ap_bitmap(matrix_mdev->matrix.aqm, buf, idx, ','); + idx +=3D write_ap_bitmap(matrix_mdev->matrix.adm, buf, idx, '\n'); + + return idx; +} + +static ssize_t ap_config_store(struct device *dev, struct device_attribute= *attr, + const char *buf, size_t count) +{ + return count; +} +static DEVICE_ATTR_RW(ap_config); + static struct attribute *vfio_ap_mdev_attrs[] =3D { &dev_attr_assign_adapter.attr, &dev_attr_unassign_adapter.attr, @@ -1564,6 +1590,7 @@ static struct attribute *vfio_ap_mdev_attrs[] =3D { &dev_attr_unassign_domain.attr, &dev_attr_assign_control_domain.attr, &dev_attr_unassign_control_domain.attr, + &dev_attr_ap_config.attr, &dev_attr_control_domains.attr, &dev_attr_matrix.attr, &dev_attr_guest_matrix.attr, --=20 2.41.0 From nobody Sat Feb 7 23:55:00 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 EA507133983; Wed, 6 Mar 2024 14:08:51 +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=1709734133; cv=none; b=bzB27EDFxqxA1xf9kVEjVCRwjG8svpSU4tTiVCAbIvHk14iP/2R+UmZxOuuWKDkazIIxU0pgLrCn46bJl83SPlVkwaMskzsF4Z1IGwOw1LF00R5abKu1m8enEAn1gyukNmVlXszzyYoRVkjwTbyBJw4K/gsuJ5xVbigxPdHNRjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709734133; c=relaxed/simple; bh=4IID6LPN9K8zYIsFYymwirnkhJdBoOJSJ4xLr0OLViU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F3GZ7lCDJ78mMDbMKBJ+tpeWZ59SDNKczgzsVCM7ox8WElSPWE/mVDcKDmlIsCq49qGRbIvMdfLK17qt1nnw006aBwZ0K2JxmwTAhFFnFeWmB/bE8IAXE58g7n/01NirBshZ6XhHK0ByZxBz9V4AdlCF7AgyPK6QDweuL8Jw1PE= 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=qE8yZ4xI; 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="qE8yZ4xI" Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 426E8Zt2016405; Wed, 6 Mar 2024 14:08:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=l9TT7zLQfLtl5v9k6D80hIILIygBrOzp5/OnDDCsHmQ=; b=qE8yZ4xIFWLIykC/tNRu7OP4wPpt14sSyQlYcNQqOAdbV2yMGJfCLXjIAlX9Fy4idGww clnZAIrby33hT0Tt/05lqv6yJ4C8iwM6tp2ntZYmcaoo3pR7eyDAY8i7BP80Ogug/J0Z /aZDImCDNLrX2z47Cg5i2En+4jfBSEKOUDgo9Bs/VnbFeZZGX7OCiWaoQrRMtj0azKBJ ko3QQLoOFWDQX5YvDhc9KDqGPRoQdy8gcYloXPVvtMZbl2HMdpsoJeh6kiecylvrWpZW X54tQrHoeb0n0jpEETh9IFo/zMca2pn8GIqjEz6e1PQjJIjj5FAHSdlxDvRme4l7YJP8 GA== 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 3wpsyxr065-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:50 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 426BWXef010886; Wed, 6 Mar 2024 14:08:50 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wmh52emjg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:50 +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 426E8kMw32309742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Mar 2024 14:08:48 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DAD858065; Wed, 6 Mar 2024 14:08:46 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB02E58071; Wed, 6 Mar 2024 14:08:45 +0000 (GMT) Received: from jason-laptop.home.arpa (unknown [9.61.164.86]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 6 Mar 2024 14:08:45 +0000 (GMT) From: "Jason J. Herne" To: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, akrowiak@linux.ibm.com, borntraeger@de.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com Subject: [PATCH v2 3/5] s390/vfio-ap: Ignore duplicate link requests in vfio_ap_mdev_link_queue Date: Wed, 6 Mar 2024 09:08:41 -0500 Message-ID: <20240306140843.10782-4-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240306140843.10782-1-jjherne@linux.ibm.com> References: <20240306140843.10782-1-jjherne@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: ZcP-uevQ6_0GbRyoYZ96JNMcetMVJCEy X-Proofpoint-ORIG-GUID: ZcP-uevQ6_0GbRyoYZ96JNMcetMVJCEy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-06_08,2024-03-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403060113 Content-Type: text/plain; charset="utf-8" vfio_ap_mdev_link_queue is changed to detect if a matrix_mdev has already linked the given queue. If so, it bails out. Signed-off-by: Jason J. Herne Reviewed-by: Tony Krowiak Tested-by: Matthew Rosato --- drivers/s390/crypto/vfio_ap_ops.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index b1c1dc0233e1..259130347d00 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -781,10 +781,11 @@ static int vfio_ap_mdev_probe(struct mdev_device *mde= v) static void vfio_ap_mdev_link_queue(struct ap_matrix_mdev *matrix_mdev, struct vfio_ap_queue *q) { - if (q) { - q->matrix_mdev =3D matrix_mdev; - hash_add(matrix_mdev->qtable.queues, &q->mdev_qnode, q->apqn); - } + if (!q || vfio_ap_mdev_get_queue(matrix_mdev, q->apqn)) + return; + + q->matrix_mdev =3D matrix_mdev; + hash_add(matrix_mdev->qtable.queues, &q->mdev_qnode, q->apqn); } =20 static void vfio_ap_mdev_link_apqn(struct ap_matrix_mdev *matrix_mdev, int= apqn) --=20 2.41.0 From nobody Sat Feb 7 23:55:00 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 2CE9F13398E; Wed, 6 Mar 2024 14:08:52 +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=1709734133; cv=none; b=I7o0XtYFwEBAQFZNnV1Q/N+orXdUA9mj0ZbbjDM6bcJXk4mQ66VCvNnjQxSM6lY3DqE6nVsXIqJlbHECrVbZPWW6yuf6K0Wa+Tdev1v1jIWuxxsVjHwktA8hmT0lCPObVpuE/86KqMUnPZIhE5WRvFoP6I6B8Vn6NmrtNfo+2qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709734133; c=relaxed/simple; bh=djG84eLJvLtXI19d+/zrcsI8LrGuAMIS82AImC5cwXA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UFETtM339rg6Bt8hwzRZtrRbvy2UjIcWPr+PMOTIm9jvXFqkcsV9CGjlGeItokUNhZm1D7ZfLU2jk+mQI+7aKwGSo+kKu6pqd+Q1OS73pWbDiidf2ggpDl7L1iqWM/7f3VBXYf9FRgOYEi/OUGb2ENUNXOuymXPOPiSPJI8O42E= 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=ac30AS//; 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="ac30AS//" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 426E2Deq028566; Wed, 6 Mar 2024 14:08:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=hopZOzOyVgh8k0XusFRldMm99GHKfa3bt0n+/4LrcGI=; b=ac30AS//MJbUuj1YIPtgITw8+DUmN1GoMIlizZpaWqUJ0XZ3uXof67f5+rdBiXX3RKiS gnXX1BhxjI+kOgHwvx5wd2a+/pKXY/fAYMvqgi/tjQ+rKbfTMJftnU1LBT/fPbciANro +yG6SzcDxr7ykIwoesnp0O24069l5beSvZ/Des5cnUza/c1KSMevCfAwBo6Z6HK1eMlx Uqtr9XXjaGsLHggr3ajpWURDw4Ds/tKA/6I0N5YXXYelA5TFx+J8rKFB44HFum8hlL2w cV/lE3rRiGGFhacyHuBB0f/Rx3sOSijBJ4+LOVap5wxZzNHSGRcAq16xY0WrVC5MVyWU zA== 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 3wpsw28dkt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:51 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 426C3d3J024166; Wed, 6 Mar 2024 14:08:50 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wpjwsab63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:50 +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 426E8lak24707334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Mar 2024 14:08:49 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0324558052; Wed, 6 Mar 2024 14:08:47 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 790345806B; Wed, 6 Mar 2024 14:08:46 +0000 (GMT) Received: from jason-laptop.home.arpa (unknown [9.61.164.86]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 6 Mar 2024 14:08:46 +0000 (GMT) From: "Jason J. Herne" To: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, akrowiak@linux.ibm.com, borntraeger@de.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com Subject: [PATCH v2 4/5] s390/vfio-ap: Add write support to sysfs attr ap_config Date: Wed, 6 Mar 2024 09:08:42 -0500 Message-ID: <20240306140843.10782-5-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240306140843.10782-1-jjherne@linux.ibm.com> References: <20240306140843.10782-1-jjherne@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: 8UNMWBDpQ6CqbqvI15Q1zy7U1ZUKNK-Z X-Proofpoint-ORIG-GUID: 8UNMWBDpQ6CqbqvI15Q1zy7U1ZUKNK-Z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-06_08,2024-03-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 phishscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403060113 Content-Type: text/plain; charset="utf-8" Allow writing a complete set of masks to ap_config. Doing so will cause the vfio-ap driver to replace the vfio-ap mediated device's entire state with the given set of masks. If the given state cannot be set, then no changes are made to the vfio-ap mediated device. The format of the data written to ap_config is as follows: {amask},{dmask},{cmask}\n \n is a newline character. amask, dmask, and cmask are masks identifying which adapters, domains, and control domains should be assigned to the mediated device. The format of a mask is as follows: 0xNN..NN Where NN..NN is 64 hexadecimal characters representing a 256-bit value. The leftmost (highest order) bit represents adapter/domain 0. For an example set of masks that represent your mdev's current configuration, simply cat ap_config. This attribute is intended to be used by an mdevctl callout script supporting the mdev type vfio_ap-passthrough to atomically update a vfio-ap mediated device's state. Signed-off-by: Jason J. Herne Tested-by: Matthew Rosato --- drivers/s390/crypto/vfio_ap_ops.c | 172 ++++++++++++++++++++++++-- drivers/s390/crypto/vfio_ap_private.h | 6 +- 2 files changed, 162 insertions(+), 16 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index 259130347d00..c382e46f620f 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1106,19 +1106,22 @@ static void vfio_ap_mdev_unlink_adapter(struct ap_m= atrix_mdev *matrix_mdev, } } =20 -static void vfio_ap_mdev_hot_unplug_adapter(struct ap_matrix_mdev *matrix_= mdev, - unsigned long apid) +static void vfio_ap_mdev_hot_unplug_adapters(struct ap_matrix_mdev *matrix= _mdev, + unsigned long *apids) { struct vfio_ap_queue *q, *tmpq; struct list_head qlist; + unsigned long apid; =20 INIT_LIST_HEAD(&qlist); - vfio_ap_mdev_unlink_adapter(matrix_mdev, apid, &qlist); =20 - if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm)) { - clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); - vfio_ap_mdev_update_guest_apcb(matrix_mdev); + for_each_set_bit_inv(apid, apids, AP_DEVICES) { + vfio_ap_mdev_unlink_adapter(matrix_mdev, apid, &qlist); + + if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm)) + clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); } + vfio_ap_mdev_update_guest_apcb(matrix_mdev); =20 vfio_ap_mdev_reset_qlist(&qlist); =20 @@ -1128,6 +1131,15 @@ static void vfio_ap_mdev_hot_unplug_adapter(struct a= p_matrix_mdev *matrix_mdev, } } =20 +static void vfio_ap_mdev_hot_unplug_adapter(struct ap_matrix_mdev *matrix_= mdev, + unsigned long apid) +{ + DECLARE_BITMAP(apids, AP_DEVICES); + + set_bit_inv(apid, apids); + vfio_ap_mdev_hot_unplug_adapters(matrix_mdev, apids); +} + /** * unassign_adapter_store - parses the APID from @buf and clears the * corresponding bit in the mediated matrix device's APM @@ -1288,19 +1300,22 @@ static void vfio_ap_mdev_unlink_domain(struct ap_ma= trix_mdev *matrix_mdev, } } =20 -static void vfio_ap_mdev_hot_unplug_domain(struct ap_matrix_mdev *matrix_m= dev, - unsigned long apqi) +static void vfio_ap_mdev_hot_unplug_domains(struct ap_matrix_mdev *matrix_= mdev, + unsigned long *apqis) { struct vfio_ap_queue *q, *tmpq; struct list_head qlist; + unsigned long apqi; =20 INIT_LIST_HEAD(&qlist); - vfio_ap_mdev_unlink_domain(matrix_mdev, apqi, &qlist); =20 - if (test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { - clear_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm); - vfio_ap_mdev_update_guest_apcb(matrix_mdev); + for_each_set_bit_inv(apqi, apqis, AP_DOMAINS) { + vfio_ap_mdev_unlink_domain(matrix_mdev, apqi, &qlist); + + if (test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) + clear_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm); } + vfio_ap_mdev_update_guest_apcb(matrix_mdev); =20 vfio_ap_mdev_reset_qlist(&qlist); =20 @@ -1310,6 +1325,15 @@ static void vfio_ap_mdev_hot_unplug_domain(struct ap= _matrix_mdev *matrix_mdev, } } =20 +static void vfio_ap_mdev_hot_unplug_domain(struct ap_matrix_mdev *matrix_m= dev, + unsigned long apqi) +{ + DECLARE_BITMAP(apqis, AP_DOMAINS); + + set_bit_inv(apqi, apqis); + vfio_ap_mdev_hot_unplug_domains(matrix_mdev, apqis); +} + /** * unassign_domain_store - parses the APQI from @buf and clears the * corresponding bit in the mediated matrix device's AQM @@ -1577,10 +1601,132 @@ static ssize_t ap_config_show(struct device *dev, = struct device_attribute *attr, return idx; } =20 +/* Number of characters needed for a complete hex mask representing the bi= ts in .. */ +#define AP_DEVICES_STRLEN (AP_DEVICES/4 + 3) +#define AP_DOMAINS_STRLEN (AP_DOMAINS/4 + 3) +#define AP_CONFIG_STRLEN (AP_DEVICES_STRLEN + 2 * AP_DOMAINS_STRLEN) + +static int parse_bitmap(char **strbufptr, unsigned long *bitmap, int nbits) +{ + char *curmask; + + curmask =3D strsep(strbufptr, ",\n"); + if (!curmask) + return -EINVAL; + + bitmap_clear(bitmap, 0, nbits); + return ap_hex2bitmap(curmask, bitmap, nbits); +} + +static int ap_matrix_length_check(struct ap_matrix_mdev *matrix_mdev) +{ + unsigned long bit; + + for_each_set_bit_inv(bit, matrix_mdev->matrix.apm, AP_DEVICES) { + if (bit > matrix_mdev->matrix.apm_max) + return -ENODEV; + } + + for_each_set_bit_inv(bit, matrix_mdev->matrix.aqm, AP_DOMAINS) { + if (bit > matrix_mdev->matrix.aqm_max) + return -ENODEV; + } + + for_each_set_bit_inv(bit, matrix_mdev->matrix.adm, AP_DOMAINS) { + if (bit > matrix_mdev->matrix.adm_max) + return -ENODEV; + } + + return 0; +} + +static void ap_matrix_copy(struct ap_matrix *dst, struct ap_matrix *src) +{ + bitmap_copy(dst->apm, src->apm, AP_DEVICES); + bitmap_copy(dst->aqm, src->aqm, AP_DOMAINS); + bitmap_copy(dst->adm, src->adm, AP_DOMAINS); +} + static ssize_t ap_config_store(struct device *dev, struct device_attribute= *attr, const char *buf, size_t count) { - return count; + struct ap_matrix_mdev *matrix_mdev =3D dev_get_drvdata(dev); + struct ap_matrix m_new, m_old, m_added, m_removed; + DECLARE_BITMAP(apm_filtered, AP_DEVICES); + unsigned long newbit; + char *newbuf, *rest; + int rc =3D count; + bool do_update; + + newbuf =3D rest =3D kstrndup(buf, AP_CONFIG_STRLEN, GFP_KERNEL); + if (!newbuf) + return -ENOMEM; + + mutex_lock(&ap_perms_mutex); + get_update_locks_for_mdev(matrix_mdev); + + /* Save old state */ + ap_matrix_copy(&m_old, &matrix_mdev->matrix); + + if (parse_bitmap(&rest, m_new.apm, AP_DEVICES) || + parse_bitmap(&rest, m_new.aqm, AP_DOMAINS) || + parse_bitmap(&rest, m_new.adm, AP_DOMAINS)) { + rc =3D -EINVAL; + goto out; + } + + bitmap_andnot(m_removed.apm, m_old.apm, m_new.apm, AP_DEVICES); + bitmap_andnot(m_removed.aqm, m_old.aqm, m_new.aqm, AP_DOMAINS); + bitmap_andnot(m_added.apm, m_new.apm, m_old.apm, AP_DEVICES); + bitmap_andnot(m_added.aqm, m_new.aqm, m_old.aqm, AP_DOMAINS); + + /* Need new bitmaps in matrix_mdev for validation */ + ap_matrix_copy(&matrix_mdev->matrix, &m_new); + + /* Ensure new state is valid, else undo new state */ + rc =3D vfio_ap_mdev_validate_masks(matrix_mdev); + if (rc) { + ap_matrix_copy(&matrix_mdev->matrix, &m_old); + goto out; + } + rc =3D ap_matrix_length_check(matrix_mdev); + if (rc) { + ap_matrix_copy(&matrix_mdev->matrix, &m_old); + goto out; + } + rc =3D count; + + /* Need old bitmaps in matrix_mdev for unplug/unlink */ + ap_matrix_copy(&matrix_mdev->matrix, &m_old); + + /* Unlink removed adapters/domains */ + vfio_ap_mdev_hot_unplug_adapters(matrix_mdev, m_removed.apm); + vfio_ap_mdev_hot_unplug_domains(matrix_mdev, m_removed.aqm); + + /* Need new bitmaps in matrix_mdev for linking new adapters/domains */ + ap_matrix_copy(&matrix_mdev->matrix, &m_new); + + /* Link newly added adapters */ + for_each_set_bit_inv(newbit, m_added.apm, AP_DEVICES) + vfio_ap_mdev_link_adapter(matrix_mdev, newbit); + + for_each_set_bit_inv(newbit, m_added.aqm, AP_DOMAINS) + vfio_ap_mdev_link_domain(matrix_mdev, newbit); + + /* filter resources not bound to vfio-ap */ + do_update =3D vfio_ap_mdev_filter_matrix(matrix_mdev, apm_filtered); + do_update |=3D vfio_ap_mdev_filter_cdoms(matrix_mdev); + + /* Apply changes to shadow apbc if things changed */ + if (do_update) { + vfio_ap_mdev_update_guest_apcb(matrix_mdev); + reset_queues_for_apids(matrix_mdev, apm_filtered); + } +out: + release_update_locks_for_mdev(matrix_mdev); + mutex_unlock(&ap_perms_mutex); + kfree(newbuf); + return rc; } static DEVICE_ATTR_RW(ap_config); =20 diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_ap_private.h index 98d37aa27044..437a161c8659 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -75,11 +75,11 @@ extern struct ap_matrix_dev *matrix_dev; */ struct ap_matrix { unsigned long apm_max; - DECLARE_BITMAP(apm, 256); + DECLARE_BITMAP(apm, AP_DEVICES); unsigned long aqm_max; - DECLARE_BITMAP(aqm, 256); + DECLARE_BITMAP(aqm, AP_DOMAINS); unsigned long adm_max; - DECLARE_BITMAP(adm, 256); + DECLARE_BITMAP(adm, AP_DOMAINS); }; =20 /** --=20 2.41.0 From nobody Sat Feb 7 23:55:00 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 8B3E9134721; Wed, 6 Mar 2024 14:08:52 +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=1709734134; cv=none; b=W8UMjJvxZnDzzcN3CRQW27dcZku5LT1sdKseL4zsyniKJetVqrpFega6smnzKJ5X1NFVwMd/z61Qcx9VK615xiI65ms7jQtEnOqAeH9GXCd/pOuiLQy5YSq+Bb1TlW17DmWnAajri4AE3wyRYzSC4mi1jor1E4mQaJLJJzhlK1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709734134; c=relaxed/simple; bh=0zm2X/KDZl63etiI4NfF7/kknQN0paR11/NfnXifv4E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T6XGIiOZ/xNHG6UEEdoPowO+dkBpShYbyDWcqjhOrsS2LL3GOCVcwyYEh+G4PgPCnWDApLMhw4MpDKLqR71FCSimlfOaKRdZTQ5FTj/LqPgSDGtQ9tkAsxmaEegLBoPJQ3ilo5cIACuRHQhtmxFYQ2wyRaUIdACbj4r2NCRkgCU= 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=eXHXngj0; 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="eXHXngj0" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 426DXZTl020959; Wed, 6 Mar 2024 14:08:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=/Pce4az328om0ozWYrHKebq5la97J2ZUIXLIxmMGpFk=; b=eXHXngj0FqVFeuBGEyb6Yk4OrK7PhbNiDgkm256XjSNQgzeK0+kJD6E1pvufQVe2VNeI QSI98MYOVdYVw8Y6gCswvJ7hVuZdUR9dXTphToWizsQGhcK9FkpjAxm1SE81Bxgjeb9v tOMckW2HLtEutkZXp41TmmX6FB5qGvdfiRdnEkza9GHkoBImGYysCrrnizhRE56Z7zKg YuhEKgX1AcuWRjMpejEvx9b0pcHSzxm48ujyAQ/+Iu6lIXDpTwsk5sU5SapyPqmhbrwd qsxIenS8c07jEypQexu2hdi6hLEbnPqZqVCBK/05278au8HZHAmEjb6gtgEAJhKmapd2 Vw== 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 3wpsfj1ewb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:51 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 426DHTOZ025366; Wed, 6 Mar 2024 14:08:50 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wmetyq85a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:50 +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 426E8le311928132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Mar 2024 14:08:49 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9ADEC58068; Wed, 6 Mar 2024 14:08:47 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1C48558056; Wed, 6 Mar 2024 14:08:47 +0000 (GMT) Received: from jason-laptop.home.arpa (unknown [9.61.164.86]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 6 Mar 2024 14:08:47 +0000 (GMT) From: "Jason J. Herne" To: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, akrowiak@linux.ibm.com, borntraeger@de.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com Subject: [PATCH v2 5/5] s390: doc: Update doc Date: Wed, 6 Mar 2024 09:08:43 -0500 Message-ID: <20240306140843.10782-6-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240306140843.10782-1-jjherne@linux.ibm.com> References: <20240306140843.10782-1-jjherne@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: aoEAmvhaWnwxiHVGGaSciocZdcgIzaCm X-Proofpoint-GUID: aoEAmvhaWnwxiHVGGaSciocZdcgIzaCm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-06_08,2024-03-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 mlxlogscore=993 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403060113 Content-Type: text/plain; charset="utf-8" fix me Signed-off-by: Jason J. Herne Tested-by: Matthew Rosato --- Documentation/arch/s390/vfio-ap.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/arch/s390/vfio-ap.rst b/Documentation/arch/s390/= vfio-ap.rst index 929ee1c1c940..af5ef60355a2 100644 --- a/Documentation/arch/s390/vfio-ap.rst +++ b/Documentation/arch/s390/vfio-ap.rst @@ -380,6 +380,33 @@ matrix device. control_domains: A read-only file for displaying the control domain numbers assigned = to the vfio_ap mediated device. + ap_config: + A read/write file that, when written to, allows the entire vfio_ap= mediated + device's ap configuration to be replaced in one shot. Three masks = are given, + one for adapters, one for domains, and one for control domains. If= the + given state cannot be set, then no changes are made to the vfio-ap + mediated device. + + The format of the data written to ap_config is as follows: + {amask},{dmask},{cmask}\n + + \n is a newline character. + + amask, dmask, and cmask are masks identifying which adapters, doma= ins, + and control domains should be assigned to the mediated device. + + The format of a mask is as follows: + 0xNN..NN + + Where NN..NN is 64 hexadecimal characters representing a 256-bit v= alue. + The leftmost (highest order) bit represents adapter/domain 0. + + For an example set of masks that represent your mdev's current + configuration, simply cat ap_config. + + This attribute is intended to be used by automation. End users wou= ld be + better served using the respective assign/unassign attributes for + adapters, domains, and control domains. =20 * functions: =20 --=20 2.41.0