yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ddf19c
From d738b4336c79be68b6040f73427e089f46957728 Mon Sep 17 00:00:00 2001
ddf19c
From: Thomas Huth <thuth@redhat.com>
ddf19c
Date: Fri, 29 May 2020 05:54:11 -0400
ddf19c
Subject: [PATCH 29/42] s390x: protvirt: Set guest IPL PSW
ddf19c
ddf19c
RH-Author: Thomas Huth <thuth@redhat.com>
ddf19c
Message-id: <20200529055420.16855-30-thuth@redhat.com>
ddf19c
Patchwork-id: 97049
ddf19c
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 29/38] s390x: protvirt: Set guest IPL PSW
ddf19c
Bugzilla: 1828317
ddf19c
RH-Acked-by: Claudio Imbrenda <cimbrend@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
Handling of CPU reset and setting of the IPL psw from guest storage at
ddf19c
offset 0 is done by a Ultravisor call. Let's only fetch it if
ddf19c
necessary.
ddf19c
ddf19c
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
ddf19c
Reviewed-by: Thomas Huth <thuth@redhat.com>
ddf19c
Reviewed-by: David Hildenbrand <david@redhat.com>
ddf19c
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
ddf19c
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
ddf19c
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
Message-Id: <20200319131921.2367-11-frankja@linux.ibm.com>
ddf19c
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
(cherry picked from commit 59181010a2ff82c3a97e9b5768ee87c38e4815f1)
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 target/s390x/cpu.c | 26 +++++++++++++++++---------
ddf19c
 1 file changed, 17 insertions(+), 9 deletions(-)
ddf19c
ddf19c
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
ddf19c
index 8f38cd8e6f..371b91b2d7 100644
ddf19c
--- a/target/s390x/cpu.c
ddf19c
+++ b/target/s390x/cpu.c
ddf19c
@@ -77,16 +77,24 @@ static bool s390_cpu_has_work(CPUState *cs)
ddf19c
 static void s390_cpu_load_normal(CPUState *s)
ddf19c
 {
ddf19c
     S390CPU *cpu = S390_CPU(s);
ddf19c
-    uint64_t spsw = ldq_phys(s->as, 0);
ddf19c
-
ddf19c
-    cpu->env.psw.mask = spsw & PSW_MASK_SHORT_CTRL;
ddf19c
-    /*
ddf19c
-     * Invert short psw indication, so SIE will report a specification
ddf19c
-     * exception if it was not set.
ddf19c
-     */
ddf19c
-    cpu->env.psw.mask ^= PSW_MASK_SHORTPSW;
ddf19c
-    cpu->env.psw.addr = spsw & PSW_MASK_SHORT_ADDR;
ddf19c
+    uint64_t spsw;
ddf19c
 
ddf19c
+    if (!s390_is_pv()) {
ddf19c
+        spsw = ldq_phys(s->as, 0);
ddf19c
+        cpu->env.psw.mask = spsw & PSW_MASK_SHORT_CTRL;
ddf19c
+        /*
ddf19c
+         * Invert short psw indication, so SIE will report a specification
ddf19c
+         * exception if it was not set.
ddf19c
+         */
ddf19c
+        cpu->env.psw.mask ^= PSW_MASK_SHORTPSW;
ddf19c
+        cpu->env.psw.addr = spsw & PSW_MASK_SHORT_ADDR;
ddf19c
+    } else {
ddf19c
+        /*
ddf19c
+         * Firmware requires us to set the load state before we set
ddf19c
+         * the cpu to operating on protected guests.
ddf19c
+         */
ddf19c
+        s390_cpu_set_state(S390_CPU_STATE_LOAD, cpu);
ddf19c
+    }
ddf19c
     s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu);
ddf19c
 }
ddf19c
 #endif
ddf19c
-- 
ddf19c
2.27.0
ddf19c