From nobody Tue Jul 14 13:54:43 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 1AF1C20DDB; Wed, 13 Mar 2024 20:58:14 +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=1710363498; cv=none; b=GfctUdrE2MCndXJNIi4xN0KSg3eNsrInkcjmOYW9i8wVLjaPtdmDDytk0sIhb9IiqIooYNuXEfwtcXteqn40L0zBfoWGhZmut0VOmVU15VWi4YhMy1m4u4CcBtJCW5DeF3NHmFQHeM5SbolFTa1FEACmHpQGET49FeeOkJywlgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710363498; c=relaxed/simple; bh=Dxc1Y9DEWjmEAUQcAuJqD4/uaanYXhVQFUYqIQzbI+c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YFCFPOU2+LCvtVdSSlxRFWcKIew1SmDoeVz+/4yzBkCh3/jDcjbsjAoxN40CZKVm1Mc8HaslKY30g10GL1J7zt6rYgQSSHRsQ6sQq6UR1F5u45mQwE3JanRH84x/f04L+H9jfOrgF/A5LwRWb1Uw8Nt//24CQCVIQtVYDeWmDPc= 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=Uoua+Hbg; 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="Uoua+Hbg" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42DJsEoC006151; Wed, 13 Mar 2024 20:58:14 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=pfYAziHimuLD6Bq9AnCRElxIv/lJzmInAejaT3HQHeA=; b=Uoua+HbgPEs81pvtd0Ui2j9+zjLsu7ujAx0EvowwxfRFCxz2yAlIJaO/aMcK98RuxNN0 tVRKupJyQWwhMJrF3RL52b2J8jyKLht4m9ldzZZAR2a/FQnTCxdXvvMVAdp6+9SEYxif BNjVLNQYPxPXQXtCf26PJtsyd0k4lz1umJnBiQmn1uqaFpfSqnwuPWnrGZ9cZw8fOeX4 9s3DP4x1ZAoKcG6XSbs3ytuB4zEI987axjRPl39bcl59tTXMEmkRvF/MmDVw8buwkvwG 9bxaiDi3PJuQ6Ac2tlcfXx8PcRNI9lcT1EIzft9hHmVCIF/s3EXUrgllf24UnPvZR9ZK YA== 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 3wue9tvy48-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:13 +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 42DKhk89015539; Wed, 13 Mar 2024 20:58:12 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws2g00pjq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:12 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42DKw96K47186240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 20:58:12 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FE7758056; Wed, 13 Mar 2024 20:58:09 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AB6058060; Wed, 13 Mar 2024 20:58:09 +0000 (GMT) Received: from jason-laptop.ibmuc.com (unknown [9.61.59.128]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 20:58:08 +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 v3 1/5] s390/ap: Externalize AP bus specific bitmap reading function Date: Wed, 13 Mar 2024 16:58:03 -0400 Message-ID: <20240313205807.30554-2-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240313205807.30554-1-jjherne@linux.ibm.com> References: <20240313205807.30554-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: ljRXpmf6wj9VnMP06ZwT3BA_d2Yb722i X-Proofpoint-GUID: ljRXpmf6wj9VnMP06ZwT3BA_d2Yb722i 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-13_09,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 phishscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130160 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 ap_config sysfs attribute. Signed-off-by: Jason J. Herne Reviewed-by: Tony Krowiak Reviewed-by: Harald Freudenberger --- 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 cce0bafd4c92..1be07197eda3 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -1068,15 +1068,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 @@ -1103,6 +1095,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 @@ -1168,7 +1161,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 59c7ed49aa02..1db9597509da 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 Tue Jul 14 13:54:43 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 75C8946556; Wed, 13 Mar 2024 20:58: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=1710363497; cv=none; b=NkEZZgQ2VL4fKEaxLoIzXFLm5SV/W0YtGCkbMyP9M86oiIsjhDpO/BAqwqoq0ZkDsb4bmU6fOnk+FogEBZieY0IWg8LSeBlW0C6mz7kEhwcQn3Sg1ghR7oXfi+XcHG5jOv6LFwFsHXk2h2YNPacGCuRhkPC021CB4QQlA+wZ/Is= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710363497; c=relaxed/simple; bh=5c6guQ2FUVHHwyr6ZU/rcOyICNnEuFH5vN8FXZhfREY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BOD9LWHV4Mvvuzcw33yunWGgIJMVuWDBNCIr7UOlPY6Y0gC3hrsLylQExzf4yy8127EqYTKldsjJIxGHPTxtCik/qmO3lDZ5kGpfSKu7UCzwrBQ0o57DIoNi9YpM3nBMODefjvUJqPKLmlxI3w3Fj3MViaKZJrp4HlXU1V1yG3U= 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=AQcixv3+; 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="AQcixv3+" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42DI20Yw032232; Wed, 13 Mar 2024 20:58:15 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=6XGvqxQKmD74K7o3lJi96exBfyvMPYZq144pIakSGTg=; b=AQcixv3+txJZQDS65VyOll1w+c2Sr7M2w5G1cAZA48fF78Uu/wNWH8UQCKDLCGAy6vmF ADuqkk6Mk9ojF6tKs/9fNXUPGFHGwsRz6quI5xcBBLQISjT07R0pPTbvlrIJNWaI6ljW 8MN5FMDsPnOQ/W6OjuXLjVC0N7nLafxrduP/9TzmBuVW0fWzDr2NM6PalQ+D1rtTF+QA hb5x8bJyNpLK1MBK13H0mBWbTo3+0uyO12lSG3hZA9JAuyB0TgTLFs28c1sMoc8t8c7U KwMF8lQHCXyTbMVXoqLBshaskLXDpqMzmmZRYx18jCQuDwPVUUX5A+0UQAQylSbqqntu qg== 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 3wuh2ft0de-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:14 +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 42DKhk8A015539; Wed, 13 Mar 2024 20:58:13 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws2g00pjs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:13 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42DKwAKq42729908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 20:58:12 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4271058068; Wed, 13 Mar 2024 20:58:10 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACB2158060; Wed, 13 Mar 2024 20:58:09 +0000 (GMT) Received: from jason-laptop.ibmuc.com (unknown [9.61.59.128]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 20:58:09 +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 v3 2/5] s390/vfio-ap: Add sysfs attr, ap_config, to export mdev state Date: Wed, 13 Mar 2024 16:58:04 -0400 Message-ID: <20240313205807.30554-3-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240313205807.30554-1-jjherne@linux.ibm.com> References: <20240313205807.30554-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: Puf4sr_q5p2FzudwFj4d_Pb1UnRPcyqN X-Proofpoint-GUID: Puf4sr_q5p2FzudwFj4d_Pb1UnRPcyqN 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-13_09,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 bulkscore=0 spamscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130160 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 fc169bc61593..e01f53a3c5b7 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1570,6 +1570,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, @@ -1577,6 +1603,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 Tue Jul 14 13:54:43 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 A22774CB35; Wed, 13 Mar 2024 20:58:16 +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=1710363498; cv=none; b=bE5S41utqHJJJwQ2AcoBE+bTEXlluA2AkNFdhDxrKbTz4Vp6NUN5tq6dVL4fnReSATidKC9cauEAKSRNQnXuGPiGm7nI6+2xgbIdOybV5vj6qn0KF344PnDozphSFxMsumzFHHgT4+lSCwMt/FJ1xZRExz8N30ty90cOeLgXyTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710363498; c=relaxed/simple; bh=tSlXTR1QKZXk2pfdOpSseZfCaKNekp47ZScfnD+Fa2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CoCZtrGdXyZe74UvxrKKB29vOPEH/SgiSp9/hkIauM/vFpV2+e1RUp73aqOYeb3mwik4mxNzXYN4Eftasqg5ED+F2BvPHg/WThnNsbbCxRWfZpT8Sp6VEXqexnFNMKHqqNx6VcUvJ8biQ+dGTdqitpa4Jne+TWW1n6DWhJLzxi4= 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=tMIaBCSj; 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="tMIaBCSj" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42DI22mp032526; Wed, 13 Mar 2024 20:58:15 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=Qpf3+bKZA3IFFAh2Zgq/tCvKv4L+adz2xvIinaCNjGg=; b=tMIaBCSjDtyD9a6TFcS2Yt8nvhc1UMlC8ElDX7ZLWtY8nDElVEkZhmtVxoQ+BVh2/fkV vMxNoHJqU8BNjp95EPxvVC09i+0v9RWfE7eHif6XVrjXWD9tBRkHD95ngBBK5/9XS7IF 1wFes6mHMx4a4k1eu4mAOMC+Spu8CLJV+XshdUiTr4QhnE2svWiAfZnA+5fDiyr0b5ci bRsl/E/p5CGVbHZm/RRbLB9IBkReIJsZOOZGHfJIls99+AmOAJyGQNXEYmSIaI/XOl16 ZwTB0GKjfi9rWmD+q2nnCE5RTYsRuJXoai/Oh/x21CSolyGCDiJlDWvbNNY0Ddarp0Cx rA== 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 3wuh2ft0dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:15 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42DKXmuZ018134; Wed, 13 Mar 2024 20:58:14 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ws23tgqr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:14 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42DKwBRQ27722226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 20:58:13 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE5675806C; Wed, 13 Mar 2024 20:58:10 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EBDF58060; Wed, 13 Mar 2024 20:58:10 +0000 (GMT) Received: from jason-laptop.ibmuc.com (unknown [9.61.59.128]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 20:58:10 +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 v3 3/5] s390/vfio-ap: Ignore duplicate link requests in vfio_ap_mdev_link_queue Date: Wed, 13 Mar 2024 16:58:05 -0400 Message-ID: <20240313205807.30554-4-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240313205807.30554-1-jjherne@linux.ibm.com> References: <20240313205807.30554-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: W0uojsw1S5QvGbUSieI5qg1r8ccupXKd X-Proofpoint-GUID: W0uojsw1S5QvGbUSieI5qg1r8ccupXKd 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-13_09,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 bulkscore=0 spamscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130160 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 --- 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 e01f53a3c5b7..1499c2181122 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -794,10 +794,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 Tue Jul 14 13:54:43 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 A537551C59; Wed, 13 Mar 2024 20:58: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=1710363499; cv=none; b=R5L9QEgEavLOO9POx4PrmYoppOdMqV8+0ss1hteIYHsTWoMk8VdMgMCz739zdEF5bay2NibPJT00lM/as/CYoUrTV/ul0a/wryKxDQ7ikueDCIfXUdAUxR77vAg8wijcCN/qJfxOz6jgjdCUm24vbznUux6EdVxg+BlLn3iqVZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710363499; c=relaxed/simple; bh=n3ystnCFLioUEiuBX0bYnYRZNcw9y9+eEiGhFvERGaY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P0puY8pt9JVUNA9f7XVDIf5KosdvmEr9AnZrC3hRzA7n36Kazqo3WoZLwdOmrovxB+SMtJvWColm9vmx1kvycZfT3nnncNaJME4a86G9GJ/8QocQIxEe5LPwy6YFRWkH+uOwb5ICqLmJyDLdEvBu9DDgH4gRJbXV45Mcj59hjXY= 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=Px/APEVs; 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="Px/APEVs" 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 42DJ0WP6010066; Wed, 13 Mar 2024 20:58:16 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=1SVjZHPn2LMUiJvbwnVdGN0yMMFEVh2zgdckZhhGaI8=; b=Px/APEVsiYN2VV1P1/vcCkmcgmU/VG9EUZjwrjqj0ewvAyq6oGQ2PM/u2D/7/+G5qRQE /PIV4SwuPK8IQWS8/huyXMpe0UsRl4a9/tYlZZkWqODSylPL+FvB+YMLYevs1Fhlick5 HXWhR7Pi1w5ZU11O+vaP0FJJFhCa/Q0bjQjMwywCEkC/VJi2iwH8nIUT3QATW47fGwHk 09XMQu4NqOIZNClTHy1879JuCla8kYxDvUKxrfVr4F7xTO6/IaTTroVkIfMrPf8j2OQS i5vXFnfSWTZTxC+2CbYcp4H76CakurzlppU7FCVM+gdUAXt0l8UjDi1d7tt84eW+FB5a 6Q== 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 3wug29k1pt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:15 +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 42DJ5Y1k020446; Wed, 13 Mar 2024 20:58:15 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws3km8c0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:15 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42DKwBwX46530928 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 20:58:14 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A16EE5803F; Wed, 13 Mar 2024 20:58:11 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16A9158060; Wed, 13 Mar 2024 20:58:11 +0000 (GMT) Received: from jason-laptop.ibmuc.com (unknown [9.61.59.128]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 20:58:10 +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 v3 4/5] s390/vfio-ap: Add write support to sysfs attr ap_config Date: Wed, 13 Mar 2024 16:58:06 -0400 Message-ID: <20240313205807.30554-5-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240313205807.30554-1-jjherne@linux.ibm.com> References: <20240313205807.30554-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: nl15GPELR37VgB1MWTr8V7-o6zxtlpCB X-Proofpoint-GUID: nl15GPELR37VgB1MWTr8V7-o6zxtlpCB 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-13_09,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130160 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 matrix masks 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 Reviewed-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 186 ++++++++++++++++++++++++-- drivers/s390/crypto/vfio_ap_private.h | 6 +- 2 files changed, 176 insertions(+), 16 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_a= p_ops.c index 1499c2181122..05b1d311b31f 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -1119,20 +1119,29 @@ 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; + bool apcb_update =3D false; =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); + apcb_update =3D true; + } } =20 + /* Only update apcb if needed to avoid impacting guest */ + if (apcb_update) + vfio_ap_mdev_update_guest_apcb(matrix_mdev); + vfio_ap_mdev_reset_qlist(&qlist); =20 list_for_each_entry_safe(q, tmpq, &qlist, reset_qnode) { @@ -1141,6 +1150,16 @@ 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); + + bitmap_zero(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 @@ -1301,20 +1320,29 @@ 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; + bool apcb_update =3D false; =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); + apcb_update =3D true; + } } =20 + /* Only update apcb if needed to avoid impacting guest */ + if (apcb_update) + vfio_ap_mdev_update_guest_apcb(matrix_mdev); + vfio_ap_mdev_reset_qlist(&qlist); =20 list_for_each_entry_safe(q, tmpq, &qlist, reset_qnode) { @@ -1323,6 +1351,16 @@ 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); + + bitmap_zero(apqis, AP_DEVICES); + 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 @@ -1590,10 +1628,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_overflow_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_overflow_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 Tue Jul 14 13:54:43 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 4249E53390; Wed, 13 Mar 2024 20:58: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=1710363500; cv=none; b=PfjkGCDpT9AZt2Eidgdlr35j2Pe0wVJHs0cC0jzc3lULBN6ZJJTxkJYB3lJ5I6BUWzXkUoNzl19r3Ntl2I3WblU9AfWD+OpbYviYO4UOdo6X0/rAFt99x12q7XCTtFIiFsPZGnr4I7ee+Y4caN60P07gDOEW4uqvRJIqFMzNV6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710363500; c=relaxed/simple; bh=NpFjcNUfQjg6JaWNs+hjX6QA8yWopkHnzplj60Jq23A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SwmImfRSRUtGgdAie6VGegzqhI2tLEfxoT28MWR0YzzoOXPq/Sj7HfnuSHTtHH98NMz2AZiWYIsnVFyU/JyHnS6BFhDmah+BMGuTSHAw1yaOJwCWIdOrjVAD+ud5IxLV4CA+XFUStMM8BatDmtSZYWgO+nO/jyPeUvrxfLKUtLY= 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=cJmdM3H6; 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="cJmdM3H6" 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 42DJ0XDF010221; Wed, 13 Mar 2024 20:58:17 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=dDUKIL4CKAJWHXeBf8m3+sEfmmg46fIcRdtOGVn5uUI=; b=cJmdM3H6QITo230Xq0844UknYHcMCvRuO/jBWBXnpVV0lIWb24qOo5zhaqNXySLjTz5B FuzOYka6pkwz3kn1n80aSO0uCpLjyIBsx3D48MJqZbbxvpDxZqiQ3+T6VfLzU1r50jlk LOmTeYXlPiBBwTjFWpxSoWQP+JIr4IZUw8QUnM62j1svYpp5CturIrLTV5ZSSB3p3H+c PHXzrDekDUQFS7i3DHzbA5IDojXs+uAH7gxzVkVe1hrzajuwtewA6gS9UXQpM2VhOIUl 7GIUgpLeLhIuVadwiNi0bAMZgw0LMPnko4VjIZU9EXDGLv5jurjUaCx7NLoBSV3OAA99 OA== 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 3wug29k1q3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:16 +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 42DJn38S018552; Wed, 13 Mar 2024 20:58:16 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ws4t281hk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 20:58:16 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42DKwC6l32309524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Mar 2024 20:58:14 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5739D58056; Wed, 13 Mar 2024 20:58:12 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE0CB5805A; Wed, 13 Mar 2024 20:58:11 +0000 (GMT) Received: from jason-laptop.ibmuc.com (unknown [9.61.59.128]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Mar 2024 20:58:11 +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 v3 5/5] docs: Update s390 vfio-ap doc for ap_config sysfs attribute Date: Wed, 13 Mar 2024 16:58:07 -0400 Message-ID: <20240313205807.30554-6-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240313205807.30554-1-jjherne@linux.ibm.com> References: <20240313205807.30554-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: XK_49SgAFNsu43T5h2JENt48jYYOt8XW X-Proofpoint-GUID: XK_49SgAFNsu43T5h2JENt48jYYOt8XW 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-13_09,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403130160 Content-Type: text/plain; charset="utf-8" A new sysfs attribute, ap_config, for the vfio_ap driver is documented. Signed-off-by: Jason J. Herne Reviewed-by: Anthony Krowiak --- Documentation/arch/s390/vfio-ap.rst | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/arch/s390/vfio-ap.rst b/Documentation/arch/s390/= vfio-ap.rst index 929ee1c1c940..6056a50ee841 100644 --- a/Documentation/arch/s390/vfio-ap.rst +++ b/Documentation/arch/s390/vfio-ap.rst @@ -380,6 +380,36 @@ 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 all three of the + vfio_ap mediated device's ap matrix masks to be replaced in one sh= ot. + 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. + + Setting an adapter or domain number greater than the maximum allow= ed for + the system will result in an error. + + 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