From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6776C433FE for ; Mon, 14 Mar 2022 19:48:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 67173405B0; Mon, 14 Mar 2022 19:48:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HLXmIw4UnyZG; Mon, 14 Mar 2022 19:48:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id CB0954027A; Mon, 14 Mar 2022 19:48:06 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AF554C001D; Mon, 14 Mar 2022 19:48:06 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 292DDC000B for ; Mon, 14 Mar 2022 19:48:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0ADE840296 for ; Mon, 14 Mar 2022 19:48:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=ibm.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aLtI-_QK8vSy for ; Mon, 14 Mar 2022 19:48:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by smtp4.osuosl.org (Postfix) with ESMTPS id 593B240875 for ; Mon, 14 Mar 2022 19:48:05 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22EJlVxk009409; Mon, 14 Mar 2022 19:48:01 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=kCDw090+mnOqOV0AKY4gRGgkIfsKtTXvrNrv0uShJbo=; b=OLigEpHp/hjNJK6xcj8IZyHuD7CzWk3acRRkVgezurwScDYxNgmGHKLx9ji2lcf7vLSz ohxTRDxUZBPpn0HfGt7tdnlrrk6yr448BZznm8i2x+mCiCHdSUEATBEKKJdyWFBR78Mv 4iialU+1My1sC8c3hvIuFvHSdVGAGM+YAXgpFTipZ0VKl6NrNq74+mBSr/t38V1CITdJ 9GNwV3stPc5l4pDLa4iL7kJowLY2NDh1KAznYVVDd52Zpl2JyItZRviVF2LsFZMPcaEj lk7R2NAEDmugxx405XrDDJoZLl3NvVlssEuBMApNPeluqbdJHjdhqrRFXO4Dgag2RPyK Kw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3et6d2rffa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 19:48:00 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22EJm0XZ011600; Mon, 14 Mar 2022 19:48:00 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3et6d2rff2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 19:48:00 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 22EJlB1B005387; Mon, 14 Mar 2022 19:47:59 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma01wdc.us.ibm.com with ESMTP id 3erk59897u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 19:47:59 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22EJlw5q4260736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Mar 2022 19:47:58 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44889112067; Mon, 14 Mar 2022 19:47:58 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FCFC112064; Mon, 14 Mar 2022 19:47:50 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.32.184]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 14 Mar 2022 19:47:50 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Subject: [PATCH v4 17/32] KVM: s390: pci: add basic kvm_zdev structure Date: Mon, 14 Mar 2022 15:44:36 -0400 Message-Id: <20220314194451.58266-18-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220314194451.58266-1-mjrosato@linux.ibm.com> References: <20220314194451.58266-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 1Mn35uRJ3i3xLvAUTPndzA7keYgPfFm3 X-Proofpoint-ORIG-GUID: RX_8gz8j4AKbKw4Q2TOqJ8KI5KIsjATO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-14_13,2022-03-14_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=777 clxscore=1015 spamscore=0 impostorscore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203140116 Cc: kvm@vger.kernel.org, david@redhat.com, thuth@redhat.com, linux-kernel@vger.kernel.org, vneethv@linux.ibm.com, agordeev@linux.ibm.com, imbrenda@linux.ibm.com, will@kernel.org, frankja@linux.ibm.com, corbet@lwn.net, linux-doc@vger.kernel.org, pasic@linux.ibm.com, jgg@nvidia.com, gerald.schaefer@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, gor@linux.ibm.com, schnelle@linux.ibm.com, hca@linux.ibm.com, alex.williamson@redhat.com, freude@linux.ibm.com, pmorel@linux.ibm.com, cohuck@redhat.com, oberpar@linux.ibm.com, iommu@lists.linux-foundation.org, svens@linux.ibm.com, pbonzini@redhat.com X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" This structure will be used to carry kvm passthrough information related to zPCI devices. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 27 +++++++++++++++++++++++ arch/s390/include/asm/pci.h | 3 +++ arch/s390/kvm/Makefile | 1 + arch/s390/kvm/pci.c | 38 +++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 arch/s390/include/asm/kvm_pci.h create mode 100644 arch/s390/kvm/pci.c diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h new file mode 100644 index 000000000000..ae8669105f72 --- /dev/null +++ b/arch/s390/include/asm/kvm_pci.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * KVM PCI Passthrough for virtual machines on s390 + * + * Copyright IBM Corp. 2022 + * + * Author(s): Matthew Rosato + */ + +#ifndef ASM_KVM_PCI_H +#define ASM_KVM_PCI_H + +#include +#include +#include +#include +#include + +struct kvm_zdev { + struct zpci_dev *zdev; + struct kvm *kvm; +}; + +int kvm_s390_pci_dev_open(struct zpci_dev *zdev); +void kvm_s390_pci_dev_release(struct zpci_dev *zdev); + +#endif /* ASM_KVM_PCI_H */ diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index e8a3fd5bc169..4faff673078b 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -97,6 +97,7 @@ struct zpci_bar_struct { }; struct s390_domain; +struct kvm_zdev; #define ZPCI_FUNCTIONS_PER_BUS 256 struct zpci_bus { @@ -190,6 +191,8 @@ struct zpci_dev { struct dentry *debugfs_dev; struct s390_domain *s390_domain; /* s390 IOMMU domain data */ + + struct kvm_zdev *kzdev; /* passthrough data */ }; static inline bool zdev_enabled(struct zpci_dev *zdev) diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 26f4a74e5ce4..00cf6853d93f 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -10,4 +10,5 @@ ccflags-y := -Ivirt/kvm -Iarch/s390/kvm kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o +kvm-$(CONFIG_PCI) += pci.o obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c new file mode 100644 index 000000000000..612faf87126d --- /dev/null +++ b/arch/s390/kvm/pci.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * s390 kvm PCI passthrough support + * + * Copyright IBM Corp. 2022 + * + * Author(s): Matthew Rosato + */ + +#include +#include +#include + +int kvm_s390_pci_dev_open(struct zpci_dev *zdev) +{ + struct kvm_zdev *kzdev; + + kzdev = kzalloc(sizeof(struct kvm_zdev), GFP_KERNEL); + if (!kzdev) + return -ENOMEM; + + kzdev->zdev = zdev; + zdev->kzdev = kzdev; + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_open); + +void kvm_s390_pci_dev_release(struct zpci_dev *zdev) +{ + struct kvm_zdev *kzdev; + + kzdev = zdev->kzdev; + WARN_ON(kzdev->zdev != zdev); + zdev->kzdev = 0; + kfree(kzdev); +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_release); -- 2.27.0 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF518C433F5 for ; Mon, 14 Mar 2022 19:48:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244502AbiCNTtq (ORCPT ); Mon, 14 Mar 2022 15:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244539AbiCNTtg (ORCPT ); Mon, 14 Mar 2022 15:49:36 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C6D53ED3D; Mon, 14 Mar 2022 12:48:09 -0700 (PDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22EJlVxk009409; Mon, 14 Mar 2022 19:48:01 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=kCDw090+mnOqOV0AKY4gRGgkIfsKtTXvrNrv0uShJbo=; b=OLigEpHp/hjNJK6xcj8IZyHuD7CzWk3acRRkVgezurwScDYxNgmGHKLx9ji2lcf7vLSz ohxTRDxUZBPpn0HfGt7tdnlrrk6yr448BZznm8i2x+mCiCHdSUEATBEKKJdyWFBR78Mv 4iialU+1My1sC8c3hvIuFvHSdVGAGM+YAXgpFTipZ0VKl6NrNq74+mBSr/t38V1CITdJ 9GNwV3stPc5l4pDLa4iL7kJowLY2NDh1KAznYVVDd52Zpl2JyItZRviVF2LsFZMPcaEj lk7R2NAEDmugxx405XrDDJoZLl3NvVlssEuBMApNPeluqbdJHjdhqrRFXO4Dgag2RPyK Kw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3et6d2rffa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 19:48:00 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22EJm0XZ011600; Mon, 14 Mar 2022 19:48:00 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3et6d2rff2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 19:48:00 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 22EJlB1B005387; Mon, 14 Mar 2022 19:47:59 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma01wdc.us.ibm.com with ESMTP id 3erk59897u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 19:47:59 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22EJlw5q4260736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Mar 2022 19:47:58 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44889112067; Mon, 14 Mar 2022 19:47:58 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FCFC112064; Mon, 14 Mar 2022 19:47:50 +0000 (GMT) Received: from li-c92d2ccc-254b-11b2-a85c-a700b5bfb098.ibm.com.com (unknown [9.211.32.184]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 14 Mar 2022 19:47:50 +0000 (GMT) From: Matthew Rosato To: linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, joro@8bytes.org, will@kernel.org, pbonzini@redhat.com, corbet@lwn.net, jgg@nvidia.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-doc@vger.kernel.org Subject: [PATCH v4 17/32] KVM: s390: pci: add basic kvm_zdev structure Date: Mon, 14 Mar 2022 15:44:36 -0400 Message-Id: <20220314194451.58266-18-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220314194451.58266-1-mjrosato@linux.ibm.com> References: <20220314194451.58266-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 1Mn35uRJ3i3xLvAUTPndzA7keYgPfFm3 X-Proofpoint-ORIG-GUID: RX_8gz8j4AKbKw4Q2TOqJ8KI5KIsjATO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-14_13,2022-03-14_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=777 clxscore=1015 spamscore=0 impostorscore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203140116 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This structure will be used to carry kvm passthrough information related to zPCI devices. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 27 +++++++++++++++++++++++ arch/s390/include/asm/pci.h | 3 +++ arch/s390/kvm/Makefile | 1 + arch/s390/kvm/pci.c | 38 +++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 arch/s390/include/asm/kvm_pci.h create mode 100644 arch/s390/kvm/pci.c diff --git a/arch/s390/include/asm/kvm_pci.h b/arch/s390/include/asm/kvm_pci.h new file mode 100644 index 000000000000..ae8669105f72 --- /dev/null +++ b/arch/s390/include/asm/kvm_pci.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * KVM PCI Passthrough for virtual machines on s390 + * + * Copyright IBM Corp. 2022 + * + * Author(s): Matthew Rosato + */ + +#ifndef ASM_KVM_PCI_H +#define ASM_KVM_PCI_H + +#include +#include +#include +#include +#include + +struct kvm_zdev { + struct zpci_dev *zdev; + struct kvm *kvm; +}; + +int kvm_s390_pci_dev_open(struct zpci_dev *zdev); +void kvm_s390_pci_dev_release(struct zpci_dev *zdev); + +#endif /* ASM_KVM_PCI_H */ diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index e8a3fd5bc169..4faff673078b 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -97,6 +97,7 @@ struct zpci_bar_struct { }; struct s390_domain; +struct kvm_zdev; #define ZPCI_FUNCTIONS_PER_BUS 256 struct zpci_bus { @@ -190,6 +191,8 @@ struct zpci_dev { struct dentry *debugfs_dev; struct s390_domain *s390_domain; /* s390 IOMMU domain data */ + + struct kvm_zdev *kzdev; /* passthrough data */ }; static inline bool zdev_enabled(struct zpci_dev *zdev) diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 26f4a74e5ce4..00cf6853d93f 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -10,4 +10,5 @@ ccflags-y := -Ivirt/kvm -Iarch/s390/kvm kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o +kvm-$(CONFIG_PCI) += pci.o obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c new file mode 100644 index 000000000000..612faf87126d --- /dev/null +++ b/arch/s390/kvm/pci.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * s390 kvm PCI passthrough support + * + * Copyright IBM Corp. 2022 + * + * Author(s): Matthew Rosato + */ + +#include +#include +#include + +int kvm_s390_pci_dev_open(struct zpci_dev *zdev) +{ + struct kvm_zdev *kzdev; + + kzdev = kzalloc(sizeof(struct kvm_zdev), GFP_KERNEL); + if (!kzdev) + return -ENOMEM; + + kzdev->zdev = zdev; + zdev->kzdev = kzdev; + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_open); + +void kvm_s390_pci_dev_release(struct zpci_dev *zdev) +{ + struct kvm_zdev *kzdev; + + kzdev = zdev->kzdev; + WARN_ON(kzdev->zdev != zdev); + zdev->kzdev = 0; + kfree(kzdev); +} +EXPORT_SYMBOL_GPL(kvm_s390_pci_dev_release); -- 2.27.0