yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
902636
From bdad28b11e36f657cb8909e7223a7d8fc0948c2e Mon Sep 17 00:00:00 2001
902636
From: Thomas Huth <thuth@redhat.com>
902636
Date: Fri, 29 May 2020 05:53:51 -0400
902636
Subject: [PATCH 09/42] s390x: Fix cpu normal reset ri clearing
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-10-thuth@redhat.com>
902636
Patchwork-id: 97029
902636
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 09/38] s390x: Fix cpu normal reset ri clearing
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
As it turns out we need to clear the ri controls and PSW enablement
902636
bit to be architecture compliant.
902636
902636
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
902636
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
902636
Message-Id: <20191203132813.2734-4-frankja@linux.ibm.com>
902636
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
902636
(cherry picked from commit e893baee70149896d1e43e341da4d6c614037d5d)
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 target/s390x/cpu.c | 7 ++++++-
902636
 target/s390x/cpu.h | 7 ++++++-
902636
 2 files changed, 12 insertions(+), 2 deletions(-)
902636
902636
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
902636
index bd39cb54b7..99ea09085a 100644
902636
--- a/target/s390x/cpu.c
902636
+++ b/target/s390x/cpu.c
902636
@@ -100,7 +100,7 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
902636
     case S390_CPU_RESET_INITIAL:
902636
         /* initial reset does not clear everything! */
902636
         memset(&env->start_initial_reset_fields, 0,
902636
-               offsetof(CPUS390XState, end_reset_fields) -
902636
+               offsetof(CPUS390XState, start_normal_reset_fields) -
902636
                offsetof(CPUS390XState, start_initial_reset_fields));
902636
 
902636
         /* architectured initial value for Breaking-Event-Address register */
902636
@@ -123,6 +123,11 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
902636
                                   &env->fpu_status);
902636
        /* fall through */
902636
     case S390_CPU_RESET_NORMAL:
902636
+        env->psw.mask &= ~PSW_MASK_RI;
902636
+        memset(&env->start_normal_reset_fields, 0,
902636
+               offsetof(CPUS390XState, end_reset_fields) -
902636
+               offsetof(CPUS390XState, start_normal_reset_fields));
902636
+
902636
         env->pfault_token = -1UL;
902636
         env->bpbc = false;
902636
         break;
902636
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
902636
index d2af13b345..7e1c18d596 100644
902636
--- a/target/s390x/cpu.h
902636
+++ b/target/s390x/cpu.h
902636
@@ -58,7 +58,6 @@ struct CPUS390XState {
902636
      */
902636
     uint64_t vregs[32][2] QEMU_ALIGNED(16);  /* vector registers */
902636
     uint32_t aregs[16];    /* access registers */
902636
-    uint8_t riccb[64];     /* runtime instrumentation control */
902636
     uint64_t gscb[4];      /* guarded storage control */
902636
     uint64_t etoken;       /* etoken */
902636
     uint64_t etoken_extension; /* etoken extension */
902636
@@ -114,6 +113,10 @@ struct CPUS390XState {
902636
     uint64_t gbea;
902636
     uint64_t pp;
902636
 
902636
+    /* Fields up to this point are not cleared by normal CPU reset */
902636
+    struct {} start_normal_reset_fields;
902636
+    uint8_t riccb[64];     /* runtime instrumentation control */
902636
+
902636
     /* Fields up to this point are cleared by a CPU reset */
902636
     struct {} end_reset_fields;
902636
 
902636
@@ -252,6 +255,7 @@ extern const VMStateDescription vmstate_s390_cpu;
902636
 #undef PSW_SHIFT_ASC
902636
 #undef PSW_MASK_CC
902636
 #undef PSW_MASK_PM
902636
+#undef PSW_MASK_RI
902636
 #undef PSW_SHIFT_MASK_PM
902636
 #undef PSW_MASK_64
902636
 #undef PSW_MASK_32
902636
@@ -273,6 +277,7 @@ extern const VMStateDescription vmstate_s390_cpu;
902636
 #define PSW_MASK_CC             0x0000300000000000ULL
902636
 #define PSW_MASK_PM             0x00000F0000000000ULL
902636
 #define PSW_SHIFT_MASK_PM       40
902636
+#define PSW_MASK_RI             0x0000008000000000ULL
902636
 #define PSW_MASK_64             0x0000000100000000ULL
902636
 #define PSW_MASK_32             0x0000000080000000ULL
902636
 #define PSW_MASK_ESA_ADDR       0x000000007fffffffULL
902636
-- 
902636
2.27.0
902636