Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp30836rdb; Mon, 15 Jan 2024 10:57:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHP3+60gI0A2WlNPbbT5bP3mWGfviXNSe7IEzHX48RZrC/PTyrMwrgzGlWRGg41M341C/wr X-Received: by 2002:a05:6830:2019:b0:6dd:e442:3f6c with SMTP id e25-20020a056830201900b006dde4423f6cmr8713848otp.55.1705345025166; Mon, 15 Jan 2024 10:57:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705345025; cv=none; d=google.com; s=arc-20160816; b=ue8XdODqmHNd5ClKvXlCm4SoeR6XnQOpiKrzj2H7d5BJPnFr64S6vuv0OoX9qmUZBe nIkpLuF72LDPVWbnfDN0DPSeTTIctztCsoVMf9iVmNekc1xqCl21J5j+UsqAb3tNf089 2yMAzfNaz2FTLkH9kgwJ/wN7AvptmZJbOwJLBU5VtQJJb2Gq6jxl+rx+LjEqEzu4EcH1 MIYHPyibmG6TR/fRZdKr+vnv8cHqjOkCaAwV9DPK3+TzRLP9gUXFppzjk2LvM2ZHfWG1 sGLn6qmIIfXdOSe7cIgheO/8Ktb7uPP/rmCmNWNYvnmSjZ2WjfWXJMBBGCXlj79bGFgo BE3w== 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=bKRG8CRUSEfAt7y8e4in2UO7wdpopq3ttdLN1uPxr5c=; fh=H6lVIw+KZeomf8cbJ+jDGydQlHrKW9Bp+9pD33yGxs8=; b=xKhoZT7JaygexzMO1cOdZ9HosvCrd87Bo+Yt91/dScfCuWtth+1IeQWyIfdlTqA3pU a6nUpo+hBIiAXOID4fUoqrUFNFlVN8lI0JoOM4U9AAq2sbpzzIRI2Eeuw+Sli7BKT1v6 yfG71PvUlDDeMym/5vN0gmWG3xBXfcb966bRjD1LcKwoCnCrvCI07/I6m04KSrokOntB 1imDz7RkHtqC+gNHCvLmh74aq3phoVP+9s0ZbF1GruXC4TNRWJuv+halhYgDHDWbTNXD V/x9tF6zlCZAPUzDgAMo5J29FY65lEQoLuE341HoBnMjQnJnJgmAYVN4R31ZO5YAlWdu S0Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ANJfvFEy; spf=pass (google.com: domain of linux-kernel+bounces-26415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26415-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id cb17-20020a056a02071100b005cdb499a98esi9999950pgb.181.2024.01.15.10.57.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 10:57:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ANJfvFEy; spf=pass (google.com: domain of linux-kernel+bounces-26415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26415-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 763302810EA for ; Mon, 15 Jan 2024 18:55:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2801218EBA; Mon, 15 Jan 2024 18:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ANJfvFEy" 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 C3E3518B09; Mon, 15 Jan 2024 18:54:50 +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 (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40FISfnc016495; Mon, 15 Jan 2024 18:54:48 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=bKRG8CRUSEfAt7y8e4in2UO7wdpopq3ttdLN1uPxr5c=; b=ANJfvFEyFIzotR4H5ozUTu7vs+uEKlE5GhBbLmSzqqtHV3Ud8vrUa2LAFHGw6QQXTeC6 xA4vYoKokQN4asUbN4zow5wHi0nDKMLrZLiuXr7tPR/UgQGVIpqgB9BOQFOe+fjVpISv 89jC8mUnHtcL+h7ZjVtsGFtmdceNEIKafiqU3C7zTAfb7uVXRgStaykp9DX9zst9fUBo oeJcHqsVrSmQM6C6vyUXV/sc++5Eyx8ibjcEqw6ONbAgZjFWFwg0yxJzWPFHxncGXNIT dSqCrYuLGWAR17zjLrEzxWGt320LSuR6K7kjBZq311qbrH0Dxe8BiHDDl2Rr30oRBj2L Ww== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vna12gd19-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:48 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40FIpOfx005086; Mon, 15 Jan 2024 18:54:47 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 3vna12gd0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:47 +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 40FIMsDC008633; Mon, 15 Jan 2024 18:54:46 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vm6bk9vpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:46 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40FIsjAd16319082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Jan 2024 18:54:45 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00C235805A; Mon, 15 Jan 2024 18:54:45 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EFAED58052; Mon, 15 Jan 2024 18:54:43 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.164.202]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 15 Jan 2024 18:54:43 +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, agordeev@linux.ibm.com, gor@linux.ibm.com, Tony Krowiak , stable@vger.kernel.org Subject: [PATCH v4 2/6] s390/vfio-ap: loop over the shadow APCB when filtering guest's AP configuration Date: Mon, 15 Jan 2024 13:54:32 -0500 Message-ID: <20240115185441.31526-3-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115185441.31526-1-akrowiak@linux.ibm.com> References: <20240115185441.31526-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: tAYHrTb_G1jvAKch1bsxRdOOkifmlZsf X-Proofpoint-ORIG-GUID: s31kwEDGqjhWMsJgXZQhXTzRbOGa8l-w 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-15_13,2024-01-15_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401150139 From: Tony Krowiak 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 1f7a6c106786..e825e13847fe 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -695,8 +695,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