From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFLKk-0004T7-A5 for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFLKd-0007dx-El for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7631 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFLKd-0007dl-9s for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:07 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5LCxOdr005764 for ; Tue, 21 Jun 2016 09:03:07 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 23mywx6ner-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 21 Jun 2016 09:03:07 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 Jun 2016 14:03:05 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 14856219005F for ; Tue, 21 Jun 2016 14:02:33 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5LD32tV63897734 for ; Tue, 21 Jun 2016 13:03:02 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5LC345p017706 for ; Tue, 21 Jun 2016 06:03:04 -0600 From: David Hildenbrand Date: Tue, 21 Jun 2016 15:02:15 +0200 In-Reply-To: <1466514153-85777-1-git-send-email-dahi@linux.vnet.ibm.com> References: <1466514153-85777-1-git-send-email-dahi@linux.vnet.ibm.com> Message-Id: <1466514153-85777-11-git-send-email-dahi@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC 10/28] s390x/cpumodel: let the CPU model handle feature checks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ehabkost@redhat.com, jdenemar@redhat.com, imammedo@redhat.com, cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, fiuczy@linux.vnet.ibm.com, mimu@linux.vnet.ibm.com If we have certain features enabled, we have to migrate additional state (e.g. vector registers or runtime-instrumentation registers). Let the CPU model control that unless we have no "host" CPU model in the KVM case. This will later on be the case for compatibility machines, so migration from QEMU versions without the CPU model will still work. Acked-by: Cornelia Huck Signed-off-by: David Hildenbrand --- target-s390x/cpu_models.c | 24 ++++++++++++++++++++++++ target-s390x/cpu_models.h | 2 ++ target-s390x/machine.c | 14 ++------------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c index 93e63cb..7e3f544 100644 --- a/target-s390x/cpu_models.c +++ b/target-s390x/cpu_models.c @@ -73,6 +73,30 @@ static const S390CPUDef s390_cpu_defs[] = { CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"), }; +bool s390_has_feat(S390Feat feat) +{ + static S390CPU *cpu; + + if (!cpu) { + cpu = S390_CPU(qemu_get_cpu(0)); + } + + if (!cpu || !cpu->model) { +#ifdef CONFIG_KVM + if (kvm_enabled()) { + if (feat == S390_FEAT_VECTOR) { + return kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS); + } + if (feat == S390_FEAT_RUNTIME_INSTRUMENTATION) { + return kvm_s390_get_ri(); + } + } +#endif + return 0; + } + return test_bit(feat, cpu->model->features); +} + struct S390PrintCpuListInfo { FILE *f; fprintf_function print; diff --git a/target-s390x/cpu_models.h b/target-s390x/cpu_models.h index 244256b..fe988cc 100644 --- a/target-s390x/cpu_models.h +++ b/target-s390x/cpu_models.h @@ -43,4 +43,6 @@ typedef struct S390CPUModel { uint8_t cpu_ver; /* CPU version, usually "ff" for kvm */ } S390CPUModel; +bool s390_has_feat(S390Feat feat); + #endif /* TARGET_S390X_CPU_MODELS_H */ diff --git a/target-s390x/machine.c b/target-s390x/machine.c index aa39e5d..edc3a47 100644 --- a/target-s390x/machine.c +++ b/target-s390x/machine.c @@ -78,12 +78,7 @@ static const VMStateDescription vmstate_fpu = { static bool vregs_needed(void *opaque) { -#ifdef CONFIG_KVM - if (kvm_enabled()) { - return kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS); - } -#endif - return 0; + return s390_has_feat(S390_FEAT_VECTOR); } static const VMStateDescription vmstate_vregs = { @@ -147,12 +142,7 @@ static const VMStateDescription vmstate_vregs = { static bool riccb_needed(void *opaque) { -#ifdef CONFIG_KVM - if (kvm_enabled()) { - return kvm_s390_get_ri(); - } -#endif - return 0; + return s390_has_feat(S390_FEAT_RUNTIME_INSTRUMENTATION); } const VMStateDescription vmstate_riccb = { -- 2.6.6