yeahuh / rpms / qemu-kvm

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