diff mbox series

[SRU,B,D,2/9] KVM: s390: implement subfunction processor calls

Message ID 1563260079-14121-3-git-send-email-frank.heimes@canonical.com
State New
Headers show
Series zKVM: Add hardware CPU Model - kernel part (LP: 1836153) | expand

Commit Message

Frank Heimes July 16, 2019, 6:54 a.m. UTC
From: Christian Borntraeger <borntraeger@de.ibm.com>

BugLink: https://bugs.launchpad.net/bugs/1836153

While we will not implement interception for query functions yet, we can
and should disable functions that have a control bit based on the given
CPU model.

Let us start with enabling the subfunction interface.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
(cherry picked from commit 346fa2f891c71a9b98014f8f62c15f4c7dd95ec1)
Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
---
 arch/s390/include/asm/kvm_host.h |  1 +
 arch/s390/kvm/kvm-s390.c         | 95 ++--------------------------------------
 2 files changed, 4 insertions(+), 92 deletions(-)
diff mbox series

Patch

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index f243436..b5b7362 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -688,6 +688,7 @@  struct s390_io_adapter {
 struct kvm_s390_cpu_model {
 	/* facility mask supported by kvm & hosting machine */
 	__u64 fac_mask[S390_ARCH_FAC_LIST_SIZE_U64];
+	struct kvm_s390_vm_cpu_subfunc subfuncs;
 	/* facility list requested by guest (in dma page) */
 	__u64 *fac_list;
 	u64 cpuid;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index caea10f..951cb26 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1218,51 +1218,6 @@  static int kvm_s390_set_processor_subfunc(struct kvm *kvm,
 	}
 	mutex_unlock(&kvm->lock);
 
-	VM_EVENT(kvm, 3, "SET: guest PLO    subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[1],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[2],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[3]);
-	VM_EVENT(kvm, 3, "SET: guest PTFF   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KMAC   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KMC    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KM     subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.km)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.km)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KIMD   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KLMD   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[1]);
-	VM_EVENT(kvm, 3, "SET: guest PCKMO  subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KMCTR  subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KMF    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KMO    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[1]);
-	VM_EVENT(kvm, 3, "SET: guest PCC    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[1]);
-	VM_EVENT(kvm, 3, "SET: guest PPNO   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[1]);
-	VM_EVENT(kvm, 3, "SET: guest KMA    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[1]);
-
 	return 0;
 }
 
@@ -1378,51 +1333,6 @@  static int kvm_s390_get_processor_subfunc(struct kvm *kvm,
 	    sizeof(struct kvm_s390_vm_cpu_subfunc)))
 		return -EFAULT;
 
-	VM_EVENT(kvm, 3, "GET: guest PLO    subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[1],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[2],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[3]);
-	VM_EVENT(kvm, 3, "GET: guest PTFF   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KMAC   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KMC    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KM     subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.km)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.km)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KIMD   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KLMD   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[1]);
-	VM_EVENT(kvm, 3, "GET: guest PCKMO  subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KMCTR  subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KMF    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KMO    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[1]);
-	VM_EVENT(kvm, 3, "GET: guest PCC    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[1]);
-	VM_EVENT(kvm, 3, "GET: guest PPNO   subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[1]);
-	VM_EVENT(kvm, 3, "GET: guest KMA    subfunc 0x%16.16lx.%16.16lx",
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[0],
-		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[1]);
-
 	return 0;
 }
 
@@ -1480,6 +1390,7 @@  static int kvm_s390_get_machine_subfunc(struct kvm *kvm,
 
 	return 0;
 }
+
 static int kvm_s390_get_cpu_model(struct kvm *kvm, struct kvm_device_attr *attr)
 {
 	int ret = -ENXIO;
@@ -1597,10 +1508,9 @@  static int kvm_s390_vm_has_attr(struct kvm *kvm, struct kvm_device_attr *attr)
 		case KVM_S390_VM_CPU_PROCESSOR_FEAT:
 		case KVM_S390_VM_CPU_MACHINE_FEAT:
 		case KVM_S390_VM_CPU_MACHINE_SUBFUNC:
+		case KVM_S390_VM_CPU_PROCESSOR_SUBFUNC:
 			ret = 0;
 			break;
-		/* configuring subfunctions is not supported yet */
-		case KVM_S390_VM_CPU_PROCESSOR_SUBFUNC:
 		default:
 			ret = -ENXIO;
 			break;
@@ -2214,6 +2124,7 @@  int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 		kvm->arch.model.fac_list[i] = S390_lowcore.stfle_fac_list[i] &
 					      kvm_s390_fac_base[i];
 	}
+	kvm->arch.model.subfuncs = kvm_s390_available_subfunc;
 
 	/* we are always in czam mode - even on pre z14 machines */
 	set_kvm_facility(kvm->arch.model.fac_mask, 138);