From nobody Thu Apr 2 19:00:58 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 1CB10346E5A; Thu, 12 Feb 2026 14:02:46 +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=1770904968; cv=none; b=JcSF1jCovJhAyUriQzuec00bo3AHnXkklUuT80x+NzoHFFhZsDg7Oduh09LlflYL9oypKiWjdTbyVdMOJ3XaGtUV1pTKAss2hmFNxQtJBj3fxolFvaRRPQG5ujTXubkQD/AaKF+y4E57IIajInEhxOks4if2JaFbEbtwn0CL2EA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770904968; c=relaxed/simple; bh=R9x5Z5Kah0FOwz+XsjqJAfOjK2AVQJPUaRi3J+mut2Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UhtGp7e1vEMWp6RwpA+Tn0/iqW9p3T63v8sJ88RWYptkABjf8rgqGqRqafn8P7h9ReHRgLG26GaSHj31JZHQDhQCaEFpfCfEqhj4HtCIwEyXrTq5CA1KsFlmUt/NQcQT4Lw1oFyn8vlh9oUEnMpOdH82hFcgEVS0Nssjz3Axkt0= 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=cEACVcTX; 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="cEACVcTX" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61CDOJAL3414107; Thu, 12 Feb 2026 14:02:35 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=mhB6RF oPQK8dVzbsRqsEX6IfqiK9Fcw9WsnO2/SS6IQ=; b=cEACVcTXq43FhjX/ng0t5b pdozQtOsmKEx06Qq7i3e1Hfgu4dUxWBNVckEBry9nbHhFW28uDgBRJH8trgJXrde 7y4Y+EZrAp0UVy7MyVrODW1uDkmYKCjLBJQveBzrdHImRQffBHkJOFpwjhHGuJB6 SiD62Sah/l7Db3TnixotSjlZZN03A0UZh66pp8Ydrk7AGUbSLWLfTEDv9CEje7Gn 1k9SRfaNEX+Bk+WfNzhRAsyFlb8QZUU/ujhUU4f1kyoNyHG1mVQXTDjzjQUXqmcA 9ymprvZKNPZ2Odup4sbRYIqJtxlmda+PQMd38BYIBc+541gH2z9zDd6rzYQiIASQ == 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 4c696vbmvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Feb 2026 14:02:35 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 61C9goXG001837; Thu, 12 Feb 2026 14:02:34 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4c6je2ad0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Feb 2026 14:02:34 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 61CE2VSD61669798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Feb 2026 14:02:31 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C62A20043; Thu, 12 Feb 2026 14:02:31 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF5F22005A; Thu, 12 Feb 2026 14:02:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Feb 2026 14:02:30 +0000 (GMT) From: Julian Ruess Date: Thu, 12 Feb 2026 15:02:15 +0100 Subject: [PATCH 1/3] vfio/pci: Set VFIO_PCI_OFFSET_SHIFT to 48 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260212-vfio_pci_ism-v1-1-333262ade074@linux.ibm.com> References: <20260212-vfio_pci_ism-v1-0-333262ade074@linux.ibm.com> In-Reply-To: <20260212-vfio_pci_ism-v1-0-333262ade074@linux.ibm.com> To: schnelle@linux.ibm.com, wintera@linux.ibm.com, ts@linux.ibm.com, oberpar@linux.ibm.com, gbayer@linux.ibm.com, Alex Williamson , Jason Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian Cc: mjrosato@linux.ibm.com, alifm@linux.ibm.com, raspl@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, julianr@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-pci@vger.kernel.org X-Mailer: b4 0.14.2 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fv3arNPVHzcKc8BmdOyKW6B-d1ksJ0l7 X-Proofpoint-ORIG-GUID: fv3arNPVHzcKc8BmdOyKW6B-d1ksJ0l7 X-Authority-Analysis: v=2.4 cv=JdWxbEKV c=1 sm=1 tr=0 ts=698ddd7b cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=modniqXMBZv9BQ1X5YgA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjEyMDEwNCBTYWx0ZWRfXwLduAeLBOgD0 s7s1iJarvhbtDEp0HnZR88d8BWjr8OcFYH14Drr2PlzcDTfIQVw8qCjY8K6VaacbxG84SVjxBTD M40uX2I35PMDxk1nHEN8ELesZsYrOGnh9C6acIFvUZgk0h+psJ5oNH7WOzReqNmu/qfz5KExg3X paJv6mtOkUkLin6zGiPXyNmGa9UneXA7YWF+Jznknv0F8H8u9gF+ZBY65fjOPKu7uZgq/dAYV6o TdQrSeobKEbgmcSndVe+0wDaey5LE2QajnfS73DyjmX+BCZHS47l5gaESjH8nHwXlrHQVpDi3lN 0vB3a3HYn8Yg2fqj2LHu2X+a4yU9hbc9TNwG76i/ZnbS8K6VqV9xwImeWay1+rOkaAgnX9Us5qB vVVnxAK7HnU4Lg1gH4KfiOzaENgQYJmdAsSlb3LUFOdA+mHnnDsv5g4KuiT+1zle0gem50pu/zN uP3yPyXLq6WWyPjYV5A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-12_04,2026-02-12_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1011 impostorscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602120104 Extend VFIO_PCI_OFFSET_SHIFT to 48 to use the vfio-pci VFIO_PCI_OFFSET_TO_INDEX() mechanism with the 256 TiB pseudo-BAR 0 of the ISM device on s390. This bar is never mapped. Acked-by: Alexandra Winter Signed-off-by: Julian Ruess --- drivers/vfio/pci/vfio_pci_core.c | 4 ++-- include/linux/vfio_pci_core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_c= ore.c index 3a11e6f450f70105f17a3a621520c195d99e0671..3d70bf6668c7a69c4b466741959= 54d1ada662006 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1647,7 +1647,7 @@ static unsigned long vma_to_pfn(struct vm_area_struct= *vma) u64 pgoff; =20 pgoff =3D vma->vm_pgoff & - ((1U << (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT)) - 1); + ((1UL << (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT)) - 1); =20 return (pci_resource_start(vdev->pdev, index) >> PAGE_SHIFT) + pgoff; } @@ -1751,7 +1751,7 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev,= struct vm_area_struct *vma phys_len =3D PAGE_ALIGN(pci_resource_len(pdev, index)); req_len =3D vma->vm_end - vma->vm_start; pgoff =3D vma->vm_pgoff & - ((1U << (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT)) - 1); + ((1UL << (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT)) - 1); req_start =3D pgoff << PAGE_SHIFT; =20 if (req_start + req_len > phys_len) diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 1ac86896875cf5c9b5cc8ef25fae8bbd4394de05..12781707f086a330161990dc357= 9ec0d75887da8 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -20,7 +20,7 @@ #ifndef VFIO_PCI_CORE_H #define VFIO_PCI_CORE_H =20 -#define VFIO_PCI_OFFSET_SHIFT 40 +#define VFIO_PCI_OFFSET_SHIFT 48 #define VFIO_PCI_OFFSET_TO_INDEX(off) (off >> VFIO_PCI_OFFSET_SHIFT) #define VFIO_PCI_INDEX_TO_OFFSET(index) ((u64)(index) << VFIO_PCI_OFFSET_S= HIFT) #define VFIO_PCI_OFFSET_MASK (((u64)(1) << VFIO_PCI_OFFSET_SHIFT) - 1) --=20 2.51.0 From nobody Thu Apr 2 19:00:58 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 6D13D2253FF; Thu, 12 Feb 2026 14:02:42 +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=1770904963; cv=none; b=TeKSKUhArUioBnpMQGDgdhzad7N39A/2+pChQ5jaMbVu23XTSiKSXs5l0wd6Kn+HnwrwSSQcE0MzQVIiDKDyi+EItF9IesXS10lOs+uBVhOEnQu7SpoM0vrZEOpfoD5BQxL8cG+Xk/UjCeNzLkSBPrIaAlKZ3GtwsRjcwxqBXqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770904963; c=relaxed/simple; bh=5AZMm4V6MtU6MB8nUvcHN5TD1MVWJkjfvrL/N7CjmDw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WgkX+s6n0PnV9cNWIW61OuDzdw/xPB/fiiIEiCv+WYRCBRT44DdRrP2o1sDcZ5xv3PWdqsDawypKFu2tnSWApOM+BO4oA+T7Bz4GJ2bVQGML8lUxEx3WD3DX+bdHJc81GUuQYF8qw4VXr/TPORRO9jxw7n3banGKGYftdekNmz0= 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=L3AM24ab; 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="L3AM24ab" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61C5IqVt4037824; Thu, 12 Feb 2026 14:02:37 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=qrHuk3 GbFygxKt4he95bkyIYcNIcfCPYj1UQM6zkk6s=; b=L3AM24ab4hArYKgkIdokMb Tt2hSNS2bVZpyZJH48STxoAzR/2/JA6jxBwITxwDaN2cRuzWBEYt+RdrBtkQ6ddz zvEF9VCicdla5yD7hdFuMgZcFSJKCJmUE8Fbr0uH+0hwoaKRxIW+32/YjPdeuaYx HHunxKFppuTCzpEGRySUeIvS30Juf8C8N6qil3DUy+ffbZNRJ2zjdhY+EPbuhuOH KihyLC0B89roJyzLO+S9VUAzkpxxbEE24Ac9wBhMny3akkVDVYXI/3FSjLdMV5BA OIIsBT+Zyx7D5FDj5h+I/dL5TOIyDjSytVYlQQ7zOk8moplMojvS7fVCLhBXGYVQ == 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 4c696upcmq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Feb 2026 14:02:36 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 61CDSXvF001427; Thu, 12 Feb 2026 14:02:35 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6gqnapm3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Feb 2026 14:02:35 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 61CE2Vnc61735332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Feb 2026 14:02:31 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7474420043; Thu, 12 Feb 2026 14:02:31 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1BA3C2004E; Thu, 12 Feb 2026 14:02:31 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Feb 2026 14:02:31 +0000 (GMT) From: Julian Ruess Date: Thu, 12 Feb 2026 15:02:16 +0100 Subject: [PATCH 2/3] vfio/ism: Implement vfio_pci driver for ISM devices Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260212-vfio_pci_ism-v1-2-333262ade074@linux.ibm.com> References: <20260212-vfio_pci_ism-v1-0-333262ade074@linux.ibm.com> In-Reply-To: <20260212-vfio_pci_ism-v1-0-333262ade074@linux.ibm.com> To: schnelle@linux.ibm.com, wintera@linux.ibm.com, ts@linux.ibm.com, oberpar@linux.ibm.com, gbayer@linux.ibm.com, Alex Williamson , Jason Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian Cc: mjrosato@linux.ibm.com, alifm@linux.ibm.com, raspl@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, julianr@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-pci@vger.kernel.org X-Mailer: b4 0.14.2 X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=YZiwJgRf c=1 sm=1 tr=0 ts=698ddd7c cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=BIpM-4bQ8UbgmxpNPDoA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: ERovvUeSskgStJB7PvHRZFCqwA69ZSIP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjEyMDEwNCBTYWx0ZWRfX/L09TJyZBo0q Cd2jH2HAjI0Hlpw8gj/8NTDXrHPlyLWjiTBBjmxSDQFFfFubwbky9Tv4U4NFBsVHVvJUGmSJeaO SuEgGoktfmDVfW1SGzUrbvv1lpkBZLqvJ5GmQO6f6WILUrEKRqv5VYlSt6l5rVk/L0DlqsHtf73 Cd0tZ2q+XwTZixt4p8W/f144VL4ybYgkSJKp2J7Q4bFwJ4z2iLPS2H01fEDUKKr6O/5NtxMwlMy uBi2f98rX3Si5sVVc7rNBzold2vTWs/xIRyjgYHPTSF00FuyexofqKBs2tW3B6JrXKg1nlCH5hU Sqg8FPKpM3ywwLDf/TjYiqLABDmL5AqBCHhDw2WRNaumztZrL1s3oAnLNHCkq1Nn8yEth/CJcLg 9CURfoPNQ5vlqlc5IqzhbEg6Uf3oZqfaglAx9DKhHBwm27qQjver0524W3VPw5pFIZZDmJUbJCU 1Iqgu5q2R7fId3J1k/Q== X-Proofpoint-GUID: ERovvUeSskgStJB7PvHRZFCqwA69ZSIP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-12_04,2026-02-12_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 impostorscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1011 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602120104 Add a vfio_pci variant driver for the s390-specific Internal Shared Memory (ISM) devices used for inter-VM communication. This enables the development of vfio-pci-based user space drivers for ISM devices. On s390, kernel primitives such as ioread() and iowrite() are switched over from function handle based PCI load/stores instructions to PCI memory-I/O (MIO) loads/stores when these are available and not explicitly disabled. Since these instructions cannot be used with ISM devices, ensure that classic function handle-based PCI instructions are used instead. The driver is still required even when MIO instructions are disabled, as the ISM device relies on the PCI store block (PCISTB) instruction to perform write operations. Stores are not fragmented, therefore one ioctl corresponds to exactly one PCISTB instruction. User space must ensure to not write more than 4096 bytes at once to an ISM BAR which is the maximum payload of the PCISTB instruction Export vfio_pci_config_rw() for config space accesses that do not rely on s390 MIO instructions. Acked-by: Alexandra Winter Signed-off-by: Julian Ruess --- drivers/vfio/pci/Kconfig | 2 + drivers/vfio/pci/Makefile | 2 + drivers/vfio/pci/ism/Kconfig | 11 ++ drivers/vfio/pci/ism/Makefile | 3 + drivers/vfio/pci/ism/main.c | 227 +++++++++++++++++++++++++++++++++= ++++ drivers/vfio/pci/vfio_pci_config.c | 1 + 6 files changed, 246 insertions(+) diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 1e82b44bda1a0a544e1add7f4b06edecf35aaf81..296bf01e185ecacc388ebc69e92= 706c99e47c814 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -60,6 +60,8 @@ config VFIO_PCI_DMABUF =20 source "drivers/vfio/pci/mlx5/Kconfig" =20 +source "drivers/vfio/pci/ism/Kconfig" + source "drivers/vfio/pci/hisilicon/Kconfig" =20 source "drivers/vfio/pci/pds/Kconfig" diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile index e0a0757dd1d2b0bc69b7e4d79441d5cacf4e1cd8..6138f1bf241df04e7419f196b40= 4abdf9b194050 100644 --- a/drivers/vfio/pci/Makefile +++ b/drivers/vfio/pci/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_VFIO_PCI) +=3D vfio-pci.o =20 obj-$(CONFIG_MLX5_VFIO_PCI) +=3D mlx5/ =20 +obj-$(CONFIG_ISM_VFIO_PCI) +=3D ism/ + obj-$(CONFIG_HISI_ACC_VFIO_PCI) +=3D hisilicon/ =20 obj-$(CONFIG_PDS_VFIO_PCI) +=3D pds/ diff --git a/drivers/vfio/pci/ism/Kconfig b/drivers/vfio/pci/ism/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..2db6c9327980827bf617afb9a82= b1d1928868d42 --- /dev/null +++ b/drivers/vfio/pci/ism/Kconfig @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 +config ISM_VFIO_PCI + tristate "VFIO support for ISM devices" + depends on ISM + select VFIO_PCI_CORE + help + This provides user space support for + IBM Internal Shared Memory (ISM) Adapter devices + using the VFIO framework. + + If you don't know what to do here, say N. diff --git a/drivers/vfio/pci/ism/Makefile b/drivers/vfio/pci/ism/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..32cc3c66dd11395da85a2b6f05b= 3d97036ed8a35 --- /dev/null +++ b/drivers/vfio/pci/ism/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_ISM_VFIO_PCI) +=3D ism-vfio-pci.o +ism-vfio-pci-y :=3D main.o diff --git a/drivers/vfio/pci/ism/main.c b/drivers/vfio/pci/ism/main.c new file mode 100644 index 0000000000000000000000000000000000000000..99f27682ec16ec855ae12ff8705= 9dbb1bc18c586 --- /dev/null +++ b/drivers/vfio/pci/ism/main.c @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * vfio-ISM driver for s390 + * + * Copyright IBM Corp. 2026 + */ + +#include "../vfio_pci_priv.h" + +struct ism_vfio_pci_core_device { + struct vfio_pci_core_device core_device; +}; + +static int ism_pci_open_device(struct vfio_device *core_vdev) +{ + struct ism_vfio_pci_core_device *mvdev =3D container_of( + core_vdev, struct ism_vfio_pci_core_device, core_device.vdev); + struct vfio_pci_core_device *vdev =3D &mvdev->core_device; + int ret; + + ret =3D vfio_pci_core_enable(vdev); + if (ret) + return ret; + + vfio_pci_core_finish_enable(vdev); + return 0; +} + +static ssize_t ism_vfio_pci_do_io_r(struct vfio_pci_core_device *vdev, + char __user *buf, loff_t off, size_t count, + int bar) +{ + struct zpci_dev *zdev =3D to_zpci(vdev->pdev); + ssize_t ret, done =3D 0; + u64 req, length, tmp; + + while (count) { + if (count >=3D 8 && IS_ALIGNED(off, 8)) + length =3D 8; + else if (count >=3D 4 && IS_ALIGNED(off, 4)) + length =3D 4; + else if (count >=3D 2 && IS_ALIGNED(off, 2)) + length =3D 2; + else + length =3D 1; + req =3D ZPCI_CREATE_REQ(READ_ONCE(zdev->fh), bar, length); + /* use pcilg to prevent using MIO instructions */ + ret =3D __zpci_load(&tmp, req, off); + if (ret) + return ret; + if (copy_to_user(buf, &tmp, length)) + return -EFAULT; + count -=3D length; + done +=3D length; + off +=3D length; + buf +=3D length; + } + return done; +} + +static ssize_t ism_vfio_pci_do_io_w(struct vfio_pci_core_device *vdev, + char __user *buf, loff_t off, size_t count, + int bar) +{ + struct zpci_dev *zdev =3D to_zpci(vdev->pdev); + void *data __free(kfree) =3D NULL; + ssize_t ret; + u64 req; + + if (count > ZPCI_BOUNDARY_SIZE) + return -EINVAL; + data =3D kzalloc(ZPCI_BOUNDARY_SIZE, GFP_KERNEL); + if (!data) + return -ENOMEM; + if (copy_from_user(data, buf, count)) + return -EFAULT; + req =3D ZPCI_CREATE_REQ(READ_ONCE(zdev->fh), bar, count); + ret =3D __zpci_store_block(data, req, off); + if (ret) + return ret; + return count; +} + +static ssize_t ism_vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, + char __user *buf, size_t count, loff_t *ppos, + bool iswrite) +{ + int bar =3D VFIO_PCI_OFFSET_TO_INDEX(*ppos); + loff_t pos =3D *ppos & VFIO_PCI_OFFSET_MASK; + resource_size_t end; + ssize_t done =3D 0; + + if (pci_resource_start(vdev->pdev, bar)) + end =3D pci_resource_len(vdev->pdev, bar); + else + return -EINVAL; + + if (pos >=3D end) + return -EINVAL; + + count =3D min(count, (size_t)(end - pos)); + + if (iswrite) + done =3D ism_vfio_pci_do_io_w(vdev, buf, pos, count, bar); + else + done =3D ism_vfio_pci_do_io_r(vdev, buf, pos, count, bar); + + if (done >=3D 0) + *ppos +=3D done; + + return done; +} + +static ssize_t ism_vfio_pci_rw(struct vfio_device *core_vdev, char __user = *buf, + size_t count, loff_t *ppos, bool iswrite) +{ + unsigned int index =3D VFIO_PCI_OFFSET_TO_INDEX(*ppos); + struct vfio_pci_core_device *vdev; + int ret; + + vdev =3D container_of(core_vdev, struct vfio_pci_core_device, vdev); + + if (!count) + return 0; + + switch (index) { + case VFIO_PCI_CONFIG_REGION_INDEX: + ret =3D vfio_pci_config_rw(vdev, buf, count, ppos, iswrite); + break; + + case VFIO_PCI_BAR0_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX: + ret =3D ism_vfio_pci_bar_rw(vdev, buf, count, ppos, iswrite); + break; + + default: + return -EINVAL; + } + + return ret; +} + +static ssize_t ism_vfio_pci_read(struct vfio_device *core_vdev, + char __user *buf, size_t count, loff_t *ppos) +{ + return ism_vfio_pci_rw(core_vdev, buf, count, ppos, false); +} + +static ssize_t ism_vfio_pci_write(struct vfio_device *core_vdev, + const char __user *buf, size_t count, + loff_t *ppos) +{ + return ism_vfio_pci_rw(core_vdev, (char __user *)buf, count, ppos, + true); +} + +static const struct vfio_device_ops ism_pci_ops =3D { + .name =3D "ism-vfio-pci", + .init =3D vfio_pci_core_init_dev, + .release =3D vfio_pci_core_release_dev, + .open_device =3D ism_pci_open_device, + .close_device =3D vfio_pci_core_close_device, + .ioctl =3D vfio_pci_core_ioctl, + .get_region_info_caps =3D vfio_pci_ioctl_get_region_info, + .device_feature =3D vfio_pci_core_ioctl_feature, + .read =3D ism_vfio_pci_read, + .write =3D ism_vfio_pci_write, + .request =3D vfio_pci_core_request, + .match =3D vfio_pci_core_match, + .match_token_uuid =3D vfio_pci_core_match_token_uuid, + .bind_iommufd =3D vfio_iommufd_physical_bind, + .unbind_iommufd =3D vfio_iommufd_physical_unbind, + .attach_ioas =3D vfio_iommufd_physical_attach_ioas, + .detach_ioas =3D vfio_iommufd_physical_detach_ioas, + +}; + +static int ism_vfio_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + struct ism_vfio_pci_core_device *ivpcd; + int ret; + + ivpcd =3D vfio_alloc_device(ism_vfio_pci_core_device, core_device.vdev, + &pdev->dev, &ism_pci_ops); + if (IS_ERR(ivpcd)) + return PTR_ERR(ivpcd); + + dev_set_drvdata(&pdev->dev, &ivpcd->core_device); + ret =3D vfio_pci_core_register_device(&ivpcd->core_device); + if (ret) + vfio_put_device(&ivpcd->core_device.vdev); + return ret; +} + +static void ism_vfio_pci_remove(struct pci_dev *pdev) +{ + struct vfio_pci_core_device *core_device; + struct ism_vfio_pci_core_device *ivpcd; + + core_device =3D dev_get_drvdata(&pdev->dev); + ivpcd =3D container_of(core_device, struct ism_vfio_pci_core_device, + core_device); + + vfio_pci_core_unregister_device(&ivpcd->core_device); + vfio_put_device(&ivpcd->core_device.vdev); +} + +static const struct pci_device_id ism_device_table[] =3D { + { PCI_DRIVER_OVERRIDE_DEVICE_VFIO(PCI_VENDOR_ID_IBM, + PCI_DEVICE_ID_IBM_ISM) }, + {} +}; +MODULE_DEVICE_TABLE(pci, ism_device_table); + +static struct pci_driver ism_vfio_pci_driver =3D { + .name =3D KBUILD_MODNAME, + .id_table =3D ism_device_table, + .probe =3D ism_vfio_pci_probe, + .remove =3D ism_vfio_pci_remove, + .driver_managed_dma =3D true, +}; + +module_pci_driver(ism_vfio_pci_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("vfio-pci variant driver for the IBM Internal Shared Me= mory (ISM) device"); +MODULE_AUTHOR("IBM Corporation"); diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci= _config.c index dc4e510e6e1bf4753e1d9005e0054399a639ea12..c7341a2d072b058965135a3d225= 894d74379e12e 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -1995,6 +1995,7 @@ ssize_t vfio_pci_config_rw(struct vfio_pci_core_devic= e *vdev, char __user *buf, =20 return done; } +EXPORT_SYMBOL(vfio_pci_config_rw); =20 /** * vfio_pci_core_range_intersect_range() - Determine overlap between a buf= fer --=20 2.51.0 From nobody Thu Apr 2 19:00:58 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 7972A2C234A; Thu, 12 Feb 2026 14:02:41 +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=1770904962; cv=none; b=d7wf6DbhBCdK9f6HO+lqei/tjE4b1t6GuLGD/7CqfvZ0R10HjOWAjywCcMpUvxLsPAG84APf8h7HSch69v0rfLxqmV82OOEEPX+WMCvwvgHj9jRr/tzGE6CNZYVUO67NzGZ9UNLXb3/53dNoIRnwKnw1b7FVtpEA1OgMbKI6YDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770904962; c=relaxed/simple; bh=iS+s19X3jjjts8Df2O63rWj3hlfZLHXYx/c7cTEzgEI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nQ0BmD+9UMxdBG8JSudd0lpPIS4qq51ZJnEJS12BEIobfLz5BLWggS0YP2TfQYZSCWt3dwgDTkIlQ5nKMZWndTfnNsXy8iMyzJqma+2tHHTmEJx6bXe+dfTuaS//SwDFFFewcIyXJeSkBoTsnZIJG3bkCDvC6u/+yCadPcZ6MCs= 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=JDm407du; 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="JDm407du" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61C741v5473751; Thu, 12 Feb 2026 14:02:36 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=tmqPTD XRn4fBwC657wa097v50m21rpJjL5kQW52yC6U=; b=JDm407du5dtyjZgys88DD2 N3eS18wKZhc86+U9mVpJOTq0LpxnVHnAWRjq5Rj7oqzSbXRikpbsloLl9uYi3/y1 and3Q9SVl4J/bYaA85gukYlV1Xs+HJkQTqknY5NDYBTmvyQCOpK4nrj7zOZmEb4I IzMKErdCXc4tvAg3/JdUEfmtP/FhZFLsnjB0aEbeVUwgpITVLzLoHW1CUx6GIPb9 30DK0bQKc0KTMFOfp8/Huw5AnX2jfx1+V8NjOY3bt1pbFIViPNTjweNDEiNQJh3N 4LmMuL/RghdTT/0P/1K1nf9ZYG0/nNBMzhUS1FZtWwiABd+RojzXvms4B5OZjjZw == 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 4c696x3qvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Feb 2026 14:02:36 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 61CCGKve008404; Thu, 12 Feb 2026 14:02:35 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6g3yjrt3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Feb 2026 14:02:35 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 61CE2VWp61669810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Feb 2026 14:02:31 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C533E20040; Thu, 12 Feb 2026 14:02:31 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79D4F2004B; Thu, 12 Feb 2026 14:02:31 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Feb 2026 14:02:31 +0000 (GMT) From: Julian Ruess Date: Thu, 12 Feb 2026 15:02:17 +0100 Subject: [PATCH 3/3] MAINTAINERS: add VFIO ISM PCI DRIVER section Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260212-vfio_pci_ism-v1-3-333262ade074@linux.ibm.com> References: <20260212-vfio_pci_ism-v1-0-333262ade074@linux.ibm.com> In-Reply-To: <20260212-vfio_pci_ism-v1-0-333262ade074@linux.ibm.com> To: schnelle@linux.ibm.com, wintera@linux.ibm.com, ts@linux.ibm.com, oberpar@linux.ibm.com, gbayer@linux.ibm.com, Alex Williamson , Jason Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian Cc: mjrosato@linux.ibm.com, alifm@linux.ibm.com, raspl@linux.ibm.com, hca@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com, julianr@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-pci@vger.kernel.org X-Mailer: b4 0.14.2 X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=WZYBqkhX c=1 sm=1 tr=0 ts=698ddd7c cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8 a=Ikd4Dj_1AAAA:8 a=N04f8XHk16Uzgq2NRSwA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: vm_oryJQ4MZObU8Y1D8-iHXUu2E0M2me X-Proofpoint-ORIG-GUID: vm_oryJQ4MZObU8Y1D8-iHXUu2E0M2me X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjEyMDEwNCBTYWx0ZWRfX5hZKwaP5Pj6d 2Qr9xdvlifsUyoju/hVBjA0okCcJizyINBMyQoZ8mbvtLuPDp8C1mAtKPzwzfO1SMsMaIS4BOFE V/FOWUOyOQuXRa6fmSp1V5FfasFgfYghf8a7rAywMvKN4BtX9GatEAcaK5NZkyqLwu7aIoP3htT kFHEgLSxZ8+cQ+If3+CCk5zVD9gyKZMOf+83oDhMQKYX0Hp0zz9XEyIcIm+o2L5OZqH+iRkSHX0 /tKd7FvZGdwe3ozg97envwZMbuFBOZtBsC0godOaeWULRWtE2CiyrEP+KulPyQOGDCjs+SBSpmW NXSf7IhwRZhae6WR8qPn9Z7+4dGxJ23Y0nw8eH6KxsIX5EGJidKeDCow5YEwVWwAvQFTudHS04O 3cGfhBS+E+JVE3iKVLQbP1vfN1uvcgknXOmtegQLZ7QynQqCPCmNmn2nGabsmr9WuT4ETzZrt4q y5Vk6dt5joLuutWqBkg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-12_04,2026-02-12_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602120104 ism_vfio_pci is a new kernel component that allows to use the ISM device from userspace. Add myself as a maintainer. Acked-by: Alexandra Winter Signed-off-by: Julian Ruess --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e087673237636268346979ddc270f8cf0905c722..e9d025ea396e71102463a50b293= 4827175356da2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27393,6 +27393,12 @@ L: kvm@vger.kernel.org S: Maintained F: drivers/vfio/pci/hisilicon/ =20 +VFIO ISM PCI DRIVER +M: Julian Ruess +L: kvm@vger.kernel.org +S: Maintained +F: drivers/vfio/pci/ism/ + VFIO MEDIATED DEVICE DRIVERS M: Kirti Wankhede L: kvm@vger.kernel.org --=20 2.51.0