0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __KVM_S390_PCI_H
0011 #define __KVM_S390_PCI_H
0012
0013 #include <linux/kvm.h>
0014 #include <linux/kvm_host.h>
0015 #include <linux/mutex.h>
0016 #include <linux/pci.h>
0017 #include <asm/airq.h>
0018 #include <asm/cpu.h>
0019
0020 struct kvm_zdev {
0021 struct zpci_dev *zdev;
0022 struct kvm *kvm;
0023 struct zpci_fib fib;
0024 struct list_head entry;
0025 };
0026
0027 struct zpci_gaite {
0028 u32 gisa;
0029 u8 gisc;
0030 u8 count;
0031 u8 reserved;
0032 u8 aisbo;
0033 u64 aisb;
0034 };
0035
0036 struct zpci_aift {
0037 struct zpci_gaite *gait;
0038 struct airq_iv *sbv;
0039 struct kvm_zdev **kzdev;
0040 spinlock_t gait_lock;
0041 struct mutex aift_lock;
0042 };
0043
0044 extern struct zpci_aift *aift;
0045
0046 static inline struct kvm *kvm_s390_pci_si_to_kvm(struct zpci_aift *aift,
0047 unsigned long si)
0048 {
0049 if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) || !aift->kzdev ||
0050 !aift->kzdev[si])
0051 return NULL;
0052 return aift->kzdev[si]->kvm;
0053 };
0054
0055 int kvm_s390_pci_aen_init(u8 nisc);
0056 void kvm_s390_pci_aen_exit(void);
0057
0058 void kvm_s390_pci_init_list(struct kvm *kvm);
0059 void kvm_s390_pci_clear_list(struct kvm *kvm);
0060
0061 int kvm_s390_pci_zpci_op(struct kvm *kvm, struct kvm_s390_zpci_op *args);
0062
0063 int kvm_s390_pci_init(void);
0064 void kvm_s390_pci_exit(void);
0065
0066 static inline bool kvm_s390_pci_interp_allowed(void)
0067 {
0068 struct cpuid cpu_id;
0069
0070 get_cpu_id(&cpu_id);
0071 switch (cpu_id.machine) {
0072 case 0x2817:
0073 case 0x2818:
0074 case 0x2827:
0075 case 0x2828:
0076 case 0x2964:
0077 case 0x2965:
0078
0079 return false;
0080 default:
0081 return (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) &&
0082 sclp.has_zpci_lsi && sclp.has_aeni && sclp.has_aisi &&
0083 sclp.has_aisii);
0084 }
0085 }
0086
0087 #endif