thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-s390x-Move-reset-normal-to-shared-reset-handler.patch

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