Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: s390: mechanism to enable guest zPCI Interpretation

The guest must have access to certain facilities in order to allow
interpretive execution of zPCI instructions and adapter event
notifications. However, there are some cases where a guest might
disable interpretation -- provide a mechanism via which we can defer
enabling the associated zPCI interpretation facilities until the guest
indicates it wishes to use them.

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Link: https://lore.kernel.org/r/20220606203325.110625-15-mjrosato@linux.ibm.com
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>

authored by

Matthew Rosato and committed by
Christian Borntraeger
3f4bbb43 73f91b00

+52
+4
arch/s390/include/asm/kvm_host.h
··· 254 254 #define ECB2_IEP 0x20 255 255 #define ECB2_PFMFI 0x08 256 256 #define ECB2_ESCA 0x04 257 + #define ECB2_ZPCI_LSI 0x02 257 258 __u8 ecb2; /* 0x0062 */ 259 + #define ECB3_AISI 0x20 260 + #define ECB3_AISII 0x10 258 261 #define ECB3_DEA 0x08 259 262 #define ECB3_AES 0x04 260 263 #define ECB3_RI 0x01 ··· 943 940 int use_cmma; 944 941 int use_pfmfi; 945 942 int use_skf; 943 + int use_zpci_interp; 946 944 int user_cpu_state_ctrl; 947 945 int user_sigp; 948 946 int user_stsi;
+38
arch/s390/kvm/kvm-s390.c
··· 1031 1031 return 0; 1032 1032 } 1033 1033 1034 + static void kvm_s390_vcpu_pci_setup(struct kvm_vcpu *vcpu) 1035 + { 1036 + /* Only set the ECB bits after guest requests zPCI interpretation */ 1037 + if (!vcpu->kvm->arch.use_zpci_interp) 1038 + return; 1039 + 1040 + vcpu->arch.sie_block->ecb2 |= ECB2_ZPCI_LSI; 1041 + vcpu->arch.sie_block->ecb3 |= ECB3_AISII + ECB3_AISI; 1042 + } 1043 + 1044 + void kvm_s390_vcpu_pci_enable_interp(struct kvm *kvm) 1045 + { 1046 + struct kvm_vcpu *vcpu; 1047 + unsigned long i; 1048 + 1049 + lockdep_assert_held(&kvm->lock); 1050 + 1051 + if (!kvm_s390_pci_interp_allowed()) 1052 + return; 1053 + 1054 + /* 1055 + * If host is configured for PCI and the necessary facilities are 1056 + * available, turn on interpretation for the life of this guest 1057 + */ 1058 + kvm->arch.use_zpci_interp = 1; 1059 + 1060 + kvm_s390_vcpu_block_all(kvm); 1061 + 1062 + kvm_for_each_vcpu(i, vcpu, kvm) { 1063 + kvm_s390_vcpu_pci_setup(vcpu); 1064 + kvm_s390_sync_request(KVM_REQ_VSIE_RESTART, vcpu); 1065 + } 1066 + 1067 + kvm_s390_vcpu_unblock_all(kvm); 1068 + } 1069 + 1034 1070 static void kvm_s390_sync_request_broadcast(struct kvm *kvm, int req) 1035 1071 { 1036 1072 unsigned long cx; ··· 3371 3335 vcpu->arch.sie_block->hpid = HPID_KVM; 3372 3336 3373 3337 kvm_s390_vcpu_crypto_setup(vcpu); 3338 + 3339 + kvm_s390_vcpu_pci_setup(vcpu); 3374 3340 3375 3341 mutex_lock(&vcpu->kvm->lock); 3376 3342 if (kvm_s390_pv_is_protected(vcpu->kvm)) {
+10
arch/s390/kvm/kvm-s390.h
··· 508 508 void kvm_s390_vcpu_crypto_reset_all(struct kvm *kvm); 509 509 510 510 /** 511 + * kvm_s390_vcpu_pci_enable_interp 512 + * 513 + * Set the associated PCI attributes for each vcpu to allow for zPCI Load/Store 514 + * interpretation as well as adapter interruption forwarding. 515 + * 516 + * @kvm: the KVM guest 517 + */ 518 + void kvm_s390_vcpu_pci_enable_interp(struct kvm *kvm); 519 + 520 + /** 511 521 * diag9c_forwarding_hz 512 522 * 513 523 * Set the maximum number of diag9c forwarding per second