Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1690940rdd; Thu, 11 Jan 2024 06:43:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHAL6dE7GX4d1sgX0y6l9Ksby3QJL8liqPy+SBKd8o4WZT81aBMoBQ7bX3QrziuZyRAx36f X-Received: by 2002:a17:90a:2ec5:b0:28d:950f:a207 with SMTP id h5-20020a17090a2ec500b0028d950fa207mr983575pjs.30.1704984180436; Thu, 11 Jan 2024 06:43:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704984180; cv=none; d=google.com; s=arc-20160816; b=UZo8jyyZQdmZaSn6aKe7fEOjnvA/5oiiZ2MfJ9ur+8C1zA6az290L9SHwsEqP5zuJz 6qkHlScTsr+XYdoMBpsA13uSWavtGOXwmRZxGaqTQ0iJfRwweMF0EMHHub6CxdbWAqsH b5OSzo5y5VPgxrHaQfHIWfqK2whLj9fRwm5hT6tDpYHQtHgovZxCxISbj9Pkq47MZNtg zrl2jt5u7X4ChjevqfI8UfmghoaXMZ8JxuE1HI4eUKCDV4zc1lc372vmLFZ29tkKGxA6 wK1+Bj6NzBAEPfIddYZgVzD8oytpgy/EGZwc73MT84SpWEll3KkpJJ6qpsSGS21mzZpC p0sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dcx+fQlNvklHss1smKNW/OV7lDvnCE6ScxETeVWqgh4=; fh=89dtS/PwPJUSahQCrBwvdQ9UYtztJf8P1g5jTeyUoxY=; b=DSXwjUOkXyK/jyuXZRED/1alMIu3FaXe5Jc8X4DMSMkBaXhsKjlfY3wA0dVMYjyhvB uLdsVrZZ/tur3gtsaXk/kobN0MyrFJUNP0MpOsO7wCZOngqXuOx069iGd8Tel+GdfFQv fZtJeQkMr5ycrsrGnc0nfzoJlZw6rimKzhJscecMm9+QRbdCEfmvnX8ZRayI+sSJyGDw HRad6JDNFKklo7bIfi5AsmU0C9A3bCWxzX8zogN5KdoZuyJbilKvaql4n3g5GNqwJgXU oxDfymbjfCiuBjfgkHxrnaLHE22Bp94S0LDa2kL2kFFD8W5YmUjBt6JCUmRX+EntfU3h wZoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=a1MFfxgh; spf=pass (google.com: domain of linux-kernel+bounces-23727-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23727-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id mu12-20020a17090b388c00b0028cc561d745si4087989pjb.1.2024.01.11.06.43.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:43:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23727-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=a1MFfxgh; spf=pass (google.com: domain of linux-kernel+bounces-23727-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23727-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BC65283D70 for ; Thu, 11 Jan 2024 14:43:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 488F24CB56; Thu, 11 Jan 2024 14:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="a1MFfxgh" 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 55A814C609; Thu, 11 Jan 2024 14:42:24 +0000 (UTC) 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 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 40BEgDC8001664; Thu, 11 Jan 2024 14:42:22 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=dcx+fQlNvklHss1smKNW/OV7lDvnCE6ScxETeVWqgh4=; b=a1MFfxgh8WGzF5PCgIcgKeXWdievSacns+YE4b6220XP6YNv+ZeSA6HmQTu+8HQPY05E LxxV3t/22BfMOvcxTGJo5HQtDTJl3KCQxcuQ3vK4K1BZjwd+Zq+p7q+W4bGY5U1btt/J MLn07cpX8aMVjmY6uCtcaib6xYv9sDy9dXoWcmq3BFKtqDr3fpYaKaEWiAfD8TWM/0cW xdjfJopD90TwoQ1G7LIlMf7+PQrKm2r+FdQD3h17DBS6FqK3/BAB1GO7lM+2xWYDRf4J TneQxwz1fKq+maGLyF3xCcXHNEqKcg8NWszHqNUrmWzVDJvoVFTX2170atxbrTu+Qrgz PA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjbejtynd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:42:21 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40BEgK5t002233; Thu, 11 Jan 2024 14:42:20 GMT 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 3vjbejtyek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:42:20 +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 40BCZ6cX004407; Thu, 11 Jan 2024 14:38:52 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfjpm3tv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:38:52 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40BEcoHe36372808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jan 2024 14:38:50 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A28045805F; Thu, 11 Jan 2024 14:38:50 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB29758059; Thu, 11 Jan 2024 14:38:49 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.174.181]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 11 Jan 2024 14:38:49 +0000 (GMT) From: Tony 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, pasic@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, stable@vger.kernel.org Subject: [PATCH v3 2/6] s390/vfio-ap: loop over the shadow APCB when filtering guest's AP configuration Date: Thu, 11 Jan 2024 09:38:36 -0500 Message-ID: <20240111143846.8801-3-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111143846.8801-1-akrowiak@linux.ibm.com> References: <20240111143846.8801-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: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QGi6iCLRRzr9qFfhbWi_BQw1KbWfhcDt X-Proofpoint-ORIG-GUID: UaHmhr1pUBiWCYr9LrT0OttSC9WVBg_U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-11_07,2024-01-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401110116 While filtering the mdev matrix, it doesn't make sense - and will have unexpected results - to filter an APID from the matrix if the APID or one of the associated APQIs is not in the host's AP configuration. There are two reasons for this: 1. An adapter or domain that is not in the host's AP configuration can be assigned to the matrix; this is known as over-provisioning. Queue devices, however, are only created for adapters and domains in the host's AP configuration, so there will be no queues associated with an over-provisioned adapter or domain to filter. 2. The adapter or domain may have been externally removed from the host's configuration via an SE or HMC attached to a DPM enabled LPAR. In this case, the vfio_ap device driver would have been notified by the AP bus via the on_config_changed callback and the adapter or domain would have already been filtered. Since the matrix_mdev->shadow_apcb.apm and matrix_mdev->shadow_apcb.aqm are copied from the mdev matrix sans the APIDs and APQIs not in the host's AP configuration, let's loop over those bitmaps instead of those assigned to the matrix. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic Fixes: 48cae940c31d ("s390/vfio-ap: refresh guest's APCB by filtering AP resources assigned to mdev") Cc: --- drivers/s390/crypto/vfio_ap_ops.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 9382b32e5bd1..47232e19a50e 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -691,8 +691,9 @@ static bool vfio_ap_mdev_filter_matrix(struct ap_matrix_mdev *matrix_mdev) bitmap_and(matrix_mdev->shadow_apcb.aqm, matrix_mdev->matrix.aqm, (unsigned long *)matrix_dev->info.aqm, AP_DOMAINS); - for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) { - for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, AP_DOMAINS) { + for_each_set_bit_inv(apid, matrix_mdev->shadow_apcb.apm, AP_DEVICES) { + for_each_set_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm, + AP_DOMAINS) { /* * If the APQN is not bound to the vfio_ap device * driver, then we can't assign it to the guest's -- 2.43.0