cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ddf19c
From f268cc7071ecb4322c03f3183acbcf90421da3c7 Mon Sep 17 00:00:00 2001
ddf19c
From: Thomas Huth <thuth@redhat.com>
ddf19c
Date: Fri, 29 May 2020 05:53:48 -0400
ddf19c
Subject: [PATCH 06/42] s390x: Move clear reset
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Thomas Huth <thuth@redhat.com>
ddf19c
Message-id: <20200529055420.16855-7-thuth@redhat.com>
ddf19c
Patchwork-id: 97019
ddf19c
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 06/38] s390x: Move clear reset
ddf19c
Bugzilla: 1828317
ddf19c
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
RH-Acked-by: David Hildenbrand <david@redhat.com>
ddf19c
ddf19c
From: Janosch Frank <frankja@linux.ibm.com>
ddf19c
ddf19c
Let's also move the clear reset function into the reset handler.
ddf19c
ddf19c
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
ddf19c
Message-Id: <20191127175046.4911-5-frankja@linux.ibm.com>
ddf19c
Reviewed-by: David Hildenbrand <david@redhat.com>
ddf19c
Reviewed-by: Thomas Huth <thuth@redhat.com>
ddf19c
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
(cherry picked from commit eb8adcc3e9e3b8405c104ede72cf9f3bb2a5e226)
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 target/s390x/cpu-qom.h |  1 +
ddf19c
 target/s390x/cpu.c     | 58 +++++++++++++-----------------------------
ddf19c
 2 files changed, 18 insertions(+), 41 deletions(-)
ddf19c
ddf19c
diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h
ddf19c
index 6f0a12042e..dbe5346ec9 100644
ddf19c
--- a/target/s390x/cpu-qom.h
ddf19c
+++ b/target/s390x/cpu-qom.h
ddf19c
@@ -37,6 +37,7 @@ typedef struct S390CPUDef S390CPUDef;
ddf19c
 typedef enum cpu_reset_type {
ddf19c
     S390_CPU_RESET_NORMAL,
ddf19c
     S390_CPU_RESET_INITIAL,
ddf19c
+    S390_CPU_RESET_CLEAR,
ddf19c
 } cpu_reset_type;
ddf19c
 
ddf19c
 /**
ddf19c
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
ddf19c
index ca62fe7685..bd39cb54b7 100644
ddf19c
--- a/target/s390x/cpu.c
ddf19c
+++ b/target/s390x/cpu.c
ddf19c
@@ -94,6 +94,9 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
ddf19c
     s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
ddf19c
 
ddf19c
     switch (type) {
ddf19c
+    case S390_CPU_RESET_CLEAR:
ddf19c
+        memset(env, 0, offsetof(CPUS390XState, start_initial_reset_fields));
ddf19c
+        /* fall through */
ddf19c
     case S390_CPU_RESET_INITIAL:
ddf19c
         /* initial reset does not clear everything! */
ddf19c
         memset(&env->start_initial_reset_fields, 0,
ddf19c
@@ -107,6 +110,14 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
ddf19c
         env->cregs[0] = CR0_RESET;
ddf19c
         env->cregs[14] = CR14_RESET;
ddf19c
 
ddf19c
+#if defined(CONFIG_USER_ONLY)
ddf19c
+        /* user mode should always be allowed to use the full FPU */
ddf19c
+        env->cregs[0] |= CR0_AFP;
ddf19c
+        if (s390_has_feat(S390_FEAT_VECTOR)) {
ddf19c
+            env->cregs[0] |= CR0_VECTOR;
ddf19c
+        }
ddf19c
+#endif
ddf19c
+
ddf19c
         /* tininess for underflow is detected before rounding */
ddf19c
         set_float_detect_tininess(float_tininess_before_rounding,
ddf19c
                                   &env->fpu_status);
ddf19c
@@ -125,46 +136,6 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
ddf19c
     }
ddf19c
 }
ddf19c
 
ddf19c
-/* CPUClass:reset() */
ddf19c
-static void s390_cpu_full_reset(CPUState *s)
ddf19c
-{
ddf19c
-    S390CPU *cpu = S390_CPU(s);
ddf19c
-    S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
ddf19c
-    CPUS390XState *env = &cpu->env;
ddf19c
-
ddf19c
-    scc->parent_reset(s);
ddf19c
-    cpu->env.sigp_order = 0;
ddf19c
-    s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
ddf19c
-
ddf19c
-    memset(env, 0, offsetof(CPUS390XState, end_reset_fields));
ddf19c
-
ddf19c
-    /* architectured initial values for CR 0 and 14 */
ddf19c
-    env->cregs[0] = CR0_RESET;
ddf19c
-    env->cregs[14] = CR14_RESET;
ddf19c
-
ddf19c
-#if defined(CONFIG_USER_ONLY)
ddf19c
-    /* user mode should always be allowed to use the full FPU */
ddf19c
-    env->cregs[0] |= CR0_AFP;
ddf19c
-    if (s390_has_feat(S390_FEAT_VECTOR)) {
ddf19c
-        env->cregs[0] |= CR0_VECTOR;
ddf19c
-    }
ddf19c
-#endif
ddf19c
-
ddf19c
-    /* architectured initial value for Breaking-Event-Address register */
ddf19c
-    env->gbea = 1;
ddf19c
-
ddf19c
-    env->pfault_token = -1UL;
ddf19c
-
ddf19c
-    /* tininess for underflow is detected before rounding */
ddf19c
-    set_float_detect_tininess(float_tininess_before_rounding,
ddf19c
-                              &env->fpu_status);
ddf19c
-
ddf19c
-    /* Reset state inside the kernel that we cannot access yet from QEMU. */
ddf19c
-    if (kvm_enabled()) {
ddf19c
-        kvm_s390_reset_vcpu(cpu);
ddf19c
-    }
ddf19c
-}
ddf19c
-
ddf19c
 #if !defined(CONFIG_USER_ONLY)
ddf19c
 static void s390_cpu_machine_reset_cb(void *opaque)
ddf19c
 {
ddf19c
@@ -456,6 +427,11 @@ static Property s390x_cpu_properties[] = {
ddf19c
     DEFINE_PROP_END_OF_LIST()
ddf19c
 };
ddf19c
 
ddf19c
+static void s390_cpu_reset_full(CPUState *s)
ddf19c
+{
ddf19c
+    return s390_cpu_reset(s, S390_CPU_RESET_CLEAR);
ddf19c
+}
ddf19c
+
ddf19c
 static void s390_cpu_class_init(ObjectClass *oc, void *data)
ddf19c
 {
ddf19c
     S390CPUClass *scc = S390_CPU_CLASS(oc);
ddf19c
@@ -472,7 +448,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
ddf19c
     scc->load_normal = s390_cpu_load_normal;
ddf19c
 #endif
ddf19c
     scc->reset = s390_cpu_reset;
ddf19c
-    cc->reset = s390_cpu_full_reset;
ddf19c
+    cc->reset = s390_cpu_reset_full;
ddf19c
     cc->class_by_name = s390_cpu_class_by_name,
ddf19c
     cc->has_work = s390_cpu_has_work;
ddf19c
 #ifdef CONFIG_TCG
ddf19c
-- 
ddf19c
2.27.0
ddf19c