yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ddf19c
From 53b5a7f83f3e6b94c66cbbb97ea42bbf02cb96b4 Mon Sep 17 00:00:00 2001
ddf19c
From: Thomas Huth <thuth@redhat.com>
ddf19c
Date: Fri, 29 May 2020 05:53:46 -0400
ddf19c
Subject: [PATCH 04/42] s390x: Move reset normal to shared reset handler
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-5-thuth@redhat.com>
ddf19c
Patchwork-id: 97018
ddf19c
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 04/38] s390x: Move reset normal to shared reset handler
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 start moving the cpu reset functions into a single function with
ddf19c
a switch/case, so we can later use fallthroughs and share more code
ddf19c
between resets.
ddf19c
ddf19c
This patch introduces the reset function by renaming cpu_reset().
ddf19c
ddf19c
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
ddf19c
Reviewed-by: David Hildenbrand <david@redhat.com>
ddf19c
Message-Id: <20191127175046.4911-3-frankja@linux.ibm.com>
ddf19c
Reviewed-by: Thomas Huth <thuth@redhat.com>
ddf19c
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
(cherry picked from commit eac4f82791f1807c423e85670837db103b9d59b3)
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 target/s390x/cpu-qom.h |  6 +++++-
ddf19c
 target/s390x/cpu.c     | 19 +++++++++++++------
ddf19c
 target/s390x/cpu.h     |  2 +-
ddf19c
 target/s390x/sigp.c    |  2 +-
ddf19c
 4 files changed, 20 insertions(+), 9 deletions(-)
ddf19c
ddf19c
diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h
ddf19c
index b809ec8418..f3b71bac67 100644
ddf19c
--- a/target/s390x/cpu-qom.h
ddf19c
+++ b/target/s390x/cpu-qom.h
ddf19c
@@ -34,6 +34,10 @@
ddf19c
 typedef struct S390CPUModel S390CPUModel;
ddf19c
 typedef struct S390CPUDef S390CPUDef;
ddf19c
 
ddf19c
+typedef enum cpu_reset_type {
ddf19c
+    S390_CPU_RESET_NORMAL,
ddf19c
+} cpu_reset_type;
ddf19c
+
ddf19c
 /**
ddf19c
  * S390CPUClass:
ddf19c
  * @parent_realize: The parent class' realize handler.
ddf19c
@@ -57,7 +61,7 @@ typedef struct S390CPUClass {
ddf19c
     DeviceRealize parent_realize;
ddf19c
     void (*parent_reset)(CPUState *cpu);
ddf19c
     void (*load_normal)(CPUState *cpu);
ddf19c
-    void (*cpu_reset)(CPUState *cpu);
ddf19c
+    void (*reset)(CPUState *cpu, cpu_reset_type type);
ddf19c
     void (*initial_cpu_reset)(CPUState *cpu);
ddf19c
 } S390CPUClass;
ddf19c
 
ddf19c
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
ddf19c
index 3abe7e80fd..67d6fbfa44 100644
ddf19c
--- a/target/s390x/cpu.c
ddf19c
+++ b/target/s390x/cpu.c
ddf19c
@@ -82,18 +82,25 @@ static void s390_cpu_load_normal(CPUState *s)
ddf19c
 }
ddf19c
 #endif
ddf19c
 
ddf19c
-/* S390CPUClass::cpu_reset() */
ddf19c
-static void s390_cpu_reset(CPUState *s)
ddf19c
+/* S390CPUClass::reset() */
ddf19c
+static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
ddf19c
 {
ddf19c
     S390CPU *cpu = S390_CPU(s);
ddf19c
     S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
ddf19c
     CPUS390XState *env = &cpu->env;
ddf19c
 
ddf19c
-    env->pfault_token = -1UL;
ddf19c
-    env->bpbc = false;
ddf19c
     scc->parent_reset(s);
ddf19c
     cpu->env.sigp_order = 0;
ddf19c
     s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
ddf19c
+
ddf19c
+    switch (type) {
ddf19c
+    case S390_CPU_RESET_NORMAL:
ddf19c
+        env->pfault_token = -1UL;
ddf19c
+        env->bpbc = false;
ddf19c
+        break;
ddf19c
+    default:
ddf19c
+        g_assert_not_reached();
ddf19c
+    }
ddf19c
 }
ddf19c
 
ddf19c
 /* S390CPUClass::initial_reset() */
ddf19c
@@ -102,7 +109,7 @@ static void s390_cpu_initial_reset(CPUState *s)
ddf19c
     S390CPU *cpu = S390_CPU(s);
ddf19c
     CPUS390XState *env = &cpu->env;
ddf19c
 
ddf19c
-    s390_cpu_reset(s);
ddf19c
+    s390_cpu_reset(s, S390_CPU_RESET_NORMAL);
ddf19c
     /* initial reset does not clear everything! */
ddf19c
     memset(&env->start_initial_reset_fields, 0,
ddf19c
         offsetof(CPUS390XState, end_reset_fields) -
ddf19c
@@ -473,7 +480,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
ddf19c
 #if !defined(CONFIG_USER_ONLY)
ddf19c
     scc->load_normal = s390_cpu_load_normal;
ddf19c
 #endif
ddf19c
-    scc->cpu_reset = s390_cpu_reset;
ddf19c
+    scc->reset = s390_cpu_reset;
ddf19c
     scc->initial_cpu_reset = s390_cpu_initial_reset;
ddf19c
     cc->reset = s390_cpu_full_reset;
ddf19c
     cc->class_by_name = s390_cpu_class_by_name,
ddf19c
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
ddf19c
index 17460ed7b3..18123dfd5b 100644
ddf19c
--- a/target/s390x/cpu.h
ddf19c
+++ b/target/s390x/cpu.h
ddf19c
@@ -741,7 +741,7 @@ static inline void s390_do_cpu_reset(CPUState *cs, run_on_cpu_data arg)
ddf19c
 {
ddf19c
     S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
ddf19c
 
ddf19c
-    scc->cpu_reset(cs);
ddf19c
+    scc->reset(cs, S390_CPU_RESET_NORMAL);
ddf19c
 }
ddf19c
 
ddf19c
 static inline void s390_do_cpu_initial_reset(CPUState *cs, run_on_cpu_data arg)
ddf19c
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
ddf19c
index 2ce22d4dc1..850139b9cd 100644
ddf19c
--- a/target/s390x/sigp.c
ddf19c
+++ b/target/s390x/sigp.c
ddf19c
@@ -266,7 +266,7 @@ static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg)
ddf19c
     SigpInfo *si = arg.host_ptr;
ddf19c
 
ddf19c
     cpu_synchronize_state(cs);
ddf19c
-    scc->cpu_reset(cs);
ddf19c
+    scc->reset(cs, S390_CPU_RESET_NORMAL);
ddf19c
     cpu_synchronize_post_reset(cs);
ddf19c
     si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
ddf19c
 }
ddf19c
-- 
ddf19c
2.27.0
ddf19c