From: Christian Borntraeger Date: Mon, 11 Jul 2022 09:28:57 +0000 (+0200) Subject: Merge tag 'kvm-s390-pci-5.20' into kernelorgnext X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d41b5e0176a610152072d2ce7a83879fb07ea2fa;p=linux.git Merge tag 'kvm-s390-pci-5.20' into kernelorgnext KVM: s390/pci: enable zPCI for interpretive execution Add the necessary code in s390 base, pci and KVM to enable interpretion of PCI pasthru. --- d41b5e0176a610152072d2ce7a83879fb07ea2fa diff --cc Documentation/virt/kvm/api.rst index bafaeedd455c3,d58354e9af8f1..5abc0c1a5aff4 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@@ -5930,31 -5802,52 +5930,77 @@@ of CPUID leaf 0xD on the host This ioctl injects an event channel interrupt directly to the guest vCPU. +4.136 KVM_S390_PV_CPU_COMMAND +----------------------------- + +:Capability: KVM_CAP_S390_PROTECTED_DUMP +:Architectures: s390 +:Type: vcpu ioctl +:Parameters: none +:Returns: 0 on success, < 0 on error + +This ioctl closely mirrors `KVM_S390_PV_COMMAND` but handles requests +for vcpus. It re-uses the kvm_s390_pv_dmp struct and hence also shares +the command ids. + +**command:** + +KVM_PV_DUMP + Presents an API that provides calls which facilitate dumping a vcpu + of a protected VM. + +**subcommand:** + +KVM_PV_DUMP_CPU + Provides encrypted dump data like register values. + The length of the returned data is provided by uv_info.guest_cpu_stor_len. + + 4.137 KVM_S390_ZPCI_OP + -------------------- + + :Capability: KVM_CAP_S390_ZPCI_OP + :Architectures: s390 + :Type: vm ioctl + :Parameters: struct kvm_s390_zpci_op (in) + :Returns: 0 on success, <0 on error + + Used to manage hardware-assisted virtualization features for zPCI devices. + + Parameters are specified via the following structure:: + + struct kvm_s390_zpci_op { + /* in */ + __u32 fh; /* target device */ + __u8 op; /* operation to perform */ + __u8 pad[3]; + union { + /* for KVM_S390_ZPCIOP_REG_AEN */ + struct { + __u64 ibv; /* Guest addr of interrupt bit vector */ + __u64 sb; /* Guest addr of summary bit */ + __u32 flags; + __u32 noi; /* Number of interrupts */ + __u8 isc; /* Guest interrupt subclass */ + __u8 sbo; /* Offset of guest summary bit vector */ + __u16 pad; + } reg_aen; + __u64 reserved[8]; + } u; + }; + + The type of operation is specified in the "op" field. + KVM_S390_ZPCIOP_REG_AEN is used to register the VM for adapter event + notification interpretation, which will allow firmware delivery of adapter + events directly to the vm, with KVM providing a backup delivery mechanism; + KVM_S390_ZPCIOP_DEREG_AEN is used to subsequently disable interpretation of + adapter event notifications. + + The target zPCI function must also be specified via the "fh" field. For the + KVM_S390_ZPCIOP_REG_AEN operation, additional information to establish firmware + delivery must be provided via the "reg_aen" struct. + + The "pad" and "reserved" fields may be used for future extensions and should be + set to 0s by userspace. 5. The kvm_run structure ======================== diff --cc arch/s390/kvm/kvm-s390.c index 72bd5c9b96172,f214e0fc62ed7..18b0a6f0cd9c1 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@@ -606,26 -618,9 +618,29 @@@ int kvm_vm_ioctl_check_extension(struc case KVM_CAP_S390_PROTECTED: r = is_prot_virt_host(); break; + case KVM_CAP_S390_PROTECTED_DUMP: { + u64 pv_cmds_dump[] = { + BIT_UVC_CMD_DUMP_INIT, + BIT_UVC_CMD_DUMP_CONFIG_STOR_STATE, + BIT_UVC_CMD_DUMP_CPU, + BIT_UVC_CMD_DUMP_COMPLETE, + }; + int i; + + r = is_prot_virt_host(); + + for (i = 0; i < ARRAY_SIZE(pv_cmds_dump); i++) { + if (!test_bit_inv(pv_cmds_dump[i], + (unsigned long *)&uv_info.inst_calls_list)) { + r = 0; + break; + } + } + break; + } + case KVM_CAP_S390_ZPCI_OP: + r = kvm_s390_pci_interp_allowed(); + break; default: r = 0; } diff --cc include/uapi/linux/kvm.h index a36e78710382b,2f302e2287d1c..20817dd7f2f19 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@@ -1163,10 -1157,7 +1163,11 @@@ struct kvm_ppc_resize_hpt #define KVM_CAP_VM_TSC_CONTROL 214 #define KVM_CAP_SYSTEM_EVENT_DATA 215 #define KVM_CAP_ARM_SYSTEM_SUSPEND 216 +#define KVM_CAP_S390_PROTECTED_DUMP 217 +#define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218 +#define KVM_CAP_X86_NOTIFY_VMEXIT 219 +#define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 + #define KVM_CAP_S390_ZPCI_OP 221 #ifdef KVM_CAP_IRQ_ROUTING @@@ -2179,11 -2119,34 +2180,41 @@@ struct kvm_stats_desc /* Available with KVM_CAP_XSAVE2 */ #define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave) +/* Available with KVM_CAP_S390_PROTECTED_DUMP */ +#define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) + +/* Available with KVM_CAP_X86_NOTIFY_VMEXIT */ +#define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0) +#define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1) + + /* Available with KVM_CAP_S390_ZPCI_OP */ + #define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op) + + struct kvm_s390_zpci_op { + /* in */ + __u32 fh; /* target device */ + __u8 op; /* operation to perform */ + __u8 pad[3]; + union { + /* for KVM_S390_ZPCIOP_REG_AEN */ + struct { + __u64 ibv; /* Guest addr of interrupt bit vector */ + __u64 sb; /* Guest addr of summary bit */ + __u32 flags; + __u32 noi; /* Number of interrupts */ + __u8 isc; /* Guest interrupt subclass */ + __u8 sbo; /* Offset of guest summary bit vector */ + __u16 pad; + } reg_aen; + __u64 reserved[8]; + } u; + }; + + /* types for kvm_s390_zpci_op->op */ + #define KVM_S390_ZPCIOP_REG_AEN 0 + #define KVM_S390_ZPCIOP_DEREG_AEN 1 + + /* flags for kvm_s390_zpci_op->u.reg_aen.flags */ + #define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0) + #endif /* __LINUX_KVM_H */