From patchwork Wed May 29 11:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Schnelle X-Patchwork-Id: 13678736 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 0AE63180A82; Wed, 29 May 2024 11:37:02 +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=1716982625; cv=none; b=rYvTVMRecU+7DSn4cVfWMeOELT+ZcUPIgHP0Uc5vQv5KXsNafmMTUEGyTsD61b1ByZ7Y9RPIipHuheCRQnPsGwSki6507uwTcB/uJVAmbRblxd/jjkRKZBogmawkBoycMqeStpGF/FdavHXcwYjNApUm4+foWjKM45wgnlZcacw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716982625; c=relaxed/simple; bh=kmttkYcl7RaIqBVfs1vIdHpH/R3f9A14cvLyhdB1rck=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dOHTsd+n8hkakPEIeR64wVnvaSaR+psa/gDUFcQugXlIVv9RRKsBm0uKfIYSCLgs8gy7AWtrxobMyxHKPQrR/gQJDDFvfSajK9d5JzkM1Pu5heC7ZPTarz9D082Qmb52meKZVnSAcHIFiNiSzXDcIdJmUiM0PPFFZqct+N7O6IY= 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=pguluGcq; 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="pguluGcq" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44TBDpON005211; Wed, 29 May 2024 11:37:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : content-type : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=LTrthfU6+VvQnNM7AhQqXcpa/YUXxL1CYEpRBlk6l6E=; b=pguluGcqrLKZ8SkhT+RtyY1YVxI7A+iPs21xPhmPSZ+tjZk5rJe6AW0NSUnbXza6IvnD +KoYC8FDZC8mSmaraeMXMPxjo8b35ykv/6dYlKVwBXFrvqbd+70LbDOGAZEbPk+GA43k n1qR6pWqLnh16lrDgZ0qd06bgBKPUzKPKLfHtFSQoeDe/6kfYDzds+9fBonbgexGpgpC A5DdlCoIkwuD2Xmcp5gH4l9MsrD7IZ7JWMu/1rJEBvUEMk6CzMe35S9djX5hBuPnTcar KBLBPxOh1C7nI15p2OK3mcjyuQAogjD0nGTMPFzdOXKYuQTz0oam7954nie9wx/zIkC7 6g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ye39cr1n8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 11:37:01 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44TBaHug007440; Wed, 29 May 2024 11:37:01 GMT 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 3ye39cr1n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 11:37:01 +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 44T82ufB028984; Wed, 29 May 2024 11:37:00 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ydpaykgwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 11:37:00 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44TBauuD33751328 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2024 11:36:59 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB88058074; Wed, 29 May 2024 11:36:54 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C0515805B; Wed, 29 May 2024 11:36:52 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 May 2024 11:36:52 +0000 (GMT) From: Niklas Schnelle Date: Wed, 29 May 2024 13:36:24 +0200 Subject: [PATCH v3 1/3] s390/pci: Fix s390_mmio_read/write syscall page fault handling Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-vfio_pci_mmap-v3-1-cd217d019218@linux.ibm.com> References: <20240529-vfio_pci_mmap-v3-0-cd217d019218@linux.ibm.com> In-Reply-To: <20240529-vfio_pci_mmap-v3-0-cd217d019218@linux.ibm.com> To: Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Gerd Bayer , Matthew Rosato , Jason Gunthorpe Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Niklas Schnelle , Jason Gunthorpe X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1957; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=kmttkYcl7RaIqBVfs1vIdHpH/R3f9A14cvLyhdB1rck=; b=owGbwMvMwCH2Wz534YHOJ2GMp9WSGNLChR1M1t4JTg+8vrHIxvrJ9ybJHXH3dHtdX527t/b7z GO+8c0/O0pZGMQ4GGTFFFkWdTn7rSuYYronqL8DZg4rE8gQBi5OAZiIYSfDX6krwWL/eBL9lm8p aa+a8bn/fXrzXr8dF+/sm8Dldk+rYh4jw2GmJD6ZPzsS/9kXaH3JZH+2/uG+sFxmG8lQoa4tXOY yjAA= X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 2JRiljfBl3hdHKTx1iHIh_9E1EXsoUiP X-Proofpoint-ORIG-GUID: EUrSTaRqNyfi2MMyxOBcsN5HH5SwKS8D X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-29_07,2024-05-28_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405290079 The s390 MMIO syscalls when using the classic PCI instructions do not cause a page fault when follow_pte() fails due to the page not being present. Besides being a general deficiency this breaks vfio-pci's mmap() handling once VFIO_PCI_MMAP gets enabled as this lazily maps on first access. Fix this by following a failed follow_pte() with fixup_user_page() and retrying the follow_pte(). Reviewed-by: Jason Gunthorpe Reviewed-by: Matthew Rosato Signed-off-by: Niklas Schnelle --- arch/s390/pci/pci_mmio.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/s390/pci/pci_mmio.c b/arch/s390/pci/pci_mmio.c index 5398729bfe1b..80c21b1a101c 100644 --- a/arch/s390/pci/pci_mmio.c +++ b/arch/s390/pci/pci_mmio.c @@ -170,8 +170,12 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, goto out_unlock_mmap; ret = follow_pte(vma, mmio_addr, &ptep, &ptl); - if (ret) - goto out_unlock_mmap; + if (ret) { + fixup_user_fault(current->mm, mmio_addr, FAULT_FLAG_WRITE, NULL); + ret = follow_pte(vma, mmio_addr, &ptep, &ptl); + if (ret) + goto out_unlock_mmap; + } io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK)); @@ -305,12 +309,16 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr, if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) goto out_unlock_mmap; ret = -EACCES; - if (!(vma->vm_flags & VM_WRITE)) + if (!(vma->vm_flags & VM_READ)) goto out_unlock_mmap; ret = follow_pte(vma, mmio_addr, &ptep, &ptl); - if (ret) - goto out_unlock_mmap; + if (ret) { + fixup_user_fault(current->mm, mmio_addr, 0, NULL); + ret = follow_pte(vma, mmio_addr, &ptep, &ptl); + if (ret) + goto out_unlock_mmap; + } io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK)); From patchwork Wed May 29 11:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Schnelle X-Patchwork-Id: 13678735 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 09E7C180A81; Wed, 29 May 2024 11:37:02 +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=1716982625; cv=none; b=ttZm7OeNB5qKchjERkjtj+Ee4QhfBhxRm5CWO7bYedlUQWwdqGLuazCvg1MLxkbY9C+LxpL5WGOmSsb31zqct3mxTvDxTKAdUss4j6EtGOCLUJb/SIrKpPgMMJBbpkG+9iRQFOksFoxqt9rTetwLZ23ju23bAs1RU7Z6o7ZRF5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716982625; c=relaxed/simple; bh=nKUHkHvEphYKnVTYi7g6h0+bJI4W2Di7aoc14RiURco=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W0bijgGdPRdErFjQhKna9iuKHMYezSQHJ7fouWRhpwgWh9aIB37pTJuKTFhD/lD1QJADwfjM89RtfghWQN0HcbP8BJf4o41DSZa9LZylRHFLZhyjNiuFK6ZFelxGrfUn+VyKWXuMG4phya4NPWByjIjysTl4s7OsZha+HwIYBSQ= 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=c6HLm12J; 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="c6HLm12J" 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 44TBZqLq027567; Wed, 29 May 2024 11:37:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : content-type : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=hcqHB+gMcNVZF+txZ6zeAs89VpV+YbZ8B7LKeOBq1gY=; b=c6HLm12JsCbsuzii956swjB+fzHqzicZpfuyM9f3qqHGbGocVLJkCtssgCrP4/r4h3Rw L9uONmT4nJ2iOkUmm/IHRF4I54i/FKMNVbNNTtiSldtaPUoAgIJTlsNlF+TYQqEFRFsz lnn4n6gxnzFkcraJYH9qeCTcH8kC7fyXalbf6guEAyjpDU8Dyy5pfJ4HmYUAsdjBAL/V ecsD6EMOXD44scnn+DwC6gW/Lvm4aSQB3FJAkzsXiUycMImqvNC3/K0kVU7oecxQy9LD u/tFw3/X0wgeCp1u7bo5iiem2BA/eqhJgp1Mlr1fvc/klY1YHHYspNr0mOTKAhb09Euw 9w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ye32nr2ta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 11:37:01 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44TBb1HS029920; Wed, 29 May 2024 11:37:01 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ye32nr2t8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 11:37:01 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 44T8HZpm024784; Wed, 29 May 2024 11:37:00 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ydphqkekm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 11:37:00 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44TBavEp27001288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2024 11:36:59 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 74F4B5805E; Wed, 29 May 2024 11:36:57 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E90E5805B; Wed, 29 May 2024 11:36:55 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 May 2024 11:36:54 +0000 (GMT) From: Niklas Schnelle Date: Wed, 29 May 2024 13:36:25 +0200 Subject: [PATCH v3 2/3] vfio/pci: Tolerate oversized BARs by disallowing mmap Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-vfio_pci_mmap-v3-2-cd217d019218@linux.ibm.com> References: <20240529-vfio_pci_mmap-v3-0-cd217d019218@linux.ibm.com> In-Reply-To: <20240529-vfio_pci_mmap-v3-0-cd217d019218@linux.ibm.com> To: Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Gerd Bayer , Matthew Rosato , Jason Gunthorpe Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Niklas Schnelle , Jason Gunthorpe X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2030; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=nKUHkHvEphYKnVTYi7g6h0+bJI4W2Di7aoc14RiURco=; b=owGbwMvMwCH2Wz534YHOJ2GMp9WSGNLChd0sq++osLgeCOjgVEx35nrqyHhDojzwt96nfT+ev uuZcca1o5SFQYyDQVZMkWVRl7PfuoIppnuC+jtg5rAygQxh4OIUgIn8fM3wP5792n+fn5Z887Nn Vi2Z8HLFG4dtL9b8XvZ5SbNb6pTPVU4M/5QrZry4XHwp92j329i5zNO2aogVbmv3m/tc9/qi2ic ql/gA X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ewZ8vlQMt6KnEhUKPnWKfIOpqJaMVtML X-Proofpoint-GUID: aXQ0qthgY3w9QWRSEhruPgT6rC002qBH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-29_07,2024-05-28_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405290079 On s390 there is a virtual PCI device called ISM which has a few rather annoying oddities. For one it claims to have a 256 TiB PCI BAR (not a typo) which leads to any attempt to mmap() it failing during vmap. Even if one tried to map this "BAR" only partially the mapping would not be usable on systems with MIO support enabled however. This is because of another oddity in that this virtual PCI device does not support the newer memory I/O (MIO) PCI instructions and legacy PCI instructions are not accessible by user-space when MIO is in use. If this device needs to be accessed by user-space it will thus need a vfio-pci variant driver. Until then work around both issues by excluding resources which don't fit between IOREMAP_START and IOREMAP_END in vfio_pci_probe_mmaps(). Reviewed-by: Jason Gunthorpe Reviewed-by: Matthew Rosato Signed-off-by: Niklas Schnelle --- drivers/vfio/pci/vfio_pci_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 80cae87fff36..0f1ddf2d3ef2 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -28,6 +28,7 @@ #include #include #include +#include #if IS_ENABLED(CONFIG_EEH) #include #endif @@ -129,9 +130,12 @@ static void vfio_pci_probe_mmaps(struct vfio_pci_core_device *vdev) /* * The PCI core shouldn't set up a resource with a * type but zero size. But there may be bugs that - * cause us to do that. + * cause us to do that. There is also at least one + * device which advertises a resource too large to + * ioremap(). */ - if (!resource_size(res)) + if (!resource_size(res) || + resource_size(res) > (IOREMAP_END + 1 - IOREMAP_START)) goto no_mmap; if (resource_size(res) >= PAGE_SIZE) { From patchwork Wed May 29 11:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Schnelle X-Patchwork-Id: 13678743 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 99567180A99; Wed, 29 May 2024 12:04:22 +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=1716984264; cv=none; b=j87wmULoyujkPKo0BSJtM5xuNB6j0KboL0InGEAFbhcaeRWp38RP4mVfq7m5kBur+TFafQIBJFqCmEBqvZKI8VePyX3YZATfo9U62u/9dr1hRsIcPxi9J24UX4a44PRMve1md94rLk36fzWqdgybR779vgGorlMji/VI4dj8ddE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716984264; c=relaxed/simple; bh=i0eyyMMvW9e10XOJrVNQwFpRIiJqX7RCrvmSyLcYF0E=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=EthIQQFC4ESP2+jP2Z1e+LrT0wT32Ud9fHzBWAICHiu+hzgOhbn3wDKFXeHvbPfWm+BP7YIAp7lkDwlxZ6M8GrajtWC8hCNp7lGg/PrH7KputuSsueZMFWk85VYTaQMtnfvAWTG45X/P2xYQOhc93Sb2YwbJs871lijMzNJCrtQ= 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=g4aEtzaF; 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="g4aEtzaF" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44TBqhZ4025455; Wed, 29 May 2024 12:04:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : content-type : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=euCN2rq9Y/cy5muRfHlpyotcwKgvKirkbyMUy28OLQA=; b=g4aEtzaFtpRx72LF0nZGm0y65VC6L8h3QP0099dVQOX32J781MS3cDL9H3RKNk+GQna1 NQ6JjMpSmTmd+CCIjplYkyM9VyzcpUuu0KV+CdsRvKmso+M/qwY+8tEkf7HHk0mxc5WD D1OLV2wwb/BH9l4zsU5xnCjTBoILeXCj+vqxDWaq9X6RXhn4FnqO2VYjv3dVg8nq8fnj k/fJQg/AqJVa8vyZBGhGkO7GfuxDble7+sfnHqHWK7u+IERXAbLhAqW20ZQiIc2AinZX InF4GKIvZHLIQAOy4QVkT5OEq4hX9MS2xnVqHu9VaPMFuh/mqnRlke60aKAQGu2NmDzI 2Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ye3v8g17e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 12:04:21 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44TC4LDZ014072; Wed, 29 May 2024 12:04:21 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ye3v8g16w-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 12:04:20 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 44TBZKTh002438; Wed, 29 May 2024 11:37:03 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ydpb0kh7e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 11:37:03 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44TBb0jJ23527948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2024 11:37:02 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DC9F58061; Wed, 29 May 2024 11:37:00 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD55F58060; Wed, 29 May 2024 11:36:57 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 May 2024 11:36:57 +0000 (GMT) From: Niklas Schnelle Date: Wed, 29 May 2024 13:36:26 +0200 Subject: [PATCH v3 3/3] vfio/pci: Enable PCI resource mmap() on s390 and remove VFIO_PCI_MMAP Message-Id: <20240529-vfio_pci_mmap-v3-3-cd217d019218@linux.ibm.com> References: <20240529-vfio_pci_mmap-v3-0-cd217d019218@linux.ibm.com> In-Reply-To: <20240529-vfio_pci_mmap-v3-0-cd217d019218@linux.ibm.com> To: Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Gerd Bayer , Matthew Rosato , Jason Gunthorpe Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Niklas Schnelle , Jason Gunthorpe X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1848; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=i0eyyMMvW9e10XOJrVNQwFpRIiJqX7RCrvmSyLcYF0E=; b=owGbwMvMwCH2Wz534YHOJ2GMp9WSGNLChb0dK2azP9mb82/+rsOiGTefsmrGf1vJsk1AZpNm3 Nw3z02tO0pZGMQ4GGTFFFkWdTn7rSuYYronqL8DZg4rE8gQBi5OAZiI83OGP5zSbOoz2VfLX93h tfVdjr7OhivrFQormlYpnGFivp/ensnIsEj60JuYPouDoo0VP1b6Mgf2H3p1Zv4jpmeCS9lXuwf fYAYA X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bBOaEOB85zer_lprQlDf1bKQfNs-SOWp X-Proofpoint-GUID: -cqccsE2RxQO8XA0zLgu-4xcrbm-Gj50 X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-29_07,2024-05-28_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 impostorscore=0 mlxscore=0 mlxlogscore=825 spamscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405290082 With the introduction of memory I/O (MIO) instructions enbaled in commit 71ba41c9b1d9 ("s390/pci: provide support for MIO instructions") s390 gained support for direct user-space access to mapped PCI resources. Even without those however user-space can access mapped PCI resources via the s390 specific MMIO syscalls. Thus mmap() can and should be supported on all s390 systems with native PCI. Since VFIO_PCI_MMAP enablement for s390 would make it unconditionally true and thus pointless just remove it entirely. Link: https://lore.kernel.org/all/c5ba134a1d4f4465b5956027e6a4ea6f6beff969.camel@linux.ibm.com/ Suggested-by: Jason Gunthorpe Reviewed-by: Matthew Rosato Reviewed-by: Jason Gunthorpe Signed-off-by: Niklas Schnelle --- drivers/vfio/pci/Kconfig | 4 ---- drivers/vfio/pci/vfio_pci_core.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index bf50ffa10bde..c3bcb6911c53 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -7,10 +7,6 @@ config VFIO_PCI_CORE select VFIO_VIRQFD select IRQ_BYPASS_MANAGER -config VFIO_PCI_MMAP - def_bool y if !S390 - depends on VFIO_PCI_CORE - config VFIO_PCI_INTX def_bool y if !S390 depends on VFIO_PCI_CORE diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 0f1ddf2d3ef2..a0e2e2a806d1 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -121,9 +121,6 @@ static void vfio_pci_probe_mmaps(struct vfio_pci_core_device *vdev) res = &vdev->pdev->resource[bar]; - if (!IS_ENABLED(CONFIG_VFIO_PCI_MMAP)) - goto no_mmap; - if (!(res->flags & IORESOURCE_MEM)) goto no_mmap;