Skip to content

Commit

Permalink
KVM: s390: pci: add basic kvm_zdev structure
Browse files Browse the repository at this point in the history
This structure will be used to carry kvm passthrough information related to
zPCI devices.

Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
  • Loading branch information
rosatomj authored and intel-lab-lkp committed Apr 26, 2022
1 parent 7c1e525 commit e6d8c62
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/s390/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct zpci_bar_struct {
};

struct s390_domain;
struct kvm_zdev;

#define ZPCI_FUNCTIONS_PER_BUS 256
struct zpci_bus {
Expand Down Expand Up @@ -189,7 +190,9 @@ struct zpci_dev {

struct dentry *debugfs_dev;

/* IOMMU and passthrough */
struct s390_domain *s390_domain; /* s390 IOMMU domain data */
struct kvm_zdev *kzdev;
};

static inline bool zdev_enabled(struct zpci_dev *zdev)
Expand Down
1 change: 1 addition & 0 deletions arch/s390/kvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 38 additions & 0 deletions arch/s390/kvm/pci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-2.0
/*
* s390 kvm PCI passthrough support
*
* Copyright IBM Corp. 2022
*
* Author(s): Matthew Rosato <mjrosato@linux.ibm.com>
*/

#include <linux/kvm_host.h>
#include <linux/pci.h>
#include "pci.h"

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);
21 changes: 21 additions & 0 deletions arch/s390/kvm/pci.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* s390 kvm PCI passthrough support
*
* Copyright IBM Corp. 2022
*
* Author(s): Matthew Rosato <mjrosato@linux.ibm.com>
*/

#ifndef __KVM_S390_PCI_H
#define __KVM_S390_PCI_H

#include <linux/kvm_host.h>
#include <linux/pci.h>

struct kvm_zdev {
struct zpci_dev *zdev;
struct kvm *kvm;
};

#endif /* __KVM_S390_PCI_H */

0 comments on commit e6d8c62

Please sign in to comment.