|
Pablo Greco |
e6a3ae |
From 10cd7878be0501be1e27b7b00c14958efcdb3d9b Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
e6a3ae |
From: Cornelia Huck <cohuck@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Date: Wed, 17 Apr 2019 13:57:22 +0100
|
|
Pablo Greco |
e6a3ae |
Subject: [PATCH 05/24] s390x/cpumodel: fix segmentation fault when baselining
|
|
Pablo Greco |
e6a3ae |
models
|
|
Pablo Greco |
e6a3ae |
MIME-Version: 1.0
|
|
Pablo Greco |
e6a3ae |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
e6a3ae |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
RH-Author: Cornelia Huck <cohuck@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Message-id: <20190417135741.25297-6-cohuck@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Patchwork-id: 85784
|
|
Pablo Greco |
e6a3ae |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 05/24] s390x/cpumodel: fix segmentation fault when baselining models
|
|
Pablo Greco |
e6a3ae |
Bugzilla: 1699070
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
Pablo Greco |
e6a3ae |
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
From: David Hildenbrand <david@redhat.com>
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Usually, when baselining two CPU models, whereby one of them has base
|
|
Pablo Greco |
e6a3ae |
CPU features disabled (e.g. z14-base,msa=off), we fallback to an older
|
|
Pablo Greco |
e6a3ae |
model that did not have these features in the base model. We always try to
|
|
Pablo Greco |
e6a3ae |
create a "sane" CPU model (as far as possible), and one part of it is that
|
|
Pablo Greco |
e6a3ae |
removing base features is no good and to be avoided.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Now, if we disable base features that were part of a z900, we're out of
|
|
Pablo Greco |
e6a3ae |
luck. We won't find a CPU model and QEMU will segfault. This is a
|
|
Pablo Greco |
e6a3ae |
scenario that should never happen in real life, but it can be used to
|
|
Pablo Greco |
e6a3ae |
crash QEMU.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
So let's properly report an error if we baseline e.g.:
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
{ "execute": "query-cpu-model-baseline",
|
|
Pablo Greco |
e6a3ae |
"arguments" : { "modela": { "name": "z14-base", "props": {"esan3" : false}},
|
|
Pablo Greco |
e6a3ae |
"modelb": { "name": "z14"}} }
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Instead of segfaulting.
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Message-Id: <20180718092330.19465-1-david@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
Pablo Greco |
e6a3ae |
(cherry picked from commit 677ff32db12bcd1bca3a3df733d2478896d6df96)
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
Pablo Greco |
e6a3ae |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
Pablo Greco |
e6a3ae |
---
|
|
Pablo Greco |
e6a3ae |
target/s390x/cpu_models.c | 8 ++++++++
|
|
Pablo Greco |
e6a3ae |
1 file changed, 8 insertions(+)
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
|
|
Pablo Greco |
e6a3ae |
index 5e9b716..d2c16b8 100644
|
|
Pablo Greco |
e6a3ae |
--- a/target/s390x/cpu_models.c
|
|
Pablo Greco |
e6a3ae |
+++ b/target/s390x/cpu_models.c
|
|
Pablo Greco |
e6a3ae |
@@ -720,6 +720,14 @@ CpuModelBaselineInfo *arch_query_cpu_model_baseline(CpuModelInfo *infoa,
|
|
Pablo Greco |
e6a3ae |
|
|
Pablo Greco |
e6a3ae |
model.def = s390_find_cpu_def(cpu_type, max_gen, max_gen_ga,
|
|
Pablo Greco |
e6a3ae |
model.features);
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
+ /* models without early base features (esan3) are bad */
|
|
Pablo Greco |
e6a3ae |
+ if (!model.def) {
|
|
Pablo Greco |
e6a3ae |
+ error_setg(errp, "No compatible CPU model could be created as"
|
|
Pablo Greco |
e6a3ae |
+ " important base features are disabled");
|
|
Pablo Greco |
e6a3ae |
+ return NULL;
|
|
Pablo Greco |
e6a3ae |
+ }
|
|
Pablo Greco |
e6a3ae |
+
|
|
Pablo Greco |
e6a3ae |
/* strip off features not part of the max model */
|
|
Pablo Greco |
e6a3ae |
bitmap_and(model.features, model.features, model.def->full_feat,
|
|
Pablo Greco |
e6a3ae |
S390_FEAT_MAX);
|
|
Pablo Greco |
e6a3ae |
--
|
|
Pablo Greco |
e6a3ae |
1.8.3.1
|
|
Pablo Greco |
e6a3ae |
|